treege 3.0.0-beta.4 → 3.0.0-beta.41

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 (138) hide show
  1. package/LICENSE +18 -12
  2. package/README.md +306 -52
  3. package/dist/DefaultInputs-xMZhO-ry.js +1558 -0
  4. package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
  5. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  6. package/dist/editor/constants/defaultNode.d.ts +1 -1
  7. package/dist/editor/constants/edgeTypes.d.ts +3 -2
  8. package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
  9. package/dist/editor/constants/nodeSpacing.d.ts +33 -0
  10. package/dist/editor/constants/nodeTypes.d.ts +5 -5
  11. package/dist/editor/context/TreegeEditorContext.d.ts +53 -1
  12. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  13. package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
  14. package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
  15. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  16. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  17. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  18. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  19. package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
  20. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  21. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
  22. package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
  23. package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
  24. package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
  25. package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
  26. package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
  27. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
  28. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
  29. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  30. package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
  31. package/dist/editor/hooks/useAutoLayout.d.ts +15 -0
  32. package/dist/editor/hooks/useFlowActions.d.ts +5 -2
  33. package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
  34. package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
  35. package/dist/editor/types/ai.d.ts +65 -0
  36. package/dist/editor/types/editor.d.ts +9 -8
  37. package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
  38. package/dist/editor/utils/dagreLayout.d.ts +17 -0
  39. package/dist/editor/utils/edge.d.ts +14 -0
  40. package/dist/editor/utils/image.d.ts +7 -0
  41. package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
  42. package/dist/editor-sMVFoMxL.js +4001 -0
  43. package/dist/editor.js +3 -8
  44. package/dist/main.js +4 -53
  45. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  46. package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
  47. package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
  48. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -7
  49. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
  50. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
  51. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
  52. package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
  53. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
  54. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
  55. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
  56. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
  57. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
  58. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
  59. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
  60. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
  61. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
  62. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
  63. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
  64. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
  65. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
  66. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
  67. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
  68. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
  69. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
  70. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +84 -24
  71. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  72. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  73. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  74. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  75. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  76. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  77. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  78. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  79. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  80. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  81. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  82. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  83. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  84. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  85. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  86. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  87. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  88. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  89. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  90. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  91. package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
  92. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  93. package/dist/renderer/hooks/useTranslate.d.ts +6 -4
  94. package/dist/renderer/index.d.ts +2 -0
  95. package/dist/renderer/index.native.d.ts +19 -0
  96. package/dist/renderer/types/renderer.d.ts +60 -6
  97. package/dist/renderer/utils/form.d.ts +22 -2
  98. package/dist/renderer/utils/http.d.ts +101 -0
  99. package/dist/renderer/utils/node.d.ts +18 -1
  100. package/dist/renderer/utils/sanitize.d.ts +85 -0
  101. package/dist/renderer/utils/sanitize.native.d.ts +69 -0
  102. package/dist/renderer/utils/submit.d.ts +47 -0
  103. package/dist/renderer-native.d.ts +2 -0
  104. package/dist/renderer-native.js +3496 -0
  105. package/dist/renderer.js +3 -46
  106. package/dist/shared/components/ui/badge.d.ts +2 -2
  107. package/dist/shared/components/ui/button.d.ts +2 -2
  108. package/dist/shared/components/ui/collapsible.d.ts +1 -1
  109. package/dist/shared/components/ui/command.d.ts +1 -1
  110. package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
  111. package/dist/shared/components/ui/form.d.ts +1 -1
  112. package/dist/shared/components/ui/popover.d.ts +4 -2
  113. package/dist/shared/components/ui/select.d.ts +3 -1
  114. package/dist/shared/components/ui/sheet.d.ts +1 -1
  115. package/dist/shared/components/ui/tooltip.d.ts +1 -1
  116. package/dist/shared/constants/colors.d.ts +45 -0
  117. package/dist/shared/constants/inputType.d.ts +1 -0
  118. package/dist/shared/context/ThemeContext.d.ts +2 -0
  119. package/dist/shared/context/ThemeContext.native.d.ts +22 -0
  120. package/dist/shared/hooks/useThemeColors.d.ts +37 -0
  121. package/dist/shared/locales/ar.json.d.ts +117 -10
  122. package/dist/shared/locales/de.json.d.ts +118 -11
  123. package/dist/shared/locales/en.json.d.ts +119 -12
  124. package/dist/shared/locales/es.json.d.ts +118 -11
  125. package/dist/shared/locales/fr.json.d.ts +118 -11
  126. package/dist/shared/locales/it.json.d.ts +118 -11
  127. package/dist/shared/locales/pt.json.d.ts +118 -11
  128. package/dist/shared/types/edge.d.ts +6 -0
  129. package/dist/shared/types/node.d.ts +64 -0
  130. package/package.json +41 -16
  131. package/dist/ThemeContext-D4xMOrdt.js +0 -759
  132. package/dist/TreegeEditor-Cv0caawk.js +0 -2152
  133. package/dist/TreegeRenderer-BOCobRLr.js +0 -1414
  134. package/dist/_name_.css +0 -1
  135. package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
  136. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
  137. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
  138. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
@@ -1,2152 +0,0 @@
1
- "use client";
2
- import { j as e, i as he, e as Ue, s as D, P as Pe, p as ke, B as w, q as Ee, F as N, f as C, I as y, o as O, t as qe, S as $, w as A, x as z, y as G, A as f, L as ee, N as pe, z as q, c as ve, E as Ke, D as te, C as We, r as Ye, h as Je, k as Xe, l as Be, m as be, H as Te, a as Qe, b as et, G as tt, T as at } from "./ThemeContext-D4xMOrdt.js";
3
- import { useNodes as De, useEdges as $e, getBezierPath as st, useReactFlow as me, BaseEdge as nt, EdgeLabelRenderer as ot, Handle as se, Position as ne, NodeResizer as rt, Panel as lt, addEdge as it, ReactFlowProvider as ct, ReactFlow as dt, Background as ht, BackgroundVariant as ut, MiniMap as mt, Controls as xt } from "@xyflow/react";
4
- import { useForm as ie } from "@tanstack/react-form";
5
- import { Waypoints as pt, X as oe, Plus as xe, Network as jt, Boxes as gt, RectangleEllipsis as Ct, Type as Ae, LucidePencilRuler as vt, EllipsisVertical as ft, Copy as bt, Download as Nt, ArrowRightFromLine as yt, Save as wt, Trash2 as Ft, Variable as He, ChevronsUpDown as de, Check as St, PlusCircle as Vt, XIcon as Pt } from "lucide-react";
6
- import { useMemo as ae, createContext as kt, useState as _, useContext as Et, useRef as Tt, useCallback as Z } from "react";
7
- import * as ue from "@radix-ui/react-scroll-area";
8
- import { Slot as Dt } from "@radix-ui/react-slot";
9
- import { cva as Mt } from "class-variance-authority";
10
- import { toast as R, Toaster as It } from "sonner";
11
- import * as K from "@radix-ui/react-dropdown-menu";
12
- import * as Me from "@radix-ui/react-collapsible";
13
- import * as J from "@radix-ui/react-dialog";
14
- import { useTheme as Lt } from "next-themes";
15
- const Bt = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1809_3434)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1303%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.455%2046.7988C17.0611%2047.1509%2017.7491%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34V41.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.251%20116.58%20138.64L151.39%2078.3401C151.741%2077.7316%20151.926%2077.0413%20151.926%2076.3386C151.926%2075.636%20151.74%2074.9458%20151.389%2074.3375C151.037%2073.7293%20150.531%2073.2244%20149.922%2072.8738C149.313%2072.5231%20148.623%2072.3391%20147.92%2072.3401H92.48C91.4191%2072.3401%2090.4017%2072.7615%2089.6516%2073.5117C88.9014%2074.2618%2088.48%2075.2792%2088.48%2076.3401V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.469C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.3201H3.99999C3.29819%2072.3208%202.60893%2072.5061%202.00143%2072.8575C1.39392%2073.2089%200.88955%2073.7139%200.538962%2074.3218C0.188375%2074.9298%200.00390931%2075.6193%200.00408949%2076.3211C0.00426966%2077.0229%200.189089%2077.7123%200.539989%2078.3201L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.489C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.3101C63.4773%2075.2509%2063.0547%2074.2361%2062.3049%2073.4881C61.555%2072.7401%2060.5391%2072.3201%2059.48%2072.3201V72.3201Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='black'/%3e%3cdefs%3e%3cclipPath%20id='clip0_1809_3434'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Ht = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_2_65)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1302%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.4549%2046.7988C17.061%2047.1509%2017.749%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.25%20116.58%20138.64L151.39%2078.34C151.741%2077.7315%20151.926%2077.0412%20151.926%2076.3385C151.926%2075.6359%20151.74%2074.9457%20151.389%2074.3374C151.037%2073.7292%20150.531%2073.2243%20149.922%2072.8737C149.313%2072.523%20148.623%2072.339%20147.92%2072.34H92.48C91.4191%2072.34%2090.4017%2072.7614%2089.6516%2073.5116C88.9014%2074.2617%2088.48%2075.2791%2088.48%2076.34V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.468C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.32H4C3.2982%2072.3207%202.60894%2072.5061%202.00143%2072.8574C1.39393%2073.2088%200.889558%2073.7138%200.53897%2074.3218C0.188382%2074.9297%200.00391694%2075.6192%200.00409712%2076.321C0.00427729%2077.0228%200.189097%2077.7122%200.539997%2078.32L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.488C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.31C63.4773%2075.2509%2063.0548%2074.236%2062.3049%2073.488C61.555%2072.7401%2060.5391%2072.32%2059.48%2072.32Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='white'/%3e%3cdefs%3e%3cclipPath%20id='clip0_2_65'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Ot = ({ theme: t = "dark" }) => /* @__PURE__ */ e.jsx("div", { className: "fixed left-5 top-5 z-50 select-none", children: /* @__PURE__ */ e.jsx(
16
- "img",
17
- {
18
- src: t === "dark" ? Ht : Bt,
19
- alt: "Treege",
20
- className: "relative w-auto h-14 drop-shadow-[0_0px_35px] drop-shadow-blue-600"
21
- }
22
- ) }), Ie = (t) => {
23
- const r = De(), n = $e();
24
- return ae(() => {
25
- if (!t)
26
- return [];
27
- const l = (i, s = /* @__PURE__ */ new Set()) => {
28
- if (s.has(i))
29
- return [];
30
- const c = new Set(s).add(i);
31
- return n.filter((a) => a.target === i).flatMap((a) => [a.source, ...l(a.source, c)]);
32
- }, m = l(t);
33
- return r.filter((i) => m.includes(i.id) && he(i)).map((i) => {
34
- const s = i.data, c = (typeof s.label == "object" ? s.label.en : s.label) || `Node ${i.id.slice(0, 8)}`;
35
- return {
36
- label: s.name ? `${c} (${s.name})` : c,
37
- name: s.name,
38
- nodeId: i.id,
39
- type: s.type || "text"
40
- };
41
- });
42
- }, [t, r, n]);
43
- }, ze = kt(null), $t = ({ children: t, value: r }) => {
44
- const [n, l] = _(r?.flowId), m = ae(
45
- () => ({
46
- ...r,
47
- flowId: n,
48
- setFlowId: l
49
- }),
50
- [n, r]
51
- );
52
- return /* @__PURE__ */ e.jsx(ze.Provider, { value: m, children: t });
53
- }, Ge = () => Et(ze) ?? {
54
- flowId: void 0,
55
- language: "en",
56
- setFlowId: () => {
57
- }
58
- }, B = (t) => {
59
- const n = Ge().language;
60
- return Ue(n);
61
- };
62
- function _e({ className: t, children: r, ...n }) {
63
- return /* @__PURE__ */ e.jsxs(ue.Root, { "data-slot": "scroll-area", className: D("relative", t), ...n, children: [
64
- /* @__PURE__ */ e.jsx(
65
- ue.Viewport,
66
- {
67
- "data-slot": "scroll-area-viewport",
68
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
69
- children: r
70
- }
71
- ),
72
- /* @__PURE__ */ e.jsx(At, {}),
73
- /* @__PURE__ */ e.jsx(ue.Corner, {})
74
- ] });
75
- }
76
- function At({
77
- className: t,
78
- orientation: r = "vertical",
79
- ...n
80
- }) {
81
- return /* @__PURE__ */ e.jsx(
82
- ue.ScrollAreaScrollbar,
83
- {
84
- "data-slot": "scroll-area-scrollbar",
85
- orientation: r,
86
- className: D(
87
- "flex touch-none p-px transition-colors select-none",
88
- r === "vertical" && "h-full w-2.5 border-l border-l-transparent",
89
- r === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
90
- t
91
- ),
92
- ...n,
93
- children: /* @__PURE__ */ e.jsx(ue.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "bg-border relative flex-1 rounded-full" })
94
- }
95
- );
96
- }
97
- const zt = ({
98
- id: t,
99
- target: r,
100
- sourceX: n,
101
- sourceY: l,
102
- targetX: m,
103
- targetY: i,
104
- sourcePosition: s,
105
- targetPosition: c,
106
- markerEnd: d,
107
- style: a,
108
- data: o
109
- }) => {
110
- const [u, h, x] = st({
111
- sourcePosition: s,
112
- sourceX: n,
113
- sourceY: l,
114
- targetPosition: c,
115
- targetX: m,
116
- targetY: i
117
- }), [p, v] = _(!1), { updateEdgeData: M } = me(), F = Ie(r), S = o?.conditions && o.conditions.length > 0, g = B(), { handleSubmit: E, reset: V, Field: P } = ie({
118
- defaultValues: {
119
- conditions: o?.conditions || [{ field: F[0]?.nodeId ?? "", operator: "===", value: "" }],
120
- isFallback: !!o?.isFallback,
121
- label: o?.label || ""
122
- },
123
- listeners: {
124
- onChange: ({ formApi: j }) => {
125
- j.handleSubmit().then();
126
- },
127
- onChangeDebounceMs: 150
128
- },
129
- onSubmit: ({ value: j }) => {
130
- M(t, j);
131
- }
132
- }), T = (j) => {
133
- j.stopPropagation();
134
- }, X = () => {
135
- V({ conditions: [], isFallback: !1, label: "" }), M(t, { conditions: void 0, isFallback: void 0, label: void 0 });
136
- }, b = () => {
137
- if (o?.isFallback)
138
- return o.label || g("editor.conditionalEdge.fallback");
139
- if (!S)
140
- return null;
141
- if (o.label)
142
- return o.label;
143
- const j = o.conditions;
144
- if (j.length === 1)
145
- return `${F.find((L) => L.nodeId === j[0].field)?.label || j[0].field} ${j[0].operator} ${j[0].value}`;
146
- const I = j.filter((k) => k.logicalOperator === ee.AND).length, fe = j.filter((k) => k.logicalOperator === ee.OR).length;
147
- return I > 0 && fe === 0 ? `${j.length} ${g("editor.conditionalEdge.conditionsAnd")}` : fe > 0 && I === 0 ? `${j.length} ${g("editor.conditionalEdge.conditionsOr")}` : `${j.length} ${g("editor.conditionalEdge.conditionsMixed")}`;
148
- }, Q = () => o?.isFallback ? "var(--color-chart-4)" : S ? "var(--color-chart-2)" : "var(--color-chart-3)";
149
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
150
- /* @__PURE__ */ e.jsx(
151
- nt,
152
- {
153
- path: u,
154
- markerEnd: d,
155
- style: {
156
- ...a,
157
- stroke: Q(),
158
- strokeDasharray: o?.isFallback ? "5,5" : void 0,
159
- strokeWidth: S || o?.isFallback ? 2 : a?.strokeWidth
160
- }
161
- }
162
- ),
163
- /* @__PURE__ */ e.jsx(ot, { children: /* @__PURE__ */ e.jsx(
164
- "div",
165
- {
166
- className: "nodrag nopan absolute",
167
- style: {
168
- pointerEvents: "all",
169
- transform: `translate(-50%, -50%) translate(${h}px,${x}px)`
170
- },
171
- children: /* @__PURE__ */ e.jsxs(Pe, { open: p, onOpenChange: v, children: [
172
- /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
173
- w,
174
- {
175
- variant: S || o?.isFallback ? "default" : "secondary",
176
- className: "h-8 px-2 text-xs",
177
- onClick: T,
178
- children: [
179
- /* @__PURE__ */ e.jsx(pt, { className: "mr-1 h-3 w-3" }),
180
- S || o?.isFallback ? b() : g("editor.conditionalEdge.condition")
181
- ]
182
- }
183
- ) }),
184
- /* @__PURE__ */ e.jsx(Ee, { className: "w-96 p-1", align: "center", onClick: (j) => j.stopPropagation(), children: /* @__PURE__ */ e.jsx(_e, { className: "flex max-h-150 flex-col p-3", children: /* @__PURE__ */ e.jsx(
185
- "form",
186
- {
187
- onSubmit: (j) => {
188
- j.preventDefault(), j.stopPropagation();
189
- },
190
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-5", children: [
191
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
192
- /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: g("editor.conditionalEdge.displayConditions") }),
193
- /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: g("editor.conditionalEdge.displayConditionsDesc") })
194
- ] }),
195
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4", children: [
196
- /* @__PURE__ */ e.jsx(P, { name: "label", children: (j) => /* @__PURE__ */ e.jsxs(N, { children: [
197
- /* @__PURE__ */ e.jsx(C, { htmlFor: j.name, children: g("editor.conditionalEdge.labelOptional") }),
198
- /* @__PURE__ */ e.jsx(
199
- y,
200
- {
201
- id: j.name,
202
- placeholder: g("editor.conditionalEdge.labelPlaceholder"),
203
- value: j.state.value,
204
- onChange: (I) => j.handleChange(I.target.value)
205
- }
206
- ),
207
- /* @__PURE__ */ e.jsx(O, { children: g("editor.conditionalEdge.labelDesc") })
208
- ] }) }),
209
- /* @__PURE__ */ e.jsx(P, { name: "isFallback", children: (j) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3", children: [
210
- /* @__PURE__ */ e.jsx(
211
- qe,
212
- {
213
- id: j.name,
214
- checked: j.state.value,
215
- onCheckedChange: (I) => j.handleChange(I)
216
- }
217
- ),
218
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
219
- /* @__PURE__ */ e.jsx(C, { htmlFor: j.name, className: "cursor-pointer font-medium", children: g("editor.conditionalEdge.fallbackPath") }),
220
- /* @__PURE__ */ e.jsx(O, { className: "text-xs", children: g("editor.conditionalEdge.fallbackPathDesc") })
221
- ] })
222
- ] }) }) }),
223
- /* @__PURE__ */ e.jsx(P, { name: "conditions", mode: "array", children: (j) => {
224
- const I = j.form.getFieldValue("isFallback");
225
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
226
- /* @__PURE__ */ e.jsx(C, { className: I ? "text-muted-foreground" : "", children: g("editor.conditionalEdge.conditions") }),
227
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
228
- j.state.value?.map((fe, k) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
229
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 rounded-lg border bg-muted/30 p-3", children: [
230
- /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].field`, children: (L) => /* @__PURE__ */ e.jsxs(N, { children: [
231
- /* @__PURE__ */ e.jsx(C, { htmlFor: `field-${k}`, children: g("editor.conditionalEdge.field") }),
232
- /* @__PURE__ */ e.jsxs(
233
- $,
234
- {
235
- disabled: I,
236
- value: L.state.value || "",
237
- onValueChange: (H) => L.handleChange(H),
238
- children: [
239
- /* @__PURE__ */ e.jsx(A, { id: `field-${k}`, className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: g("editor.conditionalEdge.selectField") }) }),
240
- /* @__PURE__ */ e.jsx(G, { children: F.length === 0 ? /* @__PURE__ */ e.jsx(f, { value: "none", disabled: !0, children: g("editor.conditionalEdge.noFieldsAvailable") }) : F.map((H) => /* @__PURE__ */ e.jsxs(f, { value: H.nodeId, children: [
241
- H.label,
242
- " (",
243
- H.type,
244
- ")"
245
- ] }, H.nodeId)) })
246
- ]
247
- }
248
- )
249
- ] }) }),
250
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
251
- /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].operator`, children: (L) => /* @__PURE__ */ e.jsxs(N, { children: [
252
- /* @__PURE__ */ e.jsx(C, { htmlFor: `operator-${k}`, children: g("editor.conditionalEdge.operator") }),
253
- /* @__PURE__ */ e.jsxs(
254
- $,
255
- {
256
- disabled: I,
257
- value: L.state.value || "===",
258
- onValueChange: (H) => L.handleChange(H),
259
- children: [
260
- /* @__PURE__ */ e.jsx(A, { id: `operator-${k}`, children: /* @__PURE__ */ e.jsx(z, {}) }),
261
- /* @__PURE__ */ e.jsxs(G, { children: [
262
- /* @__PURE__ */ e.jsx(f, { value: "===", children: "=" }),
263
- /* @__PURE__ */ e.jsx(f, { value: "!==", children: "≠" }),
264
- /* @__PURE__ */ e.jsx(f, { value: ">", children: ">" }),
265
- /* @__PURE__ */ e.jsx(f, { value: "<", children: "<" }),
266
- /* @__PURE__ */ e.jsx(f, { value: ">=", children: ">=" }),
267
- /* @__PURE__ */ e.jsx(f, { value: "<=", children: "<=" })
268
- ] })
269
- ]
270
- }
271
- )
272
- ] }) }),
273
- /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].value`, children: (L) => /* @__PURE__ */ e.jsxs(N, { className: "w-full", children: [
274
- /* @__PURE__ */ e.jsx(C, { htmlFor: `value-${k}`, children: g("editor.conditionalEdge.value") }),
275
- /* @__PURE__ */ e.jsx(
276
- y,
277
- {
278
- disabled: I,
279
- id: `value-${k}`,
280
- placeholder: g("editor.conditionalEdge.valuePlaceholder"),
281
- value: L.state.value || "",
282
- onChange: (H) => L.handleChange(H.target.value)
283
- }
284
- )
285
- ] }) })
286
- ] }),
287
- j.state.value && j.state.value.length > 1 && /* @__PURE__ */ e.jsxs(
288
- w,
289
- {
290
- disabled: I,
291
- type: "button",
292
- variant: "ghost",
293
- size: "sm",
294
- className: "w-full",
295
- onClick: () => {
296
- j.removeValue(k), E().then();
297
- },
298
- children: [
299
- /* @__PURE__ */ e.jsx(oe, { className: "mr-1 h-4 w-4" }),
300
- g("editor.conditionalEdge.removeCondition")
301
- ]
302
- }
303
- )
304
- ] }),
305
- j.state.value && k < j.state.value.length - 1 && /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].logicalOperator`, children: (L) => /* @__PURE__ */ e.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ e.jsxs(
306
- $,
307
- {
308
- disabled: I,
309
- value: L.state.value || ee.AND,
310
- onValueChange: (H) => L.handleChange(H),
311
- children: [
312
- /* @__PURE__ */ e.jsx(A, { className: "h-9 w-32 font-semibold", children: /* @__PURE__ */ e.jsx(z, {}) }),
313
- /* @__PURE__ */ e.jsxs(G, { children: [
314
- /* @__PURE__ */ e.jsx(f, { value: ee.AND, children: "AND" }),
315
- /* @__PURE__ */ e.jsx(f, { value: ee.OR, children: "OR" })
316
- ] })
317
- ]
318
- }
319
- ) }) })
320
- ] }, `condition-${k}`)),
321
- /* @__PURE__ */ e.jsxs(
322
- w,
323
- {
324
- disabled: I,
325
- type: "button",
326
- variant: "outline",
327
- size: "sm",
328
- className: "w-full",
329
- onClick: () => {
330
- j.pushValue({
331
- field: F[0]?.nodeId ?? "",
332
- logicalOperator: ee.AND,
333
- operator: "===",
334
- value: ""
335
- }), E().then();
336
- },
337
- children: [
338
- /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
339
- g("editor.conditionalEdge.addCondition")
340
- ]
341
- }
342
- )
343
- ] })
344
- ] });
345
- } })
346
- ] }),
347
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
348
- /* @__PURE__ */ e.jsxs(w, { type: "button", size: "sm", variant: "outline", onClick: X, children: [
349
- /* @__PURE__ */ e.jsx(oe, { className: "mr-1 h-4 w-4" }),
350
- g("common.clear")
351
- ] }),
352
- /* @__PURE__ */ e.jsx(w, { type: "button", size: "sm", onClick: () => v(!1), children: g("common.close") })
353
- ] })
354
- ] })
355
- }
356
- ) }) })
357
- ] })
358
- }
359
- ) })
360
- ] });
361
- }, Gt = {
362
- conditional: zt
363
- }, Le = ({ children: t, inGroup: r }) => /* @__PURE__ */ e.jsx("div", { className: D("react-flow__node__wrapper", r ? "in-group" : ""), children: t }), _t = Mt(
364
- "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
365
- {
366
- defaultVariants: {
367
- variant: "default"
368
- },
369
- variants: {
370
- variant: {
371
- default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
372
- destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
373
- outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
374
- purple: "bg-purple-600 hover:bg-purple-700 text-white",
375
- secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
376
- }
377
- }
378
- }
379
- );
380
- function re({
381
- className: t,
382
- variant: r,
383
- asChild: n = !1,
384
- ...l
385
- }) {
386
- const m = n ? Dt : "span";
387
- return /* @__PURE__ */ e.jsx(m, { "data-slot": "badge", className: D(_t({ variant: r }), t), ...l });
388
- }
389
- const Rt = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
390
- const i = B()(t?.label);
391
- return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
392
- /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
393
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: i }),
394
- /* @__PURE__ */ e.jsxs(re, { variant: "destructive", children: [
395
- /* @__PURE__ */ e.jsx(jt, {}),
396
- n
397
- ] }),
398
- /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
399
- ] });
400
- }, Zt = ({ data: t }) => {
401
- const n = B()(t?.label);
402
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
403
- /* @__PURE__ */ e.jsx(rt, {}),
404
- /* @__PURE__ */ e.jsx("div", { className: "-top-3.5 absolute left-6", children: /* @__PURE__ */ e.jsxs(re, { className: "max-w-50 bg-chart-2", children: [
405
- /* @__PURE__ */ e.jsx(gt, { className: "!w-3 !h-3" }),
406
- n
407
- ] }) })
408
- ] });
409
- }, Ut = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
410
- const i = B()(t?.label);
411
- return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
412
- /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
413
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: i || t?.name }),
414
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
415
- n && /* @__PURE__ */ e.jsxs(re, { variant: "secondary", className: "bg-blue-500 text-white dark:bg-blue-600", children: [
416
- /* @__PURE__ */ e.jsx(Ct, {}),
417
- n
418
- ] }),
419
- t?.type && /* @__PURE__ */ e.jsxs(re, { variant: "outline", children: [
420
- /* @__PURE__ */ e.jsx(Ae, {}),
421
- t.type
422
- ] })
423
- ] }),
424
- /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
425
- ] });
426
- }, qt = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
427
- const i = B()(t?.label);
428
- return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
429
- /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
430
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl capitalize", children: i }),
431
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
432
- /* @__PURE__ */ e.jsxs(re, { variant: "purple", children: [
433
- /* @__PURE__ */ e.jsx(vt, {}),
434
- n
435
- ] }),
436
- t?.type && /* @__PURE__ */ e.jsxs(re, { variant: "outline", children: [
437
- /* @__PURE__ */ e.jsx(Ae, {}),
438
- t.type
439
- ] })
440
- ] }),
441
- /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
442
- ] });
443
- }, Re = {
444
- [pe.flow]: Rt,
445
- [pe.group]: Zt,
446
- [pe.input]: Ut,
447
- [pe.ui]: qt
448
- }, Kt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
449
- let le = (t = 21) => {
450
- let r = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
451
- for (; t--; )
452
- r += Kt[n[t] & 63];
453
- return r;
454
- };
455
- const Ze = {
456
- data: {
457
- type: "text"
458
- },
459
- id: le(),
460
- position: { x: 0, y: 0 },
461
- type: "input"
462
- };
463
- function Fe({ ...t }) {
464
- return /* @__PURE__ */ e.jsx(K.Root, { "data-slot": "dropdown-menu", ...t });
465
- }
466
- function Se({ ...t }) {
467
- return /* @__PURE__ */ e.jsx(K.Trigger, { "data-slot": "dropdown-menu-trigger", ...t });
468
- }
469
- function Ve({ className: t, sideOffset: r = 4, ...n }) {
470
- return /* @__PURE__ */ e.jsx(K.Portal, { children: /* @__PURE__ */ e.jsx(
471
- K.Content,
472
- {
473
- "data-slot": "dropdown-menu-content",
474
- sideOffset: r,
475
- className: D(
476
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
477
- t
478
- ),
479
- ...n
480
- }
481
- ) });
482
- }
483
- function Ne({ ...t }) {
484
- return /* @__PURE__ */ e.jsx(K.Group, { "data-slot": "dropdown-menu-group", ...t });
485
- }
486
- function U({
487
- className: t,
488
- inset: r,
489
- variant: n = "default",
490
- ...l
491
- }) {
492
- return /* @__PURE__ */ e.jsx(
493
- K.Item,
494
- {
495
- "data-slot": "dropdown-menu-item",
496
- "data-inset": r,
497
- "data-variant": n,
498
- className: D(
499
- "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
500
- t
501
- ),
502
- ...l
503
- }
504
- );
505
- }
506
- function Wt({
507
- className: t,
508
- inset: r,
509
- ...n
510
- }) {
511
- return /* @__PURE__ */ e.jsx(
512
- K.Label,
513
- {
514
- "data-slot": "dropdown-menu-label",
515
- "data-inset": r,
516
- className: D("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", t),
517
- ...n
518
- }
519
- );
520
- }
521
- function ye({ className: t, ...r }) {
522
- return /* @__PURE__ */ e.jsx(
523
- K.Separator,
524
- {
525
- "data-slot": "dropdown-menu-separator",
526
- className: D("bg-border -mx-1 my-1 h-px", t),
527
- ...r
528
- }
529
- );
530
- }
531
- const Yt = le(), Jt = ({ onExportJson: t, onSave: r }) => {
532
- const { flowId: n, setFlowId: l } = Ge(), { setNodes: m, setEdges: i, addNodes: s, screenToFlowPosition: c } = me(), d = n || Yt, a = De(), o = $e(), u = Tt(null), h = B(), x = () => {
533
- const g = (window.innerWidth || 0) / 2, E = (window.innerHeight || 0) / 2, V = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-width"), 10), P = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-height"), 10), T = c({ x: g - V, y: E - P });
534
- s([
535
- {
536
- ...Ze,
537
- id: le(),
538
- position: T
539
- }
540
- ]);
541
- }, p = ({ target: g }) => {
542
- const E = g.files?.[0];
543
- if (!E)
544
- return;
545
- const V = new FileReader();
546
- V.onload = (P) => {
547
- try {
548
- const T = JSON.parse(P.target?.result);
549
- T && Array.isArray(T.nodes) && Array.isArray(T.edges) ? (m(T.nodes), i(T.edges), R.success(h("editor.actionsPanel.importSuccess"), {
550
- description: h("editor.actionsPanel.importSuccessDesc")
551
- })) : R.error(h("editor.actionsPanel.invalidJson"), {
552
- description: h("editor.actionsPanel.invalidJsonDesc")
553
- });
554
- } catch (T) {
555
- console.warn(T), R.error(h("editor.actionsPanel.parseError"), {
556
- description: h("editor.actionsPanel.parseErrorDesc")
557
- });
558
- }
559
- u.current && (u.current.value = "");
560
- }, V.readAsText(E);
561
- }, v = () => {
562
- const g = { edges: o, id: d, nodes: a }, E = new Blob([JSON.stringify(g, null, 2)], { type: "application/json" }), V = URL.createObjectURL(E), P = document.createElement("a");
563
- P.href = V, P.download = "treege.json", P.click(), URL.revokeObjectURL(V), R.success(h("editor.actionsPanel.downloadSuccess"), {
564
- description: h("editor.actionsPanel.downloadSuccessDesc")
565
- }), n || l?.(d), t?.(g);
566
- }, M = () => {
567
- n || l?.(d), r?.({ edges: o, id: d, nodes: a });
568
- }, F = async () => {
569
- try {
570
- await navigator.clipboard.writeText(d), R.success(h("editor.actionsPanel.idCopied"), {
571
- description: d
572
- });
573
- } catch {
574
- R.error(h("editor.actionsPanel.copyFailed"));
575
- }
576
- }, S = () => {
577
- m([]), i([]), R.success(h("editor.actionsPanel.clearSuccess"), {
578
- description: h("editor.actionsPanel.clearSuccessDesc")
579
- });
580
- };
581
- return /* @__PURE__ */ e.jsxs(lt, { position: "top-right", className: "flex gap-2", children: [
582
- /* @__PURE__ */ e.jsxs(w, { variant: "outline", size: "sm", onClick: x, children: [
583
- /* @__PURE__ */ e.jsx(xe, {}),
584
- " ",
585
- h("editor.actionsPanel.addNode")
586
- ] }),
587
- /* @__PURE__ */ e.jsxs(Fe, { children: [
588
- /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "sm", children: /* @__PURE__ */ e.jsx(ft, {}) }) }),
589
- /* @__PURE__ */ e.jsxs(Ve, { align: "start", children: [
590
- /* @__PURE__ */ e.jsx(Wt, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
591
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: "Treege ID" }),
592
- /* @__PURE__ */ e.jsxs(
593
- "button",
594
- {
595
- onClick: F,
596
- className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
597
- type: "button",
598
- children: [
599
- /* @__PURE__ */ e.jsx(bt, { className: "h-3 w-3" }),
600
- /* @__PURE__ */ e.jsx("span", { className: "truncate text-xs", children: d })
601
- ]
602
- }
603
- )
604
- ] }) }),
605
- /* @__PURE__ */ e.jsx(ye, {}),
606
- /* @__PURE__ */ e.jsxs(Ne, { children: [
607
- /* @__PURE__ */ e.jsxs(U, { onClick: () => u?.current?.click(), children: [
608
- /* @__PURE__ */ e.jsx(Nt, {}),
609
- " ",
610
- h("editor.actionsPanel.importJson")
611
- ] }),
612
- /* @__PURE__ */ e.jsxs(U, { onClick: v, children: [
613
- /* @__PURE__ */ e.jsx(yt, {}),
614
- " ",
615
- h("editor.actionsPanel.exportJson")
616
- ] })
617
- ] }),
618
- /* @__PURE__ */ e.jsx(ye, {}),
619
- /* @__PURE__ */ e.jsx(Ne, { children: /* @__PURE__ */ e.jsxs(U, { onClick: M, children: [
620
- /* @__PURE__ */ e.jsx(wt, {}),
621
- " ",
622
- h("common.save")
623
- ] }) }),
624
- /* @__PURE__ */ e.jsx(ye, {}),
625
- /* @__PURE__ */ e.jsx(Ne, { children: /* @__PURE__ */ e.jsxs(U, { onClick: S, className: "text-destructive focus:text-destructive", children: [
626
- /* @__PURE__ */ e.jsx(Ft, { className: "text-destructive" }),
627
- " ",
628
- h("editor.actionsPanel.clear")
629
- ] }) })
630
- ] })
631
- ] }),
632
- /* @__PURE__ */ e.jsx("input", { type: "file", accept: "application/json,.json", className: "hidden", ref: u, onChange: p })
633
- ] });
634
- }, Xt = {
635
- ar: "ar",
636
- de: "de",
637
- en: "en",
638
- es: "es",
639
- fr: "fr",
640
- it: "it",
641
- pt: "pt"
642
- }, Y = ({ value: t = "en", onValueChange: r }) => /* @__PURE__ */ e.jsxs($, { value: t, onValueChange: r, children: [
643
- /* @__PURE__ */ e.jsx(A, { className: "uppercase", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
644
- /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.values(Xt).map((n) => /* @__PURE__ */ e.jsx(f, { value: n, className: "uppercase", children: n }, n)) }) })
645
- ] }), ce = () => {
646
- const { setNodes: t, setEdges: r, getNodes: n } = me(), l = Z(() => {
647
- t((d) => d.map(({ selected: a, ...o }) => o)), r((d) => d.map(({ selected: a, ...o }) => o));
648
- }, [r, t]), m = Z(
649
- (d, a) => {
650
- t(
651
- (o) => o.map((u) => u.id === d ? {
652
- ...u,
653
- data: {
654
- ...u.data,
655
- ...a
656
- }
657
- } : u)
658
- );
659
- },
660
- [t]
661
- ), i = Z(
662
- (d, a) => {
663
- t(
664
- (o) => o.map((u) => u.id === d ? {
665
- ...u,
666
- data: {},
667
- type: a
668
- } : u)
669
- );
670
- },
671
- [t]
672
- ), s = Z(
673
- (d) => {
674
- const a = n().find((o) => o.selected);
675
- a && i(a.id, d);
676
- },
677
- [n, i]
678
- ), c = Z(
679
- (d) => {
680
- const a = n().find((o) => o.selected);
681
- a && m(a.id, d);
682
- },
683
- [n, m]
684
- );
685
- return {
686
- clearSelection: l,
687
- updateNodeData: m,
688
- updateNodeType: i,
689
- updateSelectedNodeData: c,
690
- updateSelectedNodeType: s
691
- };
692
- }, W = () => {
693
- const t = De(), r = ae(() => t.filter(ve), [t]), n = ae(() => t.filter((m) => m.selected), [t]), l = ae(() => t.find((m) => m.selected), [t]);
694
- return {
695
- groupNodes: r,
696
- hasSelectedNodes: n.length > 0,
697
- nodes: t,
698
- selectedNode: l,
699
- selectedNodes: n
700
- };
701
- }, Qt = () => {
702
- const [t, r] = _("en"), { updateSelectedNodeData: n } = ce(), { selectedNode: l } = W(), m = B(), { Field: i } = ie({
703
- defaultValues: {
704
- label: l?.data?.label || { en: "" },
705
- targetId: l?.data?.targetId || ""
706
- },
707
- listeners: {
708
- onChange: ({ formApi: s }) => {
709
- s.handleSubmit().then();
710
- },
711
- onChangeDebounceMs: 150
712
- },
713
- onSubmit: ({ value: s }) => {
714
- n(s);
715
- }
716
- });
717
- return /* @__PURE__ */ e.jsx(
718
- "form",
719
- {
720
- onSubmit: (s) => {
721
- s.preventDefault(), s.stopPropagation();
722
- },
723
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
724
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
725
- /* @__PURE__ */ e.jsx(
726
- i,
727
- {
728
- name: "label",
729
- children: (s) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
730
- /* @__PURE__ */ e.jsx(C, { htmlFor: s.name, children: m("editor.flowNodeForm.label") }),
731
- /* @__PURE__ */ e.jsx(
732
- y,
733
- {
734
- id: s.name,
735
- name: s.name,
736
- value: s.state.value?.[t] || "",
737
- onBlur: s.handleBlur,
738
- onChange: ({ target: c }) => {
739
- s.handleChange({
740
- ...s.state.value,
741
- [t]: c.value
742
- });
743
- }
744
- }
745
- )
746
- ] })
747
- }
748
- ),
749
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
750
- ] }),
751
- /* @__PURE__ */ e.jsx(
752
- i,
753
- {
754
- name: "targetId",
755
- children: (s) => /* @__PURE__ */ e.jsxs(N, { children: [
756
- /* @__PURE__ */ e.jsxs(C, { htmlFor: s.name, children: [
757
- m("editor.flowNodeForm.targetId"),
758
- " (Flow ID)"
759
- ] }),
760
- /* @__PURE__ */ e.jsx(
761
- y,
762
- {
763
- id: s.name,
764
- name: s.name,
765
- value: s.state.value,
766
- onBlur: s.handleBlur,
767
- onChange: ({ target: c }) => s.handleChange(c.value)
768
- }
769
- ),
770
- /* @__PURE__ */ e.jsx(O, { children: "Unique identifier of the target flow." })
771
- ] })
772
- }
773
- )
774
- ] })
775
- }
776
- );
777
- }, ea = () => {
778
- const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), { Field: m } = ie({
779
- defaultValues: {
780
- label: n?.data?.label || { en: "" }
781
- },
782
- listeners: {
783
- onChange: ({ formApi: i }) => {
784
- i.handleSubmit().then();
785
- },
786
- onChangeDebounceMs: 150
787
- },
788
- onSubmit: ({ value: i }) => {
789
- l(i);
790
- }
791
- });
792
- return /* @__PURE__ */ e.jsx(
793
- "form",
794
- {
795
- onSubmit: (i) => {
796
- i.preventDefault(), i.stopPropagation();
797
- },
798
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
799
- /* @__PURE__ */ e.jsx(
800
- m,
801
- {
802
- name: "label",
803
- children: (i) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
804
- /* @__PURE__ */ e.jsx(C, { htmlFor: i.name, children: "Label" }),
805
- /* @__PURE__ */ e.jsx(
806
- y,
807
- {
808
- id: i.name,
809
- name: i.name,
810
- value: i.state.value?.[t] || "",
811
- onBlur: i.handleBlur,
812
- onChange: ({ target: s }) => {
813
- i.handleChange({
814
- ...i.state.value,
815
- [t]: s.value
816
- });
817
- }
818
- }
819
- )
820
- ] })
821
- }
822
- ),
823
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
824
- ] })
825
- }
826
- );
827
- }, ta = ["POST", "PUT", "PATCH"], aa = ({ value: t, onChange: r }) => {
828
- const { selectedNode: n } = W(), l = B(), m = Ie(n?.id), { handleSubmit: i, Field: s } = ie({
829
- defaultValues: {
830
- body: t?.body || "",
831
- // fetchOnMount should be true by default if there's no searchParam
832
- fetchOnMount: t?.fetchOnMount ?? !t?.searchParam,
833
- headers: t?.headers || [],
834
- method: t?.method || "GET",
835
- responseMapping: t?.responseMapping || {
836
- labelField: "",
837
- valueField: ""
838
- },
839
- responsePath: t?.responsePath || "",
840
- searchParam: t?.searchParam || "",
841
- showLoading: t?.showLoading !== !1,
842
- url: t?.url || ""
843
- },
844
- listeners: {
845
- onChange: ({ formApi: c }) => {
846
- c.handleSubmit().then();
847
- },
848
- onChangeDebounceMs: 150
849
- },
850
- onSubmit: ({ value: c }) => {
851
- r(c);
852
- }
853
- });
854
- return /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
855
- /* @__PURE__ */ e.jsx(
856
- s,
857
- {
858
- name: "url",
859
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
860
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.apiUrl") }),
861
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
862
- /* @__PURE__ */ e.jsx(
863
- y,
864
- {
865
- id: c.name,
866
- name: c.name,
867
- value: c.state.value,
868
- onBlur: c.handleBlur,
869
- onChange: ({ target: d }) => c.handleChange(d.value),
870
- placeholder: l("editor.httpConfigForm.apiUrlPlaceholder"),
871
- className: "flex-1"
872
- }
873
- ),
874
- /* @__PURE__ */ e.jsxs(Fe, { children: [
875
- /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { type: "button", variant: "outline", size: "icon", children: /* @__PURE__ */ e.jsx(He, { className: "h-4 w-4" }) }) }),
876
- /* @__PURE__ */ e.jsx(Ve, { align: "end", children: m.length === 0 ? /* @__PURE__ */ e.jsx(U, { disabled: !0, children: l("editor.httpConfigForm.noFieldsAvailable") }) : m.map((d) => /* @__PURE__ */ e.jsx(
877
- U,
878
- {
879
- onClick: () => {
880
- const a = `{{${d.nodeId}}}`, o = c.state.value || "";
881
- c.handleChange(o + a);
882
- },
883
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
884
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: d.label }),
885
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${d.nodeId}}}` })
886
- ] })
887
- },
888
- d.nodeId
889
- )) })
890
- ] })
891
- ] }),
892
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.apiUrlDesc") })
893
- ] })
894
- }
895
- ),
896
- /* @__PURE__ */ e.jsx(
897
- s,
898
- {
899
- name: "method",
900
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
901
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.httpMethod") }),
902
- /* @__PURE__ */ e.jsxs(
903
- $,
904
- {
905
- value: c.state.value,
906
- onValueChange: (d) => c.handleChange(d),
907
- children: [
908
- /* @__PURE__ */ e.jsx(A, { id: c.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: l("editor.httpConfigForm.selectMethod") }) }),
909
- /* @__PURE__ */ e.jsxs(G, { children: [
910
- /* @__PURE__ */ e.jsx(f, { value: "GET", children: l("editor.httpConfigForm.methodGet") }),
911
- /* @__PURE__ */ e.jsx(f, { value: "POST", children: l("editor.httpConfigForm.methodPost") }),
912
- /* @__PURE__ */ e.jsx(f, { value: "PUT", children: l("editor.httpConfigForm.methodPut") }),
913
- /* @__PURE__ */ e.jsx(f, { value: "DELETE", children: l("editor.httpConfigForm.methodDelete") }),
914
- /* @__PURE__ */ e.jsx(f, { value: "PATCH", children: l("editor.httpConfigForm.methodPatch") })
915
- ] })
916
- ]
917
- }
918
- )
919
- ] })
920
- }
921
- ),
922
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
923
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.headers") }),
924
- /* @__PURE__ */ e.jsx(s, { name: "headers", mode: "array", children: (c) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
925
- c.state.value?.map((d, a) => {
926
- const o = `headers[${a}]`;
927
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
928
- /* @__PURE__ */ e.jsx(s, { name: `headers[${a}].key`, children: (u) => /* @__PURE__ */ e.jsx(
929
- y,
930
- {
931
- placeholder: l("editor.httpConfigForm.headerName"),
932
- value: u.state.value || "",
933
- onChange: ({ target: h }) => u.handleChange(h.value)
934
- }
935
- ) }),
936
- /* @__PURE__ */ e.jsx(s, { name: `headers[${a}].value`, children: (u) => /* @__PURE__ */ e.jsx(
937
- y,
938
- {
939
- placeholder: l("editor.httpConfigForm.headerValue"),
940
- value: u.state.value || "",
941
- onChange: ({ target: h }) => u.handleChange(h.value)
942
- }
943
- ) }),
944
- /* @__PURE__ */ e.jsx(
945
- w,
946
- {
947
- type: "button",
948
- variant: "ghost",
949
- size: "icon",
950
- onClick: () => {
951
- c.removeValue(a);
952
- },
953
- children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
954
- }
955
- )
956
- ] }, o);
957
- }),
958
- /* @__PURE__ */ e.jsxs(
959
- w,
960
- {
961
- type: "button",
962
- variant: "outline",
963
- size: "sm",
964
- onClick: () => {
965
- c.pushValue({ key: "", value: "" });
966
- },
967
- children: [
968
- /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
969
- l("editor.httpConfigForm.addHeader")
970
- ]
971
- }
972
- )
973
- ] }) })
974
- ] }),
975
- /* @__PURE__ */ e.jsx(s, { name: "method", children: (c) => ta.includes(c.state.value || "") && /* @__PURE__ */ e.jsx(s, { name: "body", children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
976
- /* @__PURE__ */ e.jsxs("div", { className: "mb-2 flex items-center justify-between", children: [
977
- /* @__PURE__ */ e.jsx(C, { htmlFor: d.name, children: l("editor.httpConfigForm.requestBody") }),
978
- /* @__PURE__ */ e.jsxs(Fe, { children: [
979
- /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsxs(w, { type: "button", variant: "ghost", size: "sm", children: [
980
- /* @__PURE__ */ e.jsx(He, { className: "mr-2 h-4 w-4" }),
981
- l("editor.httpConfigForm.insertVariable")
982
- ] }) }),
983
- /* @__PURE__ */ e.jsx(Ve, { align: "end", children: m.length === 0 ? /* @__PURE__ */ e.jsx(U, { disabled: !0, children: l("editor.httpConfigForm.noFieldsAvailable") }) : m.map((a) => /* @__PURE__ */ e.jsx(
984
- U,
985
- {
986
- onClick: () => {
987
- const u = `\${${a.name || a.nodeId}}`, h = d.state.value || "";
988
- d.handleChange(h + u), i().then();
989
- },
990
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
991
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: a.label }),
992
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `\${${a.name || a.nodeId}}` })
993
- ] })
994
- },
995
- a.nodeId
996
- )) })
997
- ] })
998
- ] }),
999
- /* @__PURE__ */ e.jsx(
1000
- Ke,
1001
- {
1002
- id: d.name,
1003
- name: d.name,
1004
- value: d.state.value,
1005
- onBlur: d.handleBlur,
1006
- onChange: ({ target: a }) => d.handleChange(a.value),
1007
- placeholder: l("editor.httpConfigForm.requestBodyPlaceholder"),
1008
- rows: 4
1009
- }
1010
- ),
1011
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.requestBodyDesc") })
1012
- ] }) }) }),
1013
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1014
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.responseConfiguration") }),
1015
- /* @__PURE__ */ e.jsx(
1016
- s,
1017
- {
1018
- name: "responsePath",
1019
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1020
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.responsePath") }),
1021
- /* @__PURE__ */ e.jsx(
1022
- y,
1023
- {
1024
- id: c.name,
1025
- name: c.name,
1026
- value: c.state.value,
1027
- onBlur: c.handleBlur,
1028
- onChange: ({ target: d }) => c.handleChange(d.value),
1029
- placeholder: l("editor.httpConfigForm.responsePathPlaceholder")
1030
- }
1031
- ),
1032
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.responsePathDesc") })
1033
- ] })
1034
- }
1035
- ),
1036
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1037
- /* @__PURE__ */ e.jsx("h5", { className: "font-medium text-sm", children: l("editor.httpConfigForm.mapToOptions") }),
1038
- /* @__PURE__ */ e.jsx(
1039
- s,
1040
- {
1041
- name: "responseMapping.valueField",
1042
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1043
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.valueField") }),
1044
- /* @__PURE__ */ e.jsx(
1045
- y,
1046
- {
1047
- id: c.name,
1048
- name: c.name,
1049
- value: c.state.value,
1050
- onBlur: c.handleBlur,
1051
- onChange: ({ target: d }) => c.handleChange(d.value),
1052
- placeholder: l("editor.httpConfigForm.valueFieldPlaceholder")
1053
- }
1054
- ),
1055
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.valueFieldDesc") })
1056
- ] })
1057
- }
1058
- ),
1059
- /* @__PURE__ */ e.jsx(
1060
- s,
1061
- {
1062
- name: "responseMapping.labelField",
1063
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1064
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.labelField") }),
1065
- /* @__PURE__ */ e.jsx(
1066
- y,
1067
- {
1068
- id: c.name,
1069
- name: c.name,
1070
- value: c.state.value,
1071
- onBlur: c.handleBlur,
1072
- onChange: ({ target: d }) => c.handleChange(d.value),
1073
- placeholder: l("editor.httpConfigForm.labelFieldPlaceholder")
1074
- }
1075
- ),
1076
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.labelFieldDesc") })
1077
- ] })
1078
- }
1079
- )
1080
- ] }),
1081
- /* @__PURE__ */ e.jsx(
1082
- s,
1083
- {
1084
- name: "searchParam",
1085
- children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1086
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.searchParameter") }),
1087
- /* @__PURE__ */ e.jsx(
1088
- y,
1089
- {
1090
- id: c.name,
1091
- name: c.name,
1092
- value: c.state.value,
1093
- onBlur: c.handleBlur,
1094
- onChange: ({ target: d }) => c.handleChange(d.value),
1095
- placeholder: l("editor.httpConfigForm.searchParameterPlaceholder")
1096
- }
1097
- ),
1098
- /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.searchParameterDesc") })
1099
- ] })
1100
- }
1101
- )
1102
- ] }),
1103
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1104
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.behavior") }),
1105
- /* @__PURE__ */ e.jsx(s, { name: "searchParam", children: (c) => /* @__PURE__ */ e.jsx(s, { name: "fetchOnMount", children: (d) => {
1106
- const a = !!c.state.value?.trim(), o = a ? d.state.value : !0;
1107
- return !a && d.state.value !== !0 && d.handleChange(!0), /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1108
- /* @__PURE__ */ e.jsx(
1109
- te,
1110
- {
1111
- id: d.name,
1112
- checked: o,
1113
- disabled: !a,
1114
- onCheckedChange: (u) => d.handleChange(u)
1115
- }
1116
- ),
1117
- /* @__PURE__ */ e.jsx(C, { htmlFor: d.name, className: a ? "" : "text-muted-foreground", children: l("editor.httpConfigForm.fetchOnMount") })
1118
- ] });
1119
- } }) }),
1120
- /* @__PURE__ */ e.jsx(
1121
- s,
1122
- {
1123
- name: "showLoading",
1124
- children: (c) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1125
- /* @__PURE__ */ e.jsx(te, { id: c.name, checked: c.state.value, onCheckedChange: (d) => c.handleChange(d) }),
1126
- /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.showLoadingState") })
1127
- ] })
1128
- }
1129
- )
1130
- ] })
1131
- ] }) });
1132
- }, sa = ({
1133
- options: t,
1134
- value: r,
1135
- onValueChange: n,
1136
- placeholder: l = "Select...",
1137
- searchPlaceholder: m = "Search or create...",
1138
- createLabel: i = (u) => `Use: ${u}`,
1139
- clearLabel: s = "Clear selection",
1140
- emptyLabel: c = "No results found",
1141
- className: d,
1142
- allowClear: a = !0,
1143
- allowCreate: o = !0
1144
- }) => {
1145
- const [u, h] = _(!1), [x, p] = _(""), v = (b) => b ?? "", M = (b) => b.trim().toLowerCase(), F = v(r), S = r !== null && r !== "", g = S ? t.find((b) => v(b.value) === F) : void 0, E = M(x), V = o && E !== "" && !t.some((b) => M(b.label) === E || M(b.value ?? "") === E), P = (b) => {
1146
- b === F ? a && n?.("") : n?.(b), h(!1), p("");
1147
- }, T = () => {
1148
- x.trim() && (n?.(x.trim()), h(!1), p(""));
1149
- }, X = () => {
1150
- n?.(""), h(!1), p("");
1151
- };
1152
- return /* @__PURE__ */ e.jsxs(Pe, { open: u, onOpenChange: h, children: [
1153
- /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
1154
- w,
1155
- {
1156
- type: "button",
1157
- variant: "outline",
1158
- role: "combobox",
1159
- "aria-expanded": u,
1160
- className: D("w-full justify-between font-normal", d),
1161
- children: [
1162
- /* @__PURE__ */ e.jsx("span", { className: "truncate", children: S && g ? g.label : l }),
1163
- /* @__PURE__ */ e.jsx(de, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
1164
- ]
1165
- }
1166
- ) }),
1167
- /* @__PURE__ */ e.jsx(Ee, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ e.jsxs(We, { shouldFilter: !1, children: [
1168
- /* @__PURE__ */ e.jsx(Ye, { placeholder: m, value: x, onValueChange: p }),
1169
- /* @__PURE__ */ e.jsxs(Je, { children: [
1170
- /* @__PURE__ */ e.jsx(Xe, { children: c }),
1171
- a && S && /* @__PURE__ */ e.jsx(Be, { children: /* @__PURE__ */ e.jsxs(be, { value: "__clear__", onSelect: X, className: "text-muted-foreground mt-1", children: [
1172
- /* @__PURE__ */ e.jsx(oe, { className: "mr-2 h-4 w-4" }),
1173
- s
1174
- ] }) }),
1175
- /* @__PURE__ */ e.jsxs(Be, { children: [
1176
- V && /* @__PURE__ */ e.jsxs(be, { value: `__create__${x}`, onSelect: T, className: "text-primary", children: [
1177
- /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
1178
- i(x)
1179
- ] }),
1180
- t.filter((b) => {
1181
- const Q = x.toLowerCase();
1182
- return b.label.toLowerCase().includes(Q) || (b.value?.toLowerCase() ?? "").includes(Q);
1183
- }).map((b, Q) => /* @__PURE__ */ e.jsxs(
1184
- be,
1185
- {
1186
- value: b.label,
1187
- onSelect: () => P(b?.value || ""),
1188
- children: [
1189
- /* @__PURE__ */ e.jsx(
1190
- St,
1191
- {
1192
- "aria-hidden": "true",
1193
- className: D(
1194
- "mr-2 h-4 w-4",
1195
- S && v(b.value) === F ? "opacity-100" : "opacity-0"
1196
- )
1197
- }
1198
- ),
1199
- b.label
1200
- ]
1201
- },
1202
- b.value ?? b.label ?? Q
1203
- ))
1204
- ] })
1205
- ] })
1206
- ] }) })
1207
- ] });
1208
- }, na = {
1209
- alphanumeric: "^[a-zA-Z0-9]+$",
1210
- email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
1211
- letters: "^[a-zA-Z]+$",
1212
- number: "^[0-9]+$",
1213
- url: "^https?:\\/\\/.+$"
1214
- }, we = Object.entries(na).map(([t, r]) => ({
1215
- label: t.charAt(0).toUpperCase() + t.slice(1).replace(/_/g, " "),
1216
- value: r
1217
- })), oa = ({ value: t, onValueChange: r }) => {
1218
- const n = ae(() => t && !we.some((l) => l.value === t) ? [
1219
- ...we,
1220
- {
1221
- label: `Custom: ${t}`,
1222
- value: t
1223
- }
1224
- ] : we, [t]);
1225
- return /* @__PURE__ */ e.jsx(
1226
- sa,
1227
- {
1228
- options: n,
1229
- value: t,
1230
- onValueChange: r,
1231
- placeholder: "Select or create a pattern",
1232
- searchPlaceholder: "Search patterns...",
1233
- createLabel: (l) => `Use pattern: ${l}`
1234
- }
1235
- );
1236
- }, ra = {
1237
- address: "address",
1238
- autocomplete: "autocomplete",
1239
- checkbox: "checkbox",
1240
- date: "date",
1241
- daterange: "daterange",
1242
- file: "file",
1243
- hidden: "hidden",
1244
- http: "http",
1245
- number: "number",
1246
- password: "password",
1247
- radio: "radio",
1248
- select: "select",
1249
- switch: "switch",
1250
- text: "text",
1251
- textarea: "textarea",
1252
- time: "time",
1253
- timerange: "timerange"
1254
- }, la = ({ value: t, onValueChange: r }) => {
1255
- const n = B();
1256
- return /* @__PURE__ */ e.jsxs(q, { children: [
1257
- /* @__PURE__ */ e.jsx(Te, { children: n("editor.selectInputType.type") }),
1258
- /* @__PURE__ */ e.jsxs($, { value: t, onValueChange: r, children: [
1259
- /* @__PURE__ */ e.jsx(A, { className: "w-full capitalize", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
1260
- /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.values(ra).map((l) => /* @__PURE__ */ e.jsx(f, { value: l, className: "capitalize", children: l }, l)) }) })
1261
- ] })
1262
- ] });
1263
- };
1264
- function je({ ...t }) {
1265
- return /* @__PURE__ */ e.jsx(Me.Root, { "data-slot": "collapsible", ...t });
1266
- }
1267
- function ge({ ...t }) {
1268
- return /* @__PURE__ */ e.jsx(Me.CollapsibleTrigger, { "data-slot": "collapsible-trigger", ...t });
1269
- }
1270
- function Ce({ ...t }) {
1271
- return /* @__PURE__ */ e.jsx(Me.CollapsibleContent, { "data-slot": "collapsible-content", ...t });
1272
- }
1273
- const ia = () => {
1274
- const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), m = ["select", "radio", "autocomplete", "checkbox"].includes(n?.data?.type || ""), i = Ie(n?.id), s = B(), { handleSubmit: c, Field: d } = ie({
1275
- defaultValues: {
1276
- defaultValue: n?.data?.defaultValue,
1277
- errorMessage: n?.data?.errorMessage || { en: "" },
1278
- helperText: n?.data?.helperText || { en: "" },
1279
- httpConfig: n?.data?.httpConfig,
1280
- label: n?.data?.label || { en: "" },
1281
- multiple: n?.data?.multiple,
1282
- name: n?.data?.name || "",
1283
- options: n?.data?.options || [],
1284
- pattern: n?.data?.pattern || "",
1285
- placeholder: n?.data?.placeholder || { en: "" },
1286
- required: n?.data?.required,
1287
- type: n?.data?.type || ""
1288
- },
1289
- listeners: {
1290
- onChange: ({ formApi: a }) => {
1291
- a.handleSubmit().then();
1292
- },
1293
- onChangeDebounceMs: 150
1294
- },
1295
- onSubmit: ({ value: a }) => {
1296
- l(a);
1297
- }
1298
- });
1299
- return /* @__PURE__ */ e.jsx(
1300
- "form",
1301
- {
1302
- onSubmit: (a) => {
1303
- a.preventDefault(), a.stopPropagation();
1304
- },
1305
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1306
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1307
- /* @__PURE__ */ e.jsx(
1308
- d,
1309
- {
1310
- name: "label",
1311
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1312
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.label") }),
1313
- /* @__PURE__ */ e.jsx(
1314
- y,
1315
- {
1316
- id: a.name,
1317
- name: a.name,
1318
- value: a.state.value?.[t] || "",
1319
- onBlur: a.handleBlur,
1320
- onChange: ({ target: o }) => {
1321
- a.handleChange({
1322
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1323
- [t]: o.value
1324
- });
1325
- }
1326
- }
1327
- )
1328
- ] })
1329
- }
1330
- ),
1331
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1332
- ] }),
1333
- /* @__PURE__ */ e.jsx(
1334
- d,
1335
- {
1336
- name: "type",
1337
- children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsx(la, { value: a.state.value, onValueChange: (o) => a.handleChange(o) }) })
1338
- }
1339
- ),
1340
- /* @__PURE__ */ e.jsx(
1341
- d,
1342
- {
1343
- name: "name",
1344
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
1345
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.name") }),
1346
- /* @__PURE__ */ e.jsx(
1347
- y,
1348
- {
1349
- id: a.name,
1350
- name: a.name,
1351
- value: a.state.value,
1352
- onBlur: a.handleBlur,
1353
- onChange: ({ target: o }) => a.handleChange(o.value)
1354
- }
1355
- )
1356
- ] })
1357
- }
1358
- ),
1359
- n?.data?.type !== "file" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1360
- /* @__PURE__ */ e.jsx(
1361
- d,
1362
- {
1363
- name: "placeholder",
1364
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1365
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.placeholder") }),
1366
- /* @__PURE__ */ e.jsx(
1367
- y,
1368
- {
1369
- id: a.name,
1370
- name: a.name,
1371
- value: a.state.value?.[t] || "",
1372
- onBlur: a.handleBlur,
1373
- onChange: ({ target: o }) => {
1374
- a.handleChange({
1375
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1376
- [t]: o.value
1377
- });
1378
- }
1379
- }
1380
- )
1381
- ] })
1382
- }
1383
- ),
1384
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1385
- ] }),
1386
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1387
- /* @__PURE__ */ e.jsx(
1388
- d,
1389
- {
1390
- name: "helperText",
1391
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1392
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.helperText") }),
1393
- /* @__PURE__ */ e.jsx(
1394
- y,
1395
- {
1396
- id: a.name,
1397
- name: a.name,
1398
- value: a.state.value?.[t] || "",
1399
- onBlur: a.handleBlur,
1400
- onChange: ({ target: o }) => {
1401
- a.handleChange({
1402
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1403
- [t]: o.value
1404
- });
1405
- }
1406
- }
1407
- )
1408
- ] })
1409
- }
1410
- ),
1411
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1412
- ] }),
1413
- n?.data?.type === "http" && /* @__PURE__ */ e.jsxs(je, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1414
- /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1415
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.httpConfiguration") }),
1416
- /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1417
- /* @__PURE__ */ e.jsx(de, {}),
1418
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1419
- ] })
1420
- ] }) }),
1421
- /* @__PURE__ */ e.jsx(Ce, { className: "flex flex-col gap-4", children: /* @__PURE__ */ e.jsx(d, { name: "httpConfig", children: (a) => /* @__PURE__ */ e.jsx(
1422
- aa,
1423
- {
1424
- value: a.state.value,
1425
- onChange: (o) => {
1426
- a.handleChange(o), c().then();
1427
- }
1428
- }
1429
- ) }) })
1430
- ] }),
1431
- n?.data?.type === "file" && /* @__PURE__ */ e.jsx(
1432
- d,
1433
- {
1434
- name: "multiple",
1435
- children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1436
- /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1437
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.multipleFiles") })
1438
- ] })
1439
- }
1440
- ),
1441
- m && /* @__PURE__ */ e.jsxs(je, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1442
- /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1443
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.options") }),
1444
- /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1445
- /* @__PURE__ */ e.jsx(de, {}),
1446
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1447
- ] })
1448
- ] }) }),
1449
- /* @__PURE__ */ e.jsxs(Ce, { className: "flex flex-col gap-4", children: [
1450
- /* @__PURE__ */ e.jsx(d, { name: "options", mode: "array", children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1451
- a.state.value?.map((o, u) => {
1452
- const h = `options[${u}]`;
1453
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
1454
- /* @__PURE__ */ e.jsx(d, { name: `options[${u}].label`, children: (x) => /* @__PURE__ */ e.jsx(
1455
- y,
1456
- {
1457
- placeholder: s("editor.inputNodeForm.optionLabel"),
1458
- value: x.state.value?.[t] || "",
1459
- onChange: ({ target: p }) => {
1460
- x.handleChange({
1461
- ...typeof x.state.value == "object" && x.state.value !== null ? x.state.value : {},
1462
- [t]: p.value
1463
- });
1464
- }
1465
- }
1466
- ) }),
1467
- /* @__PURE__ */ e.jsx(d, { name: `options[${u}].value`, children: (x) => /* @__PURE__ */ e.jsx(
1468
- y,
1469
- {
1470
- placeholder: s("editor.inputNodeForm.optionValue"),
1471
- value: x.state.value || "",
1472
- onChange: ({ target: p }) => x.handleChange(p.value)
1473
- }
1474
- ) }),
1475
- /* @__PURE__ */ e.jsx(
1476
- w,
1477
- {
1478
- type: "button",
1479
- variant: "ghost",
1480
- size: "icon",
1481
- onClick: () => {
1482
- a.removeValue(u), c().then();
1483
- },
1484
- children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
1485
- }
1486
- )
1487
- ] }, h);
1488
- }),
1489
- /* @__PURE__ */ e.jsx(
1490
- w,
1491
- {
1492
- type: "button",
1493
- variant: "outline",
1494
- size: "sm",
1495
- onClick: () => {
1496
- a.pushValue({ label: { en: "" }, value: "" }), c().then();
1497
- },
1498
- children: s("editor.inputNodeForm.addOption")
1499
- }
1500
- )
1501
- ] }) }),
1502
- n?.data?.type === "select" && /* @__PURE__ */ e.jsx(
1503
- d,
1504
- {
1505
- name: "multiple",
1506
- children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1507
- /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1508
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.multipleSelection") })
1509
- ] })
1510
- }
1511
- )
1512
- ] })
1513
- ] }),
1514
- /* @__PURE__ */ e.jsxs(je, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1515
- /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1516
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.validation") }),
1517
- /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1518
- /* @__PURE__ */ e.jsx(de, {}),
1519
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1520
- ] })
1521
- ] }) }),
1522
- /* @__PURE__ */ e.jsxs(Ce, { className: "flex flex-col gap-6", children: [
1523
- /* @__PURE__ */ e.jsx(
1524
- d,
1525
- {
1526
- name: "required",
1527
- children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1528
- /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1529
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.required") })
1530
- ] }) })
1531
- }
1532
- ),
1533
- /* @__PURE__ */ e.jsx(
1534
- d,
1535
- {
1536
- name: "pattern",
1537
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
1538
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.pattern") }),
1539
- /* @__PURE__ */ e.jsx(oa, { value: a.state.value, onValueChange: a.handleChange })
1540
- ] })
1541
- }
1542
- ),
1543
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1544
- /* @__PURE__ */ e.jsx(
1545
- d,
1546
- {
1547
- name: "errorMessage",
1548
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1549
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.errorMessage") }),
1550
- /* @__PURE__ */ e.jsx(
1551
- y,
1552
- {
1553
- id: a.name,
1554
- name: a.name,
1555
- value: a.state.value?.[t] || "",
1556
- onBlur: a.handleBlur,
1557
- onChange: ({ target: o }) => {
1558
- a.handleChange({
1559
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1560
- [t]: o.value
1561
- });
1562
- }
1563
- }
1564
- )
1565
- ] })
1566
- }
1567
- ),
1568
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1569
- ] })
1570
- ] })
1571
- ] }),
1572
- /* @__PURE__ */ e.jsxs(je, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1573
- /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1574
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.advancedConfiguration") }),
1575
- /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1576
- /* @__PURE__ */ e.jsx(de, {}),
1577
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1578
- ] })
1579
- ] }) }),
1580
- /* @__PURE__ */ e.jsx(Ce, { className: "flex flex-col gap-6", children: /* @__PURE__ */ e.jsx(d, { name: "defaultValue", children: (a) => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1581
- /* @__PURE__ */ e.jsxs(N, { children: [
1582
- /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.defaultValueType") }),
1583
- /* @__PURE__ */ e.jsxs(
1584
- $,
1585
- {
1586
- value: a.state.value?.type || "none",
1587
- onValueChange: (o) => {
1588
- a.handleChange(o === "none" ? null : { type: o });
1589
- },
1590
- children: [
1591
- /* @__PURE__ */ e.jsx(A, { id: a.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectType") }) }),
1592
- /* @__PURE__ */ e.jsxs(G, { children: [
1593
- /* @__PURE__ */ e.jsx(f, { value: "none", children: s("editor.inputNodeForm.defaultValueTypeNone") }),
1594
- /* @__PURE__ */ e.jsx(f, { value: "static", children: s("editor.inputNodeForm.defaultValueTypeStatic") }),
1595
- /* @__PURE__ */ e.jsx(f, { value: "reference", children: s("editor.inputNodeForm.defaultValueTypeReference") })
1596
- ] })
1597
- ]
1598
- }
1599
- )
1600
- ] }),
1601
- a.state.value?.type === "static" && /* @__PURE__ */ e.jsx(d, { name: "defaultValue.staticValue", children: (o) => {
1602
- const u = n?.data?.type;
1603
- return (u === "select" || u === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ e.jsxs(N, { children: [
1604
- /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.defaultValuesCommaSeparated") }),
1605
- /* @__PURE__ */ e.jsx(
1606
- y,
1607
- {
1608
- id: o.name,
1609
- placeholder: s("editor.inputNodeForm.defaultValuesPlaceholder"),
1610
- value: Array.isArray(o.state.value) ? o.state.value.join(", ") : "",
1611
- onChange: ({ target: h }) => {
1612
- const x = h.value.split(",").map((p) => p.trim()).filter(Boolean);
1613
- o.handleChange(x.length > 0 ? x : null);
1614
- }
1615
- }
1616
- )
1617
- ] }) : u === "checkbox" ? /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1618
- /* @__PURE__ */ e.jsx(
1619
- te,
1620
- {
1621
- id: o.name,
1622
- checked: !!o.state.value,
1623
- onCheckedChange: (h) => o.handleChange(h)
1624
- }
1625
- ),
1626
- /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.defaultChecked") })
1627
- ] }) }) : /* @__PURE__ */ e.jsxs(N, { children: [
1628
- /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.staticValue") }),
1629
- /* @__PURE__ */ e.jsx(
1630
- y,
1631
- {
1632
- id: o.name,
1633
- placeholder: s("editor.inputNodeForm.staticValuePlaceholder"),
1634
- value: typeof o.state.value == "string" ? o.state.value : "",
1635
- onChange: ({ target: h }) => o.handleChange(h.value || "")
1636
- }
1637
- )
1638
- ] });
1639
- } }),
1640
- a.state.value?.type === "reference" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1641
- /* @__PURE__ */ e.jsx(d, { name: "defaultValue.referenceField", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1642
- /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.referenceField") }),
1643
- /* @__PURE__ */ e.jsxs(
1644
- $,
1645
- {
1646
- value: o.state.value || "",
1647
- onValueChange: (u) => {
1648
- o.handleChange(u);
1649
- },
1650
- children: [
1651
- /* @__PURE__ */ e.jsx(A, { id: o.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectReferenceField") }) }),
1652
- /* @__PURE__ */ e.jsx(G, { children: i.length === 0 ? /* @__PURE__ */ e.jsx(f, { value: "none", disabled: !0, children: s("editor.inputNodeForm.noParentFieldsAvailable") }) : i.map((u) => /* @__PURE__ */ e.jsxs(f, { value: u.nodeId, children: [
1653
- u.label,
1654
- " (",
1655
- u.type,
1656
- ")"
1657
- ] }, u.nodeId)) })
1658
- ]
1659
- }
1660
- ),
1661
- i.length === 0 && /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.addInputFieldsBeforeReference") })
1662
- ] }) }),
1663
- /* @__PURE__ */ e.jsx(d, { name: "defaultValue.transformFunction", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1664
- /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.transformType") }),
1665
- /* @__PURE__ */ e.jsxs(
1666
- $,
1667
- {
1668
- value: o.state.value || "none",
1669
- onValueChange: (u) => {
1670
- const h = u === "none" ? null : u;
1671
- if (o.handleChange(h), u === "toObject") {
1672
- const x = a.state.value;
1673
- a.handleChange({
1674
- ...x,
1675
- objectMapping: []
1676
- });
1677
- }
1678
- },
1679
- children: [
1680
- /* @__PURE__ */ e.jsx(A, { id: o.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectTransformation") }) }),
1681
- /* @__PURE__ */ e.jsxs(G, { children: [
1682
- /* @__PURE__ */ e.jsx(f, { value: "none", children: s("editor.inputNodeForm.transformNone") }),
1683
- /* @__PURE__ */ e.jsx(f, { value: "toString", children: s("editor.inputNodeForm.transformString") }),
1684
- /* @__PURE__ */ e.jsx(f, { value: "toNumber", children: s("editor.inputNodeForm.transformNumber") }),
1685
- /* @__PURE__ */ e.jsx(f, { value: "toBoolean", children: s("editor.inputNodeForm.transformBoolean") }),
1686
- /* @__PURE__ */ e.jsx(f, { value: "toArray", children: s("editor.inputNodeForm.transformArray") }),
1687
- /* @__PURE__ */ e.jsx(f, { value: "toObject", children: s("editor.inputNodeForm.transformMapToObject") })
1688
- ] })
1689
- ]
1690
- }
1691
- ),
1692
- /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.transformDesc") })
1693
- ] }) }),
1694
- a.state.value?.transformFunction === "toObject" && /* @__PURE__ */ e.jsx(d, { name: "defaultValue.objectMapping", mode: "array", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1695
- /* @__PURE__ */ e.jsx(C, { children: s("editor.inputNodeForm.objectMapping") }),
1696
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1697
- o.state.value?.map((u, h) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1698
- /* @__PURE__ */ e.jsx(d, { name: `defaultValue.objectMapping[${h}].sourceKey`, children: (x) => /* @__PURE__ */ e.jsx(
1699
- y,
1700
- {
1701
- placeholder: s("editor.inputNodeForm.sourceKey"),
1702
- value: x.state.value || "",
1703
- onChange: ({ target: p }) => x.handleChange(p.value)
1704
- }
1705
- ) }),
1706
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: "→" }),
1707
- /* @__PURE__ */ e.jsx(d, { name: `defaultValue.objectMapping[${h}].targetKey`, children: (x) => /* @__PURE__ */ e.jsx(
1708
- y,
1709
- {
1710
- placeholder: s("editor.inputNodeForm.targetKey"),
1711
- value: x.state.value || "",
1712
- onChange: ({ target: p }) => x.handleChange(p.value)
1713
- }
1714
- ) }),
1715
- /* @__PURE__ */ e.jsx(
1716
- w,
1717
- {
1718
- type: "button",
1719
- variant: "ghost",
1720
- size: "icon",
1721
- onClick: () => {
1722
- o.removeValue(h), c().then();
1723
- },
1724
- children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
1725
- }
1726
- )
1727
- ] }, `mapping-${h}`)),
1728
- /* @__PURE__ */ e.jsxs(
1729
- w,
1730
- {
1731
- type: "button",
1732
- variant: "outline",
1733
- size: "sm",
1734
- className: "w-full",
1735
- onClick: () => {
1736
- o.pushValue({ sourceKey: "", targetKey: "" }), c().then();
1737
- },
1738
- children: [
1739
- /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
1740
- s("editor.inputNodeForm.addMapping")
1741
- ]
1742
- }
1743
- )
1744
- ] }),
1745
- /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.objectMappingDesc") })
1746
- ] }) })
1747
- ] })
1748
- ] }) }) })
1749
- ] })
1750
- ] })
1751
- }
1752
- );
1753
- }, Oe = {
1754
- divider: "divider",
1755
- title: "title"
1756
- }, ca = () => {
1757
- const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), { Field: m } = ie({
1758
- defaultValues: {
1759
- label: n?.data?.label || { en: "" },
1760
- type: n?.data?.type
1761
- },
1762
- listeners: {
1763
- onChange: ({ formApi: i }) => {
1764
- i.handleSubmit().then();
1765
- },
1766
- onChangeDebounceMs: 150
1767
- },
1768
- onSubmit: ({ value: i }) => {
1769
- l(i);
1770
- }
1771
- });
1772
- return /* @__PURE__ */ e.jsx(
1773
- "form",
1774
- {
1775
- onSubmit: (i) => {
1776
- i.preventDefault(), i.stopPropagation();
1777
- },
1778
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1779
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1780
- /* @__PURE__ */ e.jsx(
1781
- m,
1782
- {
1783
- name: "label",
1784
- children: (i) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1785
- /* @__PURE__ */ e.jsx(C, { htmlFor: i.name, children: "Label" }),
1786
- /* @__PURE__ */ e.jsx(
1787
- y,
1788
- {
1789
- id: i.name,
1790
- name: i.name,
1791
- value: i.state.value?.[t] || "",
1792
- onBlur: i.handleBlur,
1793
- onChange: ({ target: s }) => {
1794
- i.handleChange({
1795
- ...i.state.value,
1796
- [t]: s.value
1797
- });
1798
- }
1799
- }
1800
- )
1801
- ] })
1802
- }
1803
- ),
1804
- /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1805
- ] }),
1806
- /* @__PURE__ */ e.jsx(
1807
- m,
1808
- {
1809
- name: "type",
1810
- children: (i) => /* @__PURE__ */ e.jsxs(q, { children: [
1811
- /* @__PURE__ */ e.jsx(Te, { children: "Type" }),
1812
- /* @__PURE__ */ e.jsxs($, { value: i.state.value, onValueChange: (s) => i.handleChange(s), children: [
1813
- /* @__PURE__ */ e.jsx(A, { className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
1814
- /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsxs(q, { children: [
1815
- /* @__PURE__ */ e.jsx(f, { value: Oe.title, children: "Title" }),
1816
- /* @__PURE__ */ e.jsx(f, { value: Oe.divider, children: "Divider" })
1817
- ] }) })
1818
- ] })
1819
- ] })
1820
- }
1821
- )
1822
- ] })
1823
- }
1824
- );
1825
- }, da = () => {
1826
- const [t, r] = _(""), [n, l] = _(!1), { selectedNode: m, groupNodes: i } = W(), { setNodes: s } = me(), c = m?.parentId || "none", d = ve(m), a = B();
1827
- if (d)
1828
- return null;
1829
- const o = (h) => {
1830
- m && s((x) => h === "none" ? x.map((v) => {
1831
- if (v.id === m.id) {
1832
- const { parentId: M, extent: F, ...S } = v;
1833
- return S;
1834
- }
1835
- return v;
1836
- }) : x.find((v) => v.id === h) ? x.map((v) => v.id === m.id ? {
1837
- ...v,
1838
- extent: "parent",
1839
- parentId: h,
1840
- position: {
1841
- x: 50,
1842
- y: 80
1843
- }
1844
- } : v) : x);
1845
- }, u = () => {
1846
- if (!(t.trim() && m))
1847
- return;
1848
- if (i.find((p) => {
1849
- const v = p.data?.label?.en || p.data?.label;
1850
- return String(v).toLowerCase() === t.trim().toLowerCase();
1851
- })) {
1852
- R.error("This group already exists", {
1853
- description: "Use the selector to add the node to an existing group."
1854
- });
1855
- return;
1856
- }
1857
- const x = le();
1858
- s((p) => {
1859
- const v = {
1860
- data: {
1861
- label: {
1862
- en: t.trim()
1863
- }
1864
- },
1865
- id: x,
1866
- position: {
1867
- x: m.position.x - 300,
1868
- y: m.position.y
1869
- },
1870
- style: {
1871
- height: 400,
1872
- width: 600
1873
- },
1874
- type: "group"
1875
- }, M = p.map((F) => F.id === m.id ? {
1876
- ...F,
1877
- extent: "parent",
1878
- parentId: x,
1879
- position: {
1880
- x: 175,
1881
- y: 30
1882
- }
1883
- } : F);
1884
- return [v, ...M];
1885
- }), r(""), l(!1), R.success("Group created", {
1886
- description: `The group "${t.trim()}" has been created successfully.`
1887
- });
1888
- };
1889
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1890
- /* @__PURE__ */ e.jsx(C, { children: a("editor.selectNodeGroup.group") }),
1891
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
1892
- /* @__PURE__ */ e.jsxs($, { value: c, onValueChange: o, children: [
1893
- /* @__PURE__ */ e.jsx(A, { className: "flex-1", children: /* @__PURE__ */ e.jsx(z, { placeholder: a("editor.selectNodeGroup.noGroup") }) }),
1894
- /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsxs(q, { children: [
1895
- /* @__PURE__ */ e.jsx(f, { value: "none", children: a("editor.selectNodeGroup.noGroup") }),
1896
- i.map((h) => /* @__PURE__ */ e.jsx(f, { value: h.id, children: h.data.label?.en ? String(h.data.label?.en) : h.id }, h.id))
1897
- ] }) })
1898
- ] }),
1899
- /* @__PURE__ */ e.jsxs(Pe, { open: n, onOpenChange: l, children: [
1900
- /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "icon", title: "Create a new group", children: /* @__PURE__ */ e.jsx(Vt, { className: "h-4 w-4" }) }) }),
1901
- /* @__PURE__ */ e.jsx(Ee, { className: "w-80", align: "end", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1902
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1903
- /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: a("editor.selectNodeGroup.newGroup") }),
1904
- /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: a("editor.selectNodeGroup.newGroupDescription") })
1905
- ] }),
1906
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1907
- /* @__PURE__ */ e.jsx(C, { htmlFor: "group-label", children: a("editor.selectNodeGroup.groupName") }),
1908
- /* @__PURE__ */ e.jsx(
1909
- y,
1910
- {
1911
- value: t,
1912
- onChange: (h) => r(h.target.value),
1913
- placeholder: "Ex: Step 1 - Personal info",
1914
- onKeyDown: (h) => {
1915
- h.key === "Enter" && (h.preventDefault(), u());
1916
- }
1917
- }
1918
- )
1919
- ] }),
1920
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2", children: [
1921
- /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "sm", onClick: () => l(!1), children: "Cancel" }),
1922
- /* @__PURE__ */ e.jsx(w, { size: "sm", onClick: u, disabled: !t.trim(), children: "Create" })
1923
- ] })
1924
- ] }) })
1925
- ] })
1926
- ] })
1927
- ] });
1928
- }, ha = () => {
1929
- const { selectedNode: t } = W(), { updateSelectedNodeType: r } = ce(), n = t?.type || "", l = ve(t), m = B();
1930
- return /* @__PURE__ */ e.jsxs(q, { children: [
1931
- /* @__PURE__ */ e.jsx(Te, { children: m("editor.selectNodeType.nodeType") }),
1932
- /* @__PURE__ */ e.jsxs($, { value: n, onValueChange: (i) => r(i), disabled: l, children: [
1933
- /* @__PURE__ */ e.jsx(A, { className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: m("editor.selectNodeType.nodeType") }) }),
1934
- /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.keys(Re).filter((i) => l ? i === "group" : i !== "group").map((i) => /* @__PURE__ */ e.jsx(f, { value: i, children: i.charAt(0).toUpperCase() + i.slice(1) }, i)) }) })
1935
- ] })
1936
- ] });
1937
- };
1938
- function ua({ ...t }) {
1939
- return /* @__PURE__ */ e.jsx(J.Root, { "data-slot": "sheet", ...t });
1940
- }
1941
- function ma({ ...t }) {
1942
- return /* @__PURE__ */ e.jsx(J.Portal, { "data-slot": "sheet-portal", ...t });
1943
- }
1944
- function xa({ className: t, ...r }) {
1945
- return /* @__PURE__ */ e.jsx(
1946
- J.Overlay,
1947
- {
1948
- "data-slot": "sheet-overlay",
1949
- className: D(
1950
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
1951
- t
1952
- ),
1953
- ...r
1954
- }
1955
- );
1956
- }
1957
- function pa({
1958
- className: t,
1959
- children: r,
1960
- side: n = "right",
1961
- ...l
1962
- }) {
1963
- return /* @__PURE__ */ e.jsxs(ma, { children: [
1964
- /* @__PURE__ */ e.jsx(xa, {}),
1965
- /* @__PURE__ */ e.jsxs(
1966
- J.Content,
1967
- {
1968
- "data-slot": "sheet-content",
1969
- className: D(
1970
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
1971
- n === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
1972
- n === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
1973
- n === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
1974
- n === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
1975
- t
1976
- ),
1977
- ...l,
1978
- children: [
1979
- r,
1980
- /* @__PURE__ */ e.jsxs(J.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
1981
- /* @__PURE__ */ e.jsx(Pt, { className: "size-4" }),
1982
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Close" })
1983
- ] })
1984
- ]
1985
- }
1986
- )
1987
- ] });
1988
- }
1989
- function ja({ className: t, ...r }) {
1990
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "sheet-header", className: D("flex flex-col gap-1.5 p-4", t), ...r });
1991
- }
1992
- function ga({ className: t, ...r }) {
1993
- return /* @__PURE__ */ e.jsx(J.Title, { "data-slot": "sheet-title", className: D("text-foreground font-semibold", t), ...r });
1994
- }
1995
- function Ca({ className: t, ...r }) {
1996
- return /* @__PURE__ */ e.jsx(J.Description, { "data-slot": "sheet-description", className: D("text-muted-foreground text-sm", t), ...r });
1997
- }
1998
- const va = () => {
1999
- const { selectedNode: t, hasSelectedNodes: r } = W(), { clearSelection: n } = ce(), m = B()(t?.data?.label);
2000
- return /* @__PURE__ */ e.jsx(ua, { open: r, onOpenChange: n, children: /* @__PURE__ */ e.jsxs(pa, { children: [
2001
- /* @__PURE__ */ e.jsxs(ja, { children: [
2002
- /* @__PURE__ */ e.jsxs(ga, { children: [
2003
- "Edit node ",
2004
- /* @__PURE__ */ e.jsx("span", { className: "font-light text-muted-foreground text-xs", children: t?.id })
2005
- ] }),
2006
- /* @__PURE__ */ e.jsx(Ca, { children: m || " " })
2007
- ] }),
2008
- /* @__PURE__ */ e.jsx(_e, { className: "flex min-h-0 flex-1 flex-col px-4 py-6", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
2009
- /* @__PURE__ */ e.jsx(ha, {}),
2010
- /* @__PURE__ */ e.jsx(da, {}),
2011
- /* @__PURE__ */ e.jsx(tt, {}),
2012
- he(t) && /* @__PURE__ */ e.jsx(ia, {}),
2013
- Qe(t) && /* @__PURE__ */ e.jsx(ca, {}),
2014
- et(t) && /* @__PURE__ */ e.jsx(Qt, {}),
2015
- ve(t) && /* @__PURE__ */ e.jsx(ea, {})
2016
- ] }) })
2017
- ] }) });
2018
- }, fa = () => {
2019
- const { setNodes: t, setEdges: r, screenToFlowPosition: n, getNode: l, getEdges: m } = me(), i = Z(
2020
- (a) => {
2021
- r((o) => {
2022
- const u = it(a, o), h = a.source, x = l(h);
2023
- return u.filter((v) => v.source === h).length > 1 && x && he(x) ? u.map((v) => v.source === h ? {
2024
- ...v,
2025
- data: {
2026
- ...v.data,
2027
- conditions: v.data?.conditions || [{ field: h, operator: "===", value: "" }]
2028
- },
2029
- type: "conditional"
2030
- } : v) : u;
2031
- });
2032
- },
2033
- [r, l]
2034
- ), s = Z(
2035
- (a, o) => {
2036
- if (!o.isValid) {
2037
- const { clientX: u, clientY: h } = "changedTouches" in a ? a.changedTouches[0] : a, x = o.fromNode;
2038
- if (!x)
2039
- return;
2040
- const p = x.id, M = m().filter((V) => V.source === p), F = x && he(x);
2041
- if (M.length > 0 && !F)
2042
- return;
2043
- const S = le(), g = le(), E = {
2044
- ...Ze,
2045
- id: S,
2046
- origin: [0.5, 0],
2047
- position: n({
2048
- x: u,
2049
- y: h
2050
- })
2051
- };
2052
- x?.parentId && (E.parentId = x.parentId, E.extent = "parent"), t((V) => V.concat(E)), r((V) => {
2053
- const T = V.filter((b) => b.source === p).length > 0, X = {
2054
- data: T && F ? {
2055
- conditions: [{ field: p, operator: "===", value: "" }]
2056
- } : void 0,
2057
- id: g,
2058
- source: p,
2059
- target: S,
2060
- type: T && F ? "conditional" : "default"
2061
- };
2062
- return T && F ? V.map((b) => b.source === p ? {
2063
- ...b,
2064
- data: {
2065
- ...b.data,
2066
- conditions: b.data?.conditions || [{ field: p, operator: "===", value: "" }]
2067
- },
2068
- type: "conditional"
2069
- } : b).concat(X) : V.concat(X);
2070
- });
2071
- }
2072
- },
2073
- [n, r, t, m]
2074
- ), c = Z(
2075
- (a) => {
2076
- r((o) => {
2077
- const u = o.filter((p) => !a.find((v) => v.id === p.id)), h = new Set(a.map((p) => p.source)), x = /* @__PURE__ */ new Map();
2078
- return u.forEach((p) => {
2079
- x.set(p.source, (x.get(p.source) ?? 0) + 1);
2080
- }), u.map((p) => {
2081
- if (h.has(p.source) && (x.get(p.source) ?? 0) === 1) {
2082
- const { conditions: M, isFallback: F, ...S } = p.data ?? {}, g = S && Object.keys(S).length > 0 ? S : void 0;
2083
- return { ...p, data: g, type: "default" };
2084
- }
2085
- return p;
2086
- });
2087
- });
2088
- },
2089
- [r]
2090
- );
2091
- return {
2092
- isValidConnection: Z(
2093
- (a) => {
2094
- if (a.source === a.target)
2095
- return !1;
2096
- const o = l(a.source);
2097
- return o ? !(m().filter((x) => x.source === a.source).length > 0 && !he(o)) : !1;
2098
- },
2099
- [l, m]
2100
- ),
2101
- onConnect: i,
2102
- onConnectEnd: s,
2103
- onEdgesDelete: c
2104
- };
2105
- }, ba = ({ ...t }) => {
2106
- const { theme: r = "system" } = Lt();
2107
- return /* @__PURE__ */ e.jsx(
2108
- It,
2109
- {
2110
- theme: r,
2111
- className: "toaster group",
2112
- style: {
2113
- "--normal-bg": "var(--popover)",
2114
- "--normal-border": "var(--border)",
2115
- "--normal-text": "var(--popover-foreground)"
2116
- },
2117
- ...t
2118
- }
2119
- );
2120
- }, Na = ({ edges: t, nodes: r, flow: n, onExportJson: l, onSave: m, theme: i }) => {
2121
- const { onConnect: s, onConnectEnd: c, onEdgesDelete: d, isValidConnection: a } = fa();
2122
- return /* @__PURE__ */ e.jsxs(
2123
- dt,
2124
- {
2125
- fitView: !0,
2126
- colorMode: i,
2127
- selectNodesOnDrag: !1,
2128
- nodeTypes: Re,
2129
- edgeTypes: Gt,
2130
- defaultEdges: t || n?.edges || [],
2131
- defaultNodes: r || n?.nodes || [],
2132
- onConnect: s,
2133
- onConnectEnd: c,
2134
- onEdgesDelete: d,
2135
- isValidConnection: a,
2136
- children: [
2137
- /* @__PURE__ */ e.jsx(ht, { gap: 10, variant: ut.Dots }),
2138
- /* @__PURE__ */ e.jsx(Jt, { onExportJson: l, onSave: m }),
2139
- /* @__PURE__ */ e.jsx(Ot, { theme: i }),
2140
- /* @__PURE__ */ e.jsx(mt, {}),
2141
- /* @__PURE__ */ e.jsx(xt, {}),
2142
- /* @__PURE__ */ e.jsx(va, {})
2143
- ]
2144
- }
2145
- );
2146
- }, Da = ({ edges: t, nodes: r, flow: n, onExportJson: l, onSave: m, theme: i = "dark", language: s = "en" }) => /* @__PURE__ */ e.jsx(at, { defaultTheme: i, storageKey: "treege-editor-theme", theme: i, children: /* @__PURE__ */ e.jsxs($t, { value: { flowId: n?.id, language: s }, children: [
2147
- /* @__PURE__ */ e.jsx(ba, { position: "bottom-center" }),
2148
- /* @__PURE__ */ e.jsx(ct, { children: /* @__PURE__ */ e.jsx(Na, { edges: t, nodes: r, onExportJson: l, onSave: m, flow: n, theme: i }) })
2149
- ] }) });
2150
- export {
2151
- Da as T
2152
- };