treege 3.0.0-beta.28 → 3.0.0-beta.29

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.
@@ -1,3312 +0,0 @@
1
- import { j as e, i as je, e as dt, L as oe, N as ye, c as Se, a as ct, b as ut, T as ht } from "./ThemeContext-BBEqRK_Q.js";
2
- import { useNodes as Oe, useEdges as We, getBezierPath as Je, useReactFlow as ue, BaseEdge as qe, EdgeLabelRenderer as Xe, addEdge as mt, Handle as ie, Position as de, NodeResizer as pt, Panel as xt, ReactFlowProvider as gt, ReactFlow as jt, Background as Ct, BackgroundVariant as vt, MiniMap as ft, Controls as bt } from "@xyflow/react";
3
- import { useForm as ne } from "@tanstack/react-form";
4
- import { Waypoints as Nt, X as se, Plus as X, Network as yt, Boxes as wt, Type as Qe, LucidePencilRuler as Ft, XIcon as et, WandSparkles as _e, Loader2 as St, Save as Et, EllipsisVertical as kt, Copy as Pt, Download as Dt, ArrowRightFromLine as Tt, Trash2 as tt, Variable as we, ChevronsUpDown as re, Check as At, PlusCircle as Vt } from "lucide-react";
5
- import { useMemo as le, createContext as It, useContext as Ot, useState as z, memo as he, useCallback as $, useRef as Mt, useEffect as Lt, useId as Fe } from "react";
6
- import { j as P, P as Me, g as Le, B as S, h as Be, F as N, L as j, I as k, f as M, k as Bt, S as _, m as R, n as Z, o as K, q as y, T as Ge, p as te, r as J, C as Gt, i as $t, a as zt, b as Ht, c as Re, d as Ve, t as $e, l as at, s as Ut } from "./separator-oCo7kxCK.js";
7
- import * as Ce from "@radix-ui/react-scroll-area";
8
- import { Slot as _t } from "@radix-ui/react-slot";
9
- import { cva as Rt } from "class-variance-authority";
10
- import { toast as U, Toaster as Zt } from "sonner";
11
- import * as L from "@radix-ui/react-dialog";
12
- import * as ae from "@radix-ui/react-dropdown-menu";
13
- import * as ze from "@radix-ui/react-collapsible";
14
- import * as Q from "@radix-ui/react-alert-dialog";
15
- import { useTheme as Kt } from "next-themes";
16
- const Yt = "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", Wt = "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", Jt = ({ theme: t = "dark" }) => /* @__PURE__ */ e.jsx("div", { className: "absolute top-5 left-5 z-50 select-none", children: /* @__PURE__ */ e.jsx(
17
- "img",
18
- {
19
- src: t === "dark" ? Wt : Yt,
20
- alt: "Treege",
21
- className: "relative h-14 w-auto drop-shadow-[0_0px_35px] drop-shadow-blue-600"
22
- }
23
- ) }), Ee = (t) => {
24
- const s = Oe(), l = We();
25
- return le(() => {
26
- if (!t)
27
- return [];
28
- const i = (o, n = /* @__PURE__ */ new Set()) => {
29
- if (n.has(o))
30
- return [];
31
- const f = new Set(n).add(o);
32
- return l.filter((c) => c.target === o).flatMap((c) => [c.source, ...i(c.source, f)]);
33
- }, h = i(t);
34
- return s.filter((o) => h.includes(o.id) && je(o)).map((o) => {
35
- const n = o.data;
36
- return {
37
- label: (typeof n.label == "object" ? n.label.en : n.label) || n.name || o.id,
38
- name: n.name,
39
- nodeId: o.id,
40
- type: n.type || "text"
41
- };
42
- });
43
- }, [t, s, l]);
44
- }, st = It(null), qt = ({ children: t, value: s }) => {
45
- const [l, i] = z(s?.flowId), h = le(
46
- () => ({
47
- ...s,
48
- ...s?.aiConfig && {
49
- aiConfig: {
50
- ...s.aiConfig,
51
- provider: s?.aiConfig.provider ?? "gemini"
52
- }
53
- },
54
- flowId: l,
55
- setFlowId: i
56
- }),
57
- [l, s]
58
- );
59
- return /* @__PURE__ */ e.jsx(st.Provider, { value: h, children: t });
60
- }, nt = () => Ot(st) ?? {
61
- flowId: void 0,
62
- language: "en",
63
- setFlowId: () => {
64
- }
65
- }, B = (t) => {
66
- const l = nt().language;
67
- return dt(l);
68
- };
69
- function ot({ className: t, children: s, ...l }) {
70
- return /* @__PURE__ */ e.jsxs(Ce.Root, { "data-slot": "scroll-area", className: P("relative", t), ...l, children: [
71
- /* @__PURE__ */ e.jsx(
72
- Ce.Viewport,
73
- {
74
- "data-slot": "scroll-area-viewport",
75
- className: "size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",
76
- children: s
77
- }
78
- ),
79
- /* @__PURE__ */ e.jsx(Xt, {}),
80
- /* @__PURE__ */ e.jsx(Ce.Corner, {})
81
- ] });
82
- }
83
- function Xt({
84
- className: t,
85
- orientation: s = "vertical",
86
- ...l
87
- }) {
88
- return /* @__PURE__ */ e.jsx(
89
- Ce.ScrollAreaScrollbar,
90
- {
91
- "data-slot": "scroll-area-scrollbar",
92
- orientation: s,
93
- className: P(
94
- "flex touch-none select-none p-px transition-colors",
95
- s === "vertical" && "h-full w-2.5 border-l border-l-transparent",
96
- s === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
97
- t
98
- ),
99
- ...l,
100
- children: /* @__PURE__ */ e.jsx(Ce.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "relative flex-1 rounded-full bg-border" })
101
- }
102
- );
103
- }
104
- const Qt = ({
105
- id: t,
106
- target: s,
107
- sourceX: l,
108
- sourceY: i,
109
- targetX: h,
110
- targetY: o,
111
- sourcePosition: n,
112
- targetPosition: f,
113
- markerEnd: d,
114
- style: c,
115
- data: a
116
- }) => {
117
- const [r, u, m] = Je({
118
- sourcePosition: n,
119
- sourceX: l,
120
- sourceY: i,
121
- targetPosition: f,
122
- targetX: h,
123
- targetY: o
124
- }), [p, x] = z(!1), { updateEdgeData: F } = ue(), g = Ee(s), w = a?.conditions && a.conditions.length > 0, C = B(), { handleSubmit: I, reset: b, Field: E } = ne({
125
- defaultValues: {
126
- conditions: a?.conditions || [{ field: g[0]?.nodeId ?? "", operator: "===", value: "" }],
127
- isFallback: !!a?.isFallback,
128
- label: a?.label || ""
129
- },
130
- listeners: {
131
- onChange: ({ formApi: v }) => {
132
- v.handleSubmit().then();
133
- },
134
- onChangeDebounceMs: 150
135
- },
136
- onSubmit: ({ value: v }) => {
137
- F(t, v);
138
- }
139
- }), A = (v) => {
140
- v.stopPropagation();
141
- }, V = () => {
142
- b({ conditions: [], isFallback: !1, label: "" }), F(t, { conditions: void 0, isFallback: void 0, label: void 0 });
143
- }, T = () => {
144
- if (a?.isFallback)
145
- return a.label || C("editor.conditionalEdge.fallback");
146
- if (!w)
147
- return null;
148
- if (a.label)
149
- return a.label;
150
- const v = a.conditions;
151
- if (v.length === 1)
152
- return `${g.find((H) => H.nodeId === v[0].field)?.label || v[0].field} ${v[0].operator} ${v[0].value}`;
153
- const G = v.filter((O) => O.logicalOperator === oe.AND).length, Ae = v.filter((O) => O.logicalOperator === oe.OR).length;
154
- return G > 0 && Ae === 0 ? `${v.length} ${C("editor.conditionalEdge.conditionsAnd")}` : Ae > 0 && G === 0 ? `${v.length} ${C("editor.conditionalEdge.conditionsOr")}` : `${v.length} ${C("editor.conditionalEdge.conditionsMixed")}`;
155
- }, D = () => a?.isFallback ? "var(--color-chart-4)" : w ? "var(--color-chart-2)" : "var(--color-chart-3)";
156
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
157
- /* @__PURE__ */ e.jsx(
158
- qe,
159
- {
160
- path: r,
161
- markerEnd: d,
162
- style: {
163
- ...c,
164
- stroke: D(),
165
- strokeDasharray: a?.isFallback ? "5,5" : void 0,
166
- strokeWidth: w || a?.isFallback ? 2 : c?.strokeWidth
167
- }
168
- }
169
- ),
170
- /* @__PURE__ */ e.jsx(Xe, { children: /* @__PURE__ */ e.jsx(
171
- "div",
172
- {
173
- className: "nodrag nopan absolute",
174
- style: {
175
- pointerEvents: "all",
176
- transform: `translate(-50%, -50%) translate(${u}px,${m}px)`
177
- },
178
- children: /* @__PURE__ */ e.jsxs(Me, { open: p, onOpenChange: x, children: [
179
- /* @__PURE__ */ e.jsx(Le, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
180
- S,
181
- {
182
- variant: w || a?.isFallback ? "default" : "secondary",
183
- className: "h-8 px-2 text-xs",
184
- onClick: A,
185
- children: [
186
- /* @__PURE__ */ e.jsx(Nt, { className: "mr-1 h-3 w-3" }),
187
- w || a?.isFallback ? T() : C("editor.conditionalEdge.condition")
188
- ]
189
- }
190
- ) }),
191
- /* @__PURE__ */ e.jsx(Be, { className: "w-96 p-1", align: "center", onClick: (v) => v.stopPropagation(), children: /* @__PURE__ */ e.jsx(ot, { className: "flex max-h-150 flex-col p-3", children: /* @__PURE__ */ e.jsx(
192
- "form",
193
- {
194
- onSubmit: (v) => {
195
- v.preventDefault(), v.stopPropagation();
196
- },
197
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-5", children: [
198
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
199
- /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: C("editor.conditionalEdge.displayConditions") }),
200
- /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: C("editor.conditionalEdge.displayConditionsDesc") })
201
- ] }),
202
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4", children: [
203
- /* @__PURE__ */ e.jsx(E, { name: "label", children: (v) => /* @__PURE__ */ e.jsxs(N, { children: [
204
- /* @__PURE__ */ e.jsx(j, { htmlFor: v.name, children: C("editor.conditionalEdge.labelOptional") }),
205
- /* @__PURE__ */ e.jsx(
206
- k,
207
- {
208
- id: v.name,
209
- placeholder: C("editor.conditionalEdge.labelPlaceholder"),
210
- value: v.state.value,
211
- onChange: (G) => v.handleChange(G.target.value)
212
- }
213
- ),
214
- /* @__PURE__ */ e.jsx(M, { children: C("editor.conditionalEdge.labelDesc") })
215
- ] }) }),
216
- /* @__PURE__ */ e.jsx(E, { name: "isFallback", children: (v) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3", children: [
217
- /* @__PURE__ */ e.jsx(
218
- Bt,
219
- {
220
- id: v.name,
221
- checked: v.state.value,
222
- onCheckedChange: (G) => v.handleChange(G)
223
- }
224
- ),
225
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
226
- /* @__PURE__ */ e.jsx(j, { htmlFor: v.name, className: "cursor-pointer font-medium", children: C("editor.conditionalEdge.fallbackPath") }),
227
- /* @__PURE__ */ e.jsx(M, { className: "text-xs", children: C("editor.conditionalEdge.fallbackPathDesc") })
228
- ] })
229
- ] }) }) }),
230
- /* @__PURE__ */ e.jsx(E, { name: "conditions", mode: "array", children: (v) => {
231
- const G = v.form.getFieldValue("isFallback");
232
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
233
- /* @__PURE__ */ e.jsx(j, { className: G ? "text-muted-foreground" : "", children: C("editor.conditionalEdge.conditions") }),
234
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
235
- v.state.value?.map((Ae, O) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
236
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 rounded-lg border bg-muted/30 p-3", children: [
237
- /* @__PURE__ */ e.jsx(E, { name: `conditions[${O}].field`, children: (H) => /* @__PURE__ */ e.jsxs(N, { children: [
238
- /* @__PURE__ */ e.jsx(j, { htmlFor: `field-${O}`, children: C("editor.conditionalEdge.field") }),
239
- /* @__PURE__ */ e.jsxs(
240
- _,
241
- {
242
- disabled: G,
243
- value: H.state.value || "",
244
- onValueChange: (Y) => H.handleChange(Y),
245
- children: [
246
- /* @__PURE__ */ e.jsx(R, { id: `field-${O}`, className: "w-full", children: /* @__PURE__ */ e.jsx(Z, { placeholder: C("editor.conditionalEdge.selectField") }) }),
247
- /* @__PURE__ */ e.jsx(K, { children: g.length === 0 ? /* @__PURE__ */ e.jsx(y, { value: "none", disabled: !0, children: C("editor.conditionalEdge.noFieldsAvailable") }) : g.map((Y) => /* @__PURE__ */ e.jsxs(y, { value: Y.nodeId, children: [
248
- Y.label,
249
- " (",
250
- Y.type,
251
- ")"
252
- ] }, Y.nodeId)) })
253
- ]
254
- }
255
- )
256
- ] }) }),
257
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
258
- /* @__PURE__ */ e.jsx(E, { name: `conditions[${O}].operator`, children: (H) => /* @__PURE__ */ e.jsxs(N, { children: [
259
- /* @__PURE__ */ e.jsx(j, { htmlFor: `operator-${O}`, children: C("editor.conditionalEdge.operator") }),
260
- /* @__PURE__ */ e.jsxs(
261
- _,
262
- {
263
- disabled: G,
264
- value: H.state.value || "===",
265
- onValueChange: (Y) => H.handleChange(Y),
266
- children: [
267
- /* @__PURE__ */ e.jsx(R, { id: `operator-${O}`, children: /* @__PURE__ */ e.jsx(Z, {}) }),
268
- /* @__PURE__ */ e.jsxs(K, { children: [
269
- /* @__PURE__ */ e.jsx(y, { value: "===", children: "=" }),
270
- /* @__PURE__ */ e.jsx(y, { value: "!==", children: "≠" }),
271
- /* @__PURE__ */ e.jsx(y, { value: ">", children: ">" }),
272
- /* @__PURE__ */ e.jsx(y, { value: "<", children: "<" }),
273
- /* @__PURE__ */ e.jsx(y, { value: ">=", children: ">=" }),
274
- /* @__PURE__ */ e.jsx(y, { value: "<=", children: "<=" })
275
- ] })
276
- ]
277
- }
278
- )
279
- ] }) }),
280
- /* @__PURE__ */ e.jsx(E, { name: `conditions[${O}].value`, children: (H) => /* @__PURE__ */ e.jsxs(N, { className: "w-full", children: [
281
- /* @__PURE__ */ e.jsx(j, { htmlFor: `value-${O}`, children: C("editor.conditionalEdge.value") }),
282
- /* @__PURE__ */ e.jsx(
283
- k,
284
- {
285
- disabled: G,
286
- id: `value-${O}`,
287
- placeholder: C("editor.conditionalEdge.valuePlaceholder"),
288
- value: H.state.value || "",
289
- onChange: (Y) => H.handleChange(Y.target.value)
290
- }
291
- )
292
- ] }) })
293
- ] }),
294
- v.state.value && v.state.value.length > 1 && /* @__PURE__ */ e.jsxs(
295
- S,
296
- {
297
- disabled: G,
298
- type: "button",
299
- variant: "ghost",
300
- size: "sm",
301
- className: "w-full",
302
- onClick: () => {
303
- v.removeValue(O), I().then();
304
- },
305
- children: [
306
- /* @__PURE__ */ e.jsx(se, { className: "mr-1 h-4 w-4" }),
307
- C("editor.conditionalEdge.removeCondition")
308
- ]
309
- }
310
- )
311
- ] }),
312
- v.state.value && O < v.state.value.length - 1 && /* @__PURE__ */ e.jsx(E, { name: `conditions[${O}].logicalOperator`, children: (H) => /* @__PURE__ */ e.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ e.jsxs(
313
- _,
314
- {
315
- disabled: G,
316
- value: H.state.value || oe.AND,
317
- onValueChange: (Y) => H.handleChange(Y),
318
- children: [
319
- /* @__PURE__ */ e.jsx(R, { className: "h-9 w-32 font-semibold", children: /* @__PURE__ */ e.jsx(Z, {}) }),
320
- /* @__PURE__ */ e.jsxs(K, { children: [
321
- /* @__PURE__ */ e.jsx(y, { value: oe.AND, children: "AND" }),
322
- /* @__PURE__ */ e.jsx(y, { value: oe.OR, children: "OR" })
323
- ] })
324
- ]
325
- }
326
- ) }) })
327
- ] }, `condition-${O}`)),
328
- /* @__PURE__ */ e.jsxs(
329
- S,
330
- {
331
- disabled: G,
332
- type: "button",
333
- variant: "outline",
334
- size: "sm",
335
- className: "w-full",
336
- onClick: () => {
337
- v.pushValue({
338
- field: g[0]?.nodeId ?? "",
339
- logicalOperator: oe.AND,
340
- operator: "===",
341
- value: ""
342
- }), I().then();
343
- },
344
- children: [
345
- /* @__PURE__ */ e.jsx(X, { className: "mr-2 h-4 w-4" }),
346
- C("editor.conditionalEdge.addCondition")
347
- ]
348
- }
349
- )
350
- ] })
351
- ] });
352
- } })
353
- ] }),
354
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
355
- /* @__PURE__ */ e.jsxs(S, { type: "button", size: "sm", variant: "outline", onClick: V, children: [
356
- /* @__PURE__ */ e.jsx(se, { className: "mr-1 h-4 w-4" }),
357
- C("common.clear")
358
- ] }),
359
- /* @__PURE__ */ e.jsx(S, { type: "button", size: "sm", onClick: () => x(!1), children: C("common.close") })
360
- ] })
361
- ] })
362
- }
363
- ) }) })
364
- ] })
365
- }
366
- ) })
367
- ] });
368
- }, ea = he(Qt), ta = ({ id: t, sourceX: s, sourceY: l, targetX: i, targetY: h, sourcePosition: o, targetPosition: n, style: f, markerEnd: d, selected: c }) => {
369
- const [a, r, u] = Je({
370
- sourcePosition: o,
371
- sourceX: s,
372
- sourceY: l,
373
- targetPosition: n,
374
- targetX: i,
375
- targetY: h
376
- }), { setEdges: m } = ue(), p = () => {
377
- m((x) => x.filter((F) => F.id !== t));
378
- };
379
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
380
- /* @__PURE__ */ e.jsx(qe, { path: a, markerEnd: d, style: f }),
381
- /* @__PURE__ */ e.jsx(Xe, { children: c && /* @__PURE__ */ e.jsx(
382
- "div",
383
- {
384
- className: "button-edge__label nodrag nopan",
385
- style: {
386
- transform: `translate(-50%, -50%) translate(${r}px,${u}px)`
387
- },
388
- children: /* @__PURE__ */ e.jsx("button", { type: "button", className: "button-edge__button", onClick: p, "aria-label": "Remove edge", children: "×" })
389
- }
390
- ) })
391
- ] });
392
- }, aa = he(ta), sa = {
393
- conditional: ea,
394
- default: aa
395
- }, na = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
396
- let ce = (t = 21) => {
397
- let s = "", l = crypto.getRandomValues(new Uint8Array(t |= 0));
398
- for (; t--; )
399
- s += na[l[t] & 63];
400
- return s;
401
- };
402
- const rt = {
403
- data: {
404
- type: "text"
405
- },
406
- id: ce(),
407
- position: { x: 0, y: 0 },
408
- type: "input"
409
- }, oa = 100, ra = 50, lt = () => {
410
- const { setNodes: t, setEdges: s, screenToFlowPosition: l, getNode: i, getNodes: h, getEdges: o } = ue(), n = $(
411
- (u, m, p = !1) => {
412
- const x = u.id, g = o().filter((b) => b.source === x), w = je(u);
413
- if (g.length > 0 && !w)
414
- return;
415
- const C = ce(), I = {
416
- ...rt,
417
- id: C,
418
- position: m,
419
- selected: p
420
- };
421
- u?.parentId && (I.parentId = u.parentId, I.extent = "parent"), t((b) => b.concat(I)), s((b) => {
422
- const A = b.filter((T) => T.source === x).length > 0, V = {
423
- data: A && w ? {
424
- conditions: [{ field: x, operator: "===", value: "" }]
425
- } : void 0,
426
- id: ce(),
427
- source: x,
428
- target: C,
429
- type: A && w ? "conditional" : "default"
430
- };
431
- return A && w ? b.map((T) => T.source === x ? {
432
- ...T,
433
- data: {
434
- ...T.data,
435
- conditions: T.data?.conditions || [{ field: x, operator: "===", value: "" }]
436
- },
437
- type: "conditional"
438
- } : T).concat(V) : b.concat(V);
439
- }), p && (t((b) => b.map((E) => ({ ...E, selected: E.id === C }))), s((b) => b.map((E) => ({ ...E, selected: !1 }))));
440
- },
441
- [o, t, s]
442
- ), f = $(
443
- (u) => {
444
- s((m) => {
445
- const p = mt(u, m), x = u.source, F = i(x);
446
- return p.filter((w) => w.source === x).length > 1 && F && je(F) ? p.map((w) => w.source === x ? {
447
- ...w,
448
- data: {
449
- ...w.data,
450
- conditions: w.data?.conditions || [{ field: x, operator: "===", value: "" }]
451
- },
452
- type: "conditional"
453
- } : w) : p;
454
- });
455
- },
456
- [s, i]
457
- ), d = $(
458
- (u) => {
459
- const m = i(u);
460
- if (!m)
461
- return;
462
- const p = getComputedStyle(document.documentElement).getPropertyValue("--node-height"), x = getComputedStyle(document.documentElement).getPropertyValue("--node-width"), F = parseFloat(p) || 100, g = parseFloat(x) || 100, w = m.position.y + F + oa, C = h(), I = o(), b = C.filter((A) => I.some((V) => V.source === u && V.target === A.id)), E = b.length > 0 ? b.reduce((A, V) => V.position.x > A.position.x ? V : A, b[0]).position.x + g + ra : m.position.x;
463
- n(m, { x: E, y: w }, !0);
464
- },
465
- [i, h, o, n]
466
- ), c = $(
467
- (u, m) => {
468
- if (!m.isValid) {
469
- const { clientX: p, clientY: x } = "changedTouches" in u ? u.changedTouches[0] : u, F = m.fromNode;
470
- if (!F)
471
- return;
472
- const g = l({ x: p, y: x }), w = F.parentId ? i(F.parentId) : void 0, C = w?.position ?? { x: 0, y: 0 }, I = w ? { x: g.x - C.x, y: g.y - C.y } : g;
473
- n(F, I);
474
- }
475
- },
476
- [n, i, l]
477
- ), a = $(
478
- (u) => {
479
- s((m) => {
480
- const p = m.filter((g) => !u.find((w) => w.id === g.id)), x = new Set(u.map((g) => g.source)), F = /* @__PURE__ */ new Map();
481
- return p.forEach((g) => {
482
- F.set(g.source, (F.get(g.source) ?? 0) + 1);
483
- }), p.map((g) => {
484
- if (x.has(g.source) && (F.get(g.source) ?? 0) === 1) {
485
- const { conditions: C, isFallback: I, ...b } = g.data ?? {}, E = b && Object.keys(b).length > 0 ? b : void 0;
486
- return { ...g, data: E, type: "default" };
487
- }
488
- return g;
489
- });
490
- });
491
- },
492
- [s]
493
- );
494
- return {
495
- isValidConnection: $(
496
- (u) => {
497
- if (u.source === u.target)
498
- return !1;
499
- const m = i(u.source);
500
- return m ? !(o().filter((F) => F.source === u.source).length > 0 && !je(m)) : !1;
501
- },
502
- [i, o]
503
- ),
504
- onAddFromHandle: d,
505
- onConnect: f,
506
- onConnectEnd: c,
507
- onEdgesDelete: a
508
- };
509
- }, He = (t) => {
510
- const { onAddFromHandle: s } = lt();
511
- return $(
512
- (l) => {
513
- l.defaultPrevented || s(t);
514
- },
515
- [s, t]
516
- );
517
- }, Ue = ({ children: t, inGroup: s, isSubmit: l }) => /* @__PURE__ */ e.jsx("div", { className: P("react-flow__node__wrapper", s && "in-group", l && "submit-type"), children: t }), la = Rt(
518
- "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",
519
- {
520
- defaultVariants: {
521
- variant: "default"
522
- },
523
- variants: {
524
- variant: {
525
- blue: "bg-blue-500 text-white dark:bg-blue-600",
526
- default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
527
- 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",
528
- outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
529
- purple: "bg-purple-600 hover:bg-purple-700 text-white",
530
- secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
531
- }
532
- }
533
- }
534
- );
535
- function ve({
536
- className: t,
537
- variant: s,
538
- asChild: l = !1,
539
- ...i
540
- }) {
541
- const h = l ? _t : "span";
542
- return /* @__PURE__ */ e.jsx(h, { "data-slot": "badge", className: P(la({ variant: s }), t), ...i });
543
- }
544
- const ia = ({ data: t, isConnectable: s, type: l, parentId: i, id: h }) => {
545
- const n = B()(t?.label), f = He(h);
546
- return /* @__PURE__ */ e.jsxs(Ue, { inGroup: !!i, children: [
547
- /* @__PURE__ */ e.jsx(ie, { type: "target", position: de.Top, isConnectable: s, isConnectableStart: !1 }),
548
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: n }),
549
- /* @__PURE__ */ e.jsxs(ve, { variant: "destructive", className: "capitalize", children: [
550
- /* @__PURE__ */ e.jsx(yt, {}),
551
- l
552
- ] }),
553
- /* @__PURE__ */ e.jsx(
554
- ie,
555
- {
556
- type: "source",
557
- position: de.Bottom,
558
- isConnectable: s,
559
- onClick: f,
560
- className: "hover:!bg-primary/80 !w-6 !h-6 flex cursor-pointer items-center justify-center rounded-sm transition-colors",
561
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4 text-primary-foreground" })
562
- }
563
- )
564
- ] });
565
- }, da = he(ia), ca = ({ data: t }) => {
566
- const l = B()(t?.label);
567
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
568
- /* @__PURE__ */ e.jsx(pt, {}),
569
- /* @__PURE__ */ e.jsx("div", { className: "-top-3.5 absolute left-6", children: /* @__PURE__ */ e.jsxs(ve, { className: "max-w-50 bg-chart-2", children: [
570
- /* @__PURE__ */ e.jsx(wt, { className: "!w-3 !h-3" }),
571
- l
572
- ] }) })
573
- ] });
574
- }, ua = he(ca), ha = ({ data: t, isConnectable: s, parentId: l, id: i }) => {
575
- const o = B()(t?.label), n = He(i);
576
- return /* @__PURE__ */ e.jsxs(Ue, { inGroup: !!l, isSubmit: t?.type === "submit", children: [
577
- /* @__PURE__ */ e.jsx(ie, { type: "target", position: de.Top, isConnectable: s, isConnectableStart: !1 }),
578
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: o || t?.name }),
579
- /* @__PURE__ */ e.jsx("div", { className: "flex gap-1", children: t?.type && /* @__PURE__ */ e.jsxs(ve, { variant: "blue", className: "capitalize", children: [
580
- /* @__PURE__ */ e.jsx(Qe, {}),
581
- t.type
582
- ] }) }),
583
- /* @__PURE__ */ e.jsx(
584
- ie,
585
- {
586
- type: "source",
587
- position: de.Bottom,
588
- isConnectable: s,
589
- onClick: n,
590
- className: "hover:!bg-primary/80 flex cursor-pointer items-center justify-center rounded-sm transition-colors",
591
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4 text-primary-foreground" })
592
- }
593
- )
594
- ] });
595
- }, ma = he(ha), pa = ({ data: t, isConnectable: s, type: l, parentId: i, id: h }) => {
596
- const n = B()(t?.label), f = He(h);
597
- return /* @__PURE__ */ e.jsxs(Ue, { inGroup: !!i, children: [
598
- /* @__PURE__ */ e.jsx(ie, { type: "target", position: de.Top, isConnectable: s }),
599
- /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl capitalize", children: n }),
600
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
601
- /* @__PURE__ */ e.jsxs(ve, { variant: "purple", children: [
602
- /* @__PURE__ */ e.jsx(Ft, {}),
603
- l
604
- ] }),
605
- t?.type && /* @__PURE__ */ e.jsxs(ve, { variant: "outline", className: "capitalize", children: [
606
- /* @__PURE__ */ e.jsx(Qe, {}),
607
- t.type
608
- ] })
609
- ] }),
610
- /* @__PURE__ */ e.jsx(
611
- ie,
612
- {
613
- type: "source",
614
- position: de.Bottom,
615
- isConnectable: s,
616
- onClick: f,
617
- className: "!bg-primary hover:!bg-primary/80 !w-6 !h-6 flex cursor-pointer items-center justify-center transition-colors",
618
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4 text-primary-foreground" })
619
- }
620
- )
621
- ] });
622
- }, xa = he(pa), it = {
623
- [ye.flow]: da,
624
- [ye.group]: ua,
625
- [ye.input]: ma,
626
- [ye.ui]: xa
627
- }, ke = `You are a Treege decision tree generator. You must generate valid JSON structures for decision trees.
628
-
629
- IMPORTANT RULES:
630
- 1. Always respond with valid JSON only, no markdown, no code blocks, no explanations outside the JSON
631
- 2. The JSON must have this exact structure: { "nodes": [...], "edges": [...] }
632
- 3. Every node must have: id (string), type (string), position ({ x: number, y: number }), data (object)
633
- 4. Every edge must have: id (string), source (string), target (string)
634
- 5. For regex patterns: ALWAYS use double backslashes (\\\\) for special characters (\\\\s, \\\\d, etc.)
635
- 6. AVOID using "pattern" field unless specifically requested - prefer using simple validation
636
- 7. For submit buttons, use type "input" with data.type "submit", NOT type "flow"
637
- 8. For conditional logic, use conditional edges with proper operators (===, !==, >, <, >=, <=)
638
-
639
- NODE TYPES:
640
- - "input": Form input fields (text, number, select, checkbox, etc.)
641
- - "ui": UI elements (title, divider)
642
- - "flow": Navigation/flow control nodes
643
- - "group": Container for organizing nodes
644
-
645
- INPUT NODE TYPES (data.type):
646
- - "text", "number", "textarea", "password"
647
- - "select", "radio", "checkbox", "switch"
648
- - "autocomplete", "date", "daterange", "time", "timerange"
649
- - "file", "address", "http", "hidden", "submit"
650
-
651
- INPUT NODE DATA STRUCTURE:
652
- {
653
- "id": "unique-id",
654
- "type": "input",
655
- "position": { "x": 0, "y": 0 },
656
- "data": {
657
- "label": "Field Label",
658
- "name": "fieldName",
659
- "type": "text",
660
- "required": true,
661
- "placeholder": "Enter value...",
662
- "helperText": "Optional helper text",
663
- "pattern": "regex pattern (optional)",
664
- "errorMessage": "Error message if validation fails",
665
- "options": [{ "value": "val", "label": "Label" }], // for select/radio/checkbox
666
- "multiple": false // for select/checkbox
667
- }
668
- }
669
-
670
- UI NODE TYPES (data.type):
671
- - "title": Display a title
672
- - "divider": Display a divider line
673
-
674
- UI NODE DATA STRUCTURE:
675
- {
676
- "id": "unique-id",
677
- "type": "ui",
678
- "position": { "x": 0, "y": 0 },
679
- "data": {
680
- "label": "UI Element Label",
681
- "type": "title" // or "divider"
682
- }
683
- }
684
-
685
- FLOW NODE DATA STRUCTURE:
686
- {
687
- "id": "unique-id",
688
- "type": "flow",
689
- "position": { "x": 0, "y": 0 },
690
- "data": {
691
- "label": "Flow Step Label",
692
- "targetId": "next-node-id" // optional
693
- }
694
- }
695
-
696
- GROUP NODE DATA STRUCTURE:
697
- {
698
- "id": "unique-id",
699
- "type": "group",
700
- "position": { "x": 0, "y": 0 },
701
- "data": {
702
- "label": "Group Label"
703
- }
704
- }
705
-
706
- EDGE STRUCTURE:
707
- {
708
- "id": "edge-id",
709
- "source": "source-node-id",
710
- "target": "target-node-id",
711
- "type": "default" // or "conditional" for conditional logic
712
- }
713
-
714
- CONDITIONAL EDGE STRUCTURE:
715
- {
716
- "id": "edge-id",
717
- "source": "source-node-id",
718
- "target": "target-node-id",
719
- "type": "conditional",
720
- "data": {
721
- "label": "If condition is true", // optional label for the edge
722
- "conditions": [
723
- {
724
- "field": "field-node-id", // ID of the field to check
725
- "operator": ">=", // operators: ===, !==, >, <, >=, <=
726
- "value": "18" // value to compare (as string)
727
- }
728
- ],
729
- "operator": "AND" // optional: "AND" or "OR" for multiple conditions (default: AND)
730
- }
731
- }
732
-
733
- IMPORTANT: For conditional edges, the value must ALWAYS be a string, even for numbers.
734
- Example: For "age >= 18", use "value": "18" (not value: 18)
735
-
736
- LAYOUT GUIDELINES:
737
- - Position nodes in a vertical flow (top to bottom)
738
- - Start at position { x: 0, y: 0 }
739
- - Space nodes vertically by exactly 250 pixels between each position (node height 150px + 100px spacing)
740
- - For horizontal spacing, use 350 pixels
741
- - Create logical flow from top to bottom
742
- - IMPORTANT: Keep consistent vertical spacing to avoid overlap
743
- - Each node position Y should increment by 250: first at y:0, second at y:250, third at y:500, etc.
744
-
745
- EXAMPLES:
746
-
747
- User: "Create a simple contact form with name, email and message"
748
- Response:
749
- {
750
- "nodes": [
751
- {
752
- "id": "title-1",
753
- "type": "ui",
754
- "position": { "x": 0, "y": 0 },
755
- "data": { "label": "Contact Form", "type": "title" }
756
- },
757
- {
758
- "id": "name-1",
759
- "type": "input",
760
- "position": { "x": 0, "y": 250 },
761
- "data": {
762
- "label": "Name",
763
- "name": "name",
764
- "type": "text",
765
- "required": true,
766
- "placeholder": "Enter your name"
767
- }
768
- },
769
- {
770
- "id": "email-1",
771
- "type": "input",
772
- "position": { "x": 0, "y": 500 },
773
- "data": {
774
- "label": "Email",
775
- "name": "email",
776
- "type": "text",
777
- "required": true,
778
- "placeholder": "your@email.com"
779
- }
780
- },
781
- {
782
- "id": "message-1",
783
- "type": "input",
784
- "position": { "x": 0, "y": 750 },
785
- "data": {
786
- "label": "Message",
787
- "name": "message",
788
- "type": "textarea",
789
- "required": true,
790
- "placeholder": "Enter your message"
791
- }
792
- }
793
- ],
794
- "edges": [
795
- { "id": "e1", "source": "title-1", "target": "name-1" },
796
- { "id": "e2", "source": "name-1", "target": "email-1" },
797
- { "id": "e3", "source": "email-1", "target": "message-1" }
798
- ]
799
- }
800
-
801
- User: "Create a user registration form with age, address and country selector"
802
- Response:
803
- {
804
- "nodes": [
805
- {
806
- "id": "title-1",
807
- "type": "ui",
808
- "position": { "x": 0, "y": 0 },
809
- "data": { "label": "User Registration", "type": "title" }
810
- },
811
- {
812
- "id": "age-1",
813
- "type": "input",
814
- "position": { "x": 0, "y": 250 },
815
- "data": {
816
- "label": "Age",
817
- "name": "age",
818
- "type": "number",
819
- "required": true,
820
- "placeholder": "Enter your age"
821
- }
822
- },
823
- {
824
- "id": "address-1",
825
- "type": "input",
826
- "position": { "x": 0, "y": 500 },
827
- "data": {
828
- "label": "Address",
829
- "name": "address",
830
- "type": "address",
831
- "required": true,
832
- "placeholder": "Enter your address"
833
- }
834
- },
835
- {
836
- "id": "country-1",
837
- "type": "input",
838
- "position": { "x": 0, "y": 750 },
839
- "data": {
840
- "label": "Country",
841
- "name": "country",
842
- "type": "select",
843
- "required": true,
844
- "options": [
845
- { "value": "us", "label": "United States" },
846
- { "value": "ca", "label": "Canada" },
847
- { "value": "uk", "label": "United Kingdom" },
848
- { "value": "fr", "label": "France" },
849
- { "value": "de", "label": "Germany" }
850
- ]
851
- }
852
- },
853
- {
854
- "id": "submit-1",
855
- "type": "input",
856
- "position": { "x": 0, "y": 1000 },
857
- "data": {
858
- "label": "Submit",
859
- "type": "submit"
860
- }
861
- }
862
- ],
863
- "edges": [
864
- { "id": "e1", "source": "title-1", "target": "age-1" },
865
- { "id": "e2", "source": "age-1", "target": "address-1" },
866
- { "id": "e3", "source": "address-1", "target": "country-1" },
867
- { "id": "e4", "source": "country-1", "target": "submit-1" }
868
- ]
869
- }
870
-
871
- User: "Create a form with name, age, and show different questions based on age (movie for 18+, color for under 18)"
872
- Response:
873
- {
874
- "nodes": [
875
- {
876
- "id": "title-1",
877
- "type": "ui",
878
- "position": { "x": 0, "y": 0 },
879
- "data": { "label": "Survey Form", "type": "title" }
880
- },
881
- {
882
- "id": "name-1",
883
- "type": "input",
884
- "position": { "x": 0, "y": 250 },
885
- "data": {
886
- "label": "Name",
887
- "name": "name",
888
- "type": "text",
889
- "required": true,
890
- "placeholder": "Enter your name"
891
- }
892
- },
893
- {
894
- "id": "age-1",
895
- "type": "input",
896
- "position": { "x": 0, "y": 500 },
897
- "data": {
898
- "label": "Age",
899
- "name": "age",
900
- "type": "number",
901
- "required": true,
902
- "placeholder": "Enter your age"
903
- }
904
- },
905
- {
906
- "id": "movie-1",
907
- "type": "input",
908
- "position": { "x": -350, "y": 750 },
909
- "data": {
910
- "label": "Favorite Movie",
911
- "name": "favoriteMovie",
912
- "type": "text",
913
- "required": true,
914
- "helperText": "For adults 18 and over"
915
- }
916
- },
917
- {
918
- "id": "color-1",
919
- "type": "input",
920
- "position": { "x": 350, "y": 750 },
921
- "data": {
922
- "label": "Favorite Color",
923
- "name": "favoriteColor",
924
- "type": "text",
925
- "required": true,
926
- "helperText": "For those under 18"
927
- }
928
- },
929
- {
930
- "id": "submit-1",
931
- "type": "input",
932
- "position": { "x": 0, "y": 1000 },
933
- "data": {
934
- "label": "Submit",
935
- "type": "submit"
936
- }
937
- }
938
- ],
939
- "edges": [
940
- { "id": "e1", "source": "title-1", "target": "name-1" },
941
- { "id": "e2", "source": "name-1", "target": "age-1" },
942
- {
943
- "id": "e3",
944
- "source": "age-1",
945
- "target": "movie-1",
946
- "type": "conditional",
947
- "data": {
948
- "label": "If 18 or older",
949
- "conditions": [
950
- {
951
- "field": "age-1",
952
- "operator": ">=",
953
- "value": "18"
954
- }
955
- ]
956
- }
957
- },
958
- {
959
- "id": "e4",
960
- "source": "age-1",
961
- "target": "color-1",
962
- "type": "conditional",
963
- "data": {
964
- "label": "If under 18",
965
- "conditions": [
966
- {
967
- "field": "age-1",
968
- "operator": "<",
969
- "value": "18"
970
- }
971
- ]
972
- }
973
- },
974
- { "id": "e5", "source": "movie-1", "target": "submit-1" },
975
- { "id": "e6", "source": "color-1", "target": "submit-1" }
976
- ]
977
- }
978
-
979
- Remember:
980
- - Always respond with ONLY valid JSON
981
- - No markdown code blocks
982
- - No explanations outside the JSON
983
- - Follow the exact structure shown above
984
- - For submit buttons, ALWAYS use type "input" with data.type "submit"
985
- - For conditional edges, ALWAYS specify the value as a string and use proper operators (>=, <, ===, etc.)
986
- - Never leave condition values empty - always provide the comparison value
987
- `, Pe = {
988
- claude: "claude-3-5-haiku-20241022",
989
- deepseek: "deepseek-chat",
990
- gemini: "gemini-2.5-flash",
991
- openai: "gpt-4o-mini"
992
- }, De = 0.3;
993
- function Te(t) {
994
- try {
995
- return JSON.parse(t);
996
- } catch (s) {
997
- const l = t.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
998
- try {
999
- return JSON.parse(l);
1000
- } catch {
1001
- throw console.error("Failed to parse AI response:", t.substring(0, 500)), new Error(`Invalid JSON response from AI: ${s instanceof Error ? s.message : "Unknown error"}`);
1002
- }
1003
- }
1004
- }
1005
- async function ga(t) {
1006
- const s = t.config.model || Pe.gemini, l = t.config.temperature ?? De, i = await fetch(
1007
- `https://generativelanguage.googleapis.com/v1beta/models/${s}:generateContent?key=${t.config.apiKey}`,
1008
- {
1009
- body: JSON.stringify({
1010
- contents: [
1011
- {
1012
- parts: [
1013
- {
1014
- text: `${ke}
1015
-
1016
- User request: ${t.prompt}`
1017
- }
1018
- ]
1019
- }
1020
- ],
1021
- generationConfig: {
1022
- responseMimeType: "application/json",
1023
- temperature: l
1024
- }
1025
- }),
1026
- headers: { "Content-Type": "application/json" },
1027
- method: "POST"
1028
- }
1029
- );
1030
- if (!i.ok) {
1031
- const n = await i.text();
1032
- throw new Error(`Gemini API error: ${n}`);
1033
- }
1034
- const o = (await i.json()).candidates?.[0]?.content?.parts?.[0]?.text;
1035
- if (!o)
1036
- throw new Error("No response from Gemini");
1037
- return Te(o);
1038
- }
1039
- async function ja(t) {
1040
- const s = t.config.model || Pe.openai, l = t.config.temperature ?? De, i = await fetch("https://api.openai.com/v1/chat/completions", {
1041
- body: JSON.stringify({
1042
- messages: [
1043
- { content: ke, role: "system" },
1044
- { content: t.prompt, role: "user" }
1045
- ],
1046
- model: s,
1047
- response_format: { type: "json_object" },
1048
- temperature: l
1049
- }),
1050
- headers: {
1051
- Authorization: `Bearer ${t.config.apiKey}`,
1052
- "Content-Type": "application/json"
1053
- },
1054
- method: "POST"
1055
- });
1056
- if (!i.ok) {
1057
- const n = await i.text();
1058
- throw new Error(`OpenAI API error: ${n}`);
1059
- }
1060
- const o = (await i.json()).choices?.[0]?.message?.content;
1061
- if (!o)
1062
- throw new Error("No response from OpenAI");
1063
- return Te(o);
1064
- }
1065
- async function Ca(t) {
1066
- const s = t.config.model || Pe.deepseek, l = t.config.temperature ?? De, i = await fetch("https://api.deepseek.com/v1/chat/completions", {
1067
- body: JSON.stringify({
1068
- messages: [
1069
- { content: ke, role: "system" },
1070
- { content: t.prompt, role: "user" }
1071
- ],
1072
- model: s,
1073
- response_format: { type: "json_object" },
1074
- temperature: l
1075
- }),
1076
- headers: {
1077
- Authorization: `Bearer ${t.config.apiKey}`,
1078
- "Content-Type": "application/json"
1079
- },
1080
- method: "POST"
1081
- });
1082
- if (!i.ok) {
1083
- const n = await i.text();
1084
- throw new Error(`DeepSeek API error: ${n}`);
1085
- }
1086
- const o = (await i.json()).choices?.[0]?.message?.content;
1087
- if (!o)
1088
- throw new Error("No response from DeepSeek");
1089
- return Te(o);
1090
- }
1091
- async function va(t) {
1092
- const s = t.config.model || Pe.claude, l = t.config.temperature ?? De, i = await fetch("https://api.anthropic.com/v1/messages", {
1093
- body: JSON.stringify({
1094
- max_tokens: 4096,
1095
- messages: [{ content: t.prompt, role: "user" }],
1096
- model: s,
1097
- system: ke,
1098
- temperature: l
1099
- }),
1100
- headers: {
1101
- "anthropic-version": "2023-06-01",
1102
- "Content-Type": "application/json",
1103
- "x-api-key": t.config.apiKey
1104
- },
1105
- method: "POST"
1106
- });
1107
- if (!i.ok) {
1108
- const n = await i.text();
1109
- throw new Error(`Claude API error: ${n}`);
1110
- }
1111
- const o = (await i.json()).content?.[0]?.text;
1112
- if (!o)
1113
- throw new Error("No response from Claude");
1114
- return Te(o);
1115
- }
1116
- function fa(t) {
1117
- switch (t.config.provider) {
1118
- case "gemini":
1119
- return ga(t);
1120
- case "openai":
1121
- return ja(t);
1122
- case "deepseek":
1123
- return Ca(t);
1124
- case "claude":
1125
- return va(t);
1126
- default:
1127
- throw new Error(`Unsupported AI provider: ${t.config.provider}`);
1128
- }
1129
- }
1130
- function ba({ ...t }) {
1131
- return /* @__PURE__ */ e.jsx(L.Root, { "data-slot": "dialog", ...t });
1132
- }
1133
- function Na({ ...t }) {
1134
- return /* @__PURE__ */ e.jsx(L.Trigger, { "data-slot": "dialog-trigger", ...t });
1135
- }
1136
- function ya({ ...t }) {
1137
- return /* @__PURE__ */ e.jsx(L.Portal, { "data-slot": "dialog-portal", ...t });
1138
- }
1139
- function wa({ className: t, ...s }) {
1140
- return /* @__PURE__ */ e.jsx(
1141
- L.Overlay,
1142
- {
1143
- "data-slot": "dialog-overlay",
1144
- className: P(
1145
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",
1146
- t
1147
- ),
1148
- ...s
1149
- }
1150
- );
1151
- }
1152
- function Fa({
1153
- className: t,
1154
- children: s,
1155
- showCloseButton: l = !0,
1156
- ...i
1157
- }) {
1158
- return /* @__PURE__ */ e.jsxs(ya, { "data-slot": "dialog-portal", children: [
1159
- /* @__PURE__ */ e.jsx(wa, {}),
1160
- /* @__PURE__ */ e.jsxs(
1161
- L.Content,
1162
- {
1163
- "data-slot": "dialog-content",
1164
- className: P(
1165
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",
1166
- t
1167
- ),
1168
- ...i,
1169
- children: [
1170
- s,
1171
- l && /* @__PURE__ */ e.jsxs(
1172
- L.Close,
1173
- {
1174
- "data-slot": "dialog-close",
1175
- className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
1176
- children: [
1177
- /* @__PURE__ */ e.jsx(et, {}),
1178
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Close" })
1179
- ]
1180
- }
1181
- )
1182
- ]
1183
- }
1184
- )
1185
- ] });
1186
- }
1187
- function Sa({ className: t, ...s }) {
1188
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "dialog-header", className: P("flex flex-col gap-2 text-center sm:text-left", t), ...s });
1189
- }
1190
- function Ea({ className: t, ...s }) {
1191
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "dialog-footer", className: P("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", t), ...s });
1192
- }
1193
- function ka({ className: t, ...s }) {
1194
- return /* @__PURE__ */ e.jsx(L.Title, { "data-slot": "dialog-title", className: P("font-semibold text-lg leading-none", t), ...s });
1195
- }
1196
- function Pa({ className: t, ...s }) {
1197
- return /* @__PURE__ */ e.jsx(L.Description, { "data-slot": "dialog-description", className: P("text-muted-foreground text-sm", t), ...s });
1198
- }
1199
- const Da = ({ aiConfig: t, onGenerate: s }) => {
1200
- const [l, i] = z(!1), [h, o] = z(""), [n, f] = z(!1), d = B(), c = async () => {
1201
- if (!h.trim()) {
1202
- U.error(d("editor.aiGenerator.enterDescription"));
1203
- return;
1204
- }
1205
- if (!t?.apiKey) {
1206
- U.error(d("editor.aiGenerator.missingApiKey"), {
1207
- description: d("editor.aiGenerator.missingApiKeyDesc")
1208
- });
1209
- return;
1210
- }
1211
- f(!0);
1212
- try {
1213
- const r = await fa({
1214
- config: t,
1215
- prompt: h.trim()
1216
- });
1217
- s({
1218
- edges: r.edges,
1219
- nodes: r.nodes
1220
- }), U.success(d("editor.aiGenerator.successTitle"), {
1221
- description: d("editor.aiGenerator.successDescription").replace("{nodes}", String(r.nodes.length)).replace("{edges}", String(r.edges.length))
1222
- }), o(""), i(!1);
1223
- } catch (r) {
1224
- console.error("AI generation error:", r), U.error(d("editor.aiGenerator.failedToGenerate"), {
1225
- description: r instanceof Error ? r.message : d("editor.aiGenerator.unknownError")
1226
- });
1227
- } finally {
1228
- f(!1);
1229
- }
1230
- }, a = (r) => {
1231
- (r.metaKey || r.ctrlKey) && r.key === "Enter" && (r.preventDefault(), c());
1232
- };
1233
- return /* @__PURE__ */ e.jsxs(ba, { open: l, onOpenChange: i, children: [
1234
- /* @__PURE__ */ e.jsx(Na, { asChild: !0, children: /* @__PURE__ */ e.jsxs(S, { variant: "outline", size: "sm", disabled: !t?.apiKey, children: [
1235
- /* @__PURE__ */ e.jsx(_e, { className: "h-4 w-4 text-[#13d3b4]" }),
1236
- " ",
1237
- d("editor.aiGenerator.buttonLabel")
1238
- ] }) }),
1239
- /* @__PURE__ */ e.jsxs(Fa, { className: "sm:max-w-[550px]", children: [
1240
- /* @__PURE__ */ e.jsxs(Sa, { children: [
1241
- /* @__PURE__ */ e.jsx(ka, { children: d("editor.aiGenerator.title") }),
1242
- /* @__PURE__ */ e.jsx(Pa, { children: d("editor.aiGenerator.titleDescription") })
1243
- ] }),
1244
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4 py-4", children: [
1245
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-2", children: [
1246
- /* @__PURE__ */ e.jsx("label", { htmlFor: "ai-prompt", className: "font-medium text-sm", children: d("editor.aiGenerator.description") }),
1247
- /* @__PURE__ */ e.jsx(
1248
- Ge,
1249
- {
1250
- placeholder: d("editor.aiGenerator.descriptionPlaceholder"),
1251
- value: h,
1252
- onChange: (r) => o(r.target.value),
1253
- onKeyDown: a,
1254
- rows: 6,
1255
- disabled: n,
1256
- className: "resize-none"
1257
- }
1258
- ),
1259
- /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-xs", children: d("editor.aiGenerator.keyboardShortcut").replace("{cmdEnter}", "⌘ Enter").replace("{ctrlEnter}", "Ctrl Enter") })
1260
- ] }),
1261
- !t?.apiKey && /* @__PURE__ */ e.jsxs("div", { className: "rounded-md bg-muted p-3 text-sm", children: [
1262
- /* @__PURE__ */ e.jsx("p", { className: "font-medium", children: d("editor.aiGenerator.aiNotConfigured") }),
1263
- /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-muted-foreground text-xs", children: [
1264
- d("editor.aiGenerator.aiNotConfiguredDesc").replace("{code}", ""),
1265
- " ",
1266
- /* @__PURE__ */ e.jsx("code", { className: "rounded bg-background px-1 py-0.5", children: "aiConfig" })
1267
- ] })
1268
- ] })
1269
- ] }),
1270
- /* @__PURE__ */ e.jsxs(Ea, { children: [
1271
- /* @__PURE__ */ e.jsx(S, { variant: "outline", onClick: () => i(!1), disabled: n, children: d("editor.aiGenerator.cancel") }),
1272
- /* @__PURE__ */ e.jsx(S, { onClick: c, disabled: n || !h.trim() || !t?.apiKey, children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1273
- /* @__PURE__ */ e.jsx(St, { className: "h-4 w-4 animate-spin" }),
1274
- d("editor.aiGenerator.generating")
1275
- ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1276
- /* @__PURE__ */ e.jsx(_e, { className: "h-4 w-4 text-[--treege-color-primary]" }),
1277
- d("editor.aiGenerator.generate")
1278
- ] }) })
1279
- ] })
1280
- ] })
1281
- ] });
1282
- };
1283
- function fe({ ...t }) {
1284
- return /* @__PURE__ */ e.jsx(ae.Root, { "data-slot": "dropdown-menu", ...t });
1285
- }
1286
- function be({ ...t }) {
1287
- return /* @__PURE__ */ e.jsx(ae.Trigger, { "data-slot": "dropdown-menu-trigger", ...t });
1288
- }
1289
- function Ne({ className: t, sideOffset: s = 4, ...l }) {
1290
- return /* @__PURE__ */ e.jsx(ae.Portal, { children: /* @__PURE__ */ e.jsx(
1291
- ae.Content,
1292
- {
1293
- "data-slot": "dropdown-menu-content",
1294
- sideOffset: s,
1295
- className: P(
1296
- "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-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
1297
- t
1298
- ),
1299
- ...l
1300
- }
1301
- ) });
1302
- }
1303
- function Ze({ ...t }) {
1304
- return /* @__PURE__ */ e.jsx(ae.Group, { "data-slot": "dropdown-menu-group", ...t });
1305
- }
1306
- function W({
1307
- className: t,
1308
- inset: s,
1309
- variant: l = "default",
1310
- ...i
1311
- }) {
1312
- return /* @__PURE__ */ e.jsx(
1313
- ae.Item,
1314
- {
1315
- "data-slot": "dropdown-menu-item",
1316
- "data-inset": s,
1317
- "data-variant": l,
1318
- className: P(
1319
- "data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[disabled]:opacity-50 data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
1320
- t
1321
- ),
1322
- ...i
1323
- }
1324
- );
1325
- }
1326
- function Ta({
1327
- className: t,
1328
- inset: s,
1329
- ...l
1330
- }) {
1331
- return /* @__PURE__ */ e.jsx(
1332
- ae.Label,
1333
- {
1334
- "data-slot": "dropdown-menu-label",
1335
- "data-inset": s,
1336
- className: P("px-2 py-1.5 font-medium text-sm data-[inset]:pl-8", t),
1337
- ...l
1338
- }
1339
- );
1340
- }
1341
- function Ke({ className: t, ...s }) {
1342
- return /* @__PURE__ */ e.jsx(
1343
- ae.Separator,
1344
- {
1345
- "data-slot": "dropdown-menu-separator",
1346
- className: P("-mx-1 my-1 h-px bg-border", t),
1347
- ...s
1348
- }
1349
- );
1350
- }
1351
- const Aa = ce(), Va = ({ onExportJson: t, onSave: s }) => {
1352
- const { flowId: l, setFlowId: i, aiConfig: h } = nt(), { setNodes: o, setEdges: n, addNodes: f, screenToFlowPosition: d } = ue(), c = l || Aa, a = Oe(), r = We(), u = Mt(null), m = B(), p = () => {
1353
- const b = (window.innerWidth || 0) / 2, E = (window.innerHeight || 0) / 2, A = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-width"), 10), V = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-height"), 10), T = d({ x: b - A, y: E - V });
1354
- f([
1355
- {
1356
- ...rt,
1357
- id: ce(),
1358
- position: T,
1359
- selected: !0
1360
- }
1361
- ]);
1362
- }, x = ({ target: b }) => {
1363
- const E = b.files?.[0];
1364
- if (!E)
1365
- return;
1366
- const A = new FileReader();
1367
- A.onload = (V) => {
1368
- try {
1369
- const T = JSON.parse(V.target?.result);
1370
- T && Array.isArray(T.nodes) && Array.isArray(T.edges) ? (o(T.nodes), n(T.edges), U.success(m("editor.actionsPanel.importSuccess"), {
1371
- description: m("editor.actionsPanel.importSuccessDesc")
1372
- })) : U.error(m("editor.actionsPanel.invalidJson"), {
1373
- description: m("editor.actionsPanel.invalidJsonDesc")
1374
- });
1375
- } catch (T) {
1376
- console.warn(T), U.error(m("editor.actionsPanel.parseError"), {
1377
- description: m("editor.actionsPanel.parseErrorDesc")
1378
- });
1379
- }
1380
- u.current && (u.current.value = "");
1381
- }, A.readAsText(E);
1382
- }, F = () => {
1383
- const b = { edges: r, id: c, nodes: a }, E = new Blob([JSON.stringify(b, null, 2)], { type: "application/json" }), A = URL.createObjectURL(E), V = document.createElement("a");
1384
- V.href = A, V.download = "treege.json", V.click(), URL.revokeObjectURL(A), U.success(m("editor.actionsPanel.downloadSuccess"), {
1385
- description: m("editor.actionsPanel.downloadSuccessDesc")
1386
- }), l || i?.(c), t?.(b);
1387
- }, g = $(() => {
1388
- l || i?.(c), s?.({ edges: r, id: c, nodes: a });
1389
- }, [r, l, c, a, s, i]), w = async () => {
1390
- try {
1391
- await navigator.clipboard.writeText(c), U.success(m("editor.actionsPanel.idCopied"), {
1392
- description: c
1393
- });
1394
- } catch {
1395
- U.error(m("editor.actionsPanel.copyFailed"));
1396
- }
1397
- }, C = () => {
1398
- o([]), n([]), U.success(m("editor.actionsPanel.clearSuccess"), {
1399
- description: m("editor.actionsPanel.clearSuccessDesc")
1400
- });
1401
- }, I = (b) => {
1402
- o(b.nodes), n(b.edges);
1403
- };
1404
- return Lt(() => {
1405
- const b = (E) => {
1406
- (E.ctrlKey || E.metaKey) && E.key === "s" && (E.preventDefault(), g());
1407
- };
1408
- return window.addEventListener("keydown", b), () => {
1409
- window.removeEventListener("keydown", b);
1410
- };
1411
- }, [g]), /* @__PURE__ */ e.jsxs(xt, { position: "top-right", className: "flex gap-2", children: [
1412
- /* @__PURE__ */ e.jsx(Da, { aiConfig: h, onGenerate: I }),
1413
- /* @__PURE__ */ e.jsxs(S, { variant: "outline", size: "sm", onClick: p, children: [
1414
- /* @__PURE__ */ e.jsx(X, {}),
1415
- " ",
1416
- m("editor.actionsPanel.addNode")
1417
- ] }),
1418
- /* @__PURE__ */ e.jsxs(S, { variant: "outline", size: "sm", onClick: g, children: [
1419
- /* @__PURE__ */ e.jsx(Et, {}),
1420
- " ",
1421
- m("common.save")
1422
- ] }),
1423
- /* @__PURE__ */ e.jsxs(fe, { children: [
1424
- /* @__PURE__ */ e.jsx(be, { asChild: !0, children: /* @__PURE__ */ e.jsx(S, { variant: "outline", size: "sm", children: /* @__PURE__ */ e.jsx(kt, {}) }) }),
1425
- /* @__PURE__ */ e.jsxs(Ne, { align: "start", children: [
1426
- /* @__PURE__ */ e.jsx(Ta, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
1427
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: "Flow ID" }),
1428
- /* @__PURE__ */ e.jsxs(
1429
- "button",
1430
- {
1431
- onClick: w,
1432
- className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
1433
- type: "button",
1434
- children: [
1435
- /* @__PURE__ */ e.jsx(Pt, { className: "h-3 w-3" }),
1436
- /* @__PURE__ */ e.jsx("span", { className: "truncate text-xs", children: c })
1437
- ]
1438
- }
1439
- )
1440
- ] }) }),
1441
- /* @__PURE__ */ e.jsx(Ke, {}),
1442
- /* @__PURE__ */ e.jsxs(Ze, { children: [
1443
- /* @__PURE__ */ e.jsxs(W, { onClick: () => u?.current?.click(), children: [
1444
- /* @__PURE__ */ e.jsx(Dt, {}),
1445
- " ",
1446
- m("editor.actionsPanel.importJson")
1447
- ] }),
1448
- /* @__PURE__ */ e.jsxs(W, { onClick: F, children: [
1449
- /* @__PURE__ */ e.jsx(Tt, {}),
1450
- " ",
1451
- m("editor.actionsPanel.exportJson")
1452
- ] })
1453
- ] }),
1454
- /* @__PURE__ */ e.jsx(Ke, {}),
1455
- /* @__PURE__ */ e.jsx(Ze, { children: /* @__PURE__ */ e.jsxs(W, { onClick: C, className: "text-destructive focus:text-destructive", children: [
1456
- /* @__PURE__ */ e.jsx(tt, { className: "text-destructive" }),
1457
- " ",
1458
- m("editor.actionsPanel.clear")
1459
- ] }) })
1460
- ] })
1461
- ] }),
1462
- /* @__PURE__ */ e.jsx("input", { type: "file", accept: "application/json,.json", className: "hidden", ref: u, onChange: x })
1463
- ] });
1464
- }, Ia = {
1465
- ar: "ar",
1466
- de: "de",
1467
- en: "en",
1468
- es: "es",
1469
- fr: "fr",
1470
- it: "it",
1471
- pt: "pt"
1472
- }, q = ({ value: t = "en", onValueChange: s }) => /* @__PURE__ */ e.jsxs(_, { value: t, onValueChange: s, children: [
1473
- /* @__PURE__ */ e.jsx(R, { className: "uppercase", children: /* @__PURE__ */ e.jsx(Z, { placeholder: "" }) }),
1474
- /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsx(te, { children: Object.values(Ia).map((l) => /* @__PURE__ */ e.jsx(y, { value: l, className: "uppercase", children: l }, l)) }) })
1475
- ] }), me = () => {
1476
- const { setNodes: t, setEdges: s, getNodes: l } = ue(), i = $(() => {
1477
- t((c) => c.map(({ selected: a, ...r }) => r)), s((c) => c.map(({ selected: a, ...r }) => r));
1478
- }, [s, t]), h = $(
1479
- (c, a) => {
1480
- t(
1481
- (r) => r.map((u) => u.id === c ? {
1482
- ...u,
1483
- data: {
1484
- ...u.data,
1485
- ...a
1486
- }
1487
- } : u)
1488
- );
1489
- },
1490
- [t]
1491
- ), o = $(
1492
- (c, a) => {
1493
- t(
1494
- (r) => r.map((u) => u.id === c ? {
1495
- ...u,
1496
- data: {},
1497
- type: a
1498
- } : u)
1499
- );
1500
- },
1501
- [t]
1502
- ), n = $(
1503
- (c) => {
1504
- const a = l().find((r) => r.selected);
1505
- a && o(a.id, c);
1506
- },
1507
- [l, o]
1508
- ), f = $(
1509
- (c) => {
1510
- const a = l().find((r) => r.selected);
1511
- a && h(a.id, c);
1512
- },
1513
- [l, h]
1514
- ), d = $(() => {
1515
- const c = l().find((a) => a.selected);
1516
- c && (t((a) => a.filter((r) => r.id !== c.id)), s((a) => a.filter((r) => r.source !== c.id && r.target !== c.id)));
1517
- }, [l, t, s]);
1518
- return {
1519
- clearSelection: i,
1520
- deleteSelectedNode: d,
1521
- updateNodeData: h,
1522
- updateNodeType: o,
1523
- updateSelectedNodeData: f,
1524
- updateSelectedNodeType: n
1525
- };
1526
- }, ee = () => {
1527
- const t = Oe(), s = le(() => t.filter(Se), [t]), l = le(() => t.filter((h) => h.selected), [t]), i = le(() => t.find((h) => h.selected), [t]);
1528
- return {
1529
- groupNodes: s,
1530
- hasSelectedNodes: l.length > 0,
1531
- nodes: t,
1532
- selectedNode: i,
1533
- selectedNodes: l
1534
- };
1535
- }, Oa = () => {
1536
- const [t, s] = z("en"), { updateSelectedNodeData: l } = me(), { selectedNode: i } = ee(), h = B(), { Field: o } = ne({
1537
- defaultValues: {
1538
- label: i?.data?.label || { en: "" },
1539
- targetId: i?.data?.targetId || ""
1540
- },
1541
- listeners: {
1542
- onChange: ({ formApi: n }) => {
1543
- n.handleSubmit().then();
1544
- },
1545
- onChangeDebounceMs: 150
1546
- },
1547
- onSubmit: ({ value: n }) => {
1548
- l(n);
1549
- }
1550
- });
1551
- return /* @__PURE__ */ e.jsx(
1552
- "form",
1553
- {
1554
- onSubmit: (n) => {
1555
- n.preventDefault(), n.stopPropagation();
1556
- },
1557
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1558
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1559
- /* @__PURE__ */ e.jsx(
1560
- o,
1561
- {
1562
- name: "label",
1563
- children: (n) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1564
- /* @__PURE__ */ e.jsx(j, { htmlFor: n.name, children: h("editor.flowNodeForm.label") }),
1565
- /* @__PURE__ */ e.jsx(
1566
- k,
1567
- {
1568
- id: n.name,
1569
- name: n.name,
1570
- value: n.state.value?.[t] || "",
1571
- onBlur: n.handleBlur,
1572
- onChange: ({ target: f }) => {
1573
- n.handleChange({
1574
- ...n.state.value,
1575
- [t]: f.value
1576
- });
1577
- }
1578
- }
1579
- )
1580
- ] })
1581
- }
1582
- ),
1583
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
1584
- ] }),
1585
- /* @__PURE__ */ e.jsx(
1586
- o,
1587
- {
1588
- name: "targetId",
1589
- children: (n) => /* @__PURE__ */ e.jsxs(N, { children: [
1590
- /* @__PURE__ */ e.jsxs(j, { htmlFor: n.name, children: [
1591
- h("editor.flowNodeForm.targetId"),
1592
- " (Flow ID)"
1593
- ] }),
1594
- /* @__PURE__ */ e.jsx(
1595
- k,
1596
- {
1597
- id: n.name,
1598
- name: n.name,
1599
- value: n.state.value,
1600
- onBlur: n.handleBlur,
1601
- onChange: ({ target: f }) => n.handleChange(f.value)
1602
- }
1603
- ),
1604
- /* @__PURE__ */ e.jsx(M, { children: "Unique identifier of the target flow." })
1605
- ] })
1606
- }
1607
- )
1608
- ] })
1609
- }
1610
- );
1611
- }, Ma = () => {
1612
- const [t, s] = z("en"), { selectedNode: l } = ee(), { updateSelectedNodeData: i } = me(), { Field: h } = ne({
1613
- defaultValues: {
1614
- label: l?.data?.label || { en: "" }
1615
- },
1616
- listeners: {
1617
- onChange: ({ formApi: o }) => {
1618
- o.handleSubmit().then();
1619
- },
1620
- onChangeDebounceMs: 150
1621
- },
1622
- onSubmit: ({ value: o }) => {
1623
- i(o);
1624
- }
1625
- });
1626
- return /* @__PURE__ */ e.jsx(
1627
- "form",
1628
- {
1629
- onSubmit: (o) => {
1630
- o.preventDefault(), o.stopPropagation();
1631
- },
1632
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1633
- /* @__PURE__ */ e.jsx(
1634
- h,
1635
- {
1636
- name: "label",
1637
- children: (o) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1638
- /* @__PURE__ */ e.jsx(j, { htmlFor: o.name, children: "Label" }),
1639
- /* @__PURE__ */ e.jsx(
1640
- k,
1641
- {
1642
- id: o.name,
1643
- name: o.name,
1644
- value: o.state.value?.[t] || "",
1645
- onBlur: o.handleBlur,
1646
- onChange: ({ target: n }) => {
1647
- o.handleChange({
1648
- ...o.state.value,
1649
- [t]: n.value
1650
- });
1651
- }
1652
- }
1653
- )
1654
- ] })
1655
- }
1656
- ),
1657
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
1658
- ] })
1659
- }
1660
- );
1661
- }, La = ["POST", "PUT", "PATCH"], Ba = ({ value: t, onChange: s }) => {
1662
- const { selectedNode: l } = ee(), i = B(), h = Ee(l?.id), { handleSubmit: o, Field: n, Subscribe: f } = ne({
1663
- defaultValues: {
1664
- body: t?.body || "",
1665
- fetchOnMount: t?.fetchOnMount ?? !t?.searchParam,
1666
- headers: t?.headers || [],
1667
- method: t?.method || "GET",
1668
- responseMapping: t?.responseMapping || {
1669
- labelField: "",
1670
- valueField: ""
1671
- },
1672
- responsePath: t?.responsePath || "",
1673
- searchParam: t?.searchParam || "",
1674
- sendAllFormValues: !!t?.sendAllFormValues,
1675
- showLoading: t?.showLoading !== !1,
1676
- url: t?.url || ""
1677
- },
1678
- listeners: {
1679
- onChange: ({ formApi: d }) => {
1680
- d.handleSubmit().then();
1681
- },
1682
- onChangeDebounceMs: 150
1683
- },
1684
- onSubmit: ({ value: d }) => {
1685
- s(d);
1686
- }
1687
- });
1688
- return /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1689
- /* @__PURE__ */ e.jsx(
1690
- n,
1691
- {
1692
- name: "url",
1693
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1694
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.apiUrl") }),
1695
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
1696
- /* @__PURE__ */ e.jsx(
1697
- k,
1698
- {
1699
- id: d.name,
1700
- name: d.name,
1701
- value: d.state.value,
1702
- onBlur: d.handleBlur,
1703
- onChange: ({ target: c }) => d.handleChange(c.value),
1704
- placeholder: i("editor.httpConfigForm.apiUrlPlaceholder"),
1705
- className: "flex-1"
1706
- }
1707
- ),
1708
- /* @__PURE__ */ e.jsxs(fe, { children: [
1709
- /* @__PURE__ */ e.jsx(be, { asChild: !0, children: /* @__PURE__ */ e.jsx(S, { type: "button", variant: "outline", size: "icon", children: /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4" }) }) }),
1710
- /* @__PURE__ */ e.jsx(Ne, { align: "end", children: h.length === 0 ? /* @__PURE__ */ e.jsx(W, { disabled: !0, children: i("editor.httpConfigForm.noFieldsAvailable") }) : h.map((c) => /* @__PURE__ */ e.jsx(
1711
- W,
1712
- {
1713
- onClick: () => {
1714
- const a = `{{${c.nodeId}}}`, r = d.state.value || "";
1715
- d.handleChange(r + a);
1716
- },
1717
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
1718
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: c.label }),
1719
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${c.nodeId}}}` })
1720
- ] })
1721
- },
1722
- c.nodeId
1723
- )) })
1724
- ] })
1725
- ] }),
1726
- /* @__PURE__ */ e.jsx(M, { children: i("editor.httpConfigForm.apiUrlDesc") })
1727
- ] })
1728
- }
1729
- ),
1730
- /* @__PURE__ */ e.jsx(
1731
- n,
1732
- {
1733
- name: "method",
1734
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1735
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.httpMethod") }),
1736
- /* @__PURE__ */ e.jsxs(
1737
- _,
1738
- {
1739
- value: d.state.value,
1740
- onValueChange: (c) => d.handleChange(c),
1741
- children: [
1742
- /* @__PURE__ */ e.jsx(R, { id: d.name, children: /* @__PURE__ */ e.jsx(Z, { placeholder: i("editor.httpConfigForm.selectMethod") }) }),
1743
- /* @__PURE__ */ e.jsxs(K, { children: [
1744
- /* @__PURE__ */ e.jsx(y, { value: "GET", children: i("editor.httpConfigForm.methodGet") }),
1745
- /* @__PURE__ */ e.jsx(y, { value: "POST", children: i("editor.httpConfigForm.methodPost") }),
1746
- /* @__PURE__ */ e.jsx(y, { value: "PUT", children: i("editor.httpConfigForm.methodPut") }),
1747
- /* @__PURE__ */ e.jsx(y, { value: "DELETE", children: i("editor.httpConfigForm.methodDelete") }),
1748
- /* @__PURE__ */ e.jsx(y, { value: "PATCH", children: i("editor.httpConfigForm.methodPatch") })
1749
- ] })
1750
- ]
1751
- }
1752
- )
1753
- ] })
1754
- }
1755
- ),
1756
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1757
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: i("editor.httpConfigForm.headers") }),
1758
- /* @__PURE__ */ e.jsx(n, { name: "headers", mode: "array", children: (d) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1759
- d.state.value?.map((c, a) => {
1760
- const r = `headers[${a}]`;
1761
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
1762
- /* @__PURE__ */ e.jsx(n, { name: `headers[${a}].key`, children: (u) => /* @__PURE__ */ e.jsx(
1763
- k,
1764
- {
1765
- placeholder: i("editor.httpConfigForm.headerName"),
1766
- value: u.state.value || "",
1767
- onChange: ({ target: m }) => u.handleChange(m.value)
1768
- }
1769
- ) }),
1770
- /* @__PURE__ */ e.jsx(n, { name: `headers[${a}].value`, children: (u) => /* @__PURE__ */ e.jsx(
1771
- k,
1772
- {
1773
- placeholder: i("editor.httpConfigForm.headerValue"),
1774
- value: u.state.value || "",
1775
- onChange: ({ target: m }) => u.handleChange(m.value)
1776
- }
1777
- ) }),
1778
- /* @__PURE__ */ e.jsx(
1779
- S,
1780
- {
1781
- type: "button",
1782
- variant: "ghost",
1783
- size: "icon",
1784
- onClick: () => {
1785
- d.removeValue(a);
1786
- },
1787
- children: /* @__PURE__ */ e.jsx(se, { className: "h-4 w-4" })
1788
- }
1789
- )
1790
- ] }, r);
1791
- }),
1792
- /* @__PURE__ */ e.jsxs(
1793
- S,
1794
- {
1795
- type: "button",
1796
- variant: "outline",
1797
- size: "sm",
1798
- onClick: () => {
1799
- d.pushValue({ key: "", value: "" });
1800
- },
1801
- children: [
1802
- /* @__PURE__ */ e.jsx(X, { className: "mr-2 h-4 w-4" }),
1803
- i("editor.httpConfigForm.addHeader")
1804
- ]
1805
- }
1806
- )
1807
- ] }) })
1808
- ] }),
1809
- /* @__PURE__ */ e.jsx(f, { selector: (d) => ({ method: d.values.method, sendAllFormValues: d.values.sendAllFormValues }), children: ({ method: d, sendAllFormValues: c }) => La.includes(d || "") && /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1810
- /* @__PURE__ */ e.jsx(n, { name: "sendAllFormValues", children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1811
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
1812
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: i("editor.httpConfigForm.sendAllFormValues") })
1813
- ] }) }),
1814
- /* @__PURE__ */ e.jsx(n, { name: "body", children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
1815
- /* @__PURE__ */ e.jsxs("div", { className: "mb-2 flex items-center justify-between", children: [
1816
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: i("editor.httpConfigForm.requestBody") }),
1817
- /* @__PURE__ */ e.jsxs(fe, { children: [
1818
- /* @__PURE__ */ e.jsx(be, { asChild: !0, children: /* @__PURE__ */ e.jsxs(S, { type: "button", variant: "ghost", size: "sm", disabled: c, children: [
1819
- /* @__PURE__ */ e.jsx(we, { className: "mr-2 h-4 w-4" }),
1820
- i("editor.httpConfigForm.insertVariable")
1821
- ] }) }),
1822
- /* @__PURE__ */ e.jsx(Ne, { align: "end", children: h.length === 0 ? /* @__PURE__ */ e.jsx(W, { disabled: !0, children: i("editor.httpConfigForm.noFieldsAvailable") }) : h.map((r) => /* @__PURE__ */ e.jsx(
1823
- W,
1824
- {
1825
- onClick: () => {
1826
- const u = `{{${r.nodeId}}}`, m = a.state.value || "";
1827
- a.handleChange(m + u), o().then();
1828
- },
1829
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
1830
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: r.label }),
1831
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${r.nodeId}}}` })
1832
- ] })
1833
- },
1834
- r.nodeId
1835
- )) })
1836
- ] })
1837
- ] }),
1838
- /* @__PURE__ */ e.jsx(
1839
- Ge,
1840
- {
1841
- id: a.name,
1842
- name: a.name,
1843
- value: a.state.value,
1844
- onBlur: a.handleBlur,
1845
- onChange: ({ target: r }) => a.handleChange(r.value),
1846
- placeholder: i("editor.httpConfigForm.requestBodyPlaceholder"),
1847
- rows: 4,
1848
- disabled: c
1849
- }
1850
- ),
1851
- /* @__PURE__ */ e.jsx(M, { children: i(c ? "editor.httpConfigForm.sendAllFormValuesDesc" : "editor.httpConfigForm.requestBodyDesc") })
1852
- ] }) })
1853
- ] }) }),
1854
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1855
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: i("editor.httpConfigForm.responseConfiguration") }),
1856
- /* @__PURE__ */ e.jsx(
1857
- n,
1858
- {
1859
- name: "responsePath",
1860
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1861
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.responsePath") }),
1862
- /* @__PURE__ */ e.jsx(
1863
- k,
1864
- {
1865
- id: d.name,
1866
- name: d.name,
1867
- value: d.state.value,
1868
- onBlur: d.handleBlur,
1869
- onChange: ({ target: c }) => d.handleChange(c.value),
1870
- placeholder: i("editor.httpConfigForm.responsePathPlaceholder")
1871
- }
1872
- ),
1873
- /* @__PURE__ */ e.jsx(M, { children: i("editor.httpConfigForm.responsePathDesc") })
1874
- ] })
1875
- }
1876
- ),
1877
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1878
- /* @__PURE__ */ e.jsx("h5", { className: "font-medium text-sm", children: i("editor.httpConfigForm.mapToOptions") }),
1879
- /* @__PURE__ */ e.jsx(
1880
- n,
1881
- {
1882
- name: "responseMapping.valueField",
1883
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1884
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.valueField") }),
1885
- /* @__PURE__ */ e.jsx(
1886
- k,
1887
- {
1888
- id: d.name,
1889
- name: d.name,
1890
- value: d.state.value,
1891
- onBlur: d.handleBlur,
1892
- onChange: ({ target: c }) => d.handleChange(c.value),
1893
- placeholder: i("editor.httpConfigForm.valueFieldPlaceholder")
1894
- }
1895
- ),
1896
- /* @__PURE__ */ e.jsx(M, { children: i("editor.httpConfigForm.valueFieldDesc") })
1897
- ] })
1898
- }
1899
- ),
1900
- /* @__PURE__ */ e.jsx(
1901
- n,
1902
- {
1903
- name: "responseMapping.labelField",
1904
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1905
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.labelField") }),
1906
- /* @__PURE__ */ e.jsx(
1907
- k,
1908
- {
1909
- id: d.name,
1910
- name: d.name,
1911
- value: d.state.value,
1912
- onBlur: d.handleBlur,
1913
- onChange: ({ target: c }) => d.handleChange(c.value),
1914
- placeholder: i("editor.httpConfigForm.labelFieldPlaceholder")
1915
- }
1916
- ),
1917
- /* @__PURE__ */ e.jsx(M, { children: i("editor.httpConfigForm.labelFieldDesc") })
1918
- ] })
1919
- }
1920
- )
1921
- ] }),
1922
- /* @__PURE__ */ e.jsx(
1923
- n,
1924
- {
1925
- name: "searchParam",
1926
- children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
1927
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.searchParameter") }),
1928
- /* @__PURE__ */ e.jsx(
1929
- k,
1930
- {
1931
- id: d.name,
1932
- name: d.name,
1933
- value: d.state.value,
1934
- onBlur: d.handleBlur,
1935
- onChange: ({ target: c }) => d.handleChange(c.value),
1936
- placeholder: i("editor.httpConfigForm.searchParameterPlaceholder")
1937
- }
1938
- ),
1939
- /* @__PURE__ */ e.jsx(M, { children: i("editor.httpConfigForm.searchParameterDesc") })
1940
- ] })
1941
- }
1942
- )
1943
- ] }),
1944
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1945
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: i("editor.httpConfigForm.behavior") }),
1946
- /* @__PURE__ */ e.jsx(f, { selector: (d) => d.values.searchParam, children: (d) => /* @__PURE__ */ e.jsx(n, { name: "fetchOnMount", children: (c) => {
1947
- const a = !!d?.trim(), r = a ? c.state.value : !0;
1948
- return !a && c.state.value !== !0 && c.handleChange(!0), /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1949
- /* @__PURE__ */ e.jsx(
1950
- J,
1951
- {
1952
- id: c.name,
1953
- checked: r,
1954
- disabled: !a,
1955
- onCheckedChange: (u) => c.handleChange(u)
1956
- }
1957
- ),
1958
- /* @__PURE__ */ e.jsx(j, { htmlFor: c.name, className: a ? "" : "text-muted-foreground", children: i("editor.httpConfigForm.fetchOnMount") })
1959
- ] });
1960
- } }) }),
1961
- /* @__PURE__ */ e.jsx(
1962
- n,
1963
- {
1964
- name: "showLoading",
1965
- children: (d) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1966
- /* @__PURE__ */ e.jsx(J, { id: d.name, checked: d.state.value, onCheckedChange: (c) => d.handleChange(c) }),
1967
- /* @__PURE__ */ e.jsx(j, { htmlFor: d.name, children: i("editor.httpConfigForm.showLoadingState") })
1968
- ] })
1969
- }
1970
- )
1971
- ] })
1972
- ] }) });
1973
- }, Ga = ["POST", "PUT", "PATCH"], $a = ({ value: t, onChange: s }) => {
1974
- const [l, i] = z("en"), { selectedNode: h } = ee(), o = B(), n = Ee(h?.id), { handleSubmit: f, Field: d, Subscribe: c } = ne({
1975
- defaultValues: {
1976
- body: t?.body || "",
1977
- errorMessage: t?.errorMessage || { en: "" },
1978
- headers: t?.headers || [],
1979
- method: t?.method || "POST",
1980
- redirectUrl: t?.redirectUrl || "",
1981
- sendAllFormValues: !!t?.sendAllFormValues,
1982
- showLoading: t?.showLoading !== !1,
1983
- successMessage: t?.successMessage || { en: "" },
1984
- url: t?.url || ""
1985
- },
1986
- listeners: {
1987
- onChange: ({ formApi: a }) => {
1988
- a.handleSubmit().then();
1989
- },
1990
- onChangeDebounceMs: 150
1991
- },
1992
- onSubmit: ({ value: a }) => {
1993
- s(a);
1994
- }
1995
- });
1996
- return /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1997
- /* @__PURE__ */ e.jsx(
1998
- d,
1999
- {
2000
- name: "url",
2001
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
2002
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.apiUrl") }),
2003
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
2004
- /* @__PURE__ */ e.jsx(
2005
- k,
2006
- {
2007
- id: a.name,
2008
- name: a.name,
2009
- value: a.state.value,
2010
- onBlur: a.handleBlur,
2011
- onChange: ({ target: r }) => a.handleChange(r.value),
2012
- placeholder: o("editor.submitConfigForm.apiUrlPlaceholder"),
2013
- className: "flex-1"
2014
- }
2015
- ),
2016
- /* @__PURE__ */ e.jsxs(fe, { children: [
2017
- /* @__PURE__ */ e.jsx(be, { asChild: !0, children: /* @__PURE__ */ e.jsx(S, { type: "button", variant: "outline", size: "icon", children: /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4" }) }) }),
2018
- /* @__PURE__ */ e.jsx(Ne, { align: "end", children: n.length === 0 ? /* @__PURE__ */ e.jsx(W, { disabled: !0, children: o("editor.submitConfigForm.noFieldsAvailable") }) : n.map((r) => /* @__PURE__ */ e.jsx(
2019
- W,
2020
- {
2021
- onClick: () => {
2022
- const u = `{{${r.nodeId}}}`, m = a.state.value || "";
2023
- a.handleChange(m + u);
2024
- },
2025
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
2026
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: r.label }),
2027
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${r.nodeId}}}` })
2028
- ] })
2029
- },
2030
- r.nodeId
2031
- )) })
2032
- ] })
2033
- ] }),
2034
- /* @__PURE__ */ e.jsx(M, { children: o("editor.submitConfigForm.apiUrlDesc") })
2035
- ] })
2036
- }
2037
- ),
2038
- /* @__PURE__ */ e.jsx(
2039
- d,
2040
- {
2041
- name: "method",
2042
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
2043
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.httpMethod") }),
2044
- /* @__PURE__ */ e.jsxs(
2045
- _,
2046
- {
2047
- value: a.state.value,
2048
- onValueChange: (r) => a.handleChange(r),
2049
- children: [
2050
- /* @__PURE__ */ e.jsx(R, { id: a.name, children: /* @__PURE__ */ e.jsx(Z, { placeholder: o("editor.submitConfigForm.selectMethod") }) }),
2051
- /* @__PURE__ */ e.jsxs(K, { children: [
2052
- /* @__PURE__ */ e.jsx(y, { value: "POST", children: o("editor.submitConfigForm.methodPost") }),
2053
- /* @__PURE__ */ e.jsx(y, { value: "PUT", children: o("editor.submitConfigForm.methodPut") }),
2054
- /* @__PURE__ */ e.jsx(y, { value: "DELETE", children: o("editor.submitConfigForm.methodDelete") }),
2055
- /* @__PURE__ */ e.jsx(y, { value: "PATCH", children: o("editor.submitConfigForm.methodPatch") })
2056
- ] })
2057
- ]
2058
- }
2059
- )
2060
- ] })
2061
- }
2062
- ),
2063
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2064
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: o("editor.submitConfigForm.headers") }),
2065
- /* @__PURE__ */ e.jsx(d, { name: "headers", mode: "array", children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
2066
- a.state.value?.map((r, u) => {
2067
- const m = `headers[${u}]`;
2068
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
2069
- /* @__PURE__ */ e.jsx(d, { name: `headers[${u}].key`, children: (p) => /* @__PURE__ */ e.jsx(
2070
- k,
2071
- {
2072
- placeholder: o("editor.submitConfigForm.headerName"),
2073
- value: p.state.value || "",
2074
- onChange: ({ target: x }) => p.handleChange(x.value)
2075
- }
2076
- ) }),
2077
- /* @__PURE__ */ e.jsx(d, { name: `headers[${u}].value`, children: (p) => /* @__PURE__ */ e.jsx(
2078
- k,
2079
- {
2080
- placeholder: o("editor.submitConfigForm.headerValue"),
2081
- value: p.state.value || "",
2082
- onChange: ({ target: x }) => p.handleChange(x.value)
2083
- }
2084
- ) }),
2085
- /* @__PURE__ */ e.jsx(
2086
- S,
2087
- {
2088
- type: "button",
2089
- variant: "ghost",
2090
- size: "icon",
2091
- onClick: () => {
2092
- a.removeValue(u);
2093
- },
2094
- children: /* @__PURE__ */ e.jsx(se, { className: "h-4 w-4" })
2095
- }
2096
- )
2097
- ] }, m);
2098
- }),
2099
- /* @__PURE__ */ e.jsxs(
2100
- S,
2101
- {
2102
- type: "button",
2103
- variant: "outline",
2104
- size: "sm",
2105
- onClick: () => {
2106
- a.pushValue({ key: "", value: "" });
2107
- },
2108
- children: [
2109
- /* @__PURE__ */ e.jsx(X, { className: "mr-2 h-4 w-4" }),
2110
- o("editor.submitConfigForm.addHeader")
2111
- ]
2112
- }
2113
- )
2114
- ] }) })
2115
- ] }),
2116
- /* @__PURE__ */ e.jsx(c, { selector: (a) => ({ method: a.values.method, sendAllFormValues: a.values.sendAllFormValues }), children: ({ method: a, sendAllFormValues: r }) => Ga.includes(a || "") && /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2117
- /* @__PURE__ */ e.jsx(d, { name: "sendAllFormValues", children: (u) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2118
- /* @__PURE__ */ e.jsx(J, { id: u.name, checked: u.state.value, onCheckedChange: (m) => u.handleChange(m) }),
2119
- /* @__PURE__ */ e.jsx(j, { htmlFor: u.name, children: o("editor.submitConfigForm.sendAllFormValues") })
2120
- ] }) }),
2121
- /* @__PURE__ */ e.jsx(d, { name: "body", children: (u) => /* @__PURE__ */ e.jsxs(N, { children: [
2122
- /* @__PURE__ */ e.jsxs("div", { className: "mb-2 flex items-center justify-between", children: [
2123
- /* @__PURE__ */ e.jsx(j, { htmlFor: u.name, children: o("editor.submitConfigForm.requestBody") }),
2124
- /* @__PURE__ */ e.jsxs(fe, { children: [
2125
- /* @__PURE__ */ e.jsx(be, { asChild: !0, children: /* @__PURE__ */ e.jsxs(S, { type: "button", variant: "ghost", size: "sm", disabled: r, children: [
2126
- /* @__PURE__ */ e.jsx(we, { className: "mr-2 h-4 w-4" }),
2127
- o("editor.submitConfigForm.insertVariable")
2128
- ] }) }),
2129
- /* @__PURE__ */ e.jsx(Ne, { align: "end", children: n.length === 0 ? /* @__PURE__ */ e.jsx(W, { disabled: !0, children: o("editor.submitConfigForm.noFieldsAvailable") }) : n.map((m) => /* @__PURE__ */ e.jsx(
2130
- W,
2131
- {
2132
- onClick: () => {
2133
- const p = `{{${m.nodeId}}}`, x = u.state.value || "";
2134
- u.handleChange(x + p), f().then();
2135
- },
2136
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
2137
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: m.label }),
2138
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${m.nodeId}}}` })
2139
- ] })
2140
- },
2141
- m.nodeId
2142
- )) })
2143
- ] })
2144
- ] }),
2145
- /* @__PURE__ */ e.jsx(
2146
- Ge,
2147
- {
2148
- id: u.name,
2149
- name: u.name,
2150
- value: u.state.value,
2151
- onBlur: u.handleBlur,
2152
- onChange: ({ target: m }) => u.handleChange(m.value),
2153
- placeholder: o("editor.submitConfigForm.requestBodyPlaceholder"),
2154
- rows: 4,
2155
- disabled: r
2156
- }
2157
- ),
2158
- /* @__PURE__ */ e.jsx(M, { children: o(r ? "editor.submitConfigForm.sendAllFormValuesDesc" : "editor.submitConfigForm.requestBodyDesc") })
2159
- ] }) })
2160
- ] }) }),
2161
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2162
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: o("editor.submitConfigForm.postSubmission") }),
2163
- /* @__PURE__ */ e.jsx(
2164
- d,
2165
- {
2166
- name: "redirectUrl",
2167
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
2168
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.redirectUrl") }),
2169
- /* @__PURE__ */ e.jsx(
2170
- k,
2171
- {
2172
- id: a.name,
2173
- name: a.name,
2174
- value: a.state.value,
2175
- onBlur: a.handleBlur,
2176
- onChange: ({ target: r }) => a.handleChange(r.value),
2177
- placeholder: o("editor.submitConfigForm.redirectUrlPlaceholder")
2178
- }
2179
- ),
2180
- /* @__PURE__ */ e.jsx(M, { children: o("editor.submitConfigForm.redirectUrlDesc") })
2181
- ] })
2182
- }
2183
- ),
2184
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2185
- /* @__PURE__ */ e.jsx(
2186
- d,
2187
- {
2188
- name: "successMessage",
2189
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2190
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.successMessage") }),
2191
- /* @__PURE__ */ e.jsx(
2192
- k,
2193
- {
2194
- id: a.name,
2195
- name: a.name,
2196
- value: a.state.value?.[l] || "",
2197
- onBlur: a.handleBlur,
2198
- onChange: ({ target: r }) => {
2199
- a.handleChange({
2200
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2201
- [l]: r.value
2202
- });
2203
- },
2204
- placeholder: o("editor.submitConfigForm.successMessagePlaceholder")
2205
- }
2206
- ),
2207
- /* @__PURE__ */ e.jsx(M, { children: o("editor.submitConfigForm.successMessageDesc") })
2208
- ] })
2209
- }
2210
- ),
2211
- /* @__PURE__ */ e.jsx(q, { value: l, onValueChange: i })
2212
- ] }),
2213
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2214
- /* @__PURE__ */ e.jsx(
2215
- d,
2216
- {
2217
- name: "errorMessage",
2218
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2219
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.errorMessage") }),
2220
- /* @__PURE__ */ e.jsx(
2221
- k,
2222
- {
2223
- id: a.name,
2224
- name: a.name,
2225
- value: a.state.value?.[l] || "",
2226
- onBlur: a.handleBlur,
2227
- onChange: ({ target: r }) => {
2228
- a.handleChange({
2229
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2230
- [l]: r.value
2231
- });
2232
- },
2233
- placeholder: o("editor.submitConfigForm.errorMessagePlaceholder")
2234
- }
2235
- ),
2236
- /* @__PURE__ */ e.jsx(M, { children: o("editor.submitConfigForm.errorMessageDesc") })
2237
- ] })
2238
- }
2239
- ),
2240
- /* @__PURE__ */ e.jsx(q, { value: l, onValueChange: i })
2241
- ] })
2242
- ] }),
2243
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2244
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: o("editor.submitConfigForm.behavior") }),
2245
- /* @__PURE__ */ e.jsx(
2246
- d,
2247
- {
2248
- name: "showLoading",
2249
- children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2250
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
2251
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: o("editor.submitConfigForm.showLoadingState") })
2252
- ] })
2253
- }
2254
- )
2255
- ] })
2256
- ] }) });
2257
- }, za = ({
2258
- options: t,
2259
- id: s,
2260
- value: l,
2261
- onValueChange: i,
2262
- placeholder: h = "Select...",
2263
- searchPlaceholder: o = "Search or create...",
2264
- createLabel: n = (u) => `Use: ${u}`,
2265
- clearLabel: f = "Clear selection",
2266
- emptyLabel: d = "No results found",
2267
- className: c,
2268
- allowClear: a = !0,
2269
- allowCreate: r = !0
2270
- }) => {
2271
- const [u, m] = z(!1), [p, x] = z(""), F = (D) => D ?? "", g = (D) => D.trim().toLowerCase(), w = F(l), C = l !== null && l !== "", I = C ? t.find((D) => F(D.value) === w) : void 0, b = g(p), E = r && b !== "" && !t.some((D) => g(D.label) === b || g(D.value ?? "") === b), A = (D) => {
2272
- D === w ? a && i?.("") : i?.(D), m(!1), x("");
2273
- }, V = () => {
2274
- p.trim() && (i?.(p.trim()), m(!1), x(""));
2275
- }, T = () => {
2276
- i?.(""), m(!1), x("");
2277
- };
2278
- return /* @__PURE__ */ e.jsxs(Me, { open: u, onOpenChange: m, children: [
2279
- /* @__PURE__ */ e.jsx(Le, { asChild: !0, id: s, children: /* @__PURE__ */ e.jsxs(
2280
- S,
2281
- {
2282
- type: "button",
2283
- variant: "outline",
2284
- role: "combobox",
2285
- "aria-expanded": u,
2286
- className: P("w-full justify-between font-normal", c),
2287
- children: [
2288
- /* @__PURE__ */ e.jsx("span", { className: "truncate", children: C && I ? I.label : h }),
2289
- /* @__PURE__ */ e.jsx(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
2290
- ]
2291
- }
2292
- ) }),
2293
- /* @__PURE__ */ e.jsx(Be, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ e.jsxs(Gt, { shouldFilter: !1, children: [
2294
- /* @__PURE__ */ e.jsx($t, { placeholder: o, value: p, onValueChange: x }),
2295
- /* @__PURE__ */ e.jsxs(zt, { children: [
2296
- /* @__PURE__ */ e.jsx(Ht, { children: d }),
2297
- a && C && /* @__PURE__ */ e.jsx(Re, { children: /* @__PURE__ */ e.jsxs(Ve, { value: "__clear__", onSelect: T, className: "mt-1 text-muted-foreground", children: [
2298
- /* @__PURE__ */ e.jsx(se, { className: "mr-2 h-4 w-4" }),
2299
- f
2300
- ] }) }),
2301
- /* @__PURE__ */ e.jsxs(Re, { children: [
2302
- E && /* @__PURE__ */ e.jsxs(Ve, { value: `__create__${p}`, onSelect: V, className: "text-primary", children: [
2303
- /* @__PURE__ */ e.jsx(X, { className: "mr-2 h-4 w-4" }),
2304
- n(p)
2305
- ] }),
2306
- t.filter((D) => {
2307
- const v = p.toLowerCase();
2308
- return D.label.toLowerCase().includes(v) || (D.value?.toLowerCase() ?? "").includes(v);
2309
- }).map((D, v) => /* @__PURE__ */ e.jsxs(
2310
- Ve,
2311
- {
2312
- value: D.label,
2313
- onSelect: () => A(D?.value || ""),
2314
- children: [
2315
- /* @__PURE__ */ e.jsx(
2316
- At,
2317
- {
2318
- "aria-hidden": "true",
2319
- className: P(
2320
- "mr-2 h-4 w-4",
2321
- C && F(D.value) === w ? "opacity-100" : "opacity-0"
2322
- )
2323
- }
2324
- ),
2325
- D.label
2326
- ]
2327
- },
2328
- D.value ?? D.label ?? v
2329
- ))
2330
- ] })
2331
- ] })
2332
- ] }) })
2333
- ] });
2334
- }, Ha = {
2335
- alphanumeric: "^[a-zA-Z0-9]+$",
2336
- email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
2337
- letters: "^[a-zA-Z]+$",
2338
- number: "^[0-9]+$",
2339
- url: "^https?:\\/\\/.+$"
2340
- }, Ie = Object.entries(Ha).map(([t, s]) => ({
2341
- label: t.charAt(0).toUpperCase() + t.slice(1).replace(/_/g, " "),
2342
- value: s
2343
- })), Ua = ({ id: t, value: s, onValueChange: l }) => {
2344
- const i = le(() => s && !Ie.some((h) => h.value === s) ? [
2345
- ...Ie,
2346
- {
2347
- label: `Custom: ${s}`,
2348
- value: s
2349
- }
2350
- ] : Ie, [s]);
2351
- return /* @__PURE__ */ e.jsx(
2352
- za,
2353
- {
2354
- id: t,
2355
- options: i,
2356
- value: s,
2357
- onValueChange: l,
2358
- placeholder: "Select or create a pattern",
2359
- searchPlaceholder: "Search patterns...",
2360
- createLabel: (h) => `Use pattern: ${h}`
2361
- }
2362
- );
2363
- }, _a = {
2364
- address: "address",
2365
- autocomplete: "autocomplete",
2366
- checkbox: "checkbox",
2367
- date: "date",
2368
- daterange: "daterange",
2369
- file: "file",
2370
- hidden: "hidden",
2371
- http: "http",
2372
- number: "number",
2373
- password: "password",
2374
- radio: "radio",
2375
- select: "select",
2376
- submit: "submit",
2377
- switch: "switch",
2378
- text: "text",
2379
- textarea: "textarea",
2380
- time: "time",
2381
- timerange: "timerange"
2382
- }, Ra = ({ value: t, onValueChange: s }) => {
2383
- const l = B(), i = Fe();
2384
- return /* @__PURE__ */ e.jsxs(te, { children: [
2385
- /* @__PURE__ */ e.jsx($e, { htmlFor: i, children: l("editor.selectInputType.type") }),
2386
- /* @__PURE__ */ e.jsxs(_, { value: t, onValueChange: s, children: [
2387
- /* @__PURE__ */ e.jsx(R, { id: i, className: "w-full capitalize", children: /* @__PURE__ */ e.jsx(Z, { placeholder: "" }) }),
2388
- /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsx(te, { children: Object.values(_a).map((h) => /* @__PURE__ */ e.jsx(y, { value: h, className: "capitalize", children: h }, h)) }) })
2389
- ] })
2390
- ] });
2391
- };
2392
- function pe({ ...t }) {
2393
- return /* @__PURE__ */ e.jsx(ze.Root, { "data-slot": "collapsible", ...t });
2394
- }
2395
- function xe({ ...t }) {
2396
- return /* @__PURE__ */ e.jsx(ze.CollapsibleTrigger, { "data-slot": "collapsible-trigger", ...t });
2397
- }
2398
- function ge({ ...t }) {
2399
- return /* @__PURE__ */ e.jsx(ze.CollapsibleContent, { "data-slot": "collapsible-content", ...t });
2400
- }
2401
- const Za = () => {
2402
- const [t, s] = z("en"), { selectedNode: l } = ee(), { updateSelectedNodeData: i } = me(), h = ["select", "radio", "autocomplete", "checkbox"].includes(l?.data?.type || ""), o = Ee(l?.id), n = B(), f = l?.data?.type === "submit", { handleSubmit: d, Field: c } = ne({
2403
- defaultValues: {
2404
- defaultValue: l?.data?.defaultValue,
2405
- disablePast: l?.data?.disablePast,
2406
- errorMessage: l?.data?.errorMessage || { en: "" },
2407
- helperText: l?.data?.helperText || { en: "" },
2408
- httpConfig: l?.data?.httpConfig,
2409
- label: l?.data?.label || { en: "" },
2410
- multiple: l?.data?.multiple,
2411
- name: l?.data?.name || "",
2412
- options: l?.data?.options || [],
2413
- pattern: l?.data?.pattern || "",
2414
- placeholder: l?.data?.placeholder || { en: "" },
2415
- required: l?.data?.required,
2416
- submitConfig: l?.data?.submitConfig,
2417
- type: l?.data?.type || ""
2418
- },
2419
- listeners: {
2420
- onChange: ({ formApi: a }) => {
2421
- a.handleSubmit().then();
2422
- },
2423
- onChangeDebounceMs: 150
2424
- },
2425
- onSubmit: ({ value: a }) => {
2426
- i(a);
2427
- }
2428
- });
2429
- return /* @__PURE__ */ e.jsx(
2430
- "form",
2431
- {
2432
- onSubmit: (a) => {
2433
- a.preventDefault(), a.stopPropagation();
2434
- },
2435
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
2436
- /* @__PURE__ */ e.jsx(
2437
- c,
2438
- {
2439
- name: "type",
2440
- children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsx(Ra, { value: a.state.value, onValueChange: (r) => a.handleChange(r) }) })
2441
- }
2442
- ),
2443
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2444
- /* @__PURE__ */ e.jsx(
2445
- c,
2446
- {
2447
- name: "label",
2448
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2449
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.label") }),
2450
- /* @__PURE__ */ e.jsx(
2451
- k,
2452
- {
2453
- autoFocus: !0,
2454
- id: a.name,
2455
- name: a.name,
2456
- value: a.state.value?.[t] || "",
2457
- onBlur: a.handleBlur,
2458
- onChange: ({ target: r }) => {
2459
- a.handleChange({
2460
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2461
- [t]: r.value
2462
- });
2463
- }
2464
- }
2465
- )
2466
- ] })
2467
- }
2468
- ),
2469
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
2470
- ] }),
2471
- !f && l?.data?.type !== "file" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2472
- /* @__PURE__ */ e.jsx(
2473
- c,
2474
- {
2475
- name: "placeholder",
2476
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2477
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.placeholder") }),
2478
- /* @__PURE__ */ e.jsx(
2479
- k,
2480
- {
2481
- id: a.name,
2482
- name: a.name,
2483
- value: a.state.value?.[t] || "",
2484
- onBlur: a.handleBlur,
2485
- onChange: ({ target: r }) => {
2486
- a.handleChange({
2487
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2488
- [t]: r.value
2489
- });
2490
- }
2491
- }
2492
- )
2493
- ] })
2494
- }
2495
- ),
2496
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
2497
- ] }),
2498
- !f && /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2499
- /* @__PURE__ */ e.jsx(
2500
- c,
2501
- {
2502
- name: "helperText",
2503
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2504
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.helperText") }),
2505
- /* @__PURE__ */ e.jsx(
2506
- k,
2507
- {
2508
- id: a.name,
2509
- name: a.name,
2510
- value: a.state.value?.[t] || "",
2511
- onBlur: a.handleBlur,
2512
- onChange: ({ target: r }) => {
2513
- a.handleChange({
2514
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2515
- [t]: r.value
2516
- });
2517
- }
2518
- }
2519
- )
2520
- ] })
2521
- }
2522
- ),
2523
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
2524
- ] }),
2525
- l?.data?.type === "http" && /* @__PURE__ */ e.jsxs(pe, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
2526
- /* @__PURE__ */ e.jsx(xe, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
2527
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n("editor.inputNodeForm.httpConfiguration") }),
2528
- /* @__PURE__ */ e.jsxs(S, { variant: "ghost", size: "icon", className: "size-8", children: [
2529
- /* @__PURE__ */ e.jsx(re, {}),
2530
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: n("common.toggle") })
2531
- ] })
2532
- ] }) }),
2533
- /* @__PURE__ */ e.jsx(ge, { className: "flex flex-col gap-4", children: /* @__PURE__ */ e.jsx(c, { name: "httpConfig", children: (a) => /* @__PURE__ */ e.jsx(
2534
- Ba,
2535
- {
2536
- value: a.state.value,
2537
- onChange: (r) => {
2538
- a.handleChange(r), d().then();
2539
- }
2540
- }
2541
- ) }) })
2542
- ] }),
2543
- f && /* @__PURE__ */ e.jsxs(pe, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
2544
- /* @__PURE__ */ e.jsx(xe, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
2545
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n("editor.inputNodeForm.submitConfiguration") }),
2546
- /* @__PURE__ */ e.jsxs(S, { variant: "ghost", size: "icon", className: "size-8", children: [
2547
- /* @__PURE__ */ e.jsx(re, {}),
2548
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: n("common.toggle") })
2549
- ] })
2550
- ] }) }),
2551
- /* @__PURE__ */ e.jsx(ge, { className: "flex flex-col gap-4", children: /* @__PURE__ */ e.jsx(c, { name: "submitConfig", children: (a) => /* @__PURE__ */ e.jsx(
2552
- $a,
2553
- {
2554
- value: a.state.value,
2555
- onChange: (r) => {
2556
- a.handleChange(r), d().then();
2557
- }
2558
- }
2559
- ) }) })
2560
- ] }),
2561
- l?.data?.type === "file" && /* @__PURE__ */ e.jsx(
2562
- c,
2563
- {
2564
- name: "multiple",
2565
- children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2566
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
2567
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.multipleFiles") })
2568
- ] })
2569
- }
2570
- ),
2571
- h && /* @__PURE__ */ e.jsxs(pe, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
2572
- /* @__PURE__ */ e.jsx(xe, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
2573
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n("editor.inputNodeForm.options") }),
2574
- /* @__PURE__ */ e.jsxs(S, { variant: "ghost", size: "icon", className: "size-8", children: [
2575
- /* @__PURE__ */ e.jsx(re, {}),
2576
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: n("common.toggle") })
2577
- ] })
2578
- ] }) }),
2579
- /* @__PURE__ */ e.jsxs(ge, { className: "flex flex-col gap-4", children: [
2580
- /* @__PURE__ */ e.jsx(c, { name: "options", mode: "array", children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
2581
- a.state.value?.map((r, u) => {
2582
- const m = `options[${u}]`;
2583
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
2584
- /* @__PURE__ */ e.jsx(c, { name: `options[${u}].label`, children: (p) => /* @__PURE__ */ e.jsx(
2585
- k,
2586
- {
2587
- placeholder: n("editor.inputNodeForm.optionLabel"),
2588
- value: p.state.value?.[t] || "",
2589
- onChange: ({ target: x }) => {
2590
- p.handleChange({
2591
- ...typeof p.state.value == "object" && p.state.value !== null ? p.state.value : {},
2592
- [t]: x.value
2593
- });
2594
- }
2595
- }
2596
- ) }),
2597
- /* @__PURE__ */ e.jsx(c, { name: `options[${u}].value`, children: (p) => /* @__PURE__ */ e.jsx(
2598
- k,
2599
- {
2600
- placeholder: n("editor.inputNodeForm.optionValue"),
2601
- value: p.state.value || "",
2602
- onChange: ({ target: x }) => p.handleChange(x.value)
2603
- }
2604
- ) }),
2605
- /* @__PURE__ */ e.jsx(
2606
- S,
2607
- {
2608
- type: "button",
2609
- variant: "ghost",
2610
- size: "icon",
2611
- onClick: () => {
2612
- a.removeValue(u), d().then();
2613
- },
2614
- children: /* @__PURE__ */ e.jsx(se, { className: "h-4 w-4" })
2615
- }
2616
- )
2617
- ] }, m);
2618
- }),
2619
- /* @__PURE__ */ e.jsx(
2620
- S,
2621
- {
2622
- type: "button",
2623
- variant: "outline",
2624
- size: "sm",
2625
- onClick: () => {
2626
- a.pushValue({ label: { en: "" }, value: "" }), d().then();
2627
- },
2628
- children: n("editor.inputNodeForm.addOption")
2629
- }
2630
- )
2631
- ] }) }),
2632
- l?.data?.type === "select" && /* @__PURE__ */ e.jsx(
2633
- c,
2634
- {
2635
- name: "multiple",
2636
- children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2637
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
2638
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.multipleSelection") })
2639
- ] })
2640
- }
2641
- )
2642
- ] })
2643
- ] }),
2644
- !f && /* @__PURE__ */ e.jsxs(pe, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
2645
- /* @__PURE__ */ e.jsx(xe, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
2646
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n("editor.inputNodeForm.validation") }),
2647
- /* @__PURE__ */ e.jsxs(S, { variant: "ghost", size: "icon", className: "size-8", children: [
2648
- /* @__PURE__ */ e.jsx(re, {}),
2649
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: n("common.toggle") })
2650
- ] })
2651
- ] }) }),
2652
- /* @__PURE__ */ e.jsxs(ge, { className: "flex flex-col gap-6", children: [
2653
- /* @__PURE__ */ e.jsx(
2654
- c,
2655
- {
2656
- name: "required",
2657
- children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2658
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
2659
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.required") })
2660
- ] }) })
2661
- }
2662
- ),
2663
- (l?.data?.type === "date" || l?.data?.type === "daterange") && /* @__PURE__ */ e.jsx(
2664
- c,
2665
- {
2666
- name: "disablePast",
2667
- children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2668
- /* @__PURE__ */ e.jsx(J, { id: a.name, checked: a.state.value, onCheckedChange: (r) => a.handleChange(r) }),
2669
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.disablePast") })
2670
- ] }) })
2671
- }
2672
- ),
2673
- /* @__PURE__ */ e.jsx(
2674
- c,
2675
- {
2676
- name: "pattern",
2677
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
2678
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.pattern") }),
2679
- /* @__PURE__ */ e.jsx(Ua, { id: a.name, value: a.state.value, onValueChange: a.handleChange })
2680
- ] })
2681
- }
2682
- ),
2683
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2684
- /* @__PURE__ */ e.jsx(
2685
- c,
2686
- {
2687
- name: "errorMessage",
2688
- children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2689
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.errorMessage") }),
2690
- /* @__PURE__ */ e.jsx(
2691
- k,
2692
- {
2693
- id: a.name,
2694
- name: a.name,
2695
- value: a.state.value?.[t] || "",
2696
- onBlur: a.handleBlur,
2697
- onChange: ({ target: r }) => {
2698
- a.handleChange({
2699
- ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
2700
- [t]: r.value
2701
- });
2702
- }
2703
- }
2704
- )
2705
- ] })
2706
- }
2707
- ),
2708
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
2709
- ] })
2710
- ] })
2711
- ] }),
2712
- !f && /* @__PURE__ */ e.jsxs(pe, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
2713
- /* @__PURE__ */ e.jsx(xe, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
2714
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n("editor.inputNodeForm.advancedConfiguration") }),
2715
- /* @__PURE__ */ e.jsxs(S, { variant: "ghost", size: "icon", className: "size-8", children: [
2716
- /* @__PURE__ */ e.jsx(re, {}),
2717
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: n("common.toggle") })
2718
- ] })
2719
- ] }) }),
2720
- /* @__PURE__ */ e.jsxs(ge, { className: "flex flex-col gap-6", children: [
2721
- /* @__PURE__ */ e.jsx(
2722
- c,
2723
- {
2724
- name: "name",
2725
- children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
2726
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.name") }),
2727
- /* @__PURE__ */ e.jsx(
2728
- k,
2729
- {
2730
- id: a.name,
2731
- name: a.name,
2732
- value: a.state.value,
2733
- onBlur: a.handleBlur,
2734
- onChange: ({ target: r }) => a.handleChange(r.value)
2735
- }
2736
- ),
2737
- /* @__PURE__ */ e.jsx(M, { children: n("editor.inputNodeForm.nameDescription") })
2738
- ] })
2739
- }
2740
- ),
2741
- /* @__PURE__ */ e.jsx(c, { name: "defaultValue", children: (a) => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2742
- /* @__PURE__ */ e.jsxs(N, { children: [
2743
- /* @__PURE__ */ e.jsx(j, { htmlFor: a.name, children: n("editor.inputNodeForm.defaultValueType") }),
2744
- /* @__PURE__ */ e.jsxs(
2745
- _,
2746
- {
2747
- value: a.state.value?.type || "none",
2748
- onValueChange: (r) => {
2749
- a.handleChange(r === "none" ? null : { type: r });
2750
- },
2751
- children: [
2752
- /* @__PURE__ */ e.jsx(R, { id: a.name, children: /* @__PURE__ */ e.jsx(Z, { placeholder: n("editor.inputNodeForm.selectType") }) }),
2753
- /* @__PURE__ */ e.jsxs(K, { children: [
2754
- /* @__PURE__ */ e.jsx(y, { value: "none", children: n("editor.inputNodeForm.defaultValueTypeNone") }),
2755
- /* @__PURE__ */ e.jsx(y, { value: "static", children: n("editor.inputNodeForm.defaultValueTypeStatic") }),
2756
- /* @__PURE__ */ e.jsx(y, { value: "reference", children: n("editor.inputNodeForm.defaultValueTypeReference") })
2757
- ] })
2758
- ]
2759
- }
2760
- )
2761
- ] }),
2762
- a.state.value?.type === "static" && /* @__PURE__ */ e.jsx(c, { name: "defaultValue.staticValue", children: (r) => {
2763
- const u = l?.data?.type;
2764
- return (u === "select" || u === "checkbox") && l?.data?.multiple ? /* @__PURE__ */ e.jsxs(N, { children: [
2765
- /* @__PURE__ */ e.jsx(j, { htmlFor: r.name, children: n("editor.inputNodeForm.defaultValuesCommaSeparated") }),
2766
- /* @__PURE__ */ e.jsx(
2767
- k,
2768
- {
2769
- id: r.name,
2770
- placeholder: n("editor.inputNodeForm.defaultValuesPlaceholder"),
2771
- value: Array.isArray(r.state.value) ? r.state.value.join(", ") : "",
2772
- onChange: ({ target: m }) => {
2773
- const p = m.value.split(",").map((x) => x.trim()).filter(Boolean);
2774
- r.handleChange(p.length > 0 ? p : null);
2775
- }
2776
- }
2777
- )
2778
- ] }) : u === "checkbox" ? /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2779
- /* @__PURE__ */ e.jsx(
2780
- J,
2781
- {
2782
- id: r.name,
2783
- checked: !!r.state.value,
2784
- onCheckedChange: (m) => r.handleChange(m)
2785
- }
2786
- ),
2787
- /* @__PURE__ */ e.jsx(j, { htmlFor: r.name, children: n("editor.inputNodeForm.defaultChecked") })
2788
- ] }) }) : /* @__PURE__ */ e.jsxs(N, { children: [
2789
- /* @__PURE__ */ e.jsx(j, { htmlFor: r.name, children: n("editor.inputNodeForm.staticValue") }),
2790
- /* @__PURE__ */ e.jsx(
2791
- k,
2792
- {
2793
- id: r.name,
2794
- placeholder: n("editor.inputNodeForm.staticValuePlaceholder"),
2795
- value: typeof r.state.value == "string" ? r.state.value : "",
2796
- onChange: ({ target: m }) => r.handleChange(m.value || "")
2797
- }
2798
- )
2799
- ] });
2800
- } }),
2801
- a.state.value?.type === "reference" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2802
- /* @__PURE__ */ e.jsx(c, { name: "defaultValue.referenceField", children: (r) => /* @__PURE__ */ e.jsxs(N, { children: [
2803
- /* @__PURE__ */ e.jsx(j, { htmlFor: r.name, children: n("editor.inputNodeForm.referenceField") }),
2804
- /* @__PURE__ */ e.jsxs(
2805
- _,
2806
- {
2807
- value: r.state.value || "",
2808
- onValueChange: (u) => {
2809
- r.handleChange(u);
2810
- },
2811
- children: [
2812
- /* @__PURE__ */ e.jsx(R, { id: r.name, children: /* @__PURE__ */ e.jsx(Z, { placeholder: n("editor.inputNodeForm.selectReferenceField") }) }),
2813
- /* @__PURE__ */ e.jsx(K, { children: o.length === 0 ? /* @__PURE__ */ e.jsx(y, { value: "none", disabled: !0, children: n("editor.inputNodeForm.noParentFieldsAvailable") }) : o.map((u) => /* @__PURE__ */ e.jsxs(y, { value: u.nodeId, children: [
2814
- u.label,
2815
- " (",
2816
- u.type,
2817
- ")"
2818
- ] }, u.nodeId)) })
2819
- ]
2820
- }
2821
- ),
2822
- o.length === 0 && /* @__PURE__ */ e.jsx(M, { children: n("editor.inputNodeForm.addInputFieldsBeforeReference") })
2823
- ] }) }),
2824
- /* @__PURE__ */ e.jsx(c, { name: "defaultValue.transformFunction", children: (r) => /* @__PURE__ */ e.jsxs(N, { children: [
2825
- /* @__PURE__ */ e.jsx(j, { htmlFor: r.name, children: n("editor.inputNodeForm.transformType") }),
2826
- /* @__PURE__ */ e.jsxs(
2827
- _,
2828
- {
2829
- value: r.state.value || "none",
2830
- onValueChange: (u) => {
2831
- const m = u === "none" ? null : u;
2832
- if (r.handleChange(m), u === "toObject") {
2833
- const p = a.state.value;
2834
- a.handleChange({
2835
- ...p,
2836
- objectMapping: []
2837
- });
2838
- }
2839
- },
2840
- children: [
2841
- /* @__PURE__ */ e.jsx(R, { id: r.name, children: /* @__PURE__ */ e.jsx(Z, { placeholder: n("editor.inputNodeForm.selectTransformation") }) }),
2842
- /* @__PURE__ */ e.jsxs(K, { children: [
2843
- /* @__PURE__ */ e.jsx(y, { value: "none", children: n("editor.inputNodeForm.transformNone") }),
2844
- /* @__PURE__ */ e.jsx(y, { value: "toString", children: n("editor.inputNodeForm.transformString") }),
2845
- /* @__PURE__ */ e.jsx(y, { value: "toNumber", children: n("editor.inputNodeForm.transformNumber") }),
2846
- /* @__PURE__ */ e.jsx(y, { value: "toBoolean", children: n("editor.inputNodeForm.transformBoolean") }),
2847
- /* @__PURE__ */ e.jsx(y, { value: "toArray", children: n("editor.inputNodeForm.transformArray") }),
2848
- /* @__PURE__ */ e.jsx(y, { value: "toObject", children: n("editor.inputNodeForm.transformMapToObject") })
2849
- ] })
2850
- ]
2851
- }
2852
- ),
2853
- /* @__PURE__ */ e.jsx(M, { children: n("editor.inputNodeForm.transformDesc") })
2854
- ] }) }),
2855
- a.state.value?.transformFunction === "toObject" && /* @__PURE__ */ e.jsx(c, { name: "defaultValue.objectMapping", mode: "array", children: (r) => /* @__PURE__ */ e.jsxs(N, { children: [
2856
- /* @__PURE__ */ e.jsx(j, { children: n("editor.inputNodeForm.objectMapping") }),
2857
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
2858
- r.state.value?.map((u, m) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2859
- /* @__PURE__ */ e.jsx(c, { name: `defaultValue.objectMapping[${m}].sourceKey`, children: (p) => /* @__PURE__ */ e.jsx(
2860
- k,
2861
- {
2862
- placeholder: n("editor.inputNodeForm.sourceKey"),
2863
- value: p.state.value || "",
2864
- onChange: ({ target: x }) => p.handleChange(x.value)
2865
- }
2866
- ) }),
2867
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: "→" }),
2868
- /* @__PURE__ */ e.jsx(c, { name: `defaultValue.objectMapping[${m}].targetKey`, children: (p) => /* @__PURE__ */ e.jsx(
2869
- k,
2870
- {
2871
- placeholder: n("editor.inputNodeForm.targetKey"),
2872
- value: p.state.value || "",
2873
- onChange: ({ target: x }) => p.handleChange(x.value)
2874
- }
2875
- ) }),
2876
- /* @__PURE__ */ e.jsx(
2877
- S,
2878
- {
2879
- type: "button",
2880
- variant: "ghost",
2881
- size: "icon",
2882
- onClick: () => {
2883
- r.removeValue(m), d().then();
2884
- },
2885
- children: /* @__PURE__ */ e.jsx(se, { className: "h-4 w-4" })
2886
- }
2887
- )
2888
- ] }, `mapping-${m}`)),
2889
- /* @__PURE__ */ e.jsxs(
2890
- S,
2891
- {
2892
- type: "button",
2893
- variant: "outline",
2894
- size: "sm",
2895
- className: "w-full",
2896
- onClick: () => {
2897
- r.pushValue({ sourceKey: "", targetKey: "" }), d().then();
2898
- },
2899
- children: [
2900
- /* @__PURE__ */ e.jsx(X, { className: "mr-2 h-4 w-4" }),
2901
- n("editor.inputNodeForm.addMapping")
2902
- ]
2903
- }
2904
- )
2905
- ] }),
2906
- /* @__PURE__ */ e.jsx(M, { children: n("editor.inputNodeForm.objectMappingDesc") })
2907
- ] }) })
2908
- ] })
2909
- ] }) })
2910
- ] })
2911
- ] })
2912
- ] })
2913
- }
2914
- );
2915
- }, Ye = {
2916
- divider: "divider",
2917
- title: "title"
2918
- }, Ka = () => {
2919
- const [t, s] = z("en"), { selectedNode: l } = ee(), { updateSelectedNodeData: i } = me(), { Field: h } = ne({
2920
- defaultValues: {
2921
- label: l?.data?.label || { en: "" },
2922
- type: l?.data?.type || ""
2923
- },
2924
- listeners: {
2925
- onChange: ({ formApi: o }) => {
2926
- o.handleSubmit().then();
2927
- },
2928
- onChangeDebounceMs: 150
2929
- },
2930
- onSubmit: ({ value: o }) => {
2931
- i(o);
2932
- }
2933
- });
2934
- return /* @__PURE__ */ e.jsx(
2935
- "form",
2936
- {
2937
- onSubmit: (o) => {
2938
- o.preventDefault(), o.stopPropagation();
2939
- },
2940
- children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
2941
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2942
- /* @__PURE__ */ e.jsx(
2943
- h,
2944
- {
2945
- name: "label",
2946
- children: (o) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
2947
- /* @__PURE__ */ e.jsx(j, { htmlFor: o.name, children: "Label" }),
2948
- /* @__PURE__ */ e.jsx(
2949
- k,
2950
- {
2951
- id: o.name,
2952
- name: o.name,
2953
- value: o.state.value?.[t] || "",
2954
- onBlur: o.handleBlur,
2955
- onChange: ({ target: n }) => {
2956
- o.handleChange({
2957
- ...o.state.value,
2958
- [t]: n.value
2959
- });
2960
- }
2961
- }
2962
- )
2963
- ] })
2964
- }
2965
- ),
2966
- /* @__PURE__ */ e.jsx(q, { value: t, onValueChange: s })
2967
- ] }),
2968
- /* @__PURE__ */ e.jsx(
2969
- h,
2970
- {
2971
- name: "type",
2972
- children: (o) => /* @__PURE__ */ e.jsxs(te, { children: [
2973
- /* @__PURE__ */ e.jsx($e, { htmlFor: o.name, children: "Type" }),
2974
- /* @__PURE__ */ e.jsxs(_, { value: o.state.value, onValueChange: (n) => o.handleChange(n), children: [
2975
- /* @__PURE__ */ e.jsx(R, { id: o.name, className: "w-full", children: /* @__PURE__ */ e.jsx(Z, { placeholder: "" }) }),
2976
- /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsxs(te, { children: [
2977
- /* @__PURE__ */ e.jsx(y, { value: Ye.title, children: "Title" }),
2978
- /* @__PURE__ */ e.jsx(y, { value: Ye.divider, children: "Divider" })
2979
- ] }) })
2980
- ] })
2981
- ] })
2982
- }
2983
- )
2984
- ] })
2985
- }
2986
- );
2987
- }, Ya = () => {
2988
- const [t, s] = z(""), [l, i] = z(!1), { selectedNode: h, groupNodes: o } = ee(), { setNodes: n } = ue(), f = h?.parentId || "none", d = Se(h), c = B(), a = Fe(), r = Fe();
2989
- if (d)
2990
- return null;
2991
- const u = (p) => {
2992
- h && n((x) => p === "none" ? x.map((g) => {
2993
- if (g.id === h.id) {
2994
- const { parentId: w, extent: C, ...I } = g;
2995
- return I;
2996
- }
2997
- return g;
2998
- }) : x.find((g) => g.id === p) ? x.map((g) => g.id === h.id ? {
2999
- ...g,
3000
- extent: "parent",
3001
- parentId: p,
3002
- position: {
3003
- x: 50,
3004
- y: 80
3005
- }
3006
- } : g) : x);
3007
- }, m = () => {
3008
- if (!(t.trim() && h))
3009
- return;
3010
- if (o.find((F) => {
3011
- const g = F.data?.label?.en || F.data?.label;
3012
- return String(g).toLowerCase() === t.trim().toLowerCase();
3013
- })) {
3014
- U.error("This group already exists", {
3015
- description: "Use the selector to add the node to an existing group."
3016
- });
3017
- return;
3018
- }
3019
- const x = ce();
3020
- n((F) => {
3021
- const g = {
3022
- data: {
3023
- label: {
3024
- en: t.trim()
3025
- }
3026
- },
3027
- id: x,
3028
- position: {
3029
- x: h.position.x - 300,
3030
- y: h.position.y
3031
- },
3032
- style: {
3033
- height: 400,
3034
- width: 600
3035
- },
3036
- type: "group"
3037
- }, w = F.map((C) => C.id === h.id ? {
3038
- ...C,
3039
- extent: "parent",
3040
- parentId: x,
3041
- position: {
3042
- x: 175,
3043
- y: 30
3044
- }
3045
- } : C);
3046
- return [g, ...w];
3047
- }), s(""), i(!1), U.success("Group created", {
3048
- description: `The group "${t.trim()}" has been created successfully.`
3049
- });
3050
- };
3051
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3052
- /* @__PURE__ */ e.jsx(j, { htmlFor: a, children: c("editor.selectNodeGroup.group") }),
3053
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
3054
- /* @__PURE__ */ e.jsxs(_, { value: f, onValueChange: u, children: [
3055
- /* @__PURE__ */ e.jsx(R, { id: a, className: "flex-1", children: /* @__PURE__ */ e.jsx(Z, { placeholder: c("editor.selectNodeGroup.noGroup") }) }),
3056
- /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsxs(te, { children: [
3057
- /* @__PURE__ */ e.jsx(y, { value: "none", children: c("editor.selectNodeGroup.noGroup") }),
3058
- o.map((p) => /* @__PURE__ */ e.jsx(y, { value: p.id, children: p.data.label?.en ? String(p.data.label?.en) : p.id }, p.id))
3059
- ] }) })
3060
- ] }),
3061
- /* @__PURE__ */ e.jsxs(Me, { open: l, onOpenChange: i, children: [
3062
- /* @__PURE__ */ e.jsx(Le, { asChild: !0, children: /* @__PURE__ */ e.jsx(S, { variant: "outline", size: "icon", title: "Create a new group", children: /* @__PURE__ */ e.jsx(Vt, { className: "h-4 w-4" }) }) }),
3063
- /* @__PURE__ */ e.jsx(Be, { className: "w-80", align: "end", disablePortal: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
3064
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3065
- /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: c("editor.selectNodeGroup.newGroup") }),
3066
- /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: c("editor.selectNodeGroup.newGroupDescription") })
3067
- ] }),
3068
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3069
- /* @__PURE__ */ e.jsx(j, { htmlFor: r, children: c("editor.selectNodeGroup.groupName") }),
3070
- /* @__PURE__ */ e.jsx(
3071
- k,
3072
- {
3073
- autoFocus: !0,
3074
- id: r,
3075
- value: t,
3076
- onChange: (p) => s(p.target.value),
3077
- placeholder: "Ex: Step 1 - Personal info",
3078
- onKeyDown: (p) => {
3079
- p.key === "Enter" && (p.preventDefault(), m());
3080
- }
3081
- }
3082
- )
3083
- ] }),
3084
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2", children: [
3085
- /* @__PURE__ */ e.jsx(S, { variant: "outline", size: "sm", onClick: () => i(!1), children: "Cancel" }),
3086
- /* @__PURE__ */ e.jsx(S, { size: "sm", onClick: m, disabled: !t.trim(), children: "Create" })
3087
- ] })
3088
- ] }) })
3089
- ] })
3090
- ] })
3091
- ] });
3092
- }, Wa = () => {
3093
- const { selectedNode: t } = ee(), { updateSelectedNodeType: s } = me(), l = t?.type || "", i = Se(t), h = B(), o = Fe();
3094
- return /* @__PURE__ */ e.jsxs(te, { children: [
3095
- /* @__PURE__ */ e.jsx($e, { htmlFor: o, children: h("editor.selectNodeType.nodeType") }),
3096
- /* @__PURE__ */ e.jsxs(_, { value: l, onValueChange: (n) => s(n), disabled: i, children: [
3097
- /* @__PURE__ */ e.jsx(R, { className: "w-full", id: o, children: /* @__PURE__ */ e.jsx(Z, { placeholder: h("editor.selectNodeType.nodeType") }) }),
3098
- /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsx(te, { children: Object.keys(it).filter((n) => i ? n === "group" : n !== "group").map((n) => /* @__PURE__ */ e.jsx(y, { value: n, children: h(`editor.selectNodeType.options.${n}`) }, n)) }) })
3099
- ] })
3100
- ] });
3101
- };
3102
- function Ja({ ...t }) {
3103
- return /* @__PURE__ */ e.jsx(Q.Root, { "data-slot": "alert-dialog", ...t });
3104
- }
3105
- function qa({ ...t }) {
3106
- return /* @__PURE__ */ e.jsx(Q.Trigger, { "data-slot": "alert-dialog-trigger", ...t });
3107
- }
3108
- function Xa({ ...t }) {
3109
- return /* @__PURE__ */ e.jsx(Q.Portal, { "data-slot": "alert-dialog-portal", ...t });
3110
- }
3111
- function Qa({ className: t, ...s }) {
3112
- return /* @__PURE__ */ e.jsx(
3113
- Q.Overlay,
3114
- {
3115
- "data-slot": "alert-dialog-overlay",
3116
- className: P(
3117
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",
3118
- t
3119
- ),
3120
- ...s
3121
- }
3122
- );
3123
- }
3124
- function es({ className: t, ...s }) {
3125
- return /* @__PURE__ */ e.jsxs(Xa, { children: [
3126
- /* @__PURE__ */ e.jsx(Qa, {}),
3127
- /* @__PURE__ */ e.jsx(
3128
- Q.Content,
3129
- {
3130
- "data-slot": "alert-dialog-content",
3131
- className: P(
3132
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",
3133
- t
3134
- ),
3135
- ...s
3136
- }
3137
- )
3138
- ] });
3139
- }
3140
- function ts({ className: t, ...s }) {
3141
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "alert-dialog-header", className: P("flex flex-col gap-2 text-center sm:text-left", t), ...s });
3142
- }
3143
- function as({ className: t, ...s }) {
3144
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "alert-dialog-footer", className: P("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", t), ...s });
3145
- }
3146
- function ss({ className: t, ...s }) {
3147
- return /* @__PURE__ */ e.jsx(Q.Title, { "data-slot": "alert-dialog-title", className: P("font-semibold text-lg", t), ...s });
3148
- }
3149
- function ns({ className: t, ...s }) {
3150
- return /* @__PURE__ */ e.jsx(
3151
- Q.Description,
3152
- {
3153
- "data-slot": "alert-dialog-description",
3154
- className: P("text-muted-foreground text-sm", t),
3155
- ...s
3156
- }
3157
- );
3158
- }
3159
- function os({ className: t, ...s }) {
3160
- return /* @__PURE__ */ e.jsx(Q.Action, { className: P(at(), t), ...s });
3161
- }
3162
- function rs({ className: t, ...s }) {
3163
- return /* @__PURE__ */ e.jsx(Q.Cancel, { className: P(at({ variant: "outline" }), t), ...s });
3164
- }
3165
- function ls({ ...t }) {
3166
- return /* @__PURE__ */ e.jsx(L.Root, { "data-slot": "sheet", ...t });
3167
- }
3168
- function is({ ...t }) {
3169
- return /* @__PURE__ */ e.jsx(L.Portal, { "data-slot": "sheet-portal", ...t });
3170
- }
3171
- function ds({ className: t, ...s }) {
3172
- return /* @__PURE__ */ e.jsx(
3173
- L.Overlay,
3174
- {
3175
- "data-slot": "sheet-overlay",
3176
- className: P(
3177
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",
3178
- t
3179
- ),
3180
- ...s
3181
- }
3182
- );
3183
- }
3184
- function cs({
3185
- className: t,
3186
- children: s,
3187
- side: l = "right",
3188
- ...i
3189
- }) {
3190
- return /* @__PURE__ */ e.jsxs(is, { children: [
3191
- /* @__PURE__ */ e.jsx(ds, {}),
3192
- /* @__PURE__ */ e.jsxs(
3193
- L.Content,
3194
- {
3195
- "data-slot": "sheet-content",
3196
- className: P(
3197
- "fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500",
3198
- l === "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",
3199
- l === "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",
3200
- l === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
3201
- l === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
3202
- t
3203
- ),
3204
- ...i,
3205
- children: [
3206
- s,
3207
- /* @__PURE__ */ e.jsxs(L.Close, { className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary", children: [
3208
- /* @__PURE__ */ e.jsx(et, { className: "size-4" }),
3209
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Close" })
3210
- ] })
3211
- ]
3212
- }
3213
- )
3214
- ] });
3215
- }
3216
- function us({ className: t, ...s }) {
3217
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "sheet-header", className: P("flex flex-col gap-1.5 p-4", t), ...s });
3218
- }
3219
- function hs({ className: t, ...s }) {
3220
- return /* @__PURE__ */ e.jsx("div", { "data-slot": "sheet-footer", className: P("mt-auto flex flex-col gap-2 p-4", t), ...s });
3221
- }
3222
- function ms({ className: t, ...s }) {
3223
- return /* @__PURE__ */ e.jsx(L.Title, { "data-slot": "sheet-title", className: P("font-semibold text-foreground", t), ...s });
3224
- }
3225
- function ps({ className: t, ...s }) {
3226
- return /* @__PURE__ */ e.jsx(L.Description, { "data-slot": "sheet-description", className: P("text-muted-foreground text-sm", t), ...s });
3227
- }
3228
- const xs = () => {
3229
- const { selectedNode: t, hasSelectedNodes: s } = ee(), { clearSelection: l, deleteSelectedNode: i } = me(), h = B(), o = h(t?.data?.label), n = () => {
3230
- i(), l();
3231
- };
3232
- return /* @__PURE__ */ e.jsx(ls, { open: s, onOpenChange: l, children: /* @__PURE__ */ e.jsxs(cs, { className: "flex flex-col gap-0", children: [
3233
- /* @__PURE__ */ e.jsxs(us, { children: [
3234
- /* @__PURE__ */ e.jsxs(ms, { children: [
3235
- h("editor.nodeActionsSheet.editNode"),
3236
- " ",
3237
- /* @__PURE__ */ e.jsx("span", { className: "font-light text-muted-foreground text-xs", children: t?.id })
3238
- ] }),
3239
- /* @__PURE__ */ e.jsx(ps, { children: o || " " })
3240
- ] }),
3241
- /* @__PURE__ */ e.jsx(ot, { className: "flex min-h-0 flex-1 flex-col px-4", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 py-4", children: [
3242
- /* @__PURE__ */ e.jsx(Wa, {}),
3243
- /* @__PURE__ */ e.jsx(Ya, {}),
3244
- /* @__PURE__ */ e.jsx(Ut, {}),
3245
- je(t) && /* @__PURE__ */ e.jsx(Za, {}),
3246
- ct(t) && /* @__PURE__ */ e.jsx(Ka, {}),
3247
- ut(t) && /* @__PURE__ */ e.jsx(Oa, {}),
3248
- Se(t) && /* @__PURE__ */ e.jsx(Ma, {})
3249
- ] }) }),
3250
- /* @__PURE__ */ e.jsx(hs, { className: "flex items-end border-t", children: /* @__PURE__ */ e.jsxs(Ja, { children: [
3251
- /* @__PURE__ */ e.jsx(qa, { asChild: !0, children: /* @__PURE__ */ e.jsx(S, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(tt, {}) }) }),
3252
- /* @__PURE__ */ e.jsxs(es, { children: [
3253
- /* @__PURE__ */ e.jsxs(ts, { children: [
3254
- /* @__PURE__ */ e.jsx(ss, { children: h("editor.nodeActionsSheet.deleteNode") }),
3255
- /* @__PURE__ */ e.jsx(ns, { children: h("editor.nodeActionsSheet.deleteNodeConfirm") })
3256
- ] }),
3257
- /* @__PURE__ */ e.jsxs(as, { children: [
3258
- /* @__PURE__ */ e.jsx(rs, { children: h("common.cancel") }),
3259
- /* @__PURE__ */ e.jsx(os, { onClick: n, children: h("common.delete") })
3260
- ] })
3261
- ] })
3262
- ] }) })
3263
- ] }) });
3264
- }, gs = ({ ...t }) => {
3265
- const { theme: s = "system" } = Kt();
3266
- return /* @__PURE__ */ e.jsx(
3267
- Zt,
3268
- {
3269
- theme: s,
3270
- className: "toaster group",
3271
- style: {
3272
- "--normal-bg": "var(--treege-popover)",
3273
- "--normal-border": "var(--treege-border)",
3274
- "--normal-text": "var(--treege-popover-foreground)"
3275
- },
3276
- ...t
3277
- }
3278
- );
3279
- }, js = ({ flow: t, onExportJson: s, onSave: l, theme: i, className: h }) => {
3280
- const { onConnect: o, onConnectEnd: n, onEdgesDelete: f, isValidConnection: d } = lt();
3281
- return /* @__PURE__ */ e.jsxs(
3282
- jt,
3283
- {
3284
- fitView: !0,
3285
- colorMode: i,
3286
- selectNodesOnDrag: !1,
3287
- nodeTypes: it,
3288
- edgeTypes: sa,
3289
- defaultEdges: t?.edges || [],
3290
- defaultNodes: t?.nodes || [],
3291
- onConnect: o,
3292
- onConnectEnd: n,
3293
- onEdgesDelete: f,
3294
- isValidConnection: d,
3295
- className: P(h, "treege"),
3296
- children: [
3297
- /* @__PURE__ */ e.jsx(Ct, { gap: 10, variant: vt.Dots }),
3298
- /* @__PURE__ */ e.jsx(Va, { onExportJson: s, onSave: l }),
3299
- /* @__PURE__ */ e.jsx(Jt, { theme: i }),
3300
- /* @__PURE__ */ e.jsx(ft, {}),
3301
- /* @__PURE__ */ e.jsx(bt, {}),
3302
- /* @__PURE__ */ e.jsx(xs, {})
3303
- ]
3304
- }
3305
- );
3306
- }, ks = ({ flow: t, onExportJson: s, onSave: l, theme: i = "dark", language: h = "en", aiConfig: o }) => /* @__PURE__ */ e.jsx(ht, { defaultTheme: i, storageKey: "treege-editor-theme", theme: i, children: /* @__PURE__ */ e.jsxs(qt, { value: { aiConfig: o, flowId: t?.id, language: h }, children: [
3307
- /* @__PURE__ */ e.jsx(gs, { position: "bottom-center" }),
3308
- /* @__PURE__ */ e.jsx(gt, { children: /* @__PURE__ */ e.jsx(js, { onExportJson: s, onSave: l, flow: t, theme: i }) })
3309
- ] }) });
3310
- export {
3311
- ks as T
3312
- };