@adatechnology/conversations-ui 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +23 -0
  2. package/dist/{ConversationSimulatorPanel-P6eqTSAO.d.ts → ConversationSimulatorPanel-DSVIch04.d.ts} +3 -1
  3. package/dist/{chunk-Y326LLEP.js → chunk-7OLYCCLX.js} +1 -1
  4. package/dist/{chunk-WCZNIJ3M.js → chunk-Z7U22M3K.js} +7 -0
  5. package/dist/flows/index.d.ts +90 -7
  6. package/dist/flows/index.js +1151 -455
  7. package/dist/index.d.ts +36 -5
  8. package/dist/index.js +88 -23
  9. package/dist/participant/index.js +1 -1
  10. package/dist/preview/index.d.ts +13 -29
  11. package/dist/preview/index.js +2 -2
  12. package/package.json +2 -2
  13. package/src/flows/FlowKeywordRoutesField.tsx +105 -0
  14. package/src/flows/FlowLegend.tsx +2 -2
  15. package/src/flows/FlowNodeCard.tsx +39 -10
  16. package/src/flows/FlowNodePanel.tsx +34 -10
  17. package/src/flows/FlowPalette.tsx +25 -2
  18. package/src/flows/FlowPossibleNextField.tsx +89 -0
  19. package/src/flows/FlowRunnerFields.tsx +321 -0
  20. package/src/flows/FlowWhatsAppPreview.tsx +39 -6
  21. package/src/flows/flowCanvasModel.test.ts +3 -2
  22. package/src/flows/flowCanvasModel.ts +28 -1
  23. package/src/flows/flowEditorOps.ts +41 -4
  24. package/src/flows/flowGraph.ts +124 -21
  25. package/src/flows/flowPanelStyles.ts +11 -0
  26. package/src/flows/flowPossibleNext.test.ts +70 -0
  27. package/src/flows/flowRunnerEditor.test.ts +116 -0
  28. package/src/flows/labels.ts +116 -2
  29. package/src/index.ts +2 -1
  30. package/src/lib/phone.test.ts +20 -0
  31. package/src/lib/phone.ts +13 -0
  32. package/src/preview/createPreviewBridgeClient.test.ts +23 -0
  33. package/src/preview/createPreviewBridgeClient.ts +13 -8
  34. package/src/preview/createPreviewWebhookClient.ts +2 -0
  35. package/src/workspace/ConversationPane.tsx +13 -2
  36. package/src/workspace/ConversationsWorkspace.tsx +117 -18
  37. package/src/workspace/index.ts +1 -0
  38. package/src/workspace/labels.ts +2 -0
  39. package/src/workspace/workspaceTestContactDom.test.tsx +96 -0
@@ -24,14 +24,283 @@ import {
24
24
  Headset,
25
25
  Clock3,
26
26
  ShoppingBag,
27
- RotateCcw
27
+ RotateCcw,
28
+ ListChecks
28
29
  } from "lucide-react";
29
30
 
31
+ // src/flows/labels.ts
32
+ var OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS = {
33
+ minTime: "A partir de",
34
+ maxTime: "At\xE9",
35
+ timeWindowsContextKey: "Faixas permitidas guardadas em",
36
+ timeWindowsContextKeyHint: 'Chave do contexto com as faixas (ex.: ["11:00-14:00"]), preenchida pelo sistema antes da pergunta.',
37
+ possibleNext: "Destinos que a a\xE7\xE3o pode escolher",
38
+ possibleNextHint: "A a\xE7\xE3o decide o caminho na hora. Liste aqui os destinos poss\xEDveis para eles aparecerem no mapa.",
39
+ addPossibleNext: "Adicionar destino",
40
+ removePossibleNext: "Remover destino",
41
+ possibleNextRowLabel: "Pode seguir para"
42
+ };
43
+ var DEFAULT_FLOW_RUNNER_FIELD_LABELS = {
44
+ section: "Resposta do cliente",
45
+ fallbackMessage: "Mensagem quando a resposta n\xE3o serve",
46
+ fallbackPlaceholder: "Ex.: N\xE3o entendi. Escolha uma das op\xE7\xF5es.",
47
+ maxInvalidAnswers: "Tentativas antes de chamar uma pessoa",
48
+ maxInvalidAnswersHint: "Vazio = padr\xE3o do bot (2).",
49
+ minDateToday: "S\xF3 aceitar de hoje em diante",
50
+ afterContextKey: "Depois da data guardada em",
51
+ ...OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS,
52
+ minValue: "M\xEDnimo",
53
+ maxValue: "M\xE1ximo",
54
+ minLength: "M\xEDnimo de caracteres",
55
+ maxLength: "M\xE1ximo de caracteres",
56
+ skipKeywords: "Palavras que pulam a pergunta",
57
+ skipKeywordsHint: "Separadas por v\xEDrgula. Ex.: pular, n\xE3o sei",
58
+ keywordRoutes: "Palavras-chave (texto livre)",
59
+ keywordRoutesHint: "Se a mensagem contiver a palavra, segue para o destino \u2014 sem acento e sem mai\xFAscula.",
60
+ addKeywordRoute: "Adicionar palavra-chave",
61
+ removeKeywordRoute: "Remover palavra-chave",
62
+ keywordPlaceholder: "hor\xE1rio",
63
+ optionDescription: "Descri\xE7\xE3o (lista)",
64
+ optionSection: "Se\xE7\xE3o",
65
+ listButtonLabel: "Texto do bot\xE3o da lista",
66
+ unmatchedChoice: "Resposta fora das op\xE7\xF5es",
67
+ unmatchedChoiceReask: "Perguntar de novo (padr\xE3o)",
68
+ unmatchedChoiceDefault: 'Seguir o "Caso contr\xE1rio"',
69
+ choiceProvider: "Provedor de op\xE7\xF5es",
70
+ choiceProviderHint: "Chave registrada pelo sistema (registerDynamicChoiceProvider).",
71
+ contextKey: "Guardar a escolha em",
72
+ placeholdersHint: "Use {{chave}} para inserir respostas anteriores, ex.: {{contactFirstName}}.",
73
+ paletteDynamicChoice: "Escolha din\xE2mica",
74
+ paletteDynamicChoiceHint: 'Op\xE7\xF5es calculadas na hora pelo sistema, com "ver mais"',
75
+ paletteMessage: "Mensagem",
76
+ paletteMessageHint: "Envia um texto e segue para o pr\xF3ximo passo"
77
+ };
78
+ var DEFAULT_FLOW_EDITOR_LABELS = {
79
+ legend: {
80
+ question: "Pergunta",
81
+ entrada_choice: "Escolha calculada",
82
+ action: "A\xE7\xE3o (simula\xE7\xE3o/atendimento)",
83
+ menu: "Menu",
84
+ condition: "Condi\xE7\xE3o",
85
+ dynamic_choice: "Escolha din\xE2mica"
86
+ },
87
+ startNodeTooltip: "In\xEDcio do fluxo",
88
+ detachedNodeTooltip: "Sem liga\xE7\xE3o de entrada \u2014 o bot n\xE3o chega neste n\xF3. Puxe um fio de outro card at\xE9 ele.",
89
+ liveCountTooltip: (count) => `${count} conversa(s) ativa(s) aqui agora`,
90
+ edgeFallbackLabel: "outro",
91
+ actionKindLabels: {
92
+ handoff: "Encaminhar para atendimento",
93
+ rate_limited_handoff: "Encaminhar (limite de simula\xE7\xF5es atingido)",
94
+ send_product_list: "Enviar cat\xE1logo de produtos",
95
+ send_media: "Enviar arquivos da biblioteca"
96
+ },
97
+ conditionOperatorLabels: {
98
+ ">": "maior que",
99
+ ">=": "maior ou igual a",
100
+ "<": "menor que",
101
+ "<=": "menor ou igual a",
102
+ "==": "igual a",
103
+ "!=": "diferente de",
104
+ contains: "cont\xE9m"
105
+ },
106
+ questionTypeLabels: {
107
+ text: "Texto livre",
108
+ money: "Valor em R$",
109
+ date: "Data",
110
+ time: "Hor\xE1rio",
111
+ int: "N\xFAmero inteiro",
112
+ cpf: "CPF",
113
+ choice: "Escolha (bot\xF5es/lista)"
114
+ },
115
+ runnerFields: DEFAULT_FLOW_RUNNER_FIELD_LABELS,
116
+ nodePanel: {
117
+ title: "Editar n\xF3",
118
+ contextKey: "Chave (contexto)",
119
+ nodeName: "Nome do n\xF3 (opcional)",
120
+ nodeNamePlaceholder: "Ex.: Enviar tabela de pre\xE7os",
121
+ nodeNameHint: "S\xF3 aparece no editor \u2014 o cliente n\xE3o v\xEA.",
122
+ questionType: "Tipo de resposta",
123
+ question: "Texto da pergunta",
124
+ options: "Op\xE7\xF5es (choice)",
125
+ addOption: "Adicionar op\xE7\xE3o",
126
+ removeOption: "Remover op\xE7\xE3o",
127
+ close: "Fechar painel",
128
+ optionId: "Valor",
129
+ optionLabel: "Texto exibido",
130
+ next: "Pr\xF3ximo n\xF3",
131
+ nextHint: "Tamb\xE9m \xE9 poss\xEDvel arrastar um fio no canvas para conectar.",
132
+ nextRowLabel: "Pr\xF3ximo",
133
+ otherFlowsGroup: "Outros fluxos (salto)",
134
+ nextByAnswer: (id) => `Se responder "${id}" \u2192`,
135
+ nextDefault: "Caso contr\xE1rio \u2192",
136
+ save: "Salvar altera\xE7\xF5es",
137
+ cancel: "Cancelar",
138
+ fixedLogicNotice: "Este n\xF3 tem l\xF3gica fixa (valida\xE7\xF5es/c\xE1lculos do sistema) \u2014 s\xF3 o texto e o destino s\xE3o edit\xE1veis.",
139
+ actionNotice: "N\xF3 de a\xE7\xE3o \u2014 dispara a a\xE7\xE3o registrada ou encaminha para atendimento humano.",
140
+ preview: "Como o cliente v\xEA no WhatsApp",
141
+ previewPlaceholder: "Pr\xE9-visualiza\xE7\xE3o\u2026",
142
+ previewEmptyBody: "(escreva o texto da mensagem)",
143
+ previewEmptyOption: "(sem texto)",
144
+ previewListButton: "Ver op\xE7\xF5es",
145
+ previewModeButtons: "Enviado como bot\xF5es (at\xE9 3 op\xE7\xF5es)",
146
+ previewModeList: "Enviado como lista (4+ op\xE7\xF5es)",
147
+ delete: "Excluir n\xF3",
148
+ deleteConfirm: "Excluir este n\xF3? Liga\xE7\xF5es que apontam para ele ficar\xE3o quebradas.",
149
+ directMessage: "Mensagem (opcional)",
150
+ fallbackMessage: "Mensagem de fallback (quando o cat\xE1logo n\xE3o est\xE1 dispon\xEDvel)",
151
+ conditionNotice: "N\xF3 de condi\xE7\xE3o \u2014 n\xE3o pergunta nada ao cliente, s\xF3 decide automaticamente entre Verdadeiro/Falso.",
152
+ conditionVariable: "Vari\xE1vel (chave j\xE1 coletada por uma pergunta anterior)",
153
+ conditionOperator: "Operador",
154
+ conditionValue: "Valor de compara\xE7\xE3o",
155
+ conditionTrue: "Se verdadeiro \u2192",
156
+ conditionFalse: "Se falso \u2192",
157
+ conditionVariableMissing: "Se a vari\xE1vel ainda n\xE3o foi coletada \u2192",
158
+ media: "Arquivos enviados neste ponto",
159
+ mediaUnavailable: "A biblioteca de arquivos n\xE3o est\xE1 dispon\xEDvel neste painel."
160
+ },
161
+ quickAdd: {
162
+ fromHandle: "Criar o pr\xF3ximo n\xF3 j\xE1 ligado aqui",
163
+ title: "Ligar em um n\xF3 novo",
164
+ disconnect: "Desligar este fio (o n\xF3 continua no fluxo)"
165
+ },
166
+ legendPanel: {
167
+ title: "Legenda",
168
+ nodes: "Cards",
169
+ connections: "Liga\xE7\xF5es",
170
+ linear: "Segue direto para o pr\xF3ximo",
171
+ branch: "Caminho de uma op\xE7\xE3o escolhida",
172
+ fallback: "Quando a resposta n\xE3o casa com nenhuma op\xE7\xE3o",
173
+ crossFlow: "Salta para outro fluxo",
174
+ live: "Tem conversa passando por aqui agora",
175
+ selfLoop: "Volta ao mesmo card \u2014 repete a pergunta",
176
+ detached: "Ningu\xE9m aponta para este card: o bot n\xE3o chega nele",
177
+ startNode: "Onde o fluxo come\xE7a"
178
+ },
179
+ palette: {
180
+ title: "Adicionar ao fluxo",
181
+ question: "Pergunta",
182
+ decision: "Decis\xE3o",
183
+ condition: "Condi\xE7\xE3o",
184
+ conditionHint: "Compara uma vari\xE1vel j\xE1 coletada e segue automaticamente, sem perguntar nada",
185
+ action: "A\xE7\xE3o"
186
+ },
187
+ flowMap: {
188
+ nodeCount: (count) => `${count} n\xF3(s)`,
189
+ openFlow: "Abrir fluxo",
190
+ toggleToMap: "Mapa de fluxos",
191
+ toggleToDetail: "Voltar ao editor"
192
+ },
193
+ flowGroup: {
194
+ focus: "Focar neste fluxo",
195
+ close: "Fechar"
196
+ },
197
+ crossFlowPortal: {
198
+ tooltip: "Clique para abrir esse fluxo aqui do lado, ligado ao ponto de onde ele \xE9 chamado",
199
+ goesTo: (label) => `\u21AA Vai para: ${label}`
200
+ },
201
+ collectionChain: {
202
+ feeds: (label) => `Alimenta: ${label}`
203
+ },
204
+ validation: {
205
+ title: "Antes de publicar",
206
+ errors: (count) => `${count} erro(s) \u2014 corrija antes de salvar`,
207
+ warnings: (count) => `${count} aviso(s)`,
208
+ noStart: "O fluxo precisa de um n\xF3 inicial v\xE1lido.",
209
+ brokenRef: (from, to) => `N\xF3 "${from}": liga\xE7\xE3o aponta para "${to}", que n\xE3o existe.`,
210
+ choiceWithoutOptions: (id) => `N\xF3 "${id}": escolha sem nenhuma op\xE7\xE3o.`,
211
+ duplicatedOptionId: (id, optionId) => `N\xF3 "${id}": valor de op\xE7\xE3o "${optionId}" duplicado.`,
212
+ optionWithoutTarget: (id, label) => `N\xF3 "${id}": op\xE7\xE3o "${label}" n\xE3o tem destino definido.`,
213
+ tooManyOptions: (id, count) => `N\xF3 "${id}": ${count} op\xE7\xF5es \u2014 o WhatsApp aceita no m\xE1ximo 10 em lista.`,
214
+ buttonTitleTooLong: (id, label) => `N\xF3 "${id}": bot\xE3o "${label}" passa de 20 caracteres.`,
215
+ listTitleTooLong: (id, label) => `N\xF3 "${id}": item de lista "${label}" passa de 24 caracteres.`,
216
+ bodyTooLong: (id) => `N\xF3 "${id}": texto passa de 1024 caracteres.`,
217
+ unreachable: (id) => `N\xF3 "${id}" \xE9 inalcan\xE7\xE1vel a partir do in\xEDcio do fluxo.`,
218
+ deadEndQuestion: (id) => `N\xF3 "${id}": pergunta sem pr\xF3ximo passo definido.`,
219
+ conditionIncomplete: (id) => `N\xF3 "${id}": condi\xE7\xE3o incompleta \u2014 defina vari\xE1vel, operador e valor.`,
220
+ conditionBranchMissing: (id, branch) => `N\xF3 "${id}": ramo "${branch === "true" ? "Verdadeiro" : "Falso"}" sem destino definido.`,
221
+ descriptionTooLong: (id, label) => `N\xF3 "${id}": a descri\xE7\xE3o de "${label}" passa de 72 caracteres.`,
222
+ dynamicChoiceWithoutProvider: (id) => `N\xF3 "${id}": escolha din\xE2mica sem provedor de op\xE7\xF5es.`,
223
+ choiceDefaultIgnored: (id) => `N\xF3 "${id}": o bot repergunta quando a resposta n\xE3o casa com uma op\xE7\xE3o, ent\xE3o "Caso contr\xE1rio" n\xE3o \xE9 seguido. Para seguir, mude "Resposta fora das op\xE7\xF5es".`
224
+ },
225
+ workspace: {
226
+ title: "Fluxos do Bot",
227
+ subtitle: "Blueprint visual dos fluxos de conversa, sincronizado com o que est\xE1 em produ\xE7\xE3o.",
228
+ loading: "Carregando fluxos\u2026",
229
+ loadError: "N\xE3o foi poss\xEDvel carregar os fluxos.",
230
+ saveGraph: "Publicar altera\xE7\xF5es",
231
+ saving: "Publicando\u2026",
232
+ saveSuccess: "Fluxo publicado! O bot j\xE1 est\xE1 usando a vers\xE3o nova.",
233
+ saveError: "N\xE3o foi poss\xEDvel salvar \u2014 verifique se todos os destinos apontam para n\xF3s existentes.",
234
+ organize: "Organizar",
235
+ organizeTooltip: "Reorganiza os n\xF3s automaticamente e salva as novas posi\xE7\xF5es",
236
+ discardChanges: "Desfazer altera\xE7\xF5es",
237
+ discardTooltip: "Devolve os fluxos abertos ao que est\xE1 publicado, descartando o que n\xE3o foi salvo",
238
+ discardConfirm: "Descartar todas as altera\xE7\xF5es n\xE3o publicadas e voltar ao fluxo que est\xE1 no ar?",
239
+ unsavedChangesConfirm: "Voc\xEA tem altera\xE7\xF5es n\xE3o publicadas neste fluxo. Trocar de fluxo agora descarta essas edi\xE7\xF5es. Continuar?"
240
+ },
241
+ flowManager: {
242
+ newFlow: "Novo fluxo",
243
+ createTitle: "Criar novo fluxo",
244
+ key: "Identificador \xFAnico",
245
+ keyHint: "letras min\xFAsculas, n\xFAmeros e _ (ex.: promocoes_semana)",
246
+ keyInvalid: "Use apenas letras min\xFAsculas, n\xFAmeros e _ (2 a 40 caracteres)",
247
+ label: "Nome exibido",
248
+ showInMenu: "Exibir como op\xE7\xE3o no menu principal do bot",
249
+ menuOptionLabel: "Texto da op\xE7\xE3o no menu",
250
+ create: "Criar fluxo",
251
+ creating: "Criando\u2026",
252
+ deleteFlow: "Excluir fluxo",
253
+ deleteConfirm: (label) => `Excluir o fluxo "${label}"? Esta a\xE7\xE3o n\xE3o pode ser desfeita.`,
254
+ createError: "N\xE3o foi poss\xEDvel criar o fluxo.",
255
+ deleteError: "N\xE3o foi poss\xEDvel excluir o fluxo."
256
+ }
257
+ };
258
+ function mergeFlowEditorLabels(override) {
259
+ if (!override) return DEFAULT_FLOW_EDITOR_LABELS;
260
+ return {
261
+ ...DEFAULT_FLOW_EDITOR_LABELS,
262
+ ...override,
263
+ legend: { ...DEFAULT_FLOW_EDITOR_LABELS.legend, ...override.legend },
264
+ actionKindLabels: { ...DEFAULT_FLOW_EDITOR_LABELS.actionKindLabels, ...override.actionKindLabels },
265
+ conditionOperatorLabels: {
266
+ ...DEFAULT_FLOW_EDITOR_LABELS.conditionOperatorLabels,
267
+ ...override.conditionOperatorLabels
268
+ },
269
+ questionTypeLabels: { ...DEFAULT_FLOW_EDITOR_LABELS.questionTypeLabels, ...override.questionTypeLabels },
270
+ runnerFields: { ...DEFAULT_FLOW_RUNNER_FIELD_LABELS, ...override.runnerFields },
271
+ nodePanel: { ...DEFAULT_FLOW_EDITOR_LABELS.nodePanel, ...override.nodePanel },
272
+ quickAdd: { ...DEFAULT_FLOW_EDITOR_LABELS.quickAdd, ...override.quickAdd },
273
+ legendPanel: { ...DEFAULT_FLOW_EDITOR_LABELS.legendPanel, ...override.legendPanel },
274
+ palette: { ...DEFAULT_FLOW_EDITOR_LABELS.palette, ...override.palette },
275
+ flowMap: { ...DEFAULT_FLOW_EDITOR_LABELS.flowMap, ...override.flowMap },
276
+ flowGroup: { ...DEFAULT_FLOW_EDITOR_LABELS.flowGroup, ...override.flowGroup },
277
+ crossFlowPortal: { ...DEFAULT_FLOW_EDITOR_LABELS.crossFlowPortal, ...override.crossFlowPortal },
278
+ collectionChain: { ...DEFAULT_FLOW_EDITOR_LABELS.collectionChain, ...override.collectionChain },
279
+ validation: { ...DEFAULT_FLOW_EDITOR_LABELS.validation, ...override.validation },
280
+ workspace: { ...DEFAULT_FLOW_EDITOR_LABELS.workspace, ...override.workspace },
281
+ flowManager: { ...DEFAULT_FLOW_EDITOR_LABELS.flowManager, ...override.flowManager }
282
+ };
283
+ }
284
+
30
285
  // src/flows/flowGraph.ts
31
- import { FLOW_ACTION_KIND } from "@adatechnology/meta-whatsapp-contracts";
286
+ import { FLOW_ACTION_KIND, WHATSAPP_CHOICE_LIMIT } from "@adatechnology/meta-whatsapp-contracts";
32
287
  var CONDITION_OPERATORS = [">", ">=", "<", "<=", "==", "!=", "contains"];
33
288
  var BUILT_IN_ACTION_KINDS = FLOW_ACTION_KIND;
34
289
  var PASS_THROUGH_ACTION_KINDS = ["send_media"];
290
+ function isPassThroughAction(node) {
291
+ if (node.type !== "action") return false;
292
+ return !node.actionKind || PASS_THROUGH_ACTION_KINDS.includes(node.actionKind);
293
+ }
294
+ var KEYWORD_HANDLE_PREFIX = "kw:";
295
+ var keywordHandle = (keyword) => `${KEYWORD_HANDLE_PREFIX}${keyword}`;
296
+ function keywordOfHandle(handle) {
297
+ return handle.startsWith(KEYWORD_HANDLE_PREFIX) ? handle.slice(KEYWORD_HANDLE_PREFIX.length) : void 0;
298
+ }
299
+ var POSSIBLE_NEXT_HANDLE_PREFIX = "maybe:";
300
+ var possibleNextHandle = (target) => `${POSSIBLE_NEXT_HANDLE_PREFIX}${target}`;
301
+ function possibleNextOfHandle(handle) {
302
+ return handle.startsWith(POSSIBLE_NEXT_HANDLE_PREFIX) ? handle.slice(POSSIBLE_NEXT_HANDLE_PREFIX.length) : void 0;
303
+ }
35
304
  var CROSS_FLOW_PREFIX = "flow:";
36
305
  var isCrossFlowTarget = (target) => target.startsWith(CROSS_FLOW_PREFIX);
37
306
  var crossFlowKey = (target) => target.slice(CROSS_FLOW_PREFIX.length);
@@ -42,29 +311,46 @@ function estimateNodeHeight(node) {
42
311
  const PADDING = 16;
43
312
  const ROW_HEIGHT = 34;
44
313
  const rowCount = node.type === "action" ? (
45
- // Ação de passagem desenha uma linha de saída; terminal não desenha nenhuma.
46
- node.actionKind && PASS_THROUGH_ACTION_KINDS.includes(node.actionKind) ? 1 : 0
47
- ) : node.type === "condition" ? 2 : node.type === "menu" || node.questionType === "choice" ? (node.options?.length ?? 0) + 1 : 1;
314
+ // Ação de passagem desenha uma linha de saída; terminal não desenha nenhuma. Cada destino
315
+ // declarado em `possibleNext` é mais uma linha.
316
+ (isPassThroughAction(node) ? 1 : 0) + (node.possibleNext?.length ?? 0)
317
+ ) : node.type === "condition" ? 2 : node.type === "menu" || node.questionType === "choice" ? (node.options?.length ?? 0) + 1 + keywordCount(node) : 1 + keywordCount(node);
48
318
  return HEADER_HEIGHT + BODY_HEIGHT + PADDING + rowCount * ROW_HEIGHT;
49
319
  }
320
+ function keywordCount(node) {
321
+ return typeof node.next === "object" && node.next?.byKeyword ? Object.keys(node.next.byKeyword).length : 0;
322
+ }
50
323
  var WHATSAPP_LIMITS = {
51
- MAX_BUTTONS: 3,
52
- MAX_LIST_ROWS: 10,
53
- BUTTON_TITLE_MAX: 20,
54
- LIST_ROW_TITLE_MAX: 24,
55
- BODY_MAX: 1024
324
+ MAX_BUTTONS: WHATSAPP_CHOICE_LIMIT.BUTTONS,
325
+ MAX_LIST_ROWS: WHATSAPP_CHOICE_LIMIT.LIST_ROWS,
326
+ BUTTON_TITLE_MAX: WHATSAPP_CHOICE_LIMIT.BUTTON_TITLE_LENGTH,
327
+ LIST_ROW_TITLE_MAX: WHATSAPP_CHOICE_LIMIT.LIST_ROW_TITLE_LENGTH,
328
+ LIST_ROW_DESCRIPTION_MAX: WHATSAPP_CHOICE_LIMIT.LIST_ROW_DESCRIPTION_LENGTH,
329
+ LIST_SECTION_TITLE_MAX: WHATSAPP_CHOICE_LIMIT.LIST_SECTION_TITLE_LENGTH,
330
+ BODY_MAX: WHATSAPP_CHOICE_LIMIT.BODY_LENGTH
56
331
  };
57
- function rendersAsButtons(options) {
58
- return (options?.length ?? 0) <= WHATSAPP_LIMITS.MAX_BUTTONS;
332
+ function countCharacters(text) {
333
+ return Array.from(text).length;
59
334
  }
60
- function targetsOf(node) {
335
+ function rendersAsButtons(options, optionDetails) {
336
+ const hasDetails = (options ?? []).some(
337
+ ([id]) => !!optionDetails?.[id]?.description || !!optionDetails?.[id]?.section
338
+ );
339
+ return !hasDetails && (options?.length ?? 0) <= WHATSAPP_LIMITS.MAX_BUTTONS;
340
+ }
341
+ function nextTargetsOf(node) {
61
342
  if (!node.next) return [];
62
343
  if (typeof node.next === "string") return [{ target: node.next }];
63
344
  return [
64
345
  ...Object.entries(node.next.byAnswer).map(([optionId, target]) => ({ target, optionId })),
346
+ ...Object.entries(node.next.byKeyword ?? {}).map(([keyword, target]) => ({ target, keyword })),
65
347
  { target: node.next.default, isDefault: true }
66
348
  ];
67
349
  }
350
+ function targetsOf(node) {
351
+ const possible = (node.possibleNext ?? []).map((target) => ({ target, isPossible: true }));
352
+ return [...nextTargetsOf(node), ...possible];
353
+ }
68
354
  function validateGraph(graph, issueText) {
69
355
  const issues = [];
70
356
  const nodeIds = new Set(Object.keys(graph.nodes));
@@ -94,20 +380,38 @@ function validateGraph(graph, issueText) {
94
380
  if (!byAnswer[optionId]) {
95
381
  issues.push({ severity: "warning", nodeId: node.id, message: issueText.optionWithoutTarget(node.id, label) });
96
382
  }
97
- const usesButtons = rendersAsButtons(options);
98
- if (usesButtons && label.length > WHATSAPP_LIMITS.BUTTON_TITLE_MAX) {
383
+ const usesButtons = rendersAsButtons(options, node.optionDetails);
384
+ if (usesButtons && countCharacters(label) > WHATSAPP_LIMITS.BUTTON_TITLE_MAX) {
99
385
  issues.push({ severity: "error", nodeId: node.id, message: issueText.buttonTitleTooLong(node.id, label) });
100
386
  }
101
- if (!usesButtons && label.length > WHATSAPP_LIMITS.LIST_ROW_TITLE_MAX) {
387
+ if (!usesButtons && countCharacters(label) > WHATSAPP_LIMITS.LIST_ROW_TITLE_MAX) {
102
388
  issues.push({ severity: "error", nodeId: node.id, message: issueText.listTitleTooLong(node.id, label) });
103
389
  }
390
+ const description = node.optionDetails?.[optionId]?.description ?? "";
391
+ if (countCharacters(description) > WHATSAPP_LIMITS.LIST_ROW_DESCRIPTION_MAX) {
392
+ const message = issueText.descriptionTooLong?.(node.id, label) ?? `\u201C${label}\u201D em ${node.id}: a descri\xE7\xE3o passa de ${WHATSAPP_LIMITS.LIST_ROW_DESCRIPTION_MAX} caracteres.`;
393
+ issues.push({ severity: "error", nodeId: node.id, message });
394
+ }
395
+ }
396
+ const defaultTarget = typeof node.next === "object" && node.next ? node.next.default : "";
397
+ if (defaultTarget && defaultTarget !== node.id && node.unmatchedChoice !== "default") {
398
+ const message = issueText.choiceDefaultIgnored?.(node.id) ?? `N\xF3 "${node.id}": "caso contr\xE1rio" s\xF3 \xE9 seguido com "resposta fora das op\xE7\xF5es" = seguir o caso contr\xE1rio.`;
399
+ issues.push({ severity: "warning", nodeId: node.id, message });
104
400
  }
105
401
  if (options.length > WHATSAPP_LIMITS.MAX_LIST_ROWS) {
106
402
  issues.push({ severity: "error", nodeId: node.id, message: issueText.tooManyOptions(node.id, options.length) });
107
403
  }
108
404
  }
405
+ if ((node.possibleNext?.length ?? 0) > 0 && (node.type !== "action" || !node.actionKind)) {
406
+ const message = issueText.possibleNextIgnored?.(node.id) ?? `${node.id}: "destinos que a a\xE7\xE3o pode escolher" s\xF3 valem em n\xF3 de a\xE7\xE3o com tipo de a\xE7\xE3o.`;
407
+ issues.push({ severity: "warning", nodeId: node.id, message });
408
+ }
409
+ if (node.type === "dynamic_choice" && !node.choiceProvider) {
410
+ const message = issueText.dynamicChoiceWithoutProvider?.(node.id) ?? `${node.id}: escolha din\xE2mica sem provedor de op\xE7\xF5es.`;
411
+ issues.push({ severity: "error", nodeId: node.id, message });
412
+ }
109
413
  const bodyText = node.question ?? node.directMessage ?? "";
110
- if (bodyText.length > WHATSAPP_LIMITS.BODY_MAX) {
414
+ if (countCharacters(bodyText) > WHATSAPP_LIMITS.BODY_MAX) {
111
415
  issues.push({ severity: "error", nodeId: node.id, message: issueText.bodyTooLong(node.id) });
112
416
  }
113
417
  if (node.type === "question" && !node.next) {
@@ -276,14 +580,16 @@ var NODE_TYPE_COLOR = {
276
580
  entrada_choice: "border-purple-300 bg-purple-50 dark:bg-purple-950/40 dark:border-purple-800",
277
581
  action: "border-orange-300 bg-orange-50 dark:bg-orange-950/40 dark:border-orange-800",
278
582
  menu: "border-emerald-300 bg-emerald-50 dark:bg-emerald-950/40 dark:border-emerald-800",
279
- condition: "border-cyan-300 bg-cyan-50 dark:bg-cyan-950/40 dark:border-cyan-800"
583
+ condition: "border-cyan-300 bg-cyan-50 dark:bg-cyan-950/40 dark:border-cyan-800",
584
+ dynamic_choice: "border-teal-300 bg-teal-50 dark:bg-teal-950/40 dark:border-teal-800"
280
585
  };
281
586
  var NODE_TYPE_ICON = {
282
587
  question: MessageCircleQuestion,
283
588
  entrada_choice: ListTree,
284
589
  action: Zap,
285
590
  menu: GitBranch,
286
- condition: Diamond
591
+ condition: Diamond,
592
+ dynamic_choice: ListChecks
287
593
  };
288
594
  var DEFAULT_ACTION_KIND_ICON = {
289
595
  handoff: Headset,
@@ -314,12 +620,23 @@ function selfLoopHandles(node) {
314
620
  for (const [optionId, target] of Object.entries(node.next.byAnswer ?? {})) {
315
621
  if (target === node.id) loops.add(optionId);
316
622
  }
623
+ for (const [keyword, target] of Object.entries(node.next.byKeyword ?? {})) {
624
+ if (target === node.id) loops.add(keywordHandle(keyword));
625
+ }
317
626
  if (node.next.default === node.id) loops.add("__default");
318
627
  return loops;
319
628
  }
320
629
  function sourceRows(node, labels) {
321
630
  if (node.type === "action") {
322
- return node.actionKind && PASS_THROUGH_ACTION_KINDS.includes(node.actionKind) ? [{ id: "next", label: labels.nodePanel.nextRowLabel, isDefault: false, isSelfLoop: false }] : [];
631
+ const rowLabel = labels.runnerFields?.possibleNextRowLabel ?? OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS.possibleNextRowLabel;
632
+ const possibleRows = (node.possibleNext ?? []).map((target) => ({
633
+ id: possibleNextHandle(target),
634
+ label: `${rowLabel}: ${target}`,
635
+ isDefault: true,
636
+ isSelfLoop: target === node.id
637
+ }));
638
+ const nextRows = isPassThroughAction(node) ? [{ id: "next", label: labels.nodePanel.nextRowLabel, isDefault: false, isSelfLoop: false }] : [];
639
+ return [...nextRows, ...possibleRows];
323
640
  }
324
641
  const loops = selfLoopHandles(node);
325
642
  if (node.type === "condition") {
@@ -328,12 +645,24 @@ function sourceRows(node, labels) {
328
645
  { id: "false", label: labels.nodePanel.conditionFalse, isDefault: false, isSelfLoop: loops.has("false") }
329
646
  ];
330
647
  }
648
+ const keywordRows = Object.keys(typeof node.next === "object" ? node.next.byKeyword ?? {} : {}).map((keyword) => ({
649
+ id: keywordHandle(keyword),
650
+ label: `\u201C${keyword}\u201D`,
651
+ isDefault: false,
652
+ isSelfLoop: loops.has(keywordHandle(keyword))
653
+ }));
331
654
  const isChoice = node.type === "menu" || node.questionType === "choice";
332
- if (!isChoice)
655
+ if (!isChoice && typeof node.next !== "object")
333
656
  return [{ id: "next", label: labels.nodePanel.nextRowLabel, isDefault: false, isSelfLoop: loops.has("next") }];
657
+ if (!isChoice)
658
+ return [
659
+ ...keywordRows,
660
+ { id: "__default", label: labels.nodePanel.nextRowLabel, isDefault: true, isSelfLoop: loops.has("__default") }
661
+ ];
334
662
  const options = node.options ?? [];
335
663
  return [
336
664
  ...options.map(([id, label]) => ({ id, label, isDefault: false, isSelfLoop: loops.has(id) })),
665
+ ...keywordRows,
337
666
  { id: "__default", label: labels.edgeFallbackLabel, isDefault: true, isSelfLoop: loops.has("__default") }
338
667
  ];
339
668
  }
@@ -439,267 +768,64 @@ function FlowNodeCard({ data }) {
439
768
  className: "!bg-gray-400 !border-2 !border-white dark:!bg-gray-500 dark:!border-gray-800"
440
769
  }
441
770
  ),
442
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
443
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 uppercase tracking-wide font-semibold text-gray-500 dark:text-gray-400 text-xs", children: [
444
- /* @__PURE__ */ jsx(Icon, { size: 12, strokeWidth: 2.5 }),
445
- isStart && /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-emerald-500", "data-cv-tooltip": labels.startNodeTooltip }),
446
- labels.legend[node.type]
447
- ] }),
448
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
449
- hasError && /* @__PURE__ */ jsx(
450
- AlertCircle,
451
- {
452
- size: 13,
453
- "data-cv-tooltip": issueTooltip,
454
- "aria-label": issueTooltip,
455
- className: "text-red-600 dark:text-red-400"
456
- }
457
- ),
458
- hasWarning && /* @__PURE__ */ jsx(
459
- AlertTriangle,
460
- {
461
- size: 13,
462
- "data-cv-tooltip": issueTooltip,
463
- "aria-label": issueTooltip,
464
- className: "text-amber-500 dark:text-amber-400"
465
- }
466
- ),
467
- liveCount > 0 && /* @__PURE__ */ jsx(
468
- "span",
469
- {
470
- "data-cv-tooltip": labels.liveCountTooltip(liveCount),
471
- className: "font-bold bg-blue-600 text-white rounded-full px-1.5 py-0.5 text-xs",
472
- children: liveCount
473
- }
474
- )
475
- ] })
476
- ] }),
477
- /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-900 dark:text-gray-100 mt-1 line-clamp-3", children: label }),
478
- rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-2 space-y-1", children: rows.map((row) => /* @__PURE__ */ jsx(
479
- SourceRow,
480
- {
481
- label: row.label,
482
- isDefault: row.isDefault,
483
- handleId: row.id,
484
- addLabel: labels.quickAdd.fromHandle,
485
- isSelfLoop: row.isSelfLoop,
486
- selfLoopLabel: labels.legendPanel.selfLoop,
487
- ...onQuickAdd ? { onQuickAdd: (params) => onQuickAdd({ nodeId: node.id, ...params }) } : {}
488
- },
489
- row.id
490
- )) })
491
- ]
492
- }
493
- );
494
- }
495
- var flowNodeTypes = { flowNode: FlowNodeCard };
496
-
497
- // src/flows/FlowMapNode.tsx
498
- import { Handle as Handle2, Position as Position2 } from "@xyflow/react";
499
- import { GitBranch as GitBranch2, Maximize2 } from "lucide-react";
500
-
501
- // src/flows/labels.ts
502
- var DEFAULT_FLOW_EDITOR_LABELS = {
503
- legend: {
504
- question: "Pergunta",
505
- entrada_choice: "Escolha calculada",
506
- action: "A\xE7\xE3o (simula\xE7\xE3o/atendimento)",
507
- menu: "Menu",
508
- condition: "Condi\xE7\xE3o"
509
- },
510
- startNodeTooltip: "In\xEDcio do fluxo",
511
- detachedNodeTooltip: "Sem liga\xE7\xE3o de entrada \u2014 o bot n\xE3o chega neste n\xF3. Puxe um fio de outro card at\xE9 ele.",
512
- liveCountTooltip: (count) => `${count} conversa(s) ativa(s) aqui agora`,
513
- edgeFallbackLabel: "outro",
514
- actionKindLabels: {
515
- handoff: "Encaminhar para atendimento",
516
- rate_limited_handoff: "Encaminhar (limite de simula\xE7\xF5es atingido)",
517
- send_product_list: "Enviar cat\xE1logo de produtos",
518
- send_media: "Enviar arquivos da biblioteca"
519
- },
520
- conditionOperatorLabels: {
521
- ">": "maior que",
522
- ">=": "maior ou igual a",
523
- "<": "menor que",
524
- "<=": "menor ou igual a",
525
- "==": "igual a",
526
- "!=": "diferente de",
527
- contains: "cont\xE9m"
528
- },
529
- questionTypeLabels: {
530
- text: "Texto livre",
531
- money: "Valor em R$",
532
- date: "Data",
533
- int: "N\xFAmero inteiro",
534
- cpf: "CPF",
535
- choice: "Escolha (bot\xF5es/lista)"
536
- },
537
- nodePanel: {
538
- title: "Editar n\xF3",
539
- contextKey: "Chave (contexto)",
540
- nodeName: "Nome do n\xF3 (opcional)",
541
- nodeNamePlaceholder: "Ex.: Enviar tabela de pre\xE7os",
542
- nodeNameHint: "S\xF3 aparece no editor \u2014 o cliente n\xE3o v\xEA.",
543
- questionType: "Tipo de resposta",
544
- question: "Texto da pergunta",
545
- options: "Op\xE7\xF5es (choice)",
546
- addOption: "Adicionar op\xE7\xE3o",
547
- removeOption: "Remover op\xE7\xE3o",
548
- close: "Fechar painel",
549
- optionId: "Valor",
550
- optionLabel: "Texto exibido",
551
- next: "Pr\xF3ximo n\xF3",
552
- nextHint: "Tamb\xE9m \xE9 poss\xEDvel arrastar um fio no canvas para conectar.",
553
- nextRowLabel: "Pr\xF3ximo",
554
- otherFlowsGroup: "Outros fluxos (salto)",
555
- nextByAnswer: (id) => `Se responder "${id}" \u2192`,
556
- nextDefault: "Caso contr\xE1rio \u2192",
557
- save: "Salvar altera\xE7\xF5es",
558
- cancel: "Cancelar",
559
- fixedLogicNotice: "Este n\xF3 tem l\xF3gica fixa (valida\xE7\xF5es/c\xE1lculos do sistema) \u2014 s\xF3 o texto e o destino s\xE3o edit\xE1veis.",
560
- actionNotice: "N\xF3 de a\xE7\xE3o \u2014 dispara a a\xE7\xE3o registrada ou encaminha para atendimento humano.",
561
- preview: "Como o cliente v\xEA no WhatsApp",
562
- previewPlaceholder: "Pr\xE9-visualiza\xE7\xE3o\u2026",
563
- previewEmptyBody: "(escreva o texto da mensagem)",
564
- previewEmptyOption: "(sem texto)",
565
- previewListButton: "Ver op\xE7\xF5es",
566
- previewModeButtons: "Enviado como bot\xF5es (at\xE9 3 op\xE7\xF5es)",
567
- previewModeList: "Enviado como lista (4+ op\xE7\xF5es)",
568
- delete: "Excluir n\xF3",
569
- deleteConfirm: "Excluir este n\xF3? Liga\xE7\xF5es que apontam para ele ficar\xE3o quebradas.",
570
- directMessage: "Mensagem (opcional)",
571
- fallbackMessage: "Mensagem de fallback (quando o cat\xE1logo n\xE3o est\xE1 dispon\xEDvel)",
572
- conditionNotice: "N\xF3 de condi\xE7\xE3o \u2014 n\xE3o pergunta nada ao cliente, s\xF3 decide automaticamente entre Verdadeiro/Falso.",
573
- conditionVariable: "Vari\xE1vel (chave j\xE1 coletada por uma pergunta anterior)",
574
- conditionOperator: "Operador",
575
- conditionValue: "Valor de compara\xE7\xE3o",
576
- conditionTrue: "Se verdadeiro \u2192",
577
- conditionFalse: "Se falso \u2192",
578
- conditionVariableMissing: "Se a vari\xE1vel ainda n\xE3o foi coletada \u2192",
579
- media: "Arquivos enviados neste ponto",
580
- mediaUnavailable: "A biblioteca de arquivos n\xE3o est\xE1 dispon\xEDvel neste painel."
581
- },
582
- quickAdd: {
583
- fromHandle: "Criar o pr\xF3ximo n\xF3 j\xE1 ligado aqui",
584
- title: "Ligar em um n\xF3 novo",
585
- disconnect: "Desligar este fio (o n\xF3 continua no fluxo)"
586
- },
587
- legendPanel: {
588
- title: "Legenda",
589
- nodes: "Cards",
590
- connections: "Liga\xE7\xF5es",
591
- linear: "Segue direto para o pr\xF3ximo",
592
- branch: "Caminho de uma op\xE7\xE3o escolhida",
593
- fallback: "Quando a resposta n\xE3o casa com nenhuma op\xE7\xE3o",
594
- crossFlow: "Salta para outro fluxo",
595
- live: "Tem conversa passando por aqui agora",
596
- selfLoop: "Volta ao mesmo card \u2014 repete a pergunta",
597
- detached: "Ningu\xE9m aponta para este card: o bot n\xE3o chega nele",
598
- startNode: "Onde o fluxo come\xE7a"
599
- },
600
- palette: {
601
- title: "Adicionar ao fluxo",
602
- question: "Pergunta",
603
- decision: "Decis\xE3o",
604
- condition: "Condi\xE7\xE3o",
605
- conditionHint: "Compara uma vari\xE1vel j\xE1 coletada e segue automaticamente, sem perguntar nada",
606
- action: "A\xE7\xE3o"
607
- },
608
- flowMap: {
609
- nodeCount: (count) => `${count} n\xF3(s)`,
610
- openFlow: "Abrir fluxo",
611
- toggleToMap: "Mapa de fluxos",
612
- toggleToDetail: "Voltar ao editor"
613
- },
614
- flowGroup: {
615
- focus: "Focar neste fluxo",
616
- close: "Fechar"
617
- },
618
- crossFlowPortal: {
619
- tooltip: "Clique para abrir esse fluxo aqui do lado, ligado ao ponto de onde ele \xE9 chamado",
620
- goesTo: (label) => `\u21AA Vai para: ${label}`
621
- },
622
- collectionChain: {
623
- feeds: (label) => `Alimenta: ${label}`
624
- },
625
- validation: {
626
- title: "Antes de publicar",
627
- errors: (count) => `${count} erro(s) \u2014 corrija antes de salvar`,
628
- warnings: (count) => `${count} aviso(s)`,
629
- noStart: "O fluxo precisa de um n\xF3 inicial v\xE1lido.",
630
- brokenRef: (from, to) => `N\xF3 "${from}": liga\xE7\xE3o aponta para "${to}", que n\xE3o existe.`,
631
- choiceWithoutOptions: (id) => `N\xF3 "${id}": escolha sem nenhuma op\xE7\xE3o.`,
632
- duplicatedOptionId: (id, optionId) => `N\xF3 "${id}": valor de op\xE7\xE3o "${optionId}" duplicado.`,
633
- optionWithoutTarget: (id, label) => `N\xF3 "${id}": op\xE7\xE3o "${label}" n\xE3o tem destino definido.`,
634
- tooManyOptions: (id, count) => `N\xF3 "${id}": ${count} op\xE7\xF5es \u2014 o WhatsApp aceita no m\xE1ximo 10 em lista.`,
635
- buttonTitleTooLong: (id, label) => `N\xF3 "${id}": bot\xE3o "${label}" passa de 20 caracteres.`,
636
- listTitleTooLong: (id, label) => `N\xF3 "${id}": item de lista "${label}" passa de 24 caracteres.`,
637
- bodyTooLong: (id) => `N\xF3 "${id}": texto passa de 1024 caracteres.`,
638
- unreachable: (id) => `N\xF3 "${id}" \xE9 inalcan\xE7\xE1vel a partir do in\xEDcio do fluxo.`,
639
- deadEndQuestion: (id) => `N\xF3 "${id}": pergunta sem pr\xF3ximo passo definido.`,
640
- conditionIncomplete: (id) => `N\xF3 "${id}": condi\xE7\xE3o incompleta \u2014 defina vari\xE1vel, operador e valor.`,
641
- conditionBranchMissing: (id, branch) => `N\xF3 "${id}": ramo "${branch === "true" ? "Verdadeiro" : "Falso"}" sem destino definido.`
642
- },
643
- workspace: {
644
- title: "Fluxos do Bot",
645
- subtitle: "Blueprint visual dos fluxos de conversa, sincronizado com o que est\xE1 em produ\xE7\xE3o.",
646
- loading: "Carregando fluxos\u2026",
647
- loadError: "N\xE3o foi poss\xEDvel carregar os fluxos.",
648
- saveGraph: "Publicar altera\xE7\xF5es",
649
- saving: "Publicando\u2026",
650
- saveSuccess: "Fluxo publicado! O bot j\xE1 est\xE1 usando a vers\xE3o nova.",
651
- saveError: "N\xE3o foi poss\xEDvel salvar \u2014 verifique se todos os destinos apontam para n\xF3s existentes.",
652
- organize: "Organizar",
653
- organizeTooltip: "Reorganiza os n\xF3s automaticamente e salva as novas posi\xE7\xF5es",
654
- discardChanges: "Desfazer altera\xE7\xF5es",
655
- discardTooltip: "Devolve os fluxos abertos ao que est\xE1 publicado, descartando o que n\xE3o foi salvo",
656
- discardConfirm: "Descartar todas as altera\xE7\xF5es n\xE3o publicadas e voltar ao fluxo que est\xE1 no ar?",
657
- unsavedChangesConfirm: "Voc\xEA tem altera\xE7\xF5es n\xE3o publicadas neste fluxo. Trocar de fluxo agora descarta essas edi\xE7\xF5es. Continuar?"
658
- },
659
- flowManager: {
660
- newFlow: "Novo fluxo",
661
- createTitle: "Criar novo fluxo",
662
- key: "Identificador \xFAnico",
663
- keyHint: "letras min\xFAsculas, n\xFAmeros e _ (ex.: promocoes_semana)",
664
- keyInvalid: "Use apenas letras min\xFAsculas, n\xFAmeros e _ (2 a 40 caracteres)",
665
- label: "Nome exibido",
666
- showInMenu: "Exibir como op\xE7\xE3o no menu principal do bot",
667
- menuOptionLabel: "Texto da op\xE7\xE3o no menu",
668
- create: "Criar fluxo",
669
- creating: "Criando\u2026",
670
- deleteFlow: "Excluir fluxo",
671
- deleteConfirm: (label) => `Excluir o fluxo "${label}"? Esta a\xE7\xE3o n\xE3o pode ser desfeita.`,
672
- createError: "N\xE3o foi poss\xEDvel criar o fluxo.",
673
- deleteError: "N\xE3o foi poss\xEDvel excluir o fluxo."
674
- }
675
- };
676
- function mergeFlowEditorLabels(override) {
677
- if (!override) return DEFAULT_FLOW_EDITOR_LABELS;
678
- return {
679
- ...DEFAULT_FLOW_EDITOR_LABELS,
680
- ...override,
681
- legend: { ...DEFAULT_FLOW_EDITOR_LABELS.legend, ...override.legend },
682
- actionKindLabels: { ...DEFAULT_FLOW_EDITOR_LABELS.actionKindLabels, ...override.actionKindLabels },
683
- conditionOperatorLabels: {
684
- ...DEFAULT_FLOW_EDITOR_LABELS.conditionOperatorLabels,
685
- ...override.conditionOperatorLabels
686
- },
687
- questionTypeLabels: { ...DEFAULT_FLOW_EDITOR_LABELS.questionTypeLabels, ...override.questionTypeLabels },
688
- nodePanel: { ...DEFAULT_FLOW_EDITOR_LABELS.nodePanel, ...override.nodePanel },
689
- quickAdd: { ...DEFAULT_FLOW_EDITOR_LABELS.quickAdd, ...override.quickAdd },
690
- legendPanel: { ...DEFAULT_FLOW_EDITOR_LABELS.legendPanel, ...override.legendPanel },
691
- palette: { ...DEFAULT_FLOW_EDITOR_LABELS.palette, ...override.palette },
692
- flowMap: { ...DEFAULT_FLOW_EDITOR_LABELS.flowMap, ...override.flowMap },
693
- flowGroup: { ...DEFAULT_FLOW_EDITOR_LABELS.flowGroup, ...override.flowGroup },
694
- crossFlowPortal: { ...DEFAULT_FLOW_EDITOR_LABELS.crossFlowPortal, ...override.crossFlowPortal },
695
- collectionChain: { ...DEFAULT_FLOW_EDITOR_LABELS.collectionChain, ...override.collectionChain },
696
- validation: { ...DEFAULT_FLOW_EDITOR_LABELS.validation, ...override.validation },
697
- workspace: { ...DEFAULT_FLOW_EDITOR_LABELS.workspace, ...override.workspace },
698
- flowManager: { ...DEFAULT_FLOW_EDITOR_LABELS.flowManager, ...override.flowManager }
699
- };
771
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
772
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 uppercase tracking-wide font-semibold text-gray-500 dark:text-gray-400 text-xs", children: [
773
+ /* @__PURE__ */ jsx(Icon, { size: 12, strokeWidth: 2.5 }),
774
+ isStart && /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-emerald-500", "data-cv-tooltip": labels.startNodeTooltip }),
775
+ labels.legend[node.type] ?? DEFAULT_FLOW_EDITOR_LABELS.legend.dynamic_choice
776
+ ] }),
777
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
778
+ hasError && /* @__PURE__ */ jsx(
779
+ AlertCircle,
780
+ {
781
+ size: 13,
782
+ "data-cv-tooltip": issueTooltip,
783
+ "aria-label": issueTooltip,
784
+ className: "text-red-600 dark:text-red-400"
785
+ }
786
+ ),
787
+ hasWarning && /* @__PURE__ */ jsx(
788
+ AlertTriangle,
789
+ {
790
+ size: 13,
791
+ "data-cv-tooltip": issueTooltip,
792
+ "aria-label": issueTooltip,
793
+ className: "text-amber-500 dark:text-amber-400"
794
+ }
795
+ ),
796
+ liveCount > 0 && /* @__PURE__ */ jsx(
797
+ "span",
798
+ {
799
+ "data-cv-tooltip": labels.liveCountTooltip(liveCount),
800
+ className: "font-bold bg-blue-600 text-white rounded-full px-1.5 py-0.5 text-xs",
801
+ children: liveCount
802
+ }
803
+ )
804
+ ] })
805
+ ] }),
806
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-900 dark:text-gray-100 mt-1 line-clamp-3", children: label }),
807
+ rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-2 space-y-1", children: rows.map((row) => /* @__PURE__ */ jsx(
808
+ SourceRow,
809
+ {
810
+ label: row.label,
811
+ isDefault: row.isDefault,
812
+ handleId: row.id,
813
+ addLabel: labels.quickAdd.fromHandle,
814
+ isSelfLoop: row.isSelfLoop,
815
+ selfLoopLabel: labels.legendPanel.selfLoop,
816
+ ...onQuickAdd ? { onQuickAdd: (params) => onQuickAdd({ nodeId: node.id, ...params }) } : {}
817
+ },
818
+ row.id
819
+ )) })
820
+ ]
821
+ }
822
+ );
700
823
  }
824
+ var flowNodeTypes = { flowNode: FlowNodeCard };
701
825
 
702
826
  // src/flows/FlowMapNode.tsx
827
+ import { Handle as Handle2, Position as Position2 } from "@xyflow/react";
828
+ import { GitBranch as GitBranch2, Maximize2 } from "lucide-react";
703
829
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
704
830
  function FlowMapNode({ data }) {
705
831
  const { label, nodeCount, isRoot, labels = DEFAULT_FLOW_EDITOR_LABELS, onOpen } = data;
@@ -862,7 +988,7 @@ var flowPortalNodeTypes = { flowPortal: FlowPortalNode };
862
988
 
863
989
  // src/flows/FlowPalette.tsx
864
990
  import { useEffect, useLayoutEffect, useRef, useState as useState2 } from "react";
865
- import { Plus as Plus2, MessageCircleQuestion as MessageCircleQuestion2, GitBranch as GitBranch3, Zap as Zap2, Diamond as Diamond2, ChevronRight } from "lucide-react";
991
+ import { Plus as Plus2, MessageCircleQuestion as MessageCircleQuestion2, GitBranch as GitBranch3, Zap as Zap2, Diamond as Diamond2, ChevronRight, ListChecks as ListChecks2, MessageSquareText } from "lucide-react";
866
992
 
867
993
  // src/flows/flowMenuPlacement.ts
868
994
  var DEFAULT_GAP = 4;
@@ -903,6 +1029,7 @@ function FlowPaletteMenu({ onSelect, labels, actionOptions }) {
903
1029
  const resolvedActionOptions = actionOptions ?? [
904
1030
  { actionKind: "handoff", label: labels.actionKindLabels.handoff ?? "Encaminhar para atendimento" }
905
1031
  ];
1032
+ const runnerLabels = labels.runnerFields ?? DEFAULT_FLOW_RUNNER_FIELD_LABELS;
906
1033
  const [submenu, setSubmenu] = useState2(null);
907
1034
  const questionTriggerRef = useRef(null);
908
1035
  const actionTriggerRef = useRef(null);
@@ -1011,6 +1138,36 @@ function FlowPaletteMenu({ onSelect, labels, actionOptions }) {
1011
1138
  ]
1012
1139
  }
1013
1140
  ),
1141
+ /* @__PURE__ */ jsxs6(
1142
+ "button",
1143
+ {
1144
+ onMouseEnter: () => setSubmenu(null),
1145
+ onClick: () => select({ kind: "dynamicChoice" }),
1146
+ className: "w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",
1147
+ "data-cv-tooltip": runnerLabels.paletteDynamicChoiceHint,
1148
+ "aria-label": runnerLabels.paletteDynamicChoiceHint,
1149
+ children: [
1150
+ /* @__PURE__ */ jsx7(ListChecks2, { size: 15, className: "text-teal-500", "aria-hidden": "true" }),
1151
+ " ",
1152
+ runnerLabels.paletteDynamicChoice
1153
+ ]
1154
+ }
1155
+ ),
1156
+ /* @__PURE__ */ jsxs6(
1157
+ "button",
1158
+ {
1159
+ onMouseEnter: () => setSubmenu(null),
1160
+ onClick: () => select({ kind: "message" }),
1161
+ className: "w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",
1162
+ "data-cv-tooltip": runnerLabels.paletteMessageHint,
1163
+ "aria-label": runnerLabels.paletteMessageHint,
1164
+ children: [
1165
+ /* @__PURE__ */ jsx7(MessageSquareText, { size: 15, className: "text-orange-500", "aria-hidden": "true" }),
1166
+ " ",
1167
+ runnerLabels.paletteMessage
1168
+ ]
1169
+ }
1170
+ ),
1014
1171
  /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
1015
1172
  /* @__PURE__ */ jsxs6(
1016
1173
  "button",
@@ -1142,7 +1299,7 @@ function FlowLegend({ labels, edgeSamples, nodeSwatches }) {
1142
1299
  /* @__PURE__ */ jsxs7("ul", { className: "space-y-1.5", children: [
1143
1300
  nodeSwatches.map((swatch) => /* @__PURE__ */ jsxs7("li", { className: "flex items-center gap-2", children: [
1144
1301
  /* @__PURE__ */ jsx8("span", { className: `h-3 w-5 shrink-0 rounded border-2 ${swatch.className}`, "aria-hidden": "true" }),
1145
- /* @__PURE__ */ jsx8("span", { className: "text-[11px] leading-tight text-gray-600 dark:text-gray-300", children: labels.legend[swatch.type] })
1302
+ /* @__PURE__ */ jsx8("span", { className: "text-[11px] leading-tight text-gray-600 dark:text-gray-300", children: labels.legend[swatch.type] ?? DEFAULT_FLOW_EDITOR_LABELS.legend.dynamic_choice })
1146
1303
  ] }, swatch.type)),
1147
1304
  /* @__PURE__ */ jsxs7("li", { className: "flex items-center gap-2", children: [
1148
1305
  /* @__PURE__ */ jsx8(
@@ -1243,20 +1400,31 @@ var flowEdgeTypes = { flowConnection: FlowConnectionEdge };
1243
1400
 
1244
1401
  // src/flows/FlowNodePanel.tsx
1245
1402
  import { useState as useState5 } from "react";
1246
- import { Plus as Plus3, Trash2, Save, X as X3, AlertTriangle as AlertTriangle2, AlertCircle as AlertCircle2 } from "lucide-react";
1403
+ import { Plus as Plus5, Trash2 as Trash23, Save, X as X3, AlertTriangle as AlertTriangle2, AlertCircle as AlertCircle2 } from "lucide-react";
1247
1404
 
1248
1405
  // src/flows/FlowWhatsAppPreview.tsx
1249
1406
  import { List } from "lucide-react";
1250
1407
  import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1408
+ function groupBySection(options, optionDetails) {
1409
+ const sections = [];
1410
+ for (const option of options.slice(0, WHATSAPP_LIMITS.MAX_LIST_ROWS)) {
1411
+ const title = optionDetails?.[option[0]]?.section?.trim() || void 0;
1412
+ const existing = sections.find((section) => section.title === title);
1413
+ if (existing) existing.rows.push(option);
1414
+ else sections.push({ title, rows: [option] });
1415
+ }
1416
+ return sections;
1417
+ }
1251
1418
  function FlowWhatsAppPreview({
1252
1419
  body,
1253
1420
  options,
1421
+ optionDetails,
1254
1422
  labels = DEFAULT_FLOW_EDITOR_LABELS.nodePanel
1255
1423
  }) {
1256
1424
  if (!body && (!options || options.length === 0)) {
1257
1425
  return /* @__PURE__ */ jsx10("p", { className: "text-xs text-gray-400 dark:text-gray-500 italic px-1", children: labels.previewPlaceholder });
1258
1426
  }
1259
- const usesButtons = rendersAsButtons(options);
1427
+ const usesButtons = rendersAsButtons(options, optionDetails);
1260
1428
  const hasOptions = (options?.length ?? 0) > 0;
1261
1429
  return /* @__PURE__ */ jsxs9(
1262
1430
  WhatsAppMessagePreview,
@@ -1270,10 +1438,16 @@ function FlowWhatsAppPreview({
1270
1438
  },
1271
1439
  id
1272
1440
  )) }),
1273
- hasOptions && !usesButtons && /* @__PURE__ */ jsx10("div", { className: "mt-1.5 rounded-lg bg-white dark:bg-gray-700 shadow-sm divide-y divide-gray-100 dark:divide-gray-600 overflow-hidden", children: options.slice(0, WHATSAPP_LIMITS.MAX_LIST_ROWS).map(([id, label]) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 px-3 py-1.5 text-sm text-gray-800 dark:text-gray-100", children: [
1274
- /* @__PURE__ */ jsx10("span", { className: "h-3.5 w-3.5 rounded-full border border-gray-300 dark:border-gray-500 shrink-0" }),
1275
- label || /* @__PURE__ */ jsx10("span", { className: "italic text-gray-400", children: labels.previewEmptyOption })
1276
- ] }, id)) })
1441
+ hasOptions && !usesButtons && /* @__PURE__ */ jsx10("div", { className: "mt-1.5 rounded-lg bg-white dark:bg-gray-700 shadow-sm divide-y divide-gray-100 dark:divide-gray-600 overflow-hidden", children: groupBySection(options, optionDetails).map((section, sectionIndex) => /* @__PURE__ */ jsxs9("div", { children: [
1442
+ section.title && /* @__PURE__ */ jsx10("p", { className: "px-3 pt-1.5 text-[11px] font-medium uppercase text-cyan-700 dark:text-cyan-400", children: section.title }),
1443
+ section.rows.map(([id, label]) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 px-3 py-1.5 text-sm text-gray-800 dark:text-gray-100", children: [
1444
+ /* @__PURE__ */ jsx10("span", { className: "h-3.5 w-3.5 rounded-full border border-gray-300 dark:border-gray-500 shrink-0" }),
1445
+ /* @__PURE__ */ jsxs9("span", { className: "min-w-0", children: [
1446
+ label || /* @__PURE__ */ jsx10("span", { className: "italic text-gray-400", children: labels.previewEmptyOption }),
1447
+ optionDetails?.[id]?.description && /* @__PURE__ */ jsx10("span", { className: "block text-xs text-gray-500 dark:text-gray-400", children: optionDetails[id].description })
1448
+ ] })
1449
+ ] }, id))
1450
+ ] }, section.title ?? `section-${sectionIndex}`)) })
1277
1451
  ] }),
1278
1452
  footer: hasOptions && /* @__PURE__ */ jsx10("p", { className: "text-[11px] text-gray-500 dark:text-gray-400 px-1", children: usesButtons ? labels.previewModeButtons : labels.previewModeList }),
1279
1453
  children: [
@@ -1288,10 +1462,459 @@ function FlowWhatsAppPreview({
1288
1462
  );
1289
1463
  }
1290
1464
 
1465
+ // src/flows/FlowPossibleNextField.tsx
1466
+ import { Plus as Plus3, Trash2 } from "lucide-react";
1467
+
1468
+ // src/flows/flowPanelStyles.ts
1469
+ var PANEL_FIELD_CLASSNAME = "border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all";
1470
+ var PANEL_LABEL_CLASSNAME = "text-xs font-medium text-gray-500 dark:text-gray-400";
1471
+ var PANEL_HINT_CLASSNAME = "text-[11px] text-gray-400 dark:text-gray-500 mt-1";
1472
+
1473
+ // src/flows/FlowPossibleNextField.tsx
1474
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1475
+ function withPossibleNext(node, targets) {
1476
+ return { ...node, possibleNext: targets.length > 0 ? targets : void 0 };
1477
+ }
1478
+ function FlowPossibleNextField({
1479
+ draft,
1480
+ onDraftChange,
1481
+ renderTargetOptions,
1482
+ labels
1483
+ }) {
1484
+ const defaults = OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS;
1485
+ const targets = draft.possibleNext ?? [];
1486
+ const addLabel = labels.addPossibleNext ?? defaults.addPossibleNext;
1487
+ const removeLabel = labels.removePossibleNext ?? defaults.removePossibleNext;
1488
+ const fieldLabel = labels.possibleNext ?? defaults.possibleNext;
1489
+ function updateTarget(index, value) {
1490
+ const next = targets.map((target, targetIndex) => targetIndex === index ? value : target);
1491
+ onDraftChange((previous) => withPossibleNext(previous, next));
1492
+ }
1493
+ return /* @__PURE__ */ jsxs10("div", { className: "pt-2 border-t border-gray-100 dark:border-gray-700", children: [
1494
+ /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
1495
+ /* @__PURE__ */ jsx11("label", { className: PANEL_LABEL_CLASSNAME, children: fieldLabel }),
1496
+ /* @__PURE__ */ jsxs10(
1497
+ "button",
1498
+ {
1499
+ type: "button",
1500
+ "aria-label": addLabel,
1501
+ onClick: () => onDraftChange((previous) => withPossibleNext(previous, [...targets, ""])),
1502
+ className: "text-xs text-blue-600 hover:underline flex items-center gap-1",
1503
+ children: [
1504
+ /* @__PURE__ */ jsx11(Plus3, { size: 12, "aria-hidden": "true" }),
1505
+ " ",
1506
+ addLabel
1507
+ ]
1508
+ }
1509
+ )
1510
+ ] }),
1511
+ /* @__PURE__ */ jsx11("p", { className: PANEL_HINT_CLASSNAME, children: labels.possibleNextHint ?? defaults.possibleNextHint }),
1512
+ /* @__PURE__ */ jsx11("div", { className: "space-y-2 mt-1", children: targets.map((target, index) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1513
+ /* @__PURE__ */ jsxs10(
1514
+ "select",
1515
+ {
1516
+ value: target,
1517
+ "aria-label": fieldLabel,
1518
+ onChange: (event) => updateTarget(index, event.target.value),
1519
+ className: `flex-1 ${PANEL_FIELD_CLASSNAME}`,
1520
+ children: [
1521
+ /* @__PURE__ */ jsx11("option", { value: "", children: "\u2014" }),
1522
+ renderTargetOptions()
1523
+ ]
1524
+ }
1525
+ ),
1526
+ /* @__PURE__ */ jsx11(
1527
+ "button",
1528
+ {
1529
+ type: "button",
1530
+ "aria-label": removeLabel,
1531
+ onClick: () => onDraftChange(
1532
+ (previous) => withPossibleNext(
1533
+ previous,
1534
+ targets.filter((_, targetIndex) => targetIndex !== index)
1535
+ )
1536
+ ),
1537
+ className: "text-gray-400 hover:text-red-600",
1538
+ children: /* @__PURE__ */ jsx11(Trash2, { size: 14, "aria-hidden": "true" })
1539
+ }
1540
+ )
1541
+ ] }, index)) })
1542
+ ] });
1543
+ }
1544
+
1545
+ // src/flows/FlowKeywordRoutesField.tsx
1546
+ import { Plus as Plus4, Trash2 as Trash22 } from "lucide-react";
1547
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1548
+ function withRoutes(node, routes) {
1549
+ const current = typeof node.next === "object" && node.next ? node.next : { byAnswer: {}, default: node.next ?? "" };
1550
+ const rest = { ...current };
1551
+ delete rest.byKeyword;
1552
+ return { ...node, next: routes.length > 0 ? { ...rest, byKeyword: Object.fromEntries(routes) } : rest };
1553
+ }
1554
+ function FlowKeywordRoutesField({
1555
+ draft,
1556
+ onDraftChange,
1557
+ renderTargetOptions,
1558
+ labels
1559
+ }) {
1560
+ const routes = typeof draft.next === "object" && draft.next?.byKeyword ? Object.entries(draft.next.byKeyword) : [];
1561
+ function updateRoute(index, field, value) {
1562
+ const next = routes.map((route, routeIndex) => {
1563
+ if (routeIndex !== index) return route;
1564
+ return field === 0 ? [value, route[1]] : [route[0], value];
1565
+ });
1566
+ onDraftChange((previous) => withRoutes(previous, next));
1567
+ }
1568
+ function addRoute() {
1569
+ onDraftChange((previous) => withRoutes(previous, [...routes, [labels.keywordPlaceholder, ""]]));
1570
+ }
1571
+ function removeRoute(index) {
1572
+ onDraftChange(
1573
+ (previous) => withRoutes(
1574
+ previous,
1575
+ routes.filter((_, routeIndex) => routeIndex !== index)
1576
+ )
1577
+ );
1578
+ }
1579
+ return /* @__PURE__ */ jsxs11("div", { children: [
1580
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
1581
+ /* @__PURE__ */ jsx12("label", { className: PANEL_LABEL_CLASSNAME, children: labels.keywordRoutes }),
1582
+ /* @__PURE__ */ jsxs11(
1583
+ "button",
1584
+ {
1585
+ type: "button",
1586
+ "data-cv-tooltip": labels.addKeywordRoute,
1587
+ "aria-label": labels.addKeywordRoute,
1588
+ onClick: addRoute,
1589
+ className: "text-xs text-blue-600 hover:underline flex items-center gap-1",
1590
+ children: [
1591
+ /* @__PURE__ */ jsx12(Plus4, { size: 12, "aria-hidden": "true" }),
1592
+ " ",
1593
+ labels.addKeywordRoute
1594
+ ]
1595
+ }
1596
+ )
1597
+ ] }),
1598
+ /* @__PURE__ */ jsx12("p", { className: PANEL_HINT_CLASSNAME, children: labels.keywordRoutesHint }),
1599
+ /* @__PURE__ */ jsx12("div", { className: "space-y-2 mt-1", children: routes.map(([keyword, target], index) => /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
1600
+ /* @__PURE__ */ jsx12(
1601
+ "input",
1602
+ {
1603
+ value: keyword,
1604
+ "aria-label": labels.keywordRoutes,
1605
+ onChange: (event) => updateRoute(index, 0, event.target.value),
1606
+ className: `w-28 ${PANEL_FIELD_CLASSNAME}`
1607
+ }
1608
+ ),
1609
+ /* @__PURE__ */ jsxs11(
1610
+ "select",
1611
+ {
1612
+ value: target,
1613
+ "aria-label": labels.keywordRoutes,
1614
+ onChange: (event) => updateRoute(index, 1, event.target.value),
1615
+ className: `flex-1 ${PANEL_FIELD_CLASSNAME}`,
1616
+ children: [
1617
+ /* @__PURE__ */ jsx12("option", { value: "", children: "\u2014" }),
1618
+ renderTargetOptions()
1619
+ ]
1620
+ }
1621
+ ),
1622
+ /* @__PURE__ */ jsx12(
1623
+ "button",
1624
+ {
1625
+ type: "button",
1626
+ "data-cv-tooltip": labels.removeKeywordRoute,
1627
+ "aria-label": labels.removeKeywordRoute,
1628
+ onClick: () => removeRoute(index),
1629
+ className: "text-gray-400 hover:text-red-600",
1630
+ children: /* @__PURE__ */ jsx12(Trash22, { size: 14, "aria-hidden": "true" })
1631
+ }
1632
+ )
1633
+ ] }, index)) })
1634
+ ] });
1635
+ }
1636
+
1637
+ // src/flows/FlowRunnerFields.tsx
1638
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1639
+ function toNumber(value) {
1640
+ if (value.trim() === "") return void 0;
1641
+ const parsed = Number(value);
1642
+ return Number.isFinite(parsed) ? parsed : void 0;
1643
+ }
1644
+ function withValidation(node, patch) {
1645
+ const merged = { ...node.validation, ...patch };
1646
+ const cleaned = Object.fromEntries(Object.entries(merged).filter(([, value]) => value !== void 0 && value !== ""));
1647
+ return { ...node, validation: Object.keys(cleaned).length > 0 ? cleaned : void 0 };
1648
+ }
1649
+ function NumberField(props) {
1650
+ return /* @__PURE__ */ jsxs12("div", { className: "flex-1", children: [
1651
+ /* @__PURE__ */ jsx13("label", { className: PANEL_LABEL_CLASSNAME, children: props.label }),
1652
+ /* @__PURE__ */ jsx13(
1653
+ "input",
1654
+ {
1655
+ type: "number",
1656
+ value: props.value ?? "",
1657
+ onChange: (event) => props.onValueChange(toNumber(event.target.value)),
1658
+ className: `w-full mt-1 ${PANEL_FIELD_CLASSNAME}`
1659
+ }
1660
+ )
1661
+ ] });
1662
+ }
1663
+ function ContextKeyField(props) {
1664
+ return /* @__PURE__ */ jsxs12("div", { children: [
1665
+ /* @__PURE__ */ jsx13("label", { className: PANEL_LABEL_CLASSNAME, children: props.label }),
1666
+ /* @__PURE__ */ jsx13(
1667
+ "input",
1668
+ {
1669
+ value: props.value ?? "",
1670
+ list: "runner-context-keys",
1671
+ onChange: (event) => props.onValueChange(event.target.value || void 0),
1672
+ className: `w-full mt-1 ${PANEL_FIELD_CLASSNAME}`
1673
+ }
1674
+ ),
1675
+ /* @__PURE__ */ jsx13("datalist", { id: "runner-context-keys", children: props.knownContextKeys.map((key) => /* @__PURE__ */ jsx13("option", { value: key }, key)) }),
1676
+ props.hint && /* @__PURE__ */ jsx13("p", { className: PANEL_HINT_CLASSNAME, children: props.hint })
1677
+ ] });
1678
+ }
1679
+ function TimeValidationFields({ draft, onDraftChange, knownContextKeys, labels }) {
1680
+ const validation = draft.validation ?? {};
1681
+ const update = (patch) => onDraftChange((previous) => withValidation(previous, patch));
1682
+ const defaults = OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS;
1683
+ const timeInput = (label, value, onValueChange) => /* @__PURE__ */ jsxs12("div", { className: "flex-1", children: [
1684
+ /* @__PURE__ */ jsx13("label", { className: PANEL_LABEL_CLASSNAME, children: label }),
1685
+ /* @__PURE__ */ jsx13(
1686
+ "input",
1687
+ {
1688
+ type: "time",
1689
+ value: value ?? "",
1690
+ onChange: (event) => onValueChange(event.target.value || void 0),
1691
+ className: `w-full mt-1 ${PANEL_FIELD_CLASSNAME}`
1692
+ }
1693
+ )
1694
+ ] });
1695
+ return /* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
1696
+ /* @__PURE__ */ jsxs12("div", { className: "flex gap-2", children: [
1697
+ timeInput(labels.minTime ?? defaults.minTime, validation.minTime, (minTime) => update({ minTime })),
1698
+ timeInput(labels.maxTime ?? defaults.maxTime, validation.maxTime, (maxTime) => update({ maxTime }))
1699
+ ] }),
1700
+ /* @__PURE__ */ jsx13(
1701
+ ContextKeyField,
1702
+ {
1703
+ label: labels.timeWindowsContextKey ?? defaults.timeWindowsContextKey,
1704
+ hint: labels.timeWindowsContextKeyHint ?? defaults.timeWindowsContextKeyHint,
1705
+ value: validation.windowsContextKey,
1706
+ knownContextKeys,
1707
+ onValueChange: (windowsContextKey) => update({ windowsContextKey })
1708
+ }
1709
+ )
1710
+ ] });
1711
+ }
1712
+ function ValidationFields(props) {
1713
+ const { draft, onDraftChange, knownContextKeys, labels } = props;
1714
+ const validation = draft.validation ?? {};
1715
+ const update = (patch) => onDraftChange((previous) => withValidation(previous, patch));
1716
+ if (draft.questionType === "date") {
1717
+ return /* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
1718
+ /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-2 text-xs text-gray-600 dark:text-gray-300", children: [
1719
+ /* @__PURE__ */ jsx13(
1720
+ "input",
1721
+ {
1722
+ type: "checkbox",
1723
+ checked: validation.minDate === "today",
1724
+ onChange: (event) => update({ minDate: event.target.checked ? "today" : void 0 })
1725
+ }
1726
+ ),
1727
+ labels.minDateToday
1728
+ ] }),
1729
+ /* @__PURE__ */ jsx13(
1730
+ ContextKeyField,
1731
+ {
1732
+ label: labels.afterContextKey,
1733
+ value: validation.afterContextKey,
1734
+ knownContextKeys,
1735
+ onValueChange: (afterContextKey) => update({ afterContextKey })
1736
+ }
1737
+ )
1738
+ ] });
1739
+ }
1740
+ if (draft.questionType === "time") return /* @__PURE__ */ jsx13(TimeValidationFields, { ...props });
1741
+ if (draft.questionType === "int" || draft.questionType === "money") {
1742
+ return /* @__PURE__ */ jsxs12("div", { className: "flex gap-2", children: [
1743
+ /* @__PURE__ */ jsx13(NumberField, { label: labels.minValue, value: validation.min, onValueChange: (min) => update({ min }) }),
1744
+ /* @__PURE__ */ jsx13(NumberField, { label: labels.maxValue, value: validation.max, onValueChange: (max) => update({ max }) })
1745
+ ] });
1746
+ }
1747
+ if (!draft.questionType || draft.questionType === "text") {
1748
+ return /* @__PURE__ */ jsxs12("div", { className: "flex gap-2", children: [
1749
+ /* @__PURE__ */ jsx13(
1750
+ NumberField,
1751
+ {
1752
+ label: labels.minLength,
1753
+ value: validation.minLength,
1754
+ onValueChange: (minLength) => update({ minLength })
1755
+ }
1756
+ ),
1757
+ /* @__PURE__ */ jsx13(
1758
+ NumberField,
1759
+ {
1760
+ label: labels.maxLength,
1761
+ value: validation.maxLength,
1762
+ onValueChange: (maxLength) => update({ maxLength })
1763
+ }
1764
+ )
1765
+ ] });
1766
+ }
1767
+ return null;
1768
+ }
1769
+ function OptionDetailsField({ draft, onDraftChange, labels }) {
1770
+ const options = draft.options ?? [];
1771
+ if (options.length === 0) return null;
1772
+ function updateDetail(optionId, field, value) {
1773
+ onDraftChange((previous) => {
1774
+ const current = previous.optionDetails?.[optionId] ?? {};
1775
+ const detail = { ...current, [field]: value || void 0 };
1776
+ return { ...previous, optionDetails: { ...previous.optionDetails, [optionId]: detail } };
1777
+ });
1778
+ }
1779
+ return /* @__PURE__ */ jsx13("div", { className: "space-y-2", children: options.map(([optionId, title]) => /* @__PURE__ */ jsxs12("div", { className: "space-y-1", children: [
1780
+ /* @__PURE__ */ jsx13("span", { className: "text-[11px] font-medium text-gray-500 dark:text-gray-400", children: title || optionId }),
1781
+ /* @__PURE__ */ jsxs12("div", { className: "flex gap-2", children: [
1782
+ /* @__PURE__ */ jsx13(
1783
+ "input",
1784
+ {
1785
+ value: draft.optionDetails?.[optionId]?.description ?? "",
1786
+ placeholder: labels.optionDescription,
1787
+ "aria-label": `${labels.optionDescription}: ${title}`,
1788
+ onChange: (event) => updateDetail(optionId, "description", event.target.value),
1789
+ className: `flex-1 ${PANEL_FIELD_CLASSNAME}`
1790
+ }
1791
+ ),
1792
+ /* @__PURE__ */ jsx13(
1793
+ "input",
1794
+ {
1795
+ value: draft.optionDetails?.[optionId]?.section ?? "",
1796
+ placeholder: labels.optionSection,
1797
+ "aria-label": `${labels.optionSection}: ${title}`,
1798
+ onChange: (event) => updateDetail(optionId, "section", event.target.value),
1799
+ className: `w-24 ${PANEL_FIELD_CLASSNAME}`
1800
+ }
1801
+ )
1802
+ ] })
1803
+ ] }, optionId)) });
1804
+ }
1805
+ function TextField(props) {
1806
+ return /* @__PURE__ */ jsxs12("div", { children: [
1807
+ /* @__PURE__ */ jsx13("label", { className: PANEL_LABEL_CLASSNAME, children: props.label }),
1808
+ /* @__PURE__ */ jsx13(
1809
+ "input",
1810
+ {
1811
+ value: props.value,
1812
+ placeholder: props.placeholder,
1813
+ onChange: (event) => props.onValueChange(event.target.value),
1814
+ className: `w-full mt-1 ${PANEL_FIELD_CLASSNAME}`
1815
+ }
1816
+ ),
1817
+ props.hint && /* @__PURE__ */ jsx13("p", { className: PANEL_HINT_CLASSNAME, children: props.hint })
1818
+ ] });
1819
+ }
1820
+ function FlowRunnerFields(props) {
1821
+ const { draft, onDraftChange, labels } = props;
1822
+ const isDynamic = draft.type === "dynamic_choice";
1823
+ const isChoice = draft.type === "menu" || draft.questionType === "choice";
1824
+ const isQuestion = draft.type === "question" && !isChoice;
1825
+ return /* @__PURE__ */ jsxs12("div", { className: "pt-2 border-t border-gray-100 dark:border-gray-700 space-y-3", children: [
1826
+ /* @__PURE__ */ jsx13("p", { className: "text-xs font-semibold text-gray-700 dark:text-gray-200", children: labels.section }),
1827
+ /* @__PURE__ */ jsx13("p", { className: PANEL_HINT_CLASSNAME, children: labels.placeholdersHint }),
1828
+ isDynamic && /* @__PURE__ */ jsxs12(Fragment4, { children: [
1829
+ /* @__PURE__ */ jsx13(
1830
+ TextField,
1831
+ {
1832
+ label: labels.choiceProvider,
1833
+ hint: labels.choiceProviderHint,
1834
+ value: draft.choiceProvider ?? "",
1835
+ onValueChange: (value) => onDraftChange((previous) => ({ ...previous, choiceProvider: value || void 0 }))
1836
+ }
1837
+ ),
1838
+ /* @__PURE__ */ jsx13(
1839
+ TextField,
1840
+ {
1841
+ label: labels.contextKey,
1842
+ value: draft.contextKey ?? "",
1843
+ onValueChange: (value) => onDraftChange((previous) => ({ ...previous, contextKey: value || void 0 }))
1844
+ }
1845
+ )
1846
+ ] }),
1847
+ isQuestion && /* @__PURE__ */ jsx13(ValidationFields, { ...props }),
1848
+ isChoice && /* @__PURE__ */ jsx13(OptionDetailsField, { ...props }),
1849
+ isChoice && /* @__PURE__ */ jsxs12("div", { children: [
1850
+ /* @__PURE__ */ jsx13("label", { className: PANEL_LABEL_CLASSNAME, children: labels.unmatchedChoice }),
1851
+ /* @__PURE__ */ jsxs12(
1852
+ "select",
1853
+ {
1854
+ value: draft.unmatchedChoice ?? "reask",
1855
+ onChange: (event) => {
1856
+ const value = event.target.value === "default" ? "default" : void 0;
1857
+ onDraftChange((previous) => ({ ...previous, unmatchedChoice: value }));
1858
+ },
1859
+ className: `w-full mt-1 ${PANEL_FIELD_CLASSNAME}`,
1860
+ children: [
1861
+ /* @__PURE__ */ jsx13("option", { value: "reask", children: labels.unmatchedChoiceReask }),
1862
+ /* @__PURE__ */ jsx13("option", { value: "default", children: labels.unmatchedChoiceDefault })
1863
+ ]
1864
+ }
1865
+ )
1866
+ ] }),
1867
+ (isChoice || isDynamic) && /* @__PURE__ */ jsx13(
1868
+ TextField,
1869
+ {
1870
+ label: labels.listButtonLabel,
1871
+ value: draft.listButtonLabel ?? "",
1872
+ onValueChange: (value) => onDraftChange((previous) => ({ ...previous, listButtonLabel: value || void 0 }))
1873
+ }
1874
+ ),
1875
+ isQuestion && /* @__PURE__ */ jsx13(
1876
+ TextField,
1877
+ {
1878
+ label: labels.skipKeywords,
1879
+ hint: labels.skipKeywordsHint,
1880
+ value: (draft.skipKeywords ?? []).join(", "),
1881
+ onValueChange: (value) => {
1882
+ const keywords = value.split(",").map((keyword) => keyword.trim()).filter(Boolean);
1883
+ onDraftChange((previous) => ({ ...previous, skipKeywords: keywords.length > 0 ? keywords : void 0 }));
1884
+ }
1885
+ }
1886
+ ),
1887
+ /* @__PURE__ */ jsx13(
1888
+ TextField,
1889
+ {
1890
+ label: labels.fallbackMessage,
1891
+ placeholder: labels.fallbackPlaceholder,
1892
+ value: draft.fallbackMessage ?? "",
1893
+ onValueChange: (value) => onDraftChange((previous) => ({ ...previous, fallbackMessage: value || void 0 }))
1894
+ }
1895
+ ),
1896
+ /* @__PURE__ */ jsxs12("div", { children: [
1897
+ /* @__PURE__ */ jsx13(
1898
+ NumberField,
1899
+ {
1900
+ label: labels.maxInvalidAnswers,
1901
+ value: draft.maxInvalidAnswers,
1902
+ onValueChange: (value) => onDraftChange((previous) => ({
1903
+ ...previous,
1904
+ maxInvalidAnswers: value && value > 0 ? Math.floor(value) : void 0
1905
+ }))
1906
+ }
1907
+ ),
1908
+ /* @__PURE__ */ jsx13("p", { className: PANEL_HINT_CLASSNAME, children: labels.maxInvalidAnswersHint })
1909
+ ] }),
1910
+ (draft.type === "menu" || draft.type === "question") && /* @__PURE__ */ jsx13(FlowKeywordRoutesField, { ...props })
1911
+ ] });
1912
+ }
1913
+
1291
1914
  // src/flows/FlowNodePanel.tsx
1292
- import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1293
- var SELECT_CLASSNAME = "border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all";
1294
- var INPUT_CLASSNAME = "border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all";
1915
+ import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1916
+ var SELECT_CLASSNAME = PANEL_FIELD_CLASSNAME;
1917
+ var INPUT_CLASSNAME = PANEL_FIELD_CLASSNAME;
1295
1918
  function truncateLabel(value, max = 60) {
1296
1919
  if (!value) return "\u2014";
1297
1920
  return value.length > max ? `${value.slice(0, max - 1)}\u2026` : value;
@@ -1301,13 +1924,14 @@ function WhatsAppTextField({
1301
1924
  value,
1302
1925
  onValueChange,
1303
1926
  options,
1927
+ optionDetails,
1304
1928
  placeholder,
1305
1929
  labels
1306
1930
  }) {
1307
- return /* @__PURE__ */ jsxs10("div", { className: "space-y-2", children: [
1308
- /* @__PURE__ */ jsxs10("div", { children: [
1309
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: label }),
1310
- /* @__PURE__ */ jsx11(
1931
+ return /* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
1932
+ /* @__PURE__ */ jsxs13("div", { children: [
1933
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: label }),
1934
+ /* @__PURE__ */ jsx14(
1311
1935
  "textarea",
1312
1936
  {
1313
1937
  value,
@@ -1318,18 +1942,18 @@ function WhatsAppTextField({
1318
1942
  }
1319
1943
  )
1320
1944
  ] }),
1321
- /* @__PURE__ */ jsxs10("div", { children: [
1322
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.preview }),
1323
- /* @__PURE__ */ jsx11("div", { className: "mt-1", children: /* @__PURE__ */ jsx11(FlowWhatsAppPreview, { body: value, options, labels: labels.nodePanel }) })
1945
+ /* @__PURE__ */ jsxs13("div", { children: [
1946
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.preview }),
1947
+ /* @__PURE__ */ jsx14("div", { className: "mt-1", children: /* @__PURE__ */ jsx14(FlowWhatsAppPreview, { body: value, options, optionDetails, labels: labels.nodePanel }) })
1324
1948
  ] })
1325
1949
  ] });
1326
1950
  }
1327
1951
  function IssueRow({ issue }) {
1328
1952
  const Icon = issue.severity === "error" ? AlertCircle2 : AlertTriangle2;
1329
1953
  const color = issue.severity === "error" ? "text-red-600 dark:text-red-400" : "text-amber-600 dark:text-amber-400";
1330
- return /* @__PURE__ */ jsxs10("div", { className: `flex items-start gap-1.5 text-xs ${color}`, children: [
1331
- /* @__PURE__ */ jsx11(Icon, { size: 13, className: "mt-0.5 shrink-0" }),
1332
- /* @__PURE__ */ jsx11("span", { children: issue.message })
1954
+ return /* @__PURE__ */ jsxs13("div", { className: `flex items-start gap-1.5 text-xs ${color}`, children: [
1955
+ /* @__PURE__ */ jsx14(Icon, { size: 13, className: "mt-0.5 shrink-0" }),
1956
+ /* @__PURE__ */ jsx14("span", { children: issue.message })
1333
1957
  ] });
1334
1958
  }
1335
1959
  function FlowNodePanel({
@@ -1349,8 +1973,9 @@ function FlowNodePanel({
1349
1973
  const isFixedLogic = draft.type === "entrada_choice";
1350
1974
  const isAction = draft.type === "action";
1351
1975
  const isSendMedia = isAction && draft.actionKind === BUILT_IN_ACTION_KINDS.SEND_MEDIA;
1352
- const isPassThroughAction = isAction && Boolean(draft.actionKind && PASS_THROUGH_ACTION_KINDS.includes(draft.actionKind));
1976
+ const isPassThroughAction2 = isPassThroughAction(draft);
1353
1977
  const isCondition = draft.type === "condition";
1978
+ const isDynamicChoice = draft.type === "dynamic_choice";
1354
1979
  const isStart = graph.startNodeId === node.id;
1355
1980
  const nodeIssues = issues.filter((i) => i.nodeId === node.id);
1356
1981
  const knownContextKeys = [
@@ -1393,24 +2018,24 @@ function FlowNodePanel({
1393
2018
  setDraft((prev) => ({ ...prev, options: (prev.options ?? []).filter((_, i) => i !== index) }));
1394
2019
  }
1395
2020
  function nextNodeOptions() {
1396
- return /* @__PURE__ */ jsxs10(Fragment4, { children: [
1397
- otherNodeIds.map((id) => /* @__PURE__ */ jsx11("option", { value: id, children: truncateLabel(nodeLabel(graph.nodes[id], labels)) }, id)),
1398
- otherFlows.length > 0 && /* @__PURE__ */ jsx11("optgroup", { label: labels.nodePanel.otherFlowsGroup, children: otherFlows.map((flow) => /* @__PURE__ */ jsx11("option", { value: `${CROSS_FLOW_PREFIX}${flow.key}`, children: flow.label }, flow.key)) })
2021
+ return /* @__PURE__ */ jsxs13(Fragment5, { children: [
2022
+ otherNodeIds.map((id) => /* @__PURE__ */ jsx14("option", { value: id, children: truncateLabel(nodeLabel(graph.nodes[id], labels)) }, id)),
2023
+ otherFlows.length > 0 && /* @__PURE__ */ jsx14("optgroup", { label: labels.nodePanel.otherFlowsGroup, children: otherFlows.map((flow) => /* @__PURE__ */ jsx14("option", { value: `${CROSS_FLOW_PREFIX}${flow.key}`, children: flow.label }, flow.key)) })
1399
2024
  ] });
1400
2025
  }
1401
- return /* @__PURE__ */ jsxs10("div", { className: "fixed inset-y-0 right-0 w-96 bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 shadow-xl z-50 flex flex-col", children: [
1402
- /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-700", children: [
1403
- /* @__PURE__ */ jsx11("h3", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: labels.nodePanel.title }),
1404
- /* @__PURE__ */ jsx11("button", { "data-cv-tooltip": labels.nodePanel.close, "aria-label": labels.nodePanel.close, onClick: onClose, className: "text-gray-400 hover:text-gray-600", children: /* @__PURE__ */ jsx11(X3, { size: 18 }) })
2026
+ return /* @__PURE__ */ jsxs13("div", { className: "fixed inset-y-0 right-0 w-96 bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 shadow-xl z-50 flex flex-col", children: [
2027
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-700", children: [
2028
+ /* @__PURE__ */ jsx14("h3", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: labels.nodePanel.title }),
2029
+ /* @__PURE__ */ jsx14("button", { "data-cv-tooltip": labels.nodePanel.close, "aria-label": labels.nodePanel.close, onClick: onClose, className: "text-gray-400 hover:text-gray-600", children: /* @__PURE__ */ jsx14(X3, { size: 18 }) })
1405
2030
  ] }),
1406
- /* @__PURE__ */ jsxs10("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: [
1407
- nodeIssues.length > 0 && /* @__PURE__ */ jsx11("div", { className: "rounded-lg border border-gray-100 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 p-2.5 space-y-1.5", children: nodeIssues.map((issue, i) => /* @__PURE__ */ jsx11(IssueRow, { issue }, i)) }),
1408
- isFixedLogic && /* @__PURE__ */ jsx11("p", { className: "text-xs text-purple-700 dark:text-purple-400 bg-purple-50 dark:bg-purple-950/30 rounded-lg p-2", children: labels.nodePanel.fixedLogicNotice }),
1409
- isAction && /* @__PURE__ */ jsx11("p", { className: "text-xs text-orange-700 dark:text-orange-400 bg-orange-50 dark:bg-orange-950/30 rounded-lg p-2", children: labels.nodePanel.actionNotice }),
1410
- isCondition && /* @__PURE__ */ jsx11("p", { className: "text-xs text-cyan-700 dark:text-cyan-400 bg-cyan-50 dark:bg-cyan-950/30 rounded-lg p-2", children: labels.nodePanel.conditionNotice }),
1411
- /* @__PURE__ */ jsxs10("div", { children: [
1412
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.nodeName }),
1413
- /* @__PURE__ */ jsx11(
2031
+ /* @__PURE__ */ jsxs13("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: [
2032
+ nodeIssues.length > 0 && /* @__PURE__ */ jsx14("div", { className: "rounded-lg border border-gray-100 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 p-2.5 space-y-1.5", children: nodeIssues.map((issue, i) => /* @__PURE__ */ jsx14(IssueRow, { issue }, i)) }),
2033
+ isFixedLogic && /* @__PURE__ */ jsx14("p", { className: "text-xs text-purple-700 dark:text-purple-400 bg-purple-50 dark:bg-purple-950/30 rounded-lg p-2", children: labels.nodePanel.fixedLogicNotice }),
2034
+ isAction && /* @__PURE__ */ jsx14("p", { className: "text-xs text-orange-700 dark:text-orange-400 bg-orange-50 dark:bg-orange-950/30 rounded-lg p-2", children: labels.nodePanel.actionNotice }),
2035
+ isCondition && /* @__PURE__ */ jsx14("p", { className: "text-xs text-cyan-700 dark:text-cyan-400 bg-cyan-50 dark:bg-cyan-950/30 rounded-lg p-2", children: labels.nodePanel.conditionNotice }),
2036
+ /* @__PURE__ */ jsxs13("div", { children: [
2037
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.nodeName }),
2038
+ /* @__PURE__ */ jsx14(
1414
2039
  "input",
1415
2040
  {
1416
2041
  value: draft.label ?? "",
@@ -1419,11 +2044,11 @@ function FlowNodePanel({
1419
2044
  className: `w-full mt-1 ${INPUT_CLASSNAME}`
1420
2045
  }
1421
2046
  ),
1422
- /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-gray-400 dark:text-gray-500 mt-1", children: labels.nodePanel.nodeNameHint })
2047
+ /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-gray-400 dark:text-gray-500 mt-1", children: labels.nodePanel.nodeNameHint })
1423
2048
  ] }),
1424
- draft.contextKey && /* @__PURE__ */ jsxs10("div", { children: [
1425
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.contextKey }),
1426
- /* @__PURE__ */ jsx11(
2049
+ draft.contextKey && /* @__PURE__ */ jsxs13("div", { children: [
2050
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.contextKey }),
2051
+ /* @__PURE__ */ jsx14(
1427
2052
  "input",
1428
2053
  {
1429
2054
  value: draft.contextKey,
@@ -1432,32 +2057,33 @@ function FlowNodePanel({
1432
2057
  }
1433
2058
  )
1434
2059
  ] }),
1435
- !isFixedLogic && !isAction && !isCondition && /* @__PURE__ */ jsxs10("div", { children: [
1436
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.questionType }),
1437
- /* @__PURE__ */ jsx11(
2060
+ !isFixedLogic && !isAction && !isCondition && !isDynamicChoice && /* @__PURE__ */ jsxs13("div", { children: [
2061
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.questionType }),
2062
+ /* @__PURE__ */ jsx14(
1438
2063
  "select",
1439
2064
  {
1440
2065
  value: draft.questionType ?? "text",
1441
2066
  onChange: (e) => setDraft((prev) => ({ ...prev, questionType: e.target.value })),
1442
2067
  className: `w-full mt-1 ${SELECT_CLASSNAME}`,
1443
- children: Object.entries(labels.questionTypeLabels).map(([key, label]) => /* @__PURE__ */ jsx11("option", { value: key, children: label }, key))
2068
+ children: Object.entries(labels.questionTypeLabels).map(([key, label]) => /* @__PURE__ */ jsx14("option", { value: key, children: label }, key))
1444
2069
  }
1445
2070
  )
1446
2071
  ] }),
1447
- !isFixedLogic && !isAction && !isCondition && /* @__PURE__ */ jsx11(
2072
+ !isFixedLogic && !isAction && !isCondition && /* @__PURE__ */ jsx14(
1448
2073
  WhatsAppTextField,
1449
2074
  {
1450
2075
  label: labels.nodePanel.question,
1451
2076
  value: draft.question ?? "",
1452
- options: draft.questionType === "choice" ? draft.options : void 0,
2077
+ options: draft.questionType === "choice" || draft.type === "menu" ? draft.options : void 0,
2078
+ optionDetails: draft.optionDetails,
1453
2079
  onValueChange: (value) => setDraft((prev) => ({ ...prev, question: value })),
1454
2080
  labels
1455
2081
  }
1456
2082
  ),
1457
- isCondition && /* @__PURE__ */ jsxs10("div", { className: "space-y-3", children: [
1458
- /* @__PURE__ */ jsxs10("div", { children: [
1459
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionVariable }),
1460
- /* @__PURE__ */ jsx11(
2083
+ isCondition && /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
2084
+ /* @__PURE__ */ jsxs13("div", { children: [
2085
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionVariable }),
2086
+ /* @__PURE__ */ jsx14(
1461
2087
  "input",
1462
2088
  {
1463
2089
  value: draft.conditionContextKey ?? "",
@@ -1466,11 +2092,11 @@ function FlowNodePanel({
1466
2092
  className: `w-full mt-1 ${INPUT_CLASSNAME}`
1467
2093
  }
1468
2094
  ),
1469
- /* @__PURE__ */ jsx11("datalist", { id: "condition-context-keys", children: knownContextKeys.map((key) => /* @__PURE__ */ jsx11("option", { value: key }, key)) })
2095
+ /* @__PURE__ */ jsx14("datalist", { id: "condition-context-keys", children: knownContextKeys.map((key) => /* @__PURE__ */ jsx14("option", { value: key }, key)) })
1470
2096
  ] }),
1471
- /* @__PURE__ */ jsxs10("div", { children: [
1472
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionOperator }),
1473
- /* @__PURE__ */ jsx11(
2097
+ /* @__PURE__ */ jsxs13("div", { children: [
2098
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionOperator }),
2099
+ /* @__PURE__ */ jsx14(
1474
2100
  "select",
1475
2101
  {
1476
2102
  value: draft.conditionOperator ?? ">",
@@ -1479,13 +2105,13 @@ function FlowNodePanel({
1479
2105
  conditionOperator: e.target.value
1480
2106
  })),
1481
2107
  className: `w-full mt-1 ${SELECT_CLASSNAME}`,
1482
- children: CONDITION_OPERATORS.map((operator) => /* @__PURE__ */ jsx11("option", { value: operator, children: labels.conditionOperatorLabels[operator] ?? operator }, operator))
2108
+ children: CONDITION_OPERATORS.map((operator) => /* @__PURE__ */ jsx14("option", { value: operator, children: labels.conditionOperatorLabels[operator] ?? operator }, operator))
1483
2109
  }
1484
2110
  )
1485
2111
  ] }),
1486
- /* @__PURE__ */ jsxs10("div", { children: [
1487
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionValue }),
1488
- /* @__PURE__ */ jsx11(
2112
+ /* @__PURE__ */ jsxs13("div", { children: [
2113
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.conditionValue }),
2114
+ /* @__PURE__ */ jsx14(
1489
2115
  "input",
1490
2116
  {
1491
2117
  value: draft.conditionValue ?? "",
@@ -1495,7 +2121,7 @@ function FlowNodePanel({
1495
2121
  )
1496
2122
  ] })
1497
2123
  ] }),
1498
- isAction && draft.actionKind === "send_product_list" && /* @__PURE__ */ jsx11(
2124
+ isAction && draft.actionKind === "send_product_list" && /* @__PURE__ */ jsx14(
1499
2125
  WhatsAppTextField,
1500
2126
  {
1501
2127
  label: labels.nodePanel.fallbackMessage,
@@ -1505,11 +2131,11 @@ function FlowNodePanel({
1505
2131
  labels
1506
2132
  }
1507
2133
  ),
1508
- isSendMedia && /* @__PURE__ */ jsxs10("div", { children: [
1509
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.media }),
1510
- /* @__PURE__ */ jsx11("div", { className: "mt-1", children: renderMediaPicker?.(node, graph) ?? /* @__PURE__ */ jsx11("p", { className: "text-xs text-gray-400", children: labels.nodePanel.mediaUnavailable }) })
2134
+ isSendMedia && /* @__PURE__ */ jsxs13("div", { children: [
2135
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.media }),
2136
+ /* @__PURE__ */ jsx14("div", { className: "mt-1", children: renderMediaPicker?.(node, graph) ?? /* @__PURE__ */ jsx14("p", { className: "text-xs text-gray-400", children: labels.nodePanel.mediaUnavailable }) })
1511
2137
  ] }),
1512
- isAction && draft.actionKind !== "send_product_list" && !isSendMedia && /* @__PURE__ */ jsx11(
2138
+ isAction && draft.actionKind !== "send_product_list" && !isSendMedia && /* @__PURE__ */ jsx14(
1513
2139
  WhatsAppTextField,
1514
2140
  {
1515
2141
  label: labels.nodePanel.directMessage,
@@ -1519,17 +2145,17 @@ function FlowNodePanel({
1519
2145
  labels
1520
2146
  }
1521
2147
  ),
1522
- (draft.questionType === "choice" || draft.type === "menu") && /* @__PURE__ */ jsxs10("div", { children: [
1523
- /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between mb-1.5", children: [
1524
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.options }),
1525
- /* @__PURE__ */ jsxs10("button", { "data-cv-tooltip": labels.nodePanel.addOption, "aria-label": labels.nodePanel.addOption, onClick: addOption, className: "text-xs text-blue-600 hover:underline flex items-center gap-1", children: [
1526
- /* @__PURE__ */ jsx11(Plus3, { size: 12 }),
2148
+ (draft.questionType === "choice" || draft.type === "menu") && /* @__PURE__ */ jsxs13("div", { children: [
2149
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between mb-1.5", children: [
2150
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.options }),
2151
+ /* @__PURE__ */ jsxs13("button", { "data-cv-tooltip": labels.nodePanel.addOption, "aria-label": labels.nodePanel.addOption, onClick: addOption, className: "text-xs text-blue-600 hover:underline flex items-center gap-1", children: [
2152
+ /* @__PURE__ */ jsx14(Plus5, { size: 12 }),
1527
2153
  " ",
1528
2154
  labels.nodePanel.addOption
1529
2155
  ] })
1530
2156
  ] }),
1531
- /* @__PURE__ */ jsx11("div", { className: "space-y-2", children: (draft.options ?? []).map(([id, label], i) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1532
- /* @__PURE__ */ jsx11(
2157
+ /* @__PURE__ */ jsx14("div", { className: "space-y-2", children: (draft.options ?? []).map(([id, label], i) => /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2158
+ /* @__PURE__ */ jsx14(
1533
2159
  "input",
1534
2160
  {
1535
2161
  value: id,
@@ -1538,7 +2164,7 @@ function FlowNodePanel({
1538
2164
  className: `w-16 ${INPUT_CLASSNAME}`
1539
2165
  }
1540
2166
  ),
1541
- /* @__PURE__ */ jsx11(
2167
+ /* @__PURE__ */ jsx14(
1542
2168
  "input",
1543
2169
  {
1544
2170
  value: label,
@@ -1547,49 +2173,68 @@ function FlowNodePanel({
1547
2173
  className: `flex-1 ${INPUT_CLASSNAME}`
1548
2174
  }
1549
2175
  ),
1550
- /* @__PURE__ */ jsx11("button", { "data-cv-tooltip": labels.nodePanel.removeOption, "aria-label": labels.nodePanel.removeOption, onClick: () => removeOption(i), className: "text-gray-400 hover:text-red-600", children: /* @__PURE__ */ jsx11(Trash2, { size: 14 }) })
2176
+ /* @__PURE__ */ jsx14("button", { "data-cv-tooltip": labels.nodePanel.removeOption, "aria-label": labels.nodePanel.removeOption, onClick: () => removeOption(i), className: "text-gray-400 hover:text-red-600", children: /* @__PURE__ */ jsx14(Trash23, { size: 14 }) })
1551
2177
  ] }, i)) })
1552
2178
  ] }),
1553
- (!isAction || isPassThroughAction) && /* @__PURE__ */ jsxs10("div", { className: "pt-2 border-t border-gray-100 dark:border-gray-700", children: [
1554
- /* @__PURE__ */ jsx11("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.next }),
1555
- /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-gray-400 dark:text-gray-500 mb-1", children: labels.nodePanel.nextHint }),
1556
- typeof draft.next !== "object" && !isCondition ? /* @__PURE__ */ jsxs10(
2179
+ !isFixedLogic && !isAction && !isCondition && /* @__PURE__ */ jsx14(
2180
+ FlowRunnerFields,
2181
+ {
2182
+ draft,
2183
+ onDraftChange: setDraft,
2184
+ renderTargetOptions: nextNodeOptions,
2185
+ knownContextKeys,
2186
+ labels: labels.runnerFields ?? DEFAULT_FLOW_RUNNER_FIELD_LABELS
2187
+ }
2188
+ ),
2189
+ isAction && draft.actionKind && /* @__PURE__ */ jsx14(
2190
+ FlowPossibleNextField,
2191
+ {
2192
+ draft,
2193
+ onDraftChange: setDraft,
2194
+ renderTargetOptions: nextNodeOptions,
2195
+ labels: labels.runnerFields ?? DEFAULT_FLOW_RUNNER_FIELD_LABELS
2196
+ }
2197
+ ),
2198
+ (!isAction || isPassThroughAction2) && /* @__PURE__ */ jsxs13("div", { className: "pt-2 border-t border-gray-100 dark:border-gray-700", children: [
2199
+ /* @__PURE__ */ jsx14("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.nodePanel.next }),
2200
+ /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-gray-400 dark:text-gray-500 mb-1", children: labels.nodePanel.nextHint }),
2201
+ typeof draft.next !== "object" && !isCondition ? /* @__PURE__ */ jsxs13(
1557
2202
  "select",
1558
2203
  {
1559
2204
  value: typeof draft.next === "string" ? draft.next : "",
1560
2205
  onChange: (e) => updateNextString(e.target.value),
1561
2206
  className: `w-full mt-1 ${SELECT_CLASSNAME}`,
1562
2207
  children: [
1563
- /* @__PURE__ */ jsx11("option", { value: "", children: "\u2014" }),
2208
+ /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014" }),
1564
2209
  nextNodeOptions()
1565
2210
  ]
1566
2211
  }
1567
- ) : /* @__PURE__ */ jsxs10("div", { className: "space-y-2 mt-1", children: [
1568
- conditionAnswerIds.map((id) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1569
- /* @__PURE__ */ jsx11("span", { className: "text-xs text-gray-500 w-32 shrink-0", children: isCondition ? id === "true" ? labels.nodePanel.conditionTrue : labels.nodePanel.conditionFalse : labels.nodePanel.nextByAnswer(id) }),
1570
- /* @__PURE__ */ jsxs10(
2212
+ ) : /* @__PURE__ */ jsxs13("div", { className: "space-y-2 mt-1", children: [
2213
+ conditionAnswerIds.map((id) => /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2214
+ /* @__PURE__ */ jsx14("span", { className: "text-xs text-gray-500 w-32 shrink-0", children: isCondition ? id === "true" ? labels.nodePanel.conditionTrue : labels.nodePanel.conditionFalse : labels.nodePanel.nextByAnswer(id) }),
2215
+ /* @__PURE__ */ jsxs13(
1571
2216
  "select",
1572
2217
  {
1573
2218
  value: draft.next && typeof draft.next === "object" ? draft.next.byAnswer[id] ?? "" : "",
1574
2219
  onChange: (e) => updateNextByAnswer(id, e.target.value),
1575
2220
  className: `flex-1 ${SELECT_CLASSNAME}`,
1576
2221
  children: [
1577
- /* @__PURE__ */ jsx11("option", { value: "", children: "\u2014" }),
2222
+ /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014" }),
1578
2223
  nextNodeOptions()
1579
2224
  ]
1580
2225
  }
1581
2226
  )
1582
2227
  ] }, id)),
1583
- /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1584
- /* @__PURE__ */ jsx11("span", { className: "text-xs text-gray-500 w-32 shrink-0", children: isCondition ? labels.nodePanel.conditionVariableMissing : labels.nodePanel.nextDefault }),
1585
- /* @__PURE__ */ jsxs10(
2228
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2229
+ /* @__PURE__ */ jsx14("span", { className: "text-xs text-gray-500 w-32 shrink-0", children: isCondition ? labels.nodePanel.conditionVariableMissing : labels.nodePanel.nextDefault }),
2230
+ /* @__PURE__ */ jsxs13(
1586
2231
  "select",
1587
2232
  {
1588
2233
  value: draft.next && typeof draft.next === "object" ? draft.next.default : "",
1589
2234
  onChange: (e) => updateNextDefault(e.target.value),
1590
2235
  className: `flex-1 ${SELECT_CLASSNAME}`,
1591
2236
  children: [
1592
- /* @__PURE__ */ jsx11("option", { value: "", children: "\u2014" }),
2237
+ /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014" }),
1593
2238
  nextNodeOptions()
1594
2239
  ]
1595
2240
  }
@@ -1598,8 +2243,8 @@ function FlowNodePanel({
1598
2243
  ] })
1599
2244
  ] })
1600
2245
  ] }),
1601
- /* @__PURE__ */ jsxs10("div", { className: "p-4 border-t border-gray-100 dark:border-gray-700 flex gap-2", children: [
1602
- /* @__PURE__ */ jsxs10(
2246
+ /* @__PURE__ */ jsxs13("div", { className: "p-4 border-t border-gray-100 dark:border-gray-700 flex gap-2", children: [
2247
+ /* @__PURE__ */ jsxs13(
1603
2248
  "button",
1604
2249
  {
1605
2250
  "data-cv-tooltip": labels.nodePanel.save,
@@ -1607,13 +2252,13 @@ function FlowNodePanel({
1607
2252
  onClick: () => onChange(draft),
1608
2253
  className: "flex-1 inline-flex items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",
1609
2254
  children: [
1610
- /* @__PURE__ */ jsx11(Save, { size: 14 }),
2255
+ /* @__PURE__ */ jsx14(Save, { size: 14 }),
1611
2256
  " ",
1612
2257
  labels.nodePanel.save
1613
2258
  ]
1614
2259
  }
1615
2260
  ),
1616
- !isStart && /* @__PURE__ */ jsx11(
2261
+ !isStart && /* @__PURE__ */ jsx14(
1617
2262
  "button",
1618
2263
  {
1619
2264
  onClick: () => {
@@ -1622,10 +2267,10 @@ function FlowNodePanel({
1622
2267
  "data-cv-tooltip": labels.nodePanel.delete,
1623
2268
  "aria-label": labels.nodePanel.delete,
1624
2269
  className: "px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/30 rounded-lg",
1625
- children: /* @__PURE__ */ jsx11(Trash2, { size: 14 })
2270
+ children: /* @__PURE__ */ jsx14(Trash23, { size: 14 })
1626
2271
  }
1627
2272
  ),
1628
- /* @__PURE__ */ jsx11("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, onClick: onClose, className: "px-4 py-2 text-sm text-gray-600 dark:text-gray-300 hover:underline", children: labels.nodePanel.cancel })
2273
+ /* @__PURE__ */ jsx14("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, onClick: onClose, className: "px-4 py-2 text-sm text-gray-600 dark:text-gray-300 hover:underline", children: labels.nodePanel.cancel })
1629
2274
  ] })
1630
2275
  ] });
1631
2276
  }
@@ -1642,7 +2287,7 @@ import {
1642
2287
  applyNodeChanges
1643
2288
  } from "@xyflow/react";
1644
2289
  import "@xyflow/react/dist/style.css";
1645
- import { Plus as Plus4, Trash2 as Trash22, LayoutGrid, AlertTriangle as AlertTriangle3, AlertCircle as AlertCircle3, Save as Save2, Undo2, Map as MapIcon, Workflow } from "lucide-react";
2290
+ import { Plus as Plus6, Trash2 as Trash24, LayoutGrid, AlertTriangle as AlertTriangle3, AlertCircle as AlertCircle3, Save as Save2, Undo2, Map as MapIcon, Workflow } from "lucide-react";
1646
2291
 
1647
2292
  // src/flows/flowEditorOps.ts
1648
2293
  var NAMESPACE_SEPARATOR = "::";
@@ -1658,7 +2303,9 @@ function removeNodeAndCleanRefs(nodes, removedId) {
1658
2303
  const remaining = {};
1659
2304
  for (const [id, node] of Object.entries(nodes)) {
1660
2305
  if (id === removedId) continue;
1661
- remaining[id] = { ...node, next: cleanNext(node.next, removedId) };
2306
+ const cleaned = { ...node, next: cleanNext(node.next, removedId) };
2307
+ if (node.possibleNext) cleaned.possibleNext = node.possibleNext.filter((target) => target !== removedId);
2308
+ remaining[id] = cleaned;
1662
2309
  }
1663
2310
  return remaining;
1664
2311
  }
@@ -1707,12 +2354,27 @@ function resolveConnection(params) {
1707
2354
  function applyConnection(node, resolved) {
1708
2355
  const currentNext = typeof node.next === "object" && node.next ? node.next : void 0;
1709
2356
  if (resolved.handle === "next") return { ...node, next: resolved.targetValue };
2357
+ const possible = possibleNextOfHandle(resolved.handle);
2358
+ if (possible !== void 0) return withPossibleNext2(node, possible, resolved.targetValue);
1710
2359
  if (resolved.handle === "__default") {
1711
- return { ...node, next: { byAnswer: currentNext?.byAnswer ?? {}, default: resolved.targetValue } };
2360
+ return { ...node, next: { ...currentNext, byAnswer: currentNext?.byAnswer ?? {}, default: resolved.targetValue } };
2361
+ }
2362
+ const keyword = keywordOfHandle(resolved.handle);
2363
+ if (keyword !== void 0) {
2364
+ return {
2365
+ ...node,
2366
+ next: {
2367
+ ...currentNext,
2368
+ byAnswer: currentNext?.byAnswer ?? {},
2369
+ byKeyword: { ...currentNext?.byKeyword ?? {}, [keyword]: resolved.targetValue },
2370
+ default: currentNext?.default ?? ""
2371
+ }
2372
+ };
1712
2373
  }
1713
2374
  return {
1714
2375
  ...node,
1715
2376
  next: {
2377
+ ...currentNext,
1716
2378
  byAnswer: { ...currentNext?.byAnswer ?? {}, [resolved.handle]: resolved.targetValue },
1717
2379
  default: currentNext?.default ?? ""
1718
2380
  }
@@ -1722,16 +2384,29 @@ function isGraphDirty(working, published) {
1722
2384
  if (!working || !published) return false;
1723
2385
  return JSON.stringify(working) !== JSON.stringify(published);
1724
2386
  }
2387
+ function withPossibleNext2(node, replaced, target) {
2388
+ const current = node.possibleNext ?? [];
2389
+ const updated = current.flatMap((entry) => entry === replaced ? target ? [target] : [] : [entry]);
2390
+ if (!current.includes(replaced) && target) updated.push(target);
2391
+ return { ...node, possibleNext: [...new Set(updated)] };
2392
+ }
1725
2393
  function clearConnection(node, handle) {
2394
+ const possible = possibleNextOfHandle(handle);
2395
+ if (possible !== void 0) return withPossibleNext2(node, possible, void 0);
1726
2396
  if (handle === "next" || typeof node.next === "string" || node.next === void 0) {
1727
2397
  return { ...node, next: "" };
1728
2398
  }
1729
2399
  if (handle === "__default") {
1730
- return { ...node, next: { byAnswer: node.next.byAnswer ?? {}, default: "" } };
2400
+ return { ...node, next: { ...node.next, byAnswer: node.next.byAnswer ?? {}, default: "" } };
2401
+ }
2402
+ const keyword = keywordOfHandle(handle);
2403
+ if (keyword !== void 0) {
2404
+ return { ...node, next: { ...node.next, byKeyword: { ...node.next.byKeyword ?? {}, [keyword]: "" } } };
1731
2405
  }
1732
2406
  return {
1733
2407
  ...node,
1734
2408
  next: {
2409
+ ...node.next,
1735
2410
  byAnswer: { ...node.next.byAnswer ?? {}, [handle]: "" },
1736
2411
  default: node.next.default ?? ""
1737
2412
  }
@@ -1818,7 +2493,8 @@ function buildFlowEdges(params) {
1818
2493
  const liveCounts = countLiveByNode({ flowKey, rootFlowKey, positions: livePositions });
1819
2494
  for (const [nodeId, node] of Object.entries(graph.nodes)) {
1820
2495
  const live = (liveCounts[nodeId] ?? 0) > 0;
1821
- for (const { target, optionId, isDefault } of targetsOf(node)) {
2496
+ for (const { target, optionId: answerId, keyword, isDefault, isPossible } of targetsOf(node)) {
2497
+ const optionId = keyword !== void 0 ? keywordHandle(keyword) : answerId;
1822
2498
  if (!target) continue;
1823
2499
  const crossFlow = isCrossFlowTarget(target);
1824
2500
  let targetFlowKey = flowKey;
@@ -1836,6 +2512,18 @@ function buildFlowEdges(params) {
1836
2512
  const source = namespaceNodeId(flowKey, nodeId);
1837
2513
  const edgeTarget = namespaceNodeId(targetFlowKey, targetNodeId);
1838
2514
  if (source === edgeTarget) continue;
2515
+ if (isPossible) {
2516
+ edges.push({
2517
+ id: `${source}->${edgeTarget}-possible`,
2518
+ source,
2519
+ target: edgeTarget,
2520
+ sourceHandle: possibleNextHandle(target),
2521
+ kind: "fallback",
2522
+ crossFlow,
2523
+ live: false
2524
+ });
2525
+ continue;
2526
+ }
1839
2527
  if (isDefault) {
1840
2528
  edges.push({
1841
2529
  id: `${source}->${edgeTarget}-default`,
@@ -1918,6 +2606,14 @@ function newNodeFromSpec(spec, existingIds) {
1918
2606
  const id2 = slugifyNodeId("nova_condicao", existingIds);
1919
2607
  return { id: id2, type: "condition", conditionOperator: ">" };
1920
2608
  }
2609
+ if (spec.kind === "dynamicChoice") {
2610
+ const id2 = slugifyNodeId("nova_escolha_dinamica", existingIds);
2611
+ return { id: id2, type: "dynamic_choice", contextKey: id2, question: "" };
2612
+ }
2613
+ if (spec.kind === "message") {
2614
+ const id2 = slugifyNodeId("nova_mensagem", existingIds);
2615
+ return { id: id2, type: "action", directMessage: "" };
2616
+ }
1921
2617
  const id = slugifyNodeId("nova_acao", existingIds);
1922
2618
  return { id, type: "action", actionKind: spec.actionKind };
1923
2619
  }
@@ -1935,7 +2631,7 @@ function findFreeSlot(params) {
1935
2631
  }
1936
2632
 
1937
2633
  // src/flows/FlowsWorkspace.tsx
1938
- import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
2634
+ import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
1939
2635
  var RF_NODE_TYPES = {
1940
2636
  ...flowNodeTypes,
1941
2637
  ...flowPortalNodeTypes,
@@ -2534,17 +3230,17 @@ function FlowsWorkspace({
2534
3230
  const keyIsValid = FLOW_KEY_PATTERN.test(newFlow.key);
2535
3231
  const canCreateFlow = Boolean(api.createFlow);
2536
3232
  const canDeleteFlow = Boolean(api.deleteFlow) && primaryFlowKey !== rootFlowKey;
2537
- return /* @__PURE__ */ jsxs11("div", { className: `space-y-4 h-full flex flex-col ${className ?? ""}`, children: [
2538
- /* @__PURE__ */ jsx12(TooltipLayer, {}),
2539
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between flex-wrap gap-3", children: [
2540
- showHeader && /* @__PURE__ */ jsxs11("div", { className: "min-w-0", children: [
2541
- /* @__PURE__ */ jsx12("h2", { className: "text-2xl font-bold text-gray-900 dark:text-gray-100", children: labels.workspace.title }),
2542
- /* @__PURE__ */ jsx12("p", { className: "text-gray-500 dark:text-gray-400 text-sm mt-1", children: labels.workspace.subtitle })
3233
+ return /* @__PURE__ */ jsxs14("div", { className: `space-y-4 h-full flex flex-col ${className ?? ""}`, children: [
3234
+ /* @__PURE__ */ jsx15(TooltipLayer, {}),
3235
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between flex-wrap gap-3", children: [
3236
+ showHeader && /* @__PURE__ */ jsxs14("div", { className: "min-w-0", children: [
3237
+ /* @__PURE__ */ jsx15("h2", { className: "text-2xl font-bold text-gray-900 dark:text-gray-100", children: labels.workspace.title }),
3238
+ /* @__PURE__ */ jsx15("p", { className: "text-gray-500 dark:text-gray-400 text-sm mt-1", children: labels.workspace.subtitle })
2543
3239
  ] }),
2544
- /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center justify-end gap-3 ml-auto", children: [
2545
- saveState === "success" && /* @__PURE__ */ jsx12("span", { className: "text-sm text-green-600", children: labels.workspace.saveSuccess }),
2546
- saveState === "error" && /* @__PURE__ */ jsx12("span", { className: "text-sm text-red-600", children: saveErrorMessage ?? labels.workspace.saveError }),
2547
- /* @__PURE__ */ jsxs11(
3240
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center justify-end gap-3 ml-auto", children: [
3241
+ saveState === "success" && /* @__PURE__ */ jsx15("span", { className: "text-sm text-green-600", children: labels.workspace.saveSuccess }),
3242
+ saveState === "error" && /* @__PURE__ */ jsx15("span", { className: "text-sm text-red-600", children: saveErrorMessage ?? labels.workspace.saveError }),
3243
+ /* @__PURE__ */ jsxs14(
2548
3244
  "button",
2549
3245
  {
2550
3246
  "data-cv-tooltip": viewMode === "map" ? labels.flowMap.toggleToDetail : labels.flowMap.toggleToMap,
@@ -2553,13 +3249,13 @@ function FlowsWorkspace({
2553
3249
  onClick: () => setViewMode((mode) => mode === "map" ? "detail" : "map"),
2554
3250
  className: OUTLINE_BUTTON,
2555
3251
  children: [
2556
- viewMode === "map" ? /* @__PURE__ */ jsx12(Workflow, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ jsx12(MapIcon, { size: 14, "aria-hidden": "true" }),
3252
+ viewMode === "map" ? /* @__PURE__ */ jsx15(Workflow, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ jsx15(MapIcon, { size: 14, "aria-hidden": "true" }),
2557
3253
  viewMode === "map" ? labels.flowMap.toggleToDetail : labels.flowMap.toggleToMap
2558
3254
  ]
2559
3255
  }
2560
3256
  ),
2561
- viewMode === "detail" && /* @__PURE__ */ jsxs11(Fragment5, { children: [
2562
- /* @__PURE__ */ jsxs11(
3257
+ viewMode === "detail" && /* @__PURE__ */ jsxs14(Fragment6, { children: [
3258
+ /* @__PURE__ */ jsxs14(
2563
3259
  "button",
2564
3260
  {
2565
3261
  type: "button",
@@ -2569,13 +3265,13 @@ function FlowsWorkspace({
2569
3265
  "aria-label": labels.workspace.organizeTooltip,
2570
3266
  disabled: !primaryGraph,
2571
3267
  children: [
2572
- /* @__PURE__ */ jsx12(LayoutGrid, { size: 14, "aria-hidden": "true" }),
3268
+ /* @__PURE__ */ jsx15(LayoutGrid, { size: 14, "aria-hidden": "true" }),
2573
3269
  " ",
2574
3270
  labels.workspace.organize
2575
3271
  ]
2576
3272
  }
2577
3273
  ),
2578
- /* @__PURE__ */ jsxs11(
3274
+ /* @__PURE__ */ jsxs14(
2579
3275
  "button",
2580
3276
  {
2581
3277
  type: "button",
@@ -2585,13 +3281,13 @@ function FlowsWorkspace({
2585
3281
  "aria-label": labels.workspace.discardTooltip,
2586
3282
  disabled: !isDirty || saveState === "saving",
2587
3283
  children: [
2588
- /* @__PURE__ */ jsx12(Undo2, { size: 14, "aria-hidden": "true" }),
3284
+ /* @__PURE__ */ jsx15(Undo2, { size: 14, "aria-hidden": "true" }),
2589
3285
  " ",
2590
3286
  labels.workspace.discardChanges
2591
3287
  ]
2592
3288
  }
2593
3289
  ),
2594
- /* @__PURE__ */ jsxs11(
3290
+ /* @__PURE__ */ jsxs14(
2595
3291
  "button",
2596
3292
  {
2597
3293
  "data-cv-tooltip": labels.workspace.saveGraph,
@@ -2601,7 +3297,7 @@ function FlowsWorkspace({
2601
3297
  className: PRIMARY_BUTTON,
2602
3298
  disabled: !isDirty || errorCount > 0 || saveState === "saving",
2603
3299
  children: [
2604
- /* @__PURE__ */ jsx12(Save2, { size: 14, "aria-hidden": "true" }),
3300
+ /* @__PURE__ */ jsx15(Save2, { size: 14, "aria-hidden": "true" }),
2605
3301
  saveState === "saving" ? labels.workspace.saving : labels.workspace.saveGraph
2606
3302
  ]
2607
3303
  }
@@ -2609,9 +3305,9 @@ function FlowsWorkspace({
2609
3305
  ] })
2610
3306
  ] })
2611
3307
  ] }),
2612
- viewMode === "detail" && /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between gap-2 flex-wrap", children: [
2613
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 flex-wrap", children: [
2614
- graphs && Object.values(graphs).map((graph) => /* @__PURE__ */ jsx12(
3308
+ viewMode === "detail" && /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between gap-2 flex-wrap", children: [
3309
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 flex-wrap", children: [
3310
+ graphs && Object.values(graphs).map((graph) => /* @__PURE__ */ jsx15(
2615
3311
  "button",
2616
3312
  {
2617
3313
  "data-cv-tooltip": graph.label,
@@ -2623,7 +3319,7 @@ function FlowsWorkspace({
2623
3319
  },
2624
3320
  graph.key
2625
3321
  )),
2626
- canCreateFlow && /* @__PURE__ */ jsxs11(
3322
+ canCreateFlow && /* @__PURE__ */ jsxs14(
2627
3323
  "button",
2628
3324
  {
2629
3325
  "data-cv-tooltip": labels.flowManager.newFlow,
@@ -2635,15 +3331,15 @@ function FlowsWorkspace({
2635
3331
  },
2636
3332
  className: "inline-flex items-center gap-1 px-3 py-1.5 rounded-full text-xs font-medium border border-dashed border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:border-blue-400 hover:text-blue-600",
2637
3333
  children: [
2638
- /* @__PURE__ */ jsx12(Plus4, { size: 12, "aria-hidden": "true" }),
3334
+ /* @__PURE__ */ jsx15(Plus6, { size: 12, "aria-hidden": "true" }),
2639
3335
  " ",
2640
3336
  labels.flowManager.newFlow
2641
3337
  ]
2642
3338
  }
2643
3339
  )
2644
3340
  ] }),
2645
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
2646
- primaryGraph && /* @__PURE__ */ jsx12(
3341
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
3342
+ primaryGraph && /* @__PURE__ */ jsx15(
2647
3343
  FlowPalette,
2648
3344
  {
2649
3345
  onAdd: handleAddNode,
@@ -2651,7 +3347,7 @@ function FlowsWorkspace({
2651
3347
  ...actionOptions ? { actionOptions: [...actionOptions] } : {}
2652
3348
  }
2653
3349
  ),
2654
- primaryGraph && canDeleteFlow && /* @__PURE__ */ jsxs11(
3350
+ primaryGraph && canDeleteFlow && /* @__PURE__ */ jsxs14(
2655
3351
  "button",
2656
3352
  {
2657
3353
  "data-cv-tooltip": labels.flowManager.deleteFlow,
@@ -2663,7 +3359,7 @@ function FlowsWorkspace({
2663
3359
  },
2664
3360
  className: "inline-flex items-center gap-1.5 rounded-lg border border-red-200 dark:border-red-900 px-3 py-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/30",
2665
3361
  children: [
2666
- /* @__PURE__ */ jsx12(Trash22, { size: 13, "aria-hidden": "true" }),
3362
+ /* @__PURE__ */ jsx15(Trash24, { size: 13, "aria-hidden": "true" }),
2667
3363
  " ",
2668
3364
  labels.flowManager.deleteFlow
2669
3365
  ]
@@ -2671,26 +3367,26 @@ function FlowsWorkspace({
2671
3367
  )
2672
3368
  ] })
2673
3369
  ] }),
2674
- viewMode === "detail" && (errorCount > 0 || warningCount > 0) && /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/60 px-3 py-2 text-xs", children: [
2675
- /* @__PURE__ */ jsxs11("span", { className: "font-medium text-gray-600 dark:text-gray-300", children: [
3370
+ viewMode === "detail" && (errorCount > 0 || warningCount > 0) && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/60 px-3 py-2 text-xs", children: [
3371
+ /* @__PURE__ */ jsxs14("span", { className: "font-medium text-gray-600 dark:text-gray-300", children: [
2676
3372
  labels.validation.title,
2677
3373
  ":"
2678
3374
  ] }),
2679
- errorCount > 0 && /* @__PURE__ */ jsxs11("span", { className: "flex items-center gap-1 text-red-600 dark:text-red-400 font-medium", children: [
2680
- /* @__PURE__ */ jsx12(AlertCircle3, { size: 13, "aria-hidden": "true" }),
3375
+ errorCount > 0 && /* @__PURE__ */ jsxs14("span", { className: "flex items-center gap-1 text-red-600 dark:text-red-400 font-medium", children: [
3376
+ /* @__PURE__ */ jsx15(AlertCircle3, { size: 13, "aria-hidden": "true" }),
2681
3377
  " ",
2682
3378
  labels.validation.errors(errorCount)
2683
3379
  ] }),
2684
- warningCount > 0 && /* @__PURE__ */ jsxs11("span", { className: "flex items-center gap-1 text-amber-600 dark:text-amber-400", children: [
2685
- /* @__PURE__ */ jsx12(AlertTriangle3, { size: 13, "aria-hidden": "true" }),
3380
+ warningCount > 0 && /* @__PURE__ */ jsxs14("span", { className: "flex items-center gap-1 text-amber-600 dark:text-amber-400", children: [
3381
+ /* @__PURE__ */ jsx15(AlertTriangle3, { size: 13, "aria-hidden": "true" }),
2686
3382
  " ",
2687
3383
  labels.validation.warnings(warningCount)
2688
3384
  ] })
2689
3385
  ] }),
2690
- /* @__PURE__ */ jsxs11("div", { className: "flex-1 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden relative", children: [
2691
- loadState === "loading" && /* @__PURE__ */ jsx12("p", { className: "text-center text-gray-400 py-12", children: labels.workspace.loading }),
2692
- loadState === "error" && /* @__PURE__ */ jsx12("p", { className: "text-center text-red-500 py-12", children: labels.workspace.loadError }),
2693
- loadState === "ready" && graphs && viewMode === "map" && /* @__PURE__ */ jsx12(
3386
+ /* @__PURE__ */ jsxs14("div", { className: "flex-1 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden relative", children: [
3387
+ loadState === "loading" && /* @__PURE__ */ jsx15("p", { className: "text-center text-gray-400 py-12", children: labels.workspace.loading }),
3388
+ loadState === "error" && /* @__PURE__ */ jsx15("p", { className: "text-center text-red-500 py-12", children: labels.workspace.loadError }),
3389
+ loadState === "ready" && graphs && viewMode === "map" && /* @__PURE__ */ jsx15(
2694
3390
  FlowMapCanvas,
2695
3391
  {
2696
3392
  graphs,
@@ -2702,7 +3398,7 @@ function FlowsWorkspace({
2702
3398
  }
2703
3399
  }
2704
3400
  ),
2705
- loadState === "ready" && viewMode === "detail" && primaryGraph && /* @__PURE__ */ jsxs11(
3401
+ loadState === "ready" && viewMode === "detail" && primaryGraph && /* @__PURE__ */ jsxs14(
2706
3402
  ReactFlow2,
2707
3403
  {
2708
3404
  nodes: rfNodes,
@@ -2718,9 +3414,9 @@ function FlowsWorkspace({
2718
3414
  proOptions: { hideAttribution: true },
2719
3415
  colorMode: isDark ? "dark" : "light",
2720
3416
  children: [
2721
- /* @__PURE__ */ jsx12(Background2, { color: isDark ? BACKGROUND_COLOR_DARK2 : BACKGROUND_COLOR_LIGHT2 }),
2722
- /* @__PURE__ */ jsx12(Controls2, {}),
2723
- /* @__PURE__ */ jsx12(Panel, { position: "top-right", children: /* @__PURE__ */ jsx12(
3417
+ /* @__PURE__ */ jsx15(Background2, { color: isDark ? BACKGROUND_COLOR_DARK2 : BACKGROUND_COLOR_LIGHT2 }),
3418
+ /* @__PURE__ */ jsx15(Controls2, {}),
3419
+ /* @__PURE__ */ jsx15(Panel, { position: "top-right", children: /* @__PURE__ */ jsx15(
2724
3420
  FlowLegend,
2725
3421
  {
2726
3422
  labels,
@@ -2728,22 +3424,22 @@ function FlowsWorkspace({
2728
3424
  nodeSwatches: LEGEND_NODE_SWATCHES
2729
3425
  }
2730
3426
  ) }),
2731
- /* @__PURE__ */ jsx12(MiniMap, { pannable: true, zoomable: true, className: "!bg-white dark:!bg-gray-800" })
3427
+ /* @__PURE__ */ jsx15(MiniMap, { pannable: true, zoomable: true, className: "!bg-white dark:!bg-gray-800" })
2732
3428
  ]
2733
3429
  }
2734
3430
  )
2735
3431
  ] }),
2736
- quickAddFrom && /* @__PURE__ */ jsxs11(Fragment5, { children: [
2737
- /* @__PURE__ */ jsx12("div", { className: "fixed inset-0 z-40", onClick: () => setQuickAddFrom(null) }),
2738
- /* @__PURE__ */ jsxs11(
3432
+ quickAddFrom && /* @__PURE__ */ jsxs14(Fragment6, { children: [
3433
+ /* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-40", onClick: () => setQuickAddFrom(null) }),
3434
+ /* @__PURE__ */ jsxs14(
2739
3435
  "div",
2740
3436
  {
2741
3437
  ref: quickAddMenuRef,
2742
3438
  className: "fixed z-50 w-64 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-lg py-1",
2743
3439
  style: quickAddMenuStyle,
2744
3440
  children: [
2745
- /* @__PURE__ */ jsx12("p", { className: "px-3 py-1.5 text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500", children: labels.quickAdd.title }),
2746
- /* @__PURE__ */ jsx12(
3441
+ /* @__PURE__ */ jsx15("p", { className: "px-3 py-1.5 text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500", children: labels.quickAdd.title }),
3442
+ /* @__PURE__ */ jsx15(
2747
3443
  FlowPaletteMenu,
2748
3444
  {
2749
3445
  onSelect: handleQuickAdd,
@@ -2755,7 +3451,7 @@ function FlowsWorkspace({
2755
3451
  }
2756
3452
  )
2757
3453
  ] }),
2758
- editingNode && editingGraph && /* @__PURE__ */ jsx12(
3454
+ editingNode && editingGraph && /* @__PURE__ */ jsx15(
2759
3455
  FlowNodePanel,
2760
3456
  {
2761
3457
  graph: editingGraph,
@@ -2770,11 +3466,11 @@ function FlowsWorkspace({
2770
3466
  },
2771
3467
  `${editingRef?.flowKey}:${editingRef?.nodeId}`
2772
3468
  ),
2773
- showCreateDialog && canCreateFlow && /* @__PURE__ */ jsxs11(FlowDialog, { title: labels.flowManager.createTitle, onClose: () => setShowCreateDialog(false), children: [
2774
- /* @__PURE__ */ jsxs11("div", { className: "space-y-3", children: [
2775
- /* @__PURE__ */ jsxs11("div", { children: [
2776
- /* @__PURE__ */ jsx12("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.label }),
2777
- /* @__PURE__ */ jsx12(
3469
+ showCreateDialog && canCreateFlow && /* @__PURE__ */ jsxs14(FlowDialog, { title: labels.flowManager.createTitle, onClose: () => setShowCreateDialog(false), children: [
3470
+ /* @__PURE__ */ jsxs14("div", { className: "space-y-3", children: [
3471
+ /* @__PURE__ */ jsxs14("div", { children: [
3472
+ /* @__PURE__ */ jsx15("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.label }),
3473
+ /* @__PURE__ */ jsx15(
2778
3474
  "input",
2779
3475
  {
2780
3476
  value: newFlow.label,
@@ -2783,9 +3479,9 @@ function FlowsWorkspace({
2783
3479
  }
2784
3480
  )
2785
3481
  ] }),
2786
- /* @__PURE__ */ jsxs11("div", { children: [
2787
- /* @__PURE__ */ jsx12("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.key }),
2788
- /* @__PURE__ */ jsx12(
3482
+ /* @__PURE__ */ jsxs14("div", { children: [
3483
+ /* @__PURE__ */ jsx15("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.key }),
3484
+ /* @__PURE__ */ jsx15(
2789
3485
  "input",
2790
3486
  {
2791
3487
  value: newFlow.key,
@@ -2793,10 +3489,10 @@ function FlowsWorkspace({
2793
3489
  className: `mt-1 ${DIALOG_INPUT}`
2794
3490
  }
2795
3491
  ),
2796
- /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-gray-400 mt-1", children: newFlow.key && !keyIsValid ? labels.flowManager.keyInvalid : labels.flowManager.keyHint })
3492
+ /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-gray-400 mt-1", children: newFlow.key && !keyIsValid ? labels.flowManager.keyInvalid : labels.flowManager.keyHint })
2797
3493
  ] }),
2798
- /* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-2 text-sm text-gray-700 dark:text-gray-200", children: [
2799
- /* @__PURE__ */ jsx12(
3494
+ /* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-2 text-sm text-gray-700 dark:text-gray-200", children: [
3495
+ /* @__PURE__ */ jsx15(
2800
3496
  "input",
2801
3497
  {
2802
3498
  type: "checkbox",
@@ -2806,9 +3502,9 @@ function FlowsWorkspace({
2806
3502
  ),
2807
3503
  labels.flowManager.showInMenu
2808
3504
  ] }),
2809
- newFlow.showInMenu && /* @__PURE__ */ jsxs11("div", { children: [
2810
- /* @__PURE__ */ jsx12("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.menuOptionLabel }),
2811
- /* @__PURE__ */ jsx12(
3505
+ newFlow.showInMenu && /* @__PURE__ */ jsxs14("div", { children: [
3506
+ /* @__PURE__ */ jsx15("label", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: labels.flowManager.menuOptionLabel }),
3507
+ /* @__PURE__ */ jsx15(
2812
3508
  "input",
2813
3509
  {
2814
3510
  value: newFlow.menuOptionLabel,
@@ -2818,11 +3514,11 @@ function FlowsWorkspace({
2818
3514
  }
2819
3515
  )
2820
3516
  ] }),
2821
- flowMutationState.error && /* @__PURE__ */ jsx12("p", { className: "text-xs text-red-600", children: flowMutationState.error })
3517
+ flowMutationState.error && /* @__PURE__ */ jsx15("p", { className: "text-xs text-red-600", children: flowMutationState.error })
2822
3518
  ] }),
2823
- /* @__PURE__ */ jsxs11("div", { className: "flex justify-end gap-2 mt-4", children: [
2824
- /* @__PURE__ */ jsx12("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, type: "button", className: OUTLINE_BUTTON, onClick: () => setShowCreateDialog(false), children: labels.nodePanel.cancel }),
2825
- /* @__PURE__ */ jsx12(
3519
+ /* @__PURE__ */ jsxs14("div", { className: "flex justify-end gap-2 mt-4", children: [
3520
+ /* @__PURE__ */ jsx15("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, type: "button", className: OUTLINE_BUTTON, onClick: () => setShowCreateDialog(false), children: labels.nodePanel.cancel }),
3521
+ /* @__PURE__ */ jsx15(
2826
3522
  "button",
2827
3523
  {
2828
3524
  "data-cv-tooltip": labels.flowManager.create,
@@ -2836,12 +3532,12 @@ function FlowsWorkspace({
2836
3532
  )
2837
3533
  ] })
2838
3534
  ] }),
2839
- showDeleteDialog && canDeleteFlow && /* @__PURE__ */ jsxs11(FlowDialog, { title: labels.flowManager.deleteFlow, onClose: () => setShowDeleteDialog(false), children: [
2840
- /* @__PURE__ */ jsx12("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: primaryGraph ? labels.flowManager.deleteConfirm(primaryGraph.label) : "" }),
2841
- flowMutationState.error && /* @__PURE__ */ jsx12("p", { className: "text-xs text-red-600 mt-2", children: flowMutationState.error }),
2842
- /* @__PURE__ */ jsxs11("div", { className: "flex justify-end gap-2 mt-4", children: [
2843
- /* @__PURE__ */ jsx12("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, type: "button", className: OUTLINE_BUTTON, onClick: () => setShowDeleteDialog(false), children: labels.nodePanel.cancel }),
2844
- /* @__PURE__ */ jsxs11(
3535
+ showDeleteDialog && canDeleteFlow && /* @__PURE__ */ jsxs14(FlowDialog, { title: labels.flowManager.deleteFlow, onClose: () => setShowDeleteDialog(false), children: [
3536
+ /* @__PURE__ */ jsx15("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: primaryGraph ? labels.flowManager.deleteConfirm(primaryGraph.label) : "" }),
3537
+ flowMutationState.error && /* @__PURE__ */ jsx15("p", { className: "text-xs text-red-600 mt-2", children: flowMutationState.error }),
3538
+ /* @__PURE__ */ jsxs14("div", { className: "flex justify-end gap-2 mt-4", children: [
3539
+ /* @__PURE__ */ jsx15("button", { "data-cv-tooltip": labels.nodePanel.cancel, "aria-label": labels.nodePanel.cancel, type: "button", className: OUTLINE_BUTTON, onClick: () => setShowDeleteDialog(false), children: labels.nodePanel.cancel }),
3540
+ /* @__PURE__ */ jsxs14(
2845
3541
  "button",
2846
3542
  {
2847
3543
  "data-cv-tooltip": labels.flowManager.deleteFlow,
@@ -2851,7 +3547,7 @@ function FlowsWorkspace({
2851
3547
  onClick: () => void handleDeleteFlow(),
2852
3548
  disabled: flowMutationState.pending,
2853
3549
  children: [
2854
- /* @__PURE__ */ jsx12(Trash22, { size: 13, "aria-hidden": "true" }),
3550
+ /* @__PURE__ */ jsx15(Trash24, { size: 13, "aria-hidden": "true" }),
2855
3551
  " ",
2856
3552
  labels.flowManager.deleteFlow
2857
3553
  ]
@@ -2866,9 +3562,9 @@ function FlowDialog({
2866
3562
  onClose,
2867
3563
  children
2868
3564
  }) {
2869
- return /* @__PURE__ */ jsxs11("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4", children: [
2870
- /* @__PURE__ */ jsx12("div", { className: "absolute inset-0", onClick: onClose, "aria-hidden": "true" }),
2871
- /* @__PURE__ */ jsxs11(
3565
+ return /* @__PURE__ */ jsxs14("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4", children: [
3566
+ /* @__PURE__ */ jsx15("div", { className: "absolute inset-0", onClick: onClose, "aria-hidden": "true" }),
3567
+ /* @__PURE__ */ jsxs14(
2872
3568
  "div",
2873
3569
  {
2874
3570
  role: "dialog",
@@ -2876,7 +3572,7 @@ function FlowDialog({
2876
3572
  "aria-label": title,
2877
3573
  className: "relative w-full max-w-md rounded-2xl bg-white dark:bg-gray-800 p-5 shadow-xl",
2878
3574
  children: [
2879
- /* @__PURE__ */ jsx12("h3", { className: "text-base font-semibold text-gray-900 dark:text-gray-100 mb-3", children: title }),
3575
+ /* @__PURE__ */ jsx15("h3", { className: "text-base font-semibold text-gray-900 dark:text-gray-100 mb-3", children: title }),
2880
3576
  children
2881
3577
  ]
2882
3578
  }