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