LogstashUI 0.5.5.dev0__py3-none-any.whl

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 (762) hide show
  1. AI/__init__.py +0 -0
  2. AI/integration_factory.py +1392 -0
  3. AI/migrations/0001_initial.py +58 -0
  4. AI/migrations/0002_draftdefinition_normalizers.py +23 -0
  5. AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
  6. AI/migrations/__init__.py +0 -0
  7. AI/models.py +5 -0
  8. AI/static/js/integration_factory.js +1102 -0
  9. AI/system_prompts/dashboard_generator.md +367 -0
  10. AI/system_prompts/grok_patterns.txt +95 -0
  11. AI/system_prompts/ingest_pipeline_generator.md +331 -0
  12. AI/system_prompts/ingest_pipeline_processors.json +2851 -0
  13. AI/system_prompts/ingest_verifier.md +84 -0
  14. AI/system_prompts/integrations_list.json +2690 -0
  15. AI/system_prompts/log_classifier.md +134 -0
  16. AI/system_prompts/template_creator.md +123 -0
  17. AI/templates/integration_factory.html +200 -0
  18. AI/urls.py +16 -0
  19. AI/views.py +20 -0
  20. API/__init__.py +0 -0
  21. API/admin.py +7 -0
  22. API/api.http +784 -0
  23. API/apps.py +9 -0
  24. API/auth.py +101 -0
  25. API/connections_views.py +312 -0
  26. API/guides.py +88 -0
  27. API/mcp/__init__.py +5 -0
  28. API/mcp/dispatch.py +179 -0
  29. API/mcp/tools.py +890 -0
  30. API/mcp/views.py +215 -0
  31. API/migrations/__init__.py +0 -0
  32. API/models.py +7 -0
  33. API/pipelines_views.py +1224 -0
  34. API/policies_views.py +1015 -0
  35. API/security_views.py +488 -0
  36. API/simulation_detail.py +219 -0
  37. API/snmp_views.py +1539 -0
  38. API/urls.py +81 -0
  39. Common/__init__.py +0 -0
  40. Common/ai/agent_builder.py +690 -0
  41. Common/context_processors.py +49 -0
  42. Common/decorators.py +68 -0
  43. Common/elastic_utils.py +1154 -0
  44. Common/encryption.py +271 -0
  45. Common/error_handlers.py +65 -0
  46. Common/formatters.py +106 -0
  47. Common/logstash_config_parse.py +1469 -0
  48. Common/logstash_utils.py +34 -0
  49. Common/middleware.py +216 -0
  50. Common/product_ca.py +1124 -0
  51. Common/validators.py +66 -0
  52. Documentation/__init__.py +0 -0
  53. Documentation/admin.py +7 -0
  54. Documentation/apps.py +9 -0
  55. Documentation/content/CHANGELOG.md +890 -0
  56. Documentation/content/docs/getting_started.md +92 -0
  57. Documentation/content/docs/index.md +124 -0
  58. Documentation/content/docs/logstashagent/configuration/index.md +60 -0
  59. Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
  60. Documentation/content/docs/logstashagent/general/build.md +217 -0
  61. Documentation/content/docs/logstashagent/general/index.md +38 -0
  62. Documentation/content/docs/logstashagent/general/roles.md +267 -0
  63. Documentation/content/docs/logstashagent/index.md +264 -0
  64. Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
  65. Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
  66. Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
  67. Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
  68. Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
  69. Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
  70. Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
  71. Documentation/content/docs/logstashui/SNMP/index.md +58 -0
  72. Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
  73. Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
  74. Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
  75. Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
  76. Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
  77. Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
  78. Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
  79. Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
  80. Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
  81. Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
  82. Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
  83. Documentation/content/docs/logstashui/architecture.md +11 -0
  84. Documentation/content/docs/logstashui/compatibility.md +58 -0
  85. Documentation/content/docs/logstashui/configuration/environment.md +193 -0
  86. Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
  87. Documentation/content/docs/logstashui/configuration/index.md +72 -0
  88. Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
  89. Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
  90. Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
  91. Documentation/content/docs/logstashui/database/examples/README.md +15 -0
  92. Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
  93. Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
  94. Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
  95. Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
  96. Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
  97. Documentation/content/docs/logstashui/database/index.md +79 -0
  98. Documentation/content/docs/logstashui/database/migration.md +75 -0
  99. Documentation/content/docs/logstashui/general/build.md +154 -0
  100. Documentation/content/docs/logstashui/general/deploy.md +122 -0
  101. Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
  102. Documentation/content/docs/logstashui/general/index.md +62 -0
  103. Documentation/content/docs/logstashui/general/offline.md +68 -0
  104. Documentation/content/docs/logstashui/general/updating.md +50 -0
  105. Documentation/content/docs/logstashui/index.md +90 -0
  106. Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
  107. Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
  108. Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
  109. Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
  110. Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
  111. Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
  112. Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
  113. Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
  114. Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
  115. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
  116. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
  117. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
  118. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
  119. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
  120. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
  121. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
  122. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
  123. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
  124. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
  125. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
  126. Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
  127. Documentation/content/docs/logstashui/mcp.md +224 -0
  128. Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
  129. Documentation/content/docs/logstashui/rest_api.md +2783 -0
  130. Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
  131. Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
  132. Documentation/content/docs/logstashui/utilities/index.md +40 -0
  133. Documentation/content/images/LogstashIcon.png +0 -0
  134. Documentation/content/images/architecture.png +0 -0
  135. Documentation/content/images/connection_manager.png +0 -0
  136. Documentation/content/images/control_plane.png +0 -0
  137. Documentation/content/images/graph.gif +0 -0
  138. Documentation/content/images/login.png +0 -0
  139. Documentation/content/images/monitoring.png +0 -0
  140. Documentation/content/images/new_connection.gif +0 -0
  141. Documentation/content/images/simulate.gif +0 -0
  142. Documentation/content/images/simulate.png +0 -0
  143. Documentation/content/images/snmp.gif +0 -0
  144. Documentation/content/images/snmp.png +0 -0
  145. Documentation/content/images/snmp_architecture.png +0 -0
  146. Documentation/migrations/__init__.py +0 -0
  147. Documentation/models.py +9 -0
  148. Documentation/static/css/markdown.css +250 -0
  149. Documentation/templates/documentation.html +225 -0
  150. Documentation/templates/nav_item.html +41 -0
  151. Documentation/urls.py +11 -0
  152. Documentation/views.py +442 -0
  153. LogstashUI/__init__.py +0 -0
  154. LogstashUI/__main__.py +10 -0
  155. LogstashUI/asgi.py +16 -0
  156. LogstashUI/cli.py +626 -0
  157. LogstashUI/config.py +116 -0
  158. LogstashUI/database.py +263 -0
  159. LogstashUI/insecure_http.py +117 -0
  160. LogstashUI/logging_config.py +99 -0
  161. LogstashUI/migrate_engine.py +282 -0
  162. LogstashUI/packaging/__init__.py +3 -0
  163. LogstashUI/packaging/logstashui.default +68 -0
  164. LogstashUI/packaging/logstashui.service.in +22 -0
  165. LogstashUI/paths.py +181 -0
  166. LogstashUI/settings.py +437 -0
  167. LogstashUI/telemetry.py +159 -0
  168. LogstashUI/urls.py +56 -0
  169. LogstashUI/wsgi.py +77 -0
  170. Management/__init__.py +0 -0
  171. Management/apps.py +10 -0
  172. Management/migrations/0001_initial.py +29 -0
  173. Management/migrations/0002_settings.py +25 -0
  174. Management/migrations/0003_settings_agent_ui_url.py +29 -0
  175. Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
  176. Management/migrations/__init__.py +0 -0
  177. Management/models.py +92 -0
  178. Management/templates/api_tokens.html +214 -0
  179. Management/templates/components/api_token_created.html +38 -0
  180. Management/templates/components/api_token_row.html +84 -0
  181. Management/templates/components/logstash_artifact_row.html +100 -0
  182. Management/templates/components/logstash_artifact_tbody.html +26 -0
  183. Management/templates/components/user_row.html +67 -0
  184. Management/templates/logs.html +98 -0
  185. Management/templates/logstash_artifacts.html +172 -0
  186. Management/templates/management.html +80 -0
  187. Management/templates/management_settings.html +320 -0
  188. Management/templates/registration/login.html +404 -0
  189. Management/templates/users.html +304 -0
  190. Management/urls.py +23 -0
  191. Management/views.py +804 -0
  192. Monitoring/__init__.py +0 -0
  193. Monitoring/apps.py +9 -0
  194. Monitoring/migrations/__init__.py +0 -0
  195. Monitoring/static/js/monitoring.js +463 -0
  196. Monitoring/templates/components/node_metrics.html +161 -0
  197. Monitoring/templates/components/pipeline_metrics.html +189 -0
  198. Monitoring/templates/monitoring.html +271 -0
  199. Monitoring/urls.py +16 -0
  200. Monitoring/views.py +724 -0
  201. PipelineManager/__init__.py +0 -0
  202. PipelineManager/agent_api.py +1173 -0
  203. PipelineManager/agent_client.py +59 -0
  204. PipelineManager/agent_modes.py +880 -0
  205. PipelineManager/agent_policies.py +689 -0
  206. PipelineManager/agent_versions.py +151 -0
  207. PipelineManager/apps.py +10 -0
  208. PipelineManager/artifact_metrics.py +171 -0
  209. PipelineManager/artifacts.py +820 -0
  210. PipelineManager/connections_crud.py +722 -0
  211. PipelineManager/data/default_jvm.options +76 -0
  212. PipelineManager/data/default_log4j2.properties +165 -0
  213. PipelineManager/data/default_logstash.yml +405 -0
  214. PipelineManager/data/plugins.json +29109 -0
  215. PipelineManager/editor_views.py +608 -0
  216. PipelineManager/forms.py +284 -0
  217. PipelineManager/manager_views.py +490 -0
  218. PipelineManager/migrations/0001_initial.py +38 -0
  219. PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
  220. PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
  221. PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
  222. PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
  223. PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
  224. PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
  225. PipelineManager/migrations/0008_connection_agent_id.py +18 -0
  226. PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
  227. PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
  228. PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
  229. PipelineManager/migrations/0012_policy_binary_path.py +18 -0
  230. PipelineManager/migrations/0013_connection_status_blob.py +18 -0
  231. PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
  232. PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
  233. PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
  234. PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
  235. PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
  236. PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
  237. PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
  238. PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
  239. PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
  240. PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
  241. PipelineManager/migrations/0024_seed_system_policies.py +173 -0
  242. PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
  243. PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
  244. PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
  245. PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
  246. PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
  247. PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
  248. PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
  249. PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
  250. PipelineManager/migrations/0033_simulation_result.py +26 -0
  251. PipelineManager/migrations/__init__.py +0 -0
  252. PipelineManager/models.py +1300 -0
  253. PipelineManager/pipelines_crud.py +738 -0
  254. PipelineManager/policies_crud.py +772 -0
  255. PipelineManager/sim_keystore.py +319 -0
  256. PipelineManager/simulation.py +1581 -0
  257. PipelineManager/static/css/codemirror.min.css +1 -0
  258. PipelineManager/static/css/graph_move.css +79 -0
  259. PipelineManager/static/css/monokai.min.css +1 -0
  260. PipelineManager/static/css/move_mode.css +144 -0
  261. PipelineManager/static/css/show-hint.min.css +1 -0
  262. PipelineManager/static/images/age.png +0 -0
  263. PipelineManager/static/images/aggregate.png +0 -0
  264. PipelineManager/static/images/alter.png +0 -0
  265. PipelineManager/static/images/azure_event_hubs.png +0 -0
  266. PipelineManager/static/images/beats.png +0 -0
  267. PipelineManager/static/images/boundary.png +0 -0
  268. PipelineManager/static/images/bytes.png +0 -0
  269. PipelineManager/static/images/cidr.png +0 -0
  270. PipelineManager/static/images/cipher.png +0 -0
  271. PipelineManager/static/images/circonus.png +0 -0
  272. PipelineManager/static/images/clone.png +0 -0
  273. PipelineManager/static/images/cloudwatch.png +0 -0
  274. PipelineManager/static/images/comment.png +0 -0
  275. PipelineManager/static/images/continue.png +0 -0
  276. PipelineManager/static/images/couchdb_changes.png +0 -0
  277. PipelineManager/static/images/csv.png +0 -0
  278. PipelineManager/static/images/datadog.png +0 -0
  279. PipelineManager/static/images/datadog_metrics.png +0 -0
  280. PipelineManager/static/images/date.png +0 -0
  281. PipelineManager/static/images/de_dot.png +0 -0
  282. PipelineManager/static/images/dead_letter_queue.png +0 -0
  283. PipelineManager/static/images/dissect.png +0 -0
  284. PipelineManager/static/images/dns.png +0 -0
  285. PipelineManager/static/images/drop.png +0 -0
  286. PipelineManager/static/images/dynatrace.png +0 -0
  287. PipelineManager/static/images/elapsed.png +0 -0
  288. PipelineManager/static/images/elastic_agent.png +0 -0
  289. PipelineManager/static/images/elastic_integration.png +0 -0
  290. PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
  291. PipelineManager/static/images/elastic_workplace_search.png +0 -0
  292. PipelineManager/static/images/elasticsearch.png +0 -0
  293. PipelineManager/static/images/else.png +0 -0
  294. PipelineManager/static/images/else_if.png +0 -0
  295. PipelineManager/static/images/email.png +0 -0
  296. PipelineManager/static/images/environment.png +0 -0
  297. PipelineManager/static/images/exec.png +0 -0
  298. PipelineManager/static/images/extractnumbers.png +0 -0
  299. PipelineManager/static/images/file.png +0 -0
  300. PipelineManager/static/images/fingerprint.png +0 -0
  301. PipelineManager/static/images/ganglia.png +0 -0
  302. PipelineManager/static/images/gelf.png +0 -0
  303. PipelineManager/static/images/generator.png +0 -0
  304. PipelineManager/static/images/geoip.png +0 -0
  305. PipelineManager/static/images/github.png +0 -0
  306. PipelineManager/static/images/google_bigquery.png +0 -0
  307. PipelineManager/static/images/google_cloud_storage.png +0 -0
  308. PipelineManager/static/images/google_pubsub.png +0 -0
  309. PipelineManager/static/images/graphite.png +0 -0
  310. PipelineManager/static/images/graphtastic.png +0 -0
  311. PipelineManager/static/images/grok.png +0 -0
  312. PipelineManager/static/images/heartbeat.png +0 -0
  313. PipelineManager/static/images/http.png +0 -0
  314. PipelineManager/static/images/http_poller.png +0 -0
  315. PipelineManager/static/images/i18n.png +0 -0
  316. PipelineManager/static/images/if.png +0 -0
  317. PipelineManager/static/images/imap.png +0 -0
  318. PipelineManager/static/images/influxdb.png +0 -0
  319. PipelineManager/static/images/irc.png +0 -0
  320. PipelineManager/static/images/java_generator.png +0 -0
  321. PipelineManager/static/images/java_stdin.png +0 -0
  322. PipelineManager/static/images/java_stdout.png +0 -0
  323. PipelineManager/static/images/java_uuid.png +0 -0
  324. PipelineManager/static/images/jdbc.png +0 -0
  325. PipelineManager/static/images/jdbc_static.png +0 -0
  326. PipelineManager/static/images/jdbc_streaming.png +0 -0
  327. PipelineManager/static/images/jms.png +0 -0
  328. PipelineManager/static/images/jmx.png +0 -0
  329. PipelineManager/static/images/json.png +0 -0
  330. PipelineManager/static/images/json_encode.png +0 -0
  331. PipelineManager/static/images/juggernaut.png +0 -0
  332. PipelineManager/static/images/kafka.png +0 -0
  333. PipelineManager/static/images/kinesis.png +0 -0
  334. PipelineManager/static/images/kv.png +0 -0
  335. PipelineManager/static/images/librato.png +0 -0
  336. PipelineManager/static/images/log4j.png +0 -0
  337. PipelineManager/static/images/loggly.png +0 -0
  338. PipelineManager/static/images/logstash.png +0 -0
  339. PipelineManager/static/images/lumberjack.png +0 -0
  340. PipelineManager/static/images/meetup.png +0 -0
  341. PipelineManager/static/images/memcached.png +0 -0
  342. PipelineManager/static/images/metriccatcher.png +0 -0
  343. PipelineManager/static/images/metricize.png +0 -0
  344. PipelineManager/static/images/metrics.png +0 -0
  345. PipelineManager/static/images/mongodb.png +0 -0
  346. PipelineManager/static/images/mutate.png +0 -0
  347. PipelineManager/static/images/nagios.png +0 -0
  348. PipelineManager/static/images/nagios_nsca.png +0 -0
  349. PipelineManager/static/images/opentsdb.png +0 -0
  350. PipelineManager/static/images/pagerduty.png +0 -0
  351. PipelineManager/static/images/pipe.png +0 -0
  352. PipelineManager/static/images/pipeline.png +0 -0
  353. PipelineManager/static/images/prune.png +0 -0
  354. PipelineManager/static/images/puppet_facter.png +0 -0
  355. PipelineManager/static/images/rabbitmq.png +0 -0
  356. PipelineManager/static/images/range.png +0 -0
  357. PipelineManager/static/images/redis.png +0 -0
  358. PipelineManager/static/images/redmine.png +0 -0
  359. PipelineManager/static/images/relp.png +0 -0
  360. PipelineManager/static/images/riak.png +0 -0
  361. PipelineManager/static/images/riemann.png +0 -0
  362. PipelineManager/static/images/rss.png +0 -0
  363. PipelineManager/static/images/ruby.png +0 -0
  364. PipelineManager/static/images/s3-sns-sqs.png +0 -0
  365. PipelineManager/static/images/s3.png +0 -0
  366. PipelineManager/static/images/salesforce.png +0 -0
  367. PipelineManager/static/images/sink.png +0 -0
  368. PipelineManager/static/images/sleep.png +0 -0
  369. PipelineManager/static/images/snmp.png +0 -0
  370. PipelineManager/static/images/snmptrap.png +0 -0
  371. PipelineManager/static/images/sns.png +0 -0
  372. PipelineManager/static/images/solr_http.png +0 -0
  373. PipelineManager/static/images/split.png +0 -0
  374. PipelineManager/static/images/sqlite.png +0 -0
  375. PipelineManager/static/images/sqs.png +0 -0
  376. PipelineManager/static/images/statsd.png +0 -0
  377. PipelineManager/static/images/stdin.png +0 -0
  378. PipelineManager/static/images/stdout.png +0 -0
  379. PipelineManager/static/images/stomp.png +0 -0
  380. PipelineManager/static/images/syslog.png +0 -0
  381. PipelineManager/static/images/syslog_pri.png +0 -0
  382. PipelineManager/static/images/tcp.png +0 -0
  383. PipelineManager/static/images/threats_classifier.png +0 -0
  384. PipelineManager/static/images/throttle.png +0 -0
  385. PipelineManager/static/images/timber.png +0 -0
  386. PipelineManager/static/images/tld.png +0 -0
  387. PipelineManager/static/images/translate.png +0 -0
  388. PipelineManager/static/images/truncate.png +0 -0
  389. PipelineManager/static/images/twitter.png +0 -0
  390. PipelineManager/static/images/udp.png +0 -0
  391. PipelineManager/static/images/unix.png +0 -0
  392. PipelineManager/static/images/urldecode.png +0 -0
  393. PipelineManager/static/images/useragent.png +0 -0
  394. PipelineManager/static/images/uuid.png +0 -0
  395. PipelineManager/static/images/varnishlog.png +0 -0
  396. PipelineManager/static/images/webhdfs.png +0 -0
  397. PipelineManager/static/images/websocket.png +0 -0
  398. PipelineManager/static/images/wmi.png +0 -0
  399. PipelineManager/static/images/wurfl_device_detection.png +0 -0
  400. PipelineManager/static/images/xml.png +0 -0
  401. PipelineManager/static/images/xmpp.png +0 -0
  402. PipelineManager/static/images/zabbix.png +0 -0
  403. PipelineManager/static/js/agent_inspect_modal.js +141 -0
  404. PipelineManager/static/js/agent_policies.js +3746 -0
  405. PipelineManager/static/js/agent_status_sse.js +166 -0
  406. PipelineManager/static/js/codemirror.min.js +1 -0
  407. PipelineManager/static/js/connections_table.js +551 -0
  408. PipelineManager/static/js/d3.v7.js +20625 -0
  409. PipelineManager/static/js/diff_modal.js +995 -0
  410. PipelineManager/static/js/expression_editor.js +291 -0
  411. PipelineManager/static/js/js-yaml.min.js +1 -0
  412. PipelineManager/static/js/logstashyml_guides.js +1063 -0
  413. PipelineManager/static/js/move_graph.js +577 -0
  414. PipelineManager/static/js/move_mode.js +559 -0
  415. PipelineManager/static/js/pipeline_editor.js +4102 -0
  416. PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
  417. PipelineManager/static/js/pipeline_list.js +274 -0
  418. PipelineManager/static/js/pipeline_settings.js +121 -0
  419. PipelineManager/static/js/pipeline_text_editor.js +2088 -0
  420. PipelineManager/static/js/plugin_config_modal.js +2827 -0
  421. PipelineManager/static/js/policy_deploy_modal.js +1066 -0
  422. PipelineManager/static/js/show-hint.min.js +1 -0
  423. PipelineManager/static/js/sim_targets.js +380 -0
  424. PipelineManager/static/js/simple-comment-mode.js +56 -0
  425. PipelineManager/static/js/simulation_modal.js +1135 -0
  426. PipelineManager/static/js/simulation_results.js +2778 -0
  427. PipelineManager/static/js/stats_strip.js +231 -0
  428. PipelineManager/static/js/yaml.js +120 -0
  429. PipelineManager/system_policy_defaults.py +279 -0
  430. PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
  431. PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
  432. PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
  433. PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
  434. PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
  435. PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
  436. PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
  437. PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
  438. PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
  439. PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
  440. PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
  441. PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
  442. PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
  443. PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
  444. PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
  445. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
  446. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
  447. PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
  448. PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
  449. PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
  450. PipelineManager/templates/pipeline_editor.html +1738 -0
  451. PipelineManager/templates/pipeline_graph_editor.html +99 -0
  452. PipelineManager/templates/pipeline_manager.html +584 -0
  453. PipelineManager/templates/pipeline_text_editor.html +350 -0
  454. PipelineManager/urls.py +99 -0
  455. SNMP/__init__.py +0 -0
  456. SNMP/ai_template_generation.py +232 -0
  457. SNMP/apps.py +9 -0
  458. SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
  459. SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
  460. SNMP/data/authoring_instructions.md +65 -0
  461. SNMP/data/grounding/.gitignore +4 -0
  462. SNMP/data/grounding/build_grounding.py +35 -0
  463. SNMP/data/grounding/grounding.json +1 -0
  464. SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
  465. SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
  466. SNMP/data/mib_reference/std_entity_sensors.json +28 -0
  467. SNMP/data/mib_reference/std_host_resources.json +32 -0
  468. SNMP/data/mib_reference/std_ospf_mib.json +55 -0
  469. SNMP/data/mib_reference/std_ucd_linux.json +27 -0
  470. SNMP/data/normalizers.json +103 -0
  471. SNMP/data/official_device_templates/arista_eos.json +24 -0
  472. SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
  473. SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
  474. SNMP/data/official_device_templates/cisco_ios.json +21 -0
  475. SNMP/data/official_device_templates/default.json +13 -0
  476. SNMP/data/official_device_templates/dell_idrac.json +22 -0
  477. SNMP/data/official_device_templates/dell_x1026.json +16 -0
  478. SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
  479. SNMP/data/official_device_templates/eastpower_ups.json +20 -0
  480. SNMP/data/official_device_templates/eaton_ups.json +22 -0
  481. SNMP/data/official_device_templates/epson_printer.json +18 -0
  482. SNMP/data/official_device_templates/geist_watchdog.json +20 -0
  483. SNMP/data/official_device_templates/generic_linux.json +18 -0
  484. SNMP/data/official_device_templates/generic_ont.json +18 -0
  485. SNMP/data/official_device_templates/generic_ups.json +16 -0
  486. SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
  487. SNMP/data/official_device_templates/hpe_nimble.json +17 -0
  488. SNMP/data/official_device_templates/huawei_ups.json +19 -0
  489. SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
  490. SNMP/data/official_device_templates/isilon_onefs.json +22 -0
  491. SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
  492. SNMP/data/official_device_templates/netapp_7mode.json +22 -0
  493. SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
  494. SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
  495. SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
  496. SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
  497. SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
  498. SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
  499. SNMP/data/official_profiles/arista_eos.json +16 -0
  500. SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
  501. SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
  502. SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
  503. SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
  504. SNMP/data/official_profiles/cisco_cdp.json +26 -0
  505. SNMP/data/official_profiles/cisco_fans.json +18 -0
  506. SNMP/data/official_profiles/cisco_sensors.json +21 -0
  507. SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
  508. SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
  509. SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
  510. SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
  511. SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
  512. SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
  513. SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
  514. SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
  515. SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
  516. SNMP/data/official_profiles/eaton_ups.json +40 -0
  517. SNMP/data/official_profiles/geist_environment.json +50 -0
  518. SNMP/data/official_profiles/generic_arp.json +19 -0
  519. SNMP/data/official_profiles/generic_bgp.json +24 -0
  520. SNMP/data/official_profiles/generic_entity_psu.json +26 -0
  521. SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
  522. SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
  523. SNMP/data/official_profiles/generic_interfaces.json +86 -0
  524. SNMP/data/official_profiles/generic_ip_addr.json +19 -0
  525. SNMP/data/official_profiles/generic_lldp.json +54 -0
  526. SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
  527. SNMP/data/official_profiles/generic_mac_table.json +19 -0
  528. SNMP/data/official_profiles/generic_ont.json +88 -0
  529. SNMP/data/official_profiles/generic_ospf.json +21 -0
  530. SNMP/data/official_profiles/generic_printer_mib.json +48 -0
  531. SNMP/data/official_profiles/generic_rmon.json +38 -0
  532. SNMP/data/official_profiles/generic_system.json +17 -0
  533. SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
  534. SNMP/data/official_profiles/generic_ups_mib.json +154 -0
  535. SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
  536. SNMP/data/official_profiles/huawei_ups.json +111 -0
  537. SNMP/data/official_profiles/isilon_performance.json +92 -0
  538. SNMP/data/official_profiles/isilon_protocols.json +77 -0
  539. SNMP/data/official_profiles/isilon_system.json +86 -0
  540. SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
  541. SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
  542. SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
  543. SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
  544. SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
  545. SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
  546. SNMP/data/official_profiles/paloalto_components.json +36 -0
  547. SNMP/data/official_profiles/paloalto_system.json +15 -0
  548. SNMP/data/official_profiles/traps.json +16 -0
  549. SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
  550. SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
  551. SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
  552. SNMP/data/official_profiles/versa_flexvnf.json +14 -0
  553. SNMP/data/schema.md +650 -0
  554. SNMP/data/schema_reference/snmp_field_schema.md +747 -0
  555. SNMP/data/snmp_template.json +629 -0
  556. SNMP/data/template_profile_context.md +3986 -0
  557. SNMP/inline_grounding.py +77 -0
  558. SNMP/management/__init__.py +1 -0
  559. SNMP/management/commands/__init__.py +1 -0
  560. SNMP/management/commands/generate_template_profile_context.py +272 -0
  561. SNMP/management/commands/load_test_snmp_data.py +240 -0
  562. SNMP/management/commands/sync_snmp_official_data.py +263 -0
  563. SNMP/management/commands/unload_test_snmp_data.py +77 -0
  564. SNMP/migrations/0001_initial.py +101 -0
  565. SNMP/migrations/0002_devicetemplate.py +34 -0
  566. SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
  567. SNMP/migrations/0004_device_device_template.py +19 -0
  568. SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
  569. SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
  570. SNMP/migrations/0007_remove_device_profiles.py +17 -0
  571. SNMP/migrations/0008_devicetemplate_type.py +18 -0
  572. SNMP/migrations/0009_alter_device_device_template.py +19 -0
  573. SNMP/migrations/0010_alter_device_device_template.py +19 -0
  574. SNMP/migrations/0011_network_namespace.py +18 -0
  575. SNMP/migrations/0012_profile_normalizers.py +18 -0
  576. SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
  577. SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
  578. SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
  579. SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
  580. SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
  581. SNMP/migrations/0018_add_official_key.py +39 -0
  582. SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
  583. SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
  584. SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
  585. SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
  586. SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
  587. SNMP/migrations/0024_network_credential_mode.py +18 -0
  588. SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
  589. SNMP/migrations/__init__.py +0 -0
  590. SNMP/models.py +892 -0
  591. SNMP/network_map.py +660 -0
  592. SNMP/overview.py +394 -0
  593. SNMP/snmp_crud.py +6082 -0
  594. SNMP/snmp_grounding.py +146 -0
  595. SNMP/snmp_normalizers.py +594 -0
  596. SNMP/snmp_pipeline_generator.py +1658 -0
  597. SNMP/snmp_test.py +962 -0
  598. SNMP/static/css/snmp.css +33 -0
  599. SNMP/static/images/apc.png +0 -0
  600. SNMP/static/images/arista.png +0 -0
  601. SNMP/static/images/aruba.png +0 -0
  602. SNMP/static/images/brocade.png +0 -0
  603. SNMP/static/images/cisco.png +0 -0
  604. SNMP/static/images/dell.png +0 -0
  605. SNMP/static/images/dlink.png +0 -0
  606. SNMP/static/images/east.png +0 -0
  607. SNMP/static/images/eaton.png +0 -0
  608. SNMP/static/images/epson.png +0 -0
  609. SNMP/static/images/hauwei.png +0 -0
  610. SNMP/static/images/hp.png +0 -0
  611. SNMP/static/images/hpe.png +0 -0
  612. SNMP/static/images/ingrasys.png +0 -0
  613. SNMP/static/images/linux.png +0 -0
  614. SNMP/static/images/mellanox.png +0 -0
  615. SNMP/static/images/netapp.png +0 -0
  616. SNMP/static/images/paloalto.png +0 -0
  617. SNMP/static/images/phoenixtec.png +0 -0
  618. SNMP/static/images/ubiquiti.png +0 -0
  619. SNMP/static/images/unknown.png +0 -0
  620. SNMP/static/images/versa.png +0 -0
  621. SNMP/static/images/vertiv.png +0 -0
  622. SNMP/static/js/ai_device_template_modal.js +1116 -0
  623. SNMP/static/js/credentials_table.js +291 -0
  624. SNMP/static/js/devices_table.js +588 -0
  625. SNMP/static/js/discovered_devices.js +291 -0
  626. SNMP/static/js/network_map.js +1657 -0
  627. SNMP/static/js/networks_table.js +360 -0
  628. SNMP/static/js/onboarding.js +866 -0
  629. SNMP/static/js/overview.js +416 -0
  630. SNMP/static/js/snmp_changes_indicator.js +76 -0
  631. SNMP/static/js/snmp_commit_modal.js +39 -0
  632. SNMP/static/js/snmp_credentials_modal.js +217 -0
  633. SNMP/static/js/snmp_device_template_modal.js +669 -0
  634. SNMP/static/js/snmp_device_visual_preview.js +1707 -0
  635. SNMP/static/js/snmp_devices_modal.js +912 -0
  636. SNMP/static/js/snmp_diff_modal.js +1559 -0
  637. SNMP/static/js/snmp_network_modal.js +940 -0
  638. SNMP/static/js/snmp_profile_modal.js +1212 -0
  639. SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
  640. SNMP/static/js/snmp_test.js +538 -0
  641. SNMP/templates/Credentials.html +325 -0
  642. SNMP/templates/DeviceTemplates.html +1059 -0
  643. SNMP/templates/Devices.html +274 -0
  644. SNMP/templates/Networks.html +469 -0
  645. SNMP/templates/Onboarding.html +521 -0
  646. SNMP/templates/Overview.html +227 -0
  647. SNMP/templates/components/ai_device_template_modal.html +46 -0
  648. SNMP/templates/components/ai_generate_template_content.html +224 -0
  649. SNMP/templates/components/device_template_profile_modal.html +60 -0
  650. SNMP/templates/components/discovered_devices_content.html +86 -0
  651. SNMP/templates/components/discovered_devices_modal.html +43 -0
  652. SNMP/templates/components/gmaps_latlon_modal.html +93 -0
  653. SNMP/templates/components/network_map.html +110 -0
  654. SNMP/templates/components/snmp_commit_modal.html +53 -0
  655. SNMP/templates/components/snmp_credentials_modal.html +189 -0
  656. SNMP/templates/components/snmp_device_modal.html +6 -0
  657. SNMP/templates/components/snmp_device_template_modal.html +129 -0
  658. SNMP/templates/components/snmp_device_visual_preview.html +347 -0
  659. SNMP/templates/components/snmp_devices_modal.html +330 -0
  660. SNMP/templates/components/snmp_diff_modal.html +148 -0
  661. SNMP/templates/components/snmp_network_modal.html +380 -0
  662. SNMP/templates/components/snmp_profile_modal.html +147 -0
  663. SNMP/templates/components/snmp_test_modal.html +398 -0
  664. SNMP/templatetags/__init__.py +0 -0
  665. SNMP/templatetags/snmp_extras.py +17 -0
  666. SNMP/urls.py +94 -0
  667. SNMP/views.py +913 -0
  668. Site/__init__.py +0 -0
  669. Site/apps.py +9 -0
  670. Site/migrations/__init__.py +0 -0
  671. Site/product_ca_views.py +41 -0
  672. Site/static/images/ElasticIcon.png +0 -0
  673. Site/static/images/LoggyIcon.png +0 -0
  674. Site/static/images/LoggyWizardIcon.png +0 -0
  675. Site/static/images/LogstashAgentIcon.png +0 -0
  676. Site/static/images/LogstashIcon.png +0 -0
  677. Site/static/js/base.js +192 -0
  678. Site/static/js/marked.min.js +69 -0
  679. Site/templates/base.html +52 -0
  680. Site/templates/error.html +65 -0
  681. Site/templates/home.html +148 -0
  682. Site/templates/navigation.html +530 -0
  683. Site/templates/popup.html +251 -0
  684. Site/templatetags/__init__.py +0 -0
  685. Site/templatetags/custom_filters.py +36 -0
  686. Site/urls.py +21 -0
  687. Site/views.py +200 -0
  688. Utilities/__init__.py +0 -0
  689. Utilities/apps.py +9 -0
  690. Utilities/data/grok-patterns/LICENSE +202 -0
  691. Utilities/data/grok-patterns/ecs-v1/aws +33 -0
  692. Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
  693. Utilities/data/grok-patterns/ecs-v1/bind +13 -0
  694. Utilities/data/grok-patterns/ecs-v1/bro +30 -0
  695. Utilities/data/grok-patterns/ecs-v1/exim +26 -0
  696. Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
  697. Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
  698. Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
  699. Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
  700. Utilities/data/grok-patterns/ecs-v1/java +34 -0
  701. Utilities/data/grok-patterns/ecs-v1/junos +13 -0
  702. Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
  703. Utilities/data/grok-patterns/ecs-v1/maven +1 -0
  704. Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
  705. Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
  706. Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
  707. Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
  708. Utilities/data/grok-patterns/ecs-v1/rails +13 -0
  709. Utilities/data/grok-patterns/ecs-v1/redis +3 -0
  710. Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
  711. Utilities/data/grok-patterns/ecs-v1/squid +6 -0
  712. Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
  713. Utilities/data/grok-patterns/legacy/aws +14 -0
  714. Utilities/data/grok-patterns/legacy/bacula +50 -0
  715. Utilities/data/grok-patterns/legacy/bind +3 -0
  716. Utilities/data/grok-patterns/legacy/bro +13 -0
  717. Utilities/data/grok-patterns/legacy/exim +19 -0
  718. Utilities/data/grok-patterns/legacy/firewalls +91 -0
  719. Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
  720. Utilities/data/grok-patterns/legacy/haproxy +39 -0
  721. Utilities/data/grok-patterns/legacy/httpd +15 -0
  722. Utilities/data/grok-patterns/legacy/java +17 -0
  723. Utilities/data/grok-patterns/legacy/junos +9 -0
  724. Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
  725. Utilities/data/grok-patterns/legacy/maven +1 -0
  726. Utilities/data/grok-patterns/legacy/mcollective +1 -0
  727. Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
  728. Utilities/data/grok-patterns/legacy/mongodb +7 -0
  729. Utilities/data/grok-patterns/legacy/nagios +124 -0
  730. Utilities/data/grok-patterns/legacy/postgresql +3 -0
  731. Utilities/data/grok-patterns/legacy/rails +13 -0
  732. Utilities/data/grok-patterns/legacy/redis +3 -0
  733. Utilities/data/grok-patterns/legacy/ruby +2 -0
  734. Utilities/data/grok-patterns/legacy/squid +4 -0
  735. Utilities/dissect.py +302 -0
  736. Utilities/grok.py +412 -0
  737. Utilities/migrations/__init__.py +0 -0
  738. Utilities/static/css/debugger_editor.css +88 -0
  739. Utilities/static/js/debugger_editor.js +93 -0
  740. Utilities/static/js/grok_debugger.js +131 -0
  741. Utilities/templates/dissect_debugger.html +95 -0
  742. Utilities/templates/grok_debugger.html +99 -0
  743. Utilities/urls.py +14 -0
  744. Utilities/views.py +363 -0
  745. logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
  746. logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
  747. logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
  748. logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
  749. logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
  750. logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
  751. theme/__init__.py +0 -0
  752. theme/apps.py +9 -0
  753. theme/package-lock.json +6 -0
  754. theme/static/css/dist/styles.css +2 -0
  755. theme/static/images/favicon.ico +0 -0
  756. theme/static_src/.gitignore +1 -0
  757. theme/static_src/package-lock.json +1930 -0
  758. theme/static_src/package.json +26 -0
  759. theme/static_src/postcss.config.js +7 -0
  760. theme/static_src/src/styles.css +38 -0
  761. theme/static_src/tailwind.config.js +43 -0
  762. theme/templates/base.html +32 -0
@@ -0,0 +1,2778 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License;
4
+ * you may not use this file except in compliance with the Elastic License.
5
+ */
6
+
7
+ /**
8
+ * Simulation Results Polling
9
+ * Polls the GetSimulationResults endpoint and displays streaming results
10
+ */
11
+
12
+ /**
13
+ * Annotate an object with change status metadata
14
+ * Walks through the object and marks fields based on the changes diff
15
+ * Also includes deleted fields from the changes object
16
+ */
17
+ function annotateWithChanges(obj, changes, path = '', inheritedStatus = null) {
18
+ const annotated = {};
19
+
20
+ // First, process existing fields
21
+ for (const key in obj) {
22
+ if (!obj.hasOwnProperty(key)) continue;
23
+
24
+ const fullPath = path ? `${path}.${key}` : key;
25
+ const value = obj[key];
26
+
27
+ // Determine the status of this field
28
+ let status = inheritedStatus; // Start with inherited status from parent
29
+ if (changes) {
30
+ if (changes.added && changes.added.hasOwnProperty(fullPath)) {
31
+ status = 'added';
32
+ } else if (changes.modified && changes.modified.hasOwnProperty(fullPath)) {
33
+ status = 'modified';
34
+ }
35
+ }
36
+
37
+ // If this is an object, recursively annotate it
38
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
39
+ annotated[key] = {
40
+ __status: status,
41
+ __value: annotateWithChanges(value, changes, fullPath, status) // Pass status down
42
+ };
43
+ } else {
44
+ annotated[key] = {
45
+ __status: status,
46
+ __value: value
47
+ };
48
+ }
49
+ }
50
+
51
+ // Now add deleted fields if we're at the root level (path is empty)
52
+ if (path === '' && changes && changes.deleted) {
53
+ for (const deletedPath in changes.deleted) {
54
+ if (changes.deleted.hasOwnProperty(deletedPath)) {
55
+ const deletedValue = changes.deleted[deletedPath];
56
+
57
+ // Add the deleted field to the annotated object
58
+ if (deletedValue && typeof deletedValue === 'object' && !Array.isArray(deletedValue)) {
59
+ annotated[deletedPath] = {
60
+ __status: 'deleted',
61
+ __value: annotateDeletedObject(deletedValue, 'deleted')
62
+ };
63
+ } else {
64
+ annotated[deletedPath] = {
65
+ __status: 'deleted',
66
+ __value: deletedValue
67
+ };
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ return annotated;
74
+ }
75
+
76
+ /**
77
+ * Helper to annotate deleted objects - all nested fields inherit 'deleted' status
78
+ */
79
+ function annotateDeletedObject(obj, status) {
80
+ const annotated = {};
81
+
82
+ for (const key in obj) {
83
+ if (!obj.hasOwnProperty(key)) continue;
84
+
85
+ const value = obj[key];
86
+
87
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
88
+ annotated[key] = {
89
+ __status: status,
90
+ __value: annotateDeletedObject(value, status)
91
+ };
92
+ } else {
93
+ annotated[key] = {
94
+ __status: status,
95
+ __value: value
96
+ };
97
+ }
98
+ }
99
+
100
+ return annotated;
101
+ }
102
+
103
+ /**
104
+ * Syntax highlight JSON string with colors, optionally showing change context
105
+ * @param {string} jsonString - The JSON string to highlight
106
+ * @param {Object} changes - Optional diff object with added/modified/deleted fields
107
+ * Returns HTML with colored JSON elements
108
+ */
109
+ function highlightJSON(jsonString, changes = null) {
110
+ try {
111
+ // Parse the JSON
112
+ const obj = JSON.parse(jsonString);
113
+
114
+ // Add deleted fields to the object for display
115
+ if (changes && changes.deleted) {
116
+ for (const deletedPath in changes.deleted) {
117
+ if (changes.deleted.hasOwnProperty(deletedPath)) {
118
+ obj[deletedPath] = changes.deleted[deletedPath];
119
+ }
120
+ }
121
+ }
122
+
123
+ // Annotate with change information
124
+ const annotated = changes ? annotateWithChanges(obj, changes) : null;
125
+
126
+ // Format for display
127
+ const formatted = JSON.stringify(obj, null, 2);
128
+
129
+ // Track path as we process lines
130
+ let pathStack = [];
131
+ let lastKey = '';
132
+
133
+ const highlighted = formatted.split('\n').map(line => {
134
+ const trimmed = line.trim();
135
+
136
+ // Update path stack based on braces BEFORE processing the line
137
+ if (trimmed.endsWith('{')) {
138
+ // Line ends with opening brace - this key starts an object
139
+ // The key will be captured in the regex below, then we push it
140
+ } else if (trimmed === '}' || trimmed === '},') {
141
+ // Closing brace - pop from stack
142
+ if (pathStack.length > 0) {
143
+ pathStack.pop();
144
+ }
145
+ }
146
+
147
+ let shouldPushKey = trimmed.endsWith('{');
148
+
149
+ return line.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, (match) => {
150
+ const escaped = match.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
151
+
152
+ if (/^"/.test(match) && /:$/.test(match)) {
153
+ // This is a key
154
+ lastKey = match.slice(1, -2);
155
+
156
+ // If this line ends with {, push this key to the stack after we process it
157
+ if (shouldPushKey) {
158
+ pathStack.push(lastKey);
159
+ shouldPushKey = false; // Only push once per line
160
+ }
161
+
162
+ return `<span style="color: #60a5fa">${escaped}</span>`;
163
+ } else {
164
+ // Value - get status from annotated object
165
+ const fullPath = pathStack.length > 0 ? pathStack.join('.') + '.' + lastKey : lastKey;
166
+ let color = '#ffffff';
167
+
168
+ if (annotated) {
169
+ const status = getStatus(annotated, fullPath);
170
+ if (status === 'added') color = '#86efac'; // green
171
+ else if (status === 'modified') color = '#fbbf24'; // yellow
172
+ else if (status === 'deleted') color = '#ef4444'; // red
173
+ }
174
+
175
+ if (/null/.test(match)) color = '#9ca3af';
176
+
177
+ return `<span style="color: ${color}">${escaped}</span>`;
178
+ }
179
+ });
180
+ }).join('\n');
181
+
182
+ return highlighted;
183
+ } catch (e) {
184
+ return jsonString.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Get the status of a field from the annotated object
190
+ * Handles both dot-notation keys (like "log.original") and nested paths (like "observer.ip" -> "name")
191
+ */
192
+ function getStatus(annotated, path) {
193
+ // First, try the path as a single key (for Logstash dot-notation fields like "log.original")
194
+ if (annotated[path] && annotated[path].__status) {
195
+ return annotated[path].__status;
196
+ }
197
+
198
+ // Try as a nested path
199
+ const parts = path.split('.');
200
+ let current = annotated;
201
+
202
+ // Try different combinations - e.g., for "observer.ip.name", try:
203
+ // 1. "observer.ip" as key, then "name"
204
+ // 2. "observer" -> "ip" -> "name"
205
+ for (let i = parts.length - 1; i >= 0; i--) {
206
+ const keyPart = parts.slice(0, i + 1).join('.');
207
+ const remainingParts = parts.slice(i + 1);
208
+
209
+ if (annotated[keyPart]) {
210
+ // Found a key that matches - now traverse the remaining parts
211
+ let temp = annotated[keyPart];
212
+
213
+ if (remainingParts.length === 0) {
214
+ // This is the exact field
215
+ return temp.__status || null;
216
+ }
217
+
218
+ // Navigate through remaining parts
219
+ for (const part of remainingParts) {
220
+ if (!temp || !temp.__value || !temp.__value[part]) {
221
+ break;
222
+ }
223
+ temp = temp.__value[part];
224
+ }
225
+
226
+ if (temp && temp.__status) {
227
+ return temp.__status;
228
+ }
229
+ }
230
+ }
231
+
232
+ // Fallback: try as fully nested path
233
+ current = annotated;
234
+ for (const part of parts) {
235
+ if (!current || !current[part]) return null;
236
+
237
+ const status = current[part].__status;
238
+ if (status) return status;
239
+
240
+ current = current[part].__value;
241
+ }
242
+
243
+ return null;
244
+ }
245
+
246
+ /**
247
+ * Check if an event has parsing failure tags
248
+ * Looks for common Logstash failure tags in the tags field
249
+ * Also checks for custom tag_on_failure values if they exist in the event
250
+ * @param {Object} event - The event object to check
251
+ * @returns {Object} - Object with hasFailure boolean and failureTags array
252
+ */
253
+ function checkForParsingFailures(event) {
254
+ const result = {
255
+ hasFailure: false,
256
+ failureTags: []
257
+ };
258
+
259
+ if (!event) {
260
+ return result;
261
+ }
262
+
263
+
264
+ // Common Logstash parsing failure tags
265
+ const commonFailureTags = [
266
+ '_grokparsefailure',
267
+ '_dissectfailure',
268
+ '_dateparsefailure',
269
+ '_jsonparsefailure'
270
+ ];
271
+
272
+ // Check if event has a tags field
273
+ if (event.tags && Array.isArray(event.tags)) {
274
+
275
+ // Check for common failure tags (case-insensitive)
276
+ const foundCommonFailures = event.tags.filter(tag =>
277
+ typeof tag === 'string' && commonFailureTags.includes(tag.toLowerCase())
278
+ );
279
+
280
+ if (foundCommonFailures.length > 0) {
281
+ result.hasFailure = true;
282
+ result.failureTags.push(...foundCommonFailures);
283
+ }
284
+
285
+ // Also check for ANY tag that starts with underscore and contains "fail"
286
+ // This catches custom failure tags like "_grok_syslog_wrapper_fail", "_grok_ciscotag_fail", etc.
287
+ const customFailureTags = event.tags.filter(tag =>
288
+ typeof tag === 'string' &&
289
+ tag.startsWith('_') &&
290
+ tag.toLowerCase().includes('fail')
291
+ );
292
+
293
+ if (customFailureTags.length > 0) {
294
+ result.hasFailure = true;
295
+ result.failureTags.push(...customFailureTags);
296
+ }
297
+ } else {
298
+ console.error('checkForParsingFailures: Event has no tags field or tags is not an array');
299
+ }
300
+
301
+ // Remove duplicates from failureTags
302
+ result.failureTags = [...new Set(result.failureTags)];
303
+
304
+
305
+ return result;
306
+ }
307
+
308
+ /**
309
+ * Helper to filter simulation metadata from event objects
310
+ * Returns a copy without simulation, slot, run_id if Debug Metadata toggle is unchecked
311
+ */
312
+ function filterMetadata(obj) {
313
+ if (!obj) {
314
+ return obj;
315
+ }
316
+
317
+ const toggle = document.getElementById('debugMetadataToggle');
318
+ const showMetadata = toggle ? toggle.checked : false; // Default to hiding metadata
319
+
320
+ if (showMetadata) {
321
+ return obj; // Return original if showing metadata
322
+ }
323
+
324
+ // Create copy and remove metadata fields
325
+ const copy = JSON.parse(JSON.stringify(obj));
326
+ delete copy.simulation;
327
+ delete copy.slot;
328
+ delete copy.run_id;
329
+
330
+ return copy;
331
+ }
332
+
333
+ /**
334
+ * Mark executed plugins in the editor with visual indicators
335
+ */
336
+ function markExecutedPlugins(nodes, originalEvent, outputEvent = null) {
337
+ // Hide any visible tooltips BEFORE removing DOM elements to prevent stuck tooltips
338
+ const tooltip = document.getElementById('data-flow-tooltip');
339
+ if (tooltip) {
340
+ tooltip.style.display = 'none';
341
+ }
342
+
343
+ // Clear any existing simulation badges and data indicators
344
+ document.querySelectorAll('.simulation-executed-badge').forEach(badge => badge.remove());
345
+ document.querySelectorAll('.simulation-data-indicator').forEach(indicator => indicator.remove());
346
+ document.querySelectorAll('.simulation-data-flow').forEach(flow => flow.remove());
347
+
348
+ // Remove any existing dimming
349
+ document.querySelectorAll('.simulation-dimmed').forEach(el => {
350
+ el.classList.remove('simulation-dimmed');
351
+ });
352
+
353
+ // Collect IDs of executed plugins
354
+ const executedPluginIds = new Set();
355
+ nodes.forEach(node => {
356
+ if (node.id !== 'start') {
357
+ let componentId = node.id;
358
+ if (node.isDecisionPoint) {
359
+ componentId = node.conditionalId;
360
+ }
361
+ executedPluginIds.add(componentId);
362
+ }
363
+ });
364
+
365
+ // Dim all plugins that were NOT executed
366
+ document.querySelectorAll('[data-id]').forEach(element => {
367
+ const componentId = element.getAttribute('data-id');
368
+ if (componentId && !executedPluginIds.has(componentId)) {
369
+ element.classList.add('simulation-dimmed');
370
+ }
371
+ });
372
+
373
+ // Add original event data flow indicator at the top of filter section
374
+ if (originalEvent) {
375
+ const filterContainer = document.getElementById('filterComponents');
376
+ if (filterContainer && filterContainer.firstChild) {
377
+ addOriginalEventIndicator(filterContainer, originalEvent);
378
+ }
379
+ }
380
+
381
+ // Add badges and data indicators to executed plugins
382
+ nodes.forEach(node => {
383
+ // Skip the start node
384
+ if (node.id === 'start') return;
385
+
386
+ let componentId = node.id;
387
+
388
+ // For decision point nodes, use the conditional ID
389
+ if (node.isDecisionPoint) {
390
+ componentId = node.conditionalId;
391
+ }
392
+
393
+ // Use data-id selector (not data-component-id)
394
+ const componentElement = document.querySelector(`[data-id="${componentId}"]`);
395
+
396
+ if (componentElement) {
397
+ // Check for parsing failures ADDED by this plugin
398
+ let hasFailure = false;
399
+ let failureTags = [];
400
+ if (node.eventJson && node.changes) {
401
+ try {
402
+ // Check if this plugin ADDED any failure tags
403
+ // Look in the changes.added or changes.modified for the 'tags' field
404
+ const changes = typeof node.changes === 'string' ? JSON.parse(node.changes) : node.changes;
405
+
406
+ // Check if tags were added
407
+ if (changes.added && changes.added.tags) {
408
+ const addedTags = Array.isArray(changes.added.tags) ? changes.added.tags : [changes.added.tags];
409
+ const failureCheck = checkForParsingFailures({ tags: addedTags });
410
+ if (failureCheck.hasFailure) {
411
+ hasFailure = true;
412
+ failureTags = failureCheck.failureTags;
413
+ }
414
+ }
415
+
416
+ // Check if tags were modified (from old value to new value)
417
+ if (!hasFailure && changes.modified && changes.modified.tags) {
418
+ const modifiedTags = changes.modified.tags;
419
+ const oldTags = Array.isArray(modifiedTags.from) ? modifiedTags.from : [];
420
+ const newTags = Array.isArray(modifiedTags.to) ? modifiedTags.to : [];
421
+
422
+ // Find tags that were added (in new but not in old)
423
+ const addedInModification = newTags.filter(tag => !oldTags.includes(tag));
424
+
425
+ if (addedInModification.length > 0) {
426
+ const failureCheck = checkForParsingFailures({ tags: addedInModification });
427
+ if (failureCheck.hasFailure) {
428
+ hasFailure = true;
429
+ failureTags = failureCheck.failureTags;
430
+ }
431
+ }
432
+ }
433
+ } catch (e) {
434
+ console.error('Error checking for failure tags in changes:', e);
435
+ }
436
+ }
437
+
438
+ // Add badge indicator (success or failure)
439
+ if (!componentElement.querySelector('.simulation-executed-badge')) {
440
+ const badge = document.createElement('div');
441
+ badge.className = 'simulation-executed-badge';
442
+
443
+ if (hasFailure) {
444
+ // Failure badge - clean and professional
445
+ badge.innerHTML = '!';
446
+ badge.title = `PARSING FAILURE DETECTED\nFailed tags: ${failureTags.join(', ')}`;
447
+ badge.style.cssText = `
448
+ position: absolute;
449
+ bottom: 8px;
450
+ right: 8px;
451
+ width: 20px;
452
+ height: 20px;
453
+ background: #dc2626;
454
+ color: white;
455
+ border-radius: 3px;
456
+ display: flex;
457
+ align-items: center;
458
+ justify-content: center;
459
+ font-size: 13px;
460
+ font-weight: 700;
461
+ font-family: system-ui, -apple-system, sans-serif;
462
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
463
+ z-index: 10;
464
+ animation: badgePop 0.3s ease-out;
465
+ `;
466
+ } else {
467
+ // Success badge
468
+ badge.innerHTML = '✓';
469
+ badge.title = 'Executed in simulation';
470
+ badge.style.cssText = `
471
+ position: absolute;
472
+ bottom: 8px;
473
+ right: 8px;
474
+ width: 24px;
475
+ height: 24px;
476
+ background: linear-gradient(135deg, #10b981, #059669);
477
+ color: white;
478
+ border-radius: 50%;
479
+ display: flex;
480
+ align-items: center;
481
+ justify-content: center;
482
+ font-size: 12px;
483
+ font-weight: bold;
484
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
485
+ z-index: 10;
486
+ animation: badgePop 0.3s ease-out;
487
+ `;
488
+ }
489
+
490
+ componentElement.appendChild(badge);
491
+ }
492
+
493
+ // Add execution time badge if available (skip for drop plugins)
494
+ // Find the component to check if it's a drop plugin
495
+ const component = findComponentById(componentId);
496
+ const isDropPlugin = component && component.plugin === 'drop';
497
+
498
+ if (node.executionTimeMs && !componentElement.querySelector('.simulation-timing-badge') && !isDropPlugin) {
499
+ const timingBadge = document.createElement('div');
500
+ timingBadge.className = 'simulation-timing-badge';
501
+ timingBadge.innerHTML = `⏱ ${node.executionTimeMs}ms`;
502
+ timingBadge.title = `Execution time: ${node.executionTimeMs} milliseconds`;
503
+ timingBadge.style.cssText = `
504
+ position: absolute;
505
+ top: 8px;
506
+ right: 120px;
507
+ padding: 4px 8px;
508
+ background: linear-gradient(135deg, #eab308, #ca8a04);
509
+ color: white;
510
+ border-radius: 12px;
511
+ display: flex;
512
+ align-items: center;
513
+ justify-content: center;
514
+ font-size: 11px;
515
+ font-weight: bold;
516
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
517
+ z-index: 10;
518
+ animation: badgePop 0.3s ease-out;
519
+ white-space: nowrap;
520
+ `;
521
+
522
+ componentElement.appendChild(timingBadge);
523
+ }
524
+
525
+ // Add change indicators inside the plugin row
526
+ if (!node.isDecisionPoint && node.hasChanges && node.changesText && node.changesText !== 'No changes') {
527
+ const changesIndicator = document.createElement('div');
528
+ changesIndicator.className = 'simulation-data-indicator';
529
+ changesIndicator.style.cssText = `
530
+ margin-top: 8px;
531
+ padding: 8px;
532
+ background: rgba(16, 185, 129, 0.1);
533
+ border-left: 3px solid #10b981;
534
+ border-radius: 4px;
535
+ font-size: 11px;
536
+ color: #86efac;
537
+ `;
538
+
539
+ try {
540
+ const changes = JSON.parse(node.changesText);
541
+ let changesHtml = '<div style="font-weight: 600; margin-bottom: 4px;">Changes:</div>';
542
+
543
+ if (changes.added && Object.keys(changes.added).length > 0) {
544
+ changesHtml += '<div style="color: #86efac; margin-bottom: 4px;">';
545
+ for (const [key, value] of Object.entries(changes.added)) {
546
+ const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
547
+ changesHtml += `<div style="margin-bottom: 2px;">+ <strong>${key}</strong>: ${displayValue}</div>`;
548
+ }
549
+ changesHtml += '</div>';
550
+ }
551
+ if (changes.modified && Object.keys(changes.modified).length > 0) {
552
+ changesHtml += '<div style="color: #fbbf24; margin-bottom: 4px;">';
553
+ for (const [key, value] of Object.entries(changes.modified)) {
554
+ const fromValue = typeof value.from === 'object' ? JSON.stringify(value.from) : value.from;
555
+ const toValue = typeof value.to === 'object' ? JSON.stringify(value.to) : value.to;
556
+ changesHtml += `<div style="margin-bottom: 2px;">~ <strong>${key}</strong>: <span style="text-decoration: line-through; opacity: 0.7;">${fromValue}</span> → ${toValue}</div>`;
557
+ }
558
+ changesHtml += '</div>';
559
+ }
560
+ if (changes.deleted && Object.keys(changes.deleted).length > 0) {
561
+ changesHtml += '<div style="color: #f87171;">';
562
+ for (const [key, value] of Object.entries(changes.deleted)) {
563
+ const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
564
+ changesHtml += `<div style="margin-bottom: 2px;">- <strong>${key}</strong>: ${displayValue}</div>`;
565
+ }
566
+ changesHtml += '</div>';
567
+ }
568
+
569
+ changesIndicator.innerHTML = changesHtml;
570
+ } catch (e) {
571
+ changesIndicator.innerHTML = '<div style="font-weight: 600;">Changes detected</div>';
572
+ }
573
+
574
+ componentElement.appendChild(changesIndicator);
575
+ }
576
+
577
+ // Add data flow indicator after this plugin (showing output state)
578
+ if (!node.isDecisionPoint) {
579
+ addDataFlowIndicator(componentElement, node);
580
+ }
581
+ }
582
+ });
583
+
584
+ // Keep the final post-filter event at a predictable location, regardless of
585
+ // whether the last executed item was a plugin or a conditional.
586
+ if (outputEvent) {
587
+ const filterContainer = document.getElementById('filterComponents');
588
+ if (filterContainer) {
589
+ addOutputEventIndicator(filterContainer, outputEvent);
590
+ }
591
+ }
592
+ }
593
+
594
+ /**
595
+ * Add original event indicator at the top of filter section
596
+ */
597
+ function addOriginalEventIndicator(filterContainer, originalEvent) {
598
+ const dataFlow = document.createElement('div');
599
+ dataFlow.className = 'simulation-data-flow';
600
+ dataFlow.innerHTML = `
601
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
602
+ <path d="M12 2L2 7l10 5 10-5-10-5z"/>
603
+ <path d="M2 17l10 5 10-5"/>
604
+ <path d="M2 12l10 5 10-5"/>
605
+ </svg>
606
+ <span>Original Event</span>
607
+ <svg class="hover-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-left: auto; opacity: 0.5;">
608
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
609
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
610
+ </svg>
611
+ <svg class="click-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="opacity: 0.5;">
612
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"></path>
613
+ </svg>
614
+ `;
615
+
616
+ dataFlow.style.cssText = `
617
+ display: flex;
618
+ align-items: center;
619
+ gap: 6px;
620
+ padding: 6px 12px;
621
+ margin: 8px 0;
622
+ background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
623
+ border: 1px solid rgba(16, 185, 129, 0.3);
624
+ border-radius: 6px;
625
+ color: #10b981;
626
+ font-size: 11px;
627
+ font-weight: 600;
628
+ cursor: pointer;
629
+ transition: all 0.2s ease;
630
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
631
+ `;
632
+
633
+ // Store the original event data (filter metadata if toggle unchecked)
634
+ const filtered = filterMetadata(originalEvent);
635
+ dataFlow.dataset.eventJson = JSON.stringify(filtered, null, 2);
636
+
637
+ // Add click to show sticky tooltip
638
+ dataFlow.addEventListener('click', function(e) {
639
+ e.stopPropagation();
640
+ showDataFlowTooltip(e, this.dataset.eventJson, true, null); // No changes for original event
641
+ });
642
+
643
+ // Add hover effects and tooltip
644
+ dataFlow.addEventListener('mouseenter', function(e) {
645
+ this.style.background = 'linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2))';
646
+ this.style.borderColor = 'rgba(16, 185, 129, 0.5)';
647
+ this.style.transform = 'translateX(4px)';
648
+ this.style.boxShadow = '0 4px 6px rgba(16, 185, 129, 0.2)';
649
+
650
+ // Make icons more visible on hover
651
+ const icons = this.querySelectorAll('.hover-icon, .click-icon');
652
+ icons.forEach(icon => icon.style.opacity = '1');
653
+
654
+ // Show hover tooltip (non-sticky)
655
+ showDataFlowTooltip(e, this.dataset.eventJson, false, null);
656
+ });
657
+
658
+ dataFlow.addEventListener('mouseleave', function() {
659
+ this.style.background = 'linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1))';
660
+ this.style.borderColor = 'rgba(16, 185, 129, 0.3)';
661
+ this.style.transform = 'translateX(0)';
662
+ this.style.boxShadow = '0 1px 3px rgba(0, 0, 0, 0.1)';
663
+
664
+ // Reset icon opacity
665
+ const icons = this.querySelectorAll('.hover-icon, .click-icon');
666
+ icons.forEach(icon => icon.style.opacity = '0.5');
667
+
668
+ // Hide hover tooltip (only if not sticky)
669
+ const tooltip = document.getElementById('data-flow-tooltip');
670
+ if (tooltip && tooltip.style.display !== 'none' && !tooltip.querySelector('button[onclick*="hideDataFlowTooltip"]')) {
671
+ scheduleDataFlowTooltipHide();
672
+ }
673
+ });
674
+
675
+ // Insert at the beginning of the filter container
676
+ filterContainer.insertBefore(dataFlow, filterContainer.firstChild);
677
+ }
678
+
679
+ /**
680
+ * Add a data flow indicator after a plugin showing the event state
681
+ */
682
+ function addDataFlowIndicator(componentElement, node) {
683
+ // Create the data flow icon
684
+ const dataFlow = document.createElement('div');
685
+ dataFlow.className = 'simulation-data-flow';
686
+ dataFlow.innerHTML = `
687
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
688
+ <path d="M8 2v4"/>
689
+ <path d="M16 2v4"/>
690
+ <rect x="3" y="4" width="18" height="18" rx="2"/>
691
+ <path d="M3 10h18"/>
692
+ </svg>
693
+ <span>View Full Event</span>
694
+ <svg class="hover-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-left: auto; opacity: 0.5;">
695
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
696
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
697
+ </svg>
698
+ <svg class="click-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="opacity: 0.5;">
699
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"></path>
700
+ </svg>
701
+ `;
702
+
703
+ dataFlow.style.cssText = `
704
+ display: flex;
705
+ align-items: center;
706
+ gap: 6px;
707
+ padding: 6px 12px;
708
+ margin: 8px 0;
709
+ background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(147, 51, 234, 0.1));
710
+ border: 1px solid rgba(59, 130, 246, 0.3);
711
+ border-radius: 6px;
712
+ color: #60a5fa;
713
+ font-size: 11px;
714
+ font-weight: 600;
715
+ cursor: pointer;
716
+ transition: all 0.2s ease;
717
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
718
+ `;
719
+
720
+ // Store the full event snapshot data for tooltip (from node's eventJson if available)
721
+ let eventData = 'No data available';
722
+ let changesData = null;
723
+ if (node.eventJson) {
724
+ // Parse, filter, and re-stringify
725
+ const parsed = JSON.parse(node.eventJson);
726
+ const filtered = filterMetadata(parsed);
727
+ eventData = JSON.stringify(filtered, null, 2);
728
+ changesData = node.changes || null; // Store changes for highlighting
729
+ }
730
+ dataFlow.dataset.eventJson = eventData;
731
+ if (changesData) {
732
+ dataFlow.dataset.changes = JSON.stringify(changesData);
733
+ }
734
+
735
+ // Add click to show sticky tooltip
736
+ dataFlow.addEventListener('click', function(e) {
737
+ e.stopPropagation();
738
+ const changes = this.dataset.changes ? JSON.parse(this.dataset.changes) : null;
739
+ showDataFlowTooltip(e, this.dataset.eventJson, true, changes); // sticky = true
740
+ });
741
+
742
+ // Add hover effects and tooltip
743
+ dataFlow.addEventListener('mouseenter', function(e) {
744
+ this.style.background = 'linear-gradient(90deg, rgba(59, 130, 246, 0.2), rgba(147, 51, 234, 0.2))';
745
+ this.style.borderColor = 'rgba(59, 130, 246, 0.5)';
746
+ this.style.transform = 'translateX(4px)';
747
+ this.style.boxShadow = '0 4px 6px rgba(59, 130, 246, 0.2)';
748
+
749
+ // Make icons more visible on hover
750
+ const icons = this.querySelectorAll('.hover-icon, .click-icon');
751
+ icons.forEach(icon => icon.style.opacity = '1');
752
+
753
+ // Show hover tooltip (non-sticky)
754
+ const changes = this.dataset.changes ? JSON.parse(this.dataset.changes) : null;
755
+ showDataFlowTooltip(e, this.dataset.eventJson, false, changes);
756
+ });
757
+
758
+ dataFlow.addEventListener('mouseleave', function() {
759
+ this.style.background = 'linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(147, 51, 234, 0.1))';
760
+ this.style.borderColor = 'rgba(59, 130, 246, 0.3)';
761
+ this.style.transform = 'translateX(0)';
762
+ this.style.boxShadow = '0 1px 3px rgba(0, 0, 0, 0.1)';
763
+
764
+ // Reset icon opacity
765
+ const icons = this.querySelectorAll('.hover-icon, .click-icon');
766
+ icons.forEach(icon => icon.style.opacity = '0.5');
767
+
768
+ // Hide hover tooltip (only if not sticky)
769
+ const tooltip = document.getElementById('data-flow-tooltip');
770
+ if (tooltip && tooltip.style.display !== 'none' && !tooltip.querySelector('button[onclick*="hideDataFlowTooltip"]')) {
771
+ scheduleDataFlowTooltipHide();
772
+ }
773
+ });
774
+
775
+ // Insert after the component element
776
+ componentElement.parentNode.insertBefore(dataFlow, componentElement.nextSibling);
777
+ }
778
+
779
+ /**
780
+ * Add the final post-filter event at the bottom of the Filter section.
781
+ */
782
+ function addOutputEventIndicator(filterContainer, outputEvent) {
783
+ const dataFlow = document.createElement('div');
784
+ dataFlow.className = 'simulation-data-flow simulation-output-event';
785
+ dataFlow.innerHTML = `
786
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
787
+ <path d="M5 12h14"/>
788
+ <path d="m13 6 6 6-6 6"/>
789
+ </svg>
790
+ <span>View Output Event</span>
791
+ <svg class="hover-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-left: auto; opacity: 0.5;">
792
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
793
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
794
+ </svg>
795
+ <svg class="click-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="opacity: 0.5;">
796
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"></path>
797
+ </svg>
798
+ `;
799
+
800
+ dataFlow.style.cssText = `
801
+ display: flex;
802
+ align-items: center;
803
+ gap: 6px;
804
+ padding: 6px 12px;
805
+ margin: 8px 0;
806
+ background: linear-gradient(90deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.12));
807
+ border: 1px solid rgba(45, 212, 191, 0.4);
808
+ border-radius: 6px;
809
+ color: #5eead4;
810
+ font-size: 11px;
811
+ font-weight: 600;
812
+ cursor: pointer;
813
+ transition: all 0.2s ease;
814
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
815
+ `;
816
+
817
+ // The final event contains the internal snapshots map used to build the
818
+ // debugger. It is transport metadata, not part of the pipeline output.
819
+ const eventForDisplay = JSON.parse(JSON.stringify(outputEvent));
820
+ delete eventForDisplay.snapshots;
821
+ const filtered = filterMetadata(eventForDisplay);
822
+ dataFlow.dataset.eventJson = JSON.stringify(filtered, null, 2);
823
+
824
+ dataFlow.addEventListener('click', function(e) {
825
+ e.stopPropagation();
826
+ showDataFlowTooltip(e, this.dataset.eventJson, true, null);
827
+ });
828
+
829
+ dataFlow.addEventListener('mouseenter', function(e) {
830
+ this.style.background = 'linear-gradient(90deg, rgba(16, 185, 129, 0.22), rgba(59, 130, 246, 0.22))';
831
+ this.style.borderColor = 'rgba(45, 212, 191, 0.65)';
832
+ this.style.transform = 'translateX(4px)';
833
+ this.style.boxShadow = '0 4px 6px rgba(20, 184, 166, 0.2)';
834
+ this.querySelectorAll('.hover-icon, .click-icon').forEach(icon => icon.style.opacity = '1');
835
+ showDataFlowTooltip(e, this.dataset.eventJson, false, null);
836
+ });
837
+
838
+ dataFlow.addEventListener('mouseleave', function() {
839
+ this.style.background = 'linear-gradient(90deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.12))';
840
+ this.style.borderColor = 'rgba(45, 212, 191, 0.4)';
841
+ this.style.transform = 'translateX(0)';
842
+ this.style.boxShadow = '0 1px 3px rgba(0, 0, 0, 0.1)';
843
+ this.querySelectorAll('.hover-icon, .click-icon').forEach(icon => icon.style.opacity = '0.5');
844
+
845
+ const tooltip = document.getElementById('data-flow-tooltip');
846
+ if (tooltip && tooltip.style.display !== 'none' && !tooltip.querySelector('button[onclick*="hideDataFlowTooltip"]')) {
847
+ scheduleDataFlowTooltipHide();
848
+ }
849
+ });
850
+
851
+ const finalInsertionPoint = filterContainer.querySelector(':scope > .insertion-point.always-visible');
852
+ filterContainer.insertBefore(dataFlow, finalInsertionPoint || null);
853
+ }
854
+
855
+ /**
856
+ * Show tooltip with event JSON data
857
+ * @param {Event} event - The mouse event
858
+ * @param {string} eventJson - The JSON data to display
859
+ * @param {boolean} sticky - If true, tooltip stays open until closed; if false, auto-hides on mouse out
860
+ * @param {Object} changes - Optional changes object for context-aware highlighting
861
+ */
862
+ function showDataFlowTooltip(event, eventJson, sticky = false, changes = null) {
863
+ cancelDataFlowTooltipHide();
864
+ let tooltip = document.getElementById('data-flow-tooltip');
865
+
866
+ if (!tooltip) {
867
+ tooltip = document.createElement('div');
868
+ tooltip.id = 'data-flow-tooltip';
869
+ tooltip.style.cssText = `
870
+ position: fixed;
871
+ background: #1f2937;
872
+ border: 1px solid #4b5563;
873
+ border-radius: 8px;
874
+ padding: 12px;
875
+ max-width: 600px;
876
+ max-height: 400px;
877
+ overflow: auto;
878
+ z-index: 10000;
879
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
880
+ font-family: monospace;
881
+ font-size: 11px;
882
+ color: #d1d5db;
883
+ pointer-events: none;
884
+ cursor: default;
885
+ `;
886
+ document.body.appendChild(tooltip);
887
+ }
888
+
889
+ tooltip.dataset.sticky = sticky ? 'true' : 'false';
890
+ tooltip.onmouseenter = cancelDataFlowTooltipHide;
891
+ tooltip.onmouseleave = function() {
892
+ if (this.dataset.sticky !== 'true' && this.dataset.dragging !== 'true') {
893
+ scheduleDataFlowTooltipHide();
894
+ }
895
+ };
896
+
897
+ if (sticky) {
898
+ // Sticky mode: make interactive and draggable
899
+ tooltip.style.pointerEvents = 'auto';
900
+ tooltip.style.cursor = 'move';
901
+
902
+ // Apply syntax highlighting with change context
903
+ const highlightedJSON = highlightJSON(eventJson, changes);
904
+
905
+ // Store the raw JSON data for copying
906
+ tooltip.dataset.eventJson = eventJson;
907
+
908
+ // Update content with close button and copy button
909
+ tooltip.innerHTML = `
910
+ <div class="data-flow-tooltip-header" style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; cursor: grab;">
911
+ <div style="font-weight: 600; color: #60a5fa;">Event State at This Point:</div>
912
+ <div class="data-flow-tooltip-actions" style="display: flex; gap: 4px;">
913
+ <button onclick="copyTooltipData()"
914
+ id="copyTooltipBtn"
915
+ style="background: #3b82f6; border: none; color: white; cursor: pointer; font-size: 11px; padding: 4px 8px; border-radius: 4px; display: flex; align-items: center; gap: 4px; font-family: system-ui, -apple-system, sans-serif;"
916
+ onmouseover="this.style.background='#2563eb'" onmouseout="this.style.background='#3b82f6'"
917
+ title="Copy JSON to clipboard">
918
+ <svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
919
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
920
+ </svg>
921
+ Copy
922
+ </button>
923
+ <button class="data-flow-tooltip-close" onclick="hideDataFlowTooltip()"
924
+ style="background: transparent; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;"
925
+ onmouseover="this.style.color='#fff'" onmouseout="this.style.color='#9ca3af'"
926
+ title="Close">✕</button>
927
+ </div>
928
+ </div>
929
+ <pre style="margin: 0; white-space: pre-wrap;">${highlightedJSON}</pre>
930
+ `;
931
+
932
+ // Drag from the tooltip header.
933
+ makeDraggable(tooltip);
934
+ } else {
935
+ // Hover mode remains interactive so users can copy or reposition it.
936
+ tooltip.style.pointerEvents = 'auto';
937
+ tooltip.style.cursor = 'move';
938
+
939
+ // Apply syntax highlighting with change context
940
+ const highlightedJSON = highlightJSON(eventJson, changes);
941
+
942
+ // Store the raw JSON data for copying
943
+ tooltip.dataset.eventJson = eventJson;
944
+
945
+ tooltip.innerHTML = `
946
+ <div class="data-flow-tooltip-header" style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; cursor: grab;">
947
+ <div style="font-weight: 600; color: #60a5fa;">Event State at This Point:</div>
948
+ <div class="data-flow-tooltip-actions" style="display: flex; gap: 4px;">
949
+ <button onclick="copyTooltipData()"
950
+ id="copyTooltipBtn"
951
+ style="background: #3b82f6; border: none; color: white; cursor: pointer; font-size: 11px; padding: 4px 8px; border-radius: 4px; display: flex; align-items: center; gap: 4px; font-family: system-ui, -apple-system, sans-serif; pointer-events: auto;"
952
+ onmouseover="this.style.background='#2563eb'" onmouseout="this.style.background='#3b82f6'"
953
+ title="Copy JSON to clipboard">
954
+ <svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
955
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
956
+ </svg>
957
+ Copy
958
+ </button>
959
+ </div>
960
+ </div>
961
+ <pre style="margin: 0; white-space: pre-wrap;">${highlightedJSON}</pre>
962
+ `;
963
+
964
+ makeDraggable(tooltip);
965
+ }
966
+
967
+ tooltip.onclick = function(e) {
968
+ if (!e.target.closest('button, a, input, textarea, select')) {
969
+ pinDataFlowTooltip(this);
970
+ }
971
+ };
972
+
973
+ // Position the tooltip near the cursor
974
+ const x = event.clientX + 10;
975
+ const y = event.clientY + 10;
976
+
977
+ tooltip.style.left = x + 'px';
978
+ tooltip.style.top = y + 'px';
979
+ tooltip.style.display = 'block';
980
+ }
981
+
982
+ /**
983
+ * Make an element draggable
984
+ */
985
+ function makeDraggable(element) {
986
+ const dragHandle = element.querySelector('.data-flow-tooltip-header') || element;
987
+
988
+ dragHandle.onpointerdown = function(e) {
989
+ if (e.button !== 0 || e.target.closest('button, a, input, textarea, select')) {
990
+ return;
991
+ }
992
+
993
+ e.preventDefault();
994
+ e.stopPropagation();
995
+ const isDataFlowTooltip = element.id === 'data-flow-tooltip';
996
+ if (isDataFlowTooltip) {
997
+ cancelDataFlowTooltipHide();
998
+ pinDataFlowTooltip(element);
999
+ }
1000
+
1001
+ const startRect = element.getBoundingClientRect();
1002
+ const startX = e.clientX;
1003
+ const startY = e.clientY;
1004
+ const isFixed = window.getComputedStyle(element).position === 'fixed';
1005
+ const pageOffsetX = isFixed ? 0 : window.scrollX;
1006
+ const pageOffsetY = isFixed ? 0 : window.scrollY;
1007
+ element.dataset.dragging = 'true';
1008
+ element.style.cursor = 'grabbing';
1009
+ dragHandle.style.cursor = 'grabbing';
1010
+
1011
+ const moveElement = function(moveEvent) {
1012
+ if (element.dataset.dragging !== 'true') return;
1013
+ element.style.left = `${startRect.left + pageOffsetX + moveEvent.clientX - startX}px`;
1014
+ element.style.top = `${startRect.top + pageOffsetY + moveEvent.clientY - startY}px`;
1015
+ };
1016
+
1017
+ const finishDrag = function() {
1018
+ element.dataset.dragging = 'false';
1019
+ element.style.cursor = 'move';
1020
+ dragHandle.style.cursor = 'grab';
1021
+ window.removeEventListener('pointermove', moveElement);
1022
+ window.removeEventListener('pointerup', finishDrag);
1023
+ window.removeEventListener('pointercancel', finishDrag);
1024
+
1025
+ if (isDataFlowTooltip && element.dataset.sticky !== 'true' && !element.matches(':hover')) {
1026
+ scheduleDataFlowTooltipHide();
1027
+ }
1028
+ };
1029
+
1030
+ window.addEventListener('pointermove', moveElement);
1031
+ window.addEventListener('pointerup', finishDrag);
1032
+ window.addEventListener('pointercancel', finishDrag);
1033
+ };
1034
+ }
1035
+
1036
+ function pinDataFlowTooltip(tooltip) {
1037
+ tooltip.dataset.sticky = 'true';
1038
+ cancelDataFlowTooltipHide();
1039
+
1040
+ const actions = tooltip.querySelector('.data-flow-tooltip-actions');
1041
+ if (!actions || actions.querySelector('.data-flow-tooltip-close')) return;
1042
+
1043
+ const closeButton = document.createElement('button');
1044
+ closeButton.type = 'button';
1045
+ closeButton.className = 'data-flow-tooltip-close';
1046
+ closeButton.title = 'Close';
1047
+ closeButton.textContent = '✕';
1048
+ closeButton.style.cssText = 'background: transparent; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;';
1049
+ closeButton.onmouseenter = function() { this.style.color = '#fff'; };
1050
+ closeButton.onmouseleave = function() { this.style.color = '#9ca3af'; };
1051
+ closeButton.onclick = function(e) {
1052
+ e.stopPropagation();
1053
+ hideDataFlowTooltip();
1054
+ };
1055
+ actions.appendChild(closeButton);
1056
+ }
1057
+
1058
+ /**
1059
+ * Copy tooltip JSON data to clipboard
1060
+ */
1061
+ async function copyTooltipData() {
1062
+ const tooltip = document.getElementById('data-flow-tooltip');
1063
+ if (!tooltip || !tooltip.dataset.eventJson) return;
1064
+
1065
+ const jsonData = tooltip.dataset.eventJson;
1066
+ let copyData = jsonData;
1067
+
1068
+ try {
1069
+ copyData = JSON.stringify(JSON.parse(jsonData), null, 2);
1070
+ } catch (_) {
1071
+ // Preserve non-JSON messages exactly as shown.
1072
+ }
1073
+
1074
+ try {
1075
+ await writeTextToClipboard(copyData);
1076
+ const copyBtn = document.getElementById('copyTooltipBtn');
1077
+ if (!copyBtn) return;
1078
+
1079
+ const originalHTML = copyBtn.innerHTML;
1080
+ const originalBg = copyBtn.style.background;
1081
+ copyBtn.innerHTML = `
1082
+ <svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1083
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
1084
+ </svg>
1085
+ Copied!
1086
+ `;
1087
+ copyBtn.style.background = '#10b981';
1088
+ setTimeout(() => {
1089
+ copyBtn.innerHTML = originalHTML;
1090
+ copyBtn.style.background = originalBg;
1091
+ }, 2000);
1092
+ } catch (err) {
1093
+ console.error('Failed to copy to clipboard:', err);
1094
+ ConfirmationModal.show('Failed to copy to clipboard. Please try again.', 'Copy Failed', 'OK', null, true);
1095
+ }
1096
+ }
1097
+
1098
+ function writeTextToClipboard(text) {
1099
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
1100
+ return navigator.clipboard.writeText(text).catch(() => legacyCopyText(text));
1101
+ }
1102
+
1103
+ return legacyCopyText(text);
1104
+ }
1105
+
1106
+ function legacyCopyText(text) {
1107
+ return new Promise((resolve, reject) => {
1108
+ const textarea = document.createElement('textarea');
1109
+ textarea.value = text;
1110
+ textarea.setAttribute('readonly', '');
1111
+ textarea.style.cssText = 'position: fixed; left: -9999px; top: 0; opacity: 0;';
1112
+ document.body.appendChild(textarea);
1113
+ textarea.select();
1114
+
1115
+ try {
1116
+ if (!document.execCommand('copy')) {
1117
+ throw new Error('Browser copy command was rejected');
1118
+ }
1119
+ resolve();
1120
+ } catch (err) {
1121
+ reject(err);
1122
+ } finally {
1123
+ textarea.remove();
1124
+ }
1125
+ });
1126
+ }
1127
+
1128
+ let dataFlowTooltipHideTimer = null;
1129
+
1130
+ function cancelDataFlowTooltipHide() {
1131
+ if (dataFlowTooltipHideTimer) {
1132
+ clearTimeout(dataFlowTooltipHideTimer);
1133
+ dataFlowTooltipHideTimer = null;
1134
+ }
1135
+ }
1136
+
1137
+ function scheduleDataFlowTooltipHide() {
1138
+ cancelDataFlowTooltipHide();
1139
+ dataFlowTooltipHideTimer = setTimeout(() => {
1140
+ const tooltip = document.getElementById('data-flow-tooltip');
1141
+ if (tooltip && tooltip.dataset.sticky !== 'true' && tooltip.dataset.dragging !== 'true' && !tooltip.matches(':hover')) {
1142
+ hideDataFlowTooltip();
1143
+ }
1144
+ }, 200);
1145
+ }
1146
+
1147
+ /**
1148
+ * Hide the data flow tooltip
1149
+ */
1150
+ function hideDataFlowTooltip() {
1151
+ cancelDataFlowTooltipHide();
1152
+ const tooltip = document.getElementById('data-flow-tooltip');
1153
+ if (tooltip) {
1154
+ tooltip.style.display = 'none';
1155
+ // Reset pointer events to default for next use
1156
+ tooltip.style.pointerEvents = 'none';
1157
+ tooltip.style.cursor = 'default';
1158
+ }
1159
+ }
1160
+
1161
+ /**
1162
+ * Create a D3 force-directed graph visualization
1163
+ */
1164
+ function createForceDirectedGraph(graphData) {
1165
+ const svg = d3.select("#pipeline-graph");
1166
+ const containerElement = document.getElementById("results-container");
1167
+
1168
+ // Check if container exists - if not, the overlay hasn't been created yet
1169
+ if (!containerElement) {
1170
+ console.error('results-container not found - overlay may not be created yet');
1171
+ return;
1172
+ }
1173
+
1174
+ const height = containerElement.clientHeight || 100;
1175
+
1176
+ // Calculate proper spacing and total width needed
1177
+ const nodeSpacing = 100; // Space between nodes (adjust to match node size)
1178
+ const padding = 50; // Padding on left and right
1179
+
1180
+ // Find max step to calculate total width needed
1181
+ const maxStep = Math.max(...graphData.nodes.map(n => n.step));
1182
+ const totalWidth = (maxStep * nodeSpacing) + (padding * 2);
1183
+
1184
+ // Set SVG width to accommodate all nodes
1185
+ const width = Math.max(totalWidth, containerElement.clientWidth);
1186
+ svg.attr("width", width).attr("height", height);
1187
+
1188
+ // Clear any existing content
1189
+ svg.selectAll("*").remove();
1190
+
1191
+ // Create a container group for zoom/pan
1192
+ const container = svg.append("g");
1193
+
1194
+ // Add zoom behavior - restrict to horizontal panning only
1195
+ const zoom = d3.zoom()
1196
+ .scaleExtent([1, 1]) // Disable zooming, only allow panning
1197
+ .translateExtent([[0, 0], [width, height]]) // Limit panning boundaries
1198
+ .extent([[0, 0], [containerElement.clientWidth, height]]) // Set viewport extent
1199
+ .filter((event) => {
1200
+ // Allow mouse wheel and drag events
1201
+ return !event.ctrlKey && !event.button;
1202
+ })
1203
+ .on("zoom", (event) => {
1204
+ // Only allow horizontal translation, lock vertical position
1205
+ const transform = event.transform;
1206
+ // Clamp y to 0 to prevent any vertical movement
1207
+ container.attr("transform", `translate(${transform.x}, 0) scale(1)`);
1208
+ });
1209
+
1210
+ svg.call(zoom)
1211
+ .on("wheel.zoom", null); // Disable mouse wheel zoom completely
1212
+
1213
+ // Create arrow marker for links
1214
+ svg.append("defs").append("marker")
1215
+ .attr("id", "arrowhead")
1216
+ .attr("viewBox", "0 -5 10 10")
1217
+ .attr("refX", 25)
1218
+ .attr("refY", 0)
1219
+ .attr("markerWidth", 6)
1220
+ .attr("markerHeight", 6)
1221
+ .attr("orient", "auto")
1222
+ .append("path")
1223
+ .attr("d", "M0,-5L10,0L0,5")
1224
+ .attr("fill", "#6b7280");
1225
+
1226
+
1227
+ graphData.nodes.forEach((node, i) => {
1228
+ node.x = padding + (node.step * nodeSpacing); // Space nodes horizontally with proper spacing
1229
+ node.y = height / 2; // Center all nodes vertically for linear flow
1230
+ });
1231
+
1232
+ // Resolve link source/target to actual node objects
1233
+ graphData.links.forEach(link => {
1234
+ if (typeof link.source === 'string') {
1235
+ link.source = graphData.nodes.find(n => n.id === link.source);
1236
+ }
1237
+ if (typeof link.target === 'string') {
1238
+ link.target = graphData.nodes.find(n => n.id === link.target);
1239
+ }
1240
+ });
1241
+
1242
+
1243
+ // Create links with hover interaction
1244
+ const linkGroup = container.append("g")
1245
+ .selectAll("g")
1246
+ .data(graphData.links)
1247
+ .enter().append("g");
1248
+
1249
+ // Add visible line
1250
+ const link = linkGroup.append("line")
1251
+ .attr("stroke", "#6b7280")
1252
+ .attr("stroke-width", 2)
1253
+ .attr("marker-end", "url(#arrowhead)");
1254
+
1255
+ // Add invisible wider line for easier hovering
1256
+ const linkHover = linkGroup.append("line")
1257
+ .attr("stroke", "transparent")
1258
+ .attr("stroke-width", 10)
1259
+ .style("cursor", "pointer")
1260
+ .on("click", function(event, d) {
1261
+ event.stopPropagation();
1262
+ // Show sticky tooltip on click
1263
+ showLinkTooltip(event, d.eventJson, true, d.changes);
1264
+ })
1265
+ .on("mouseover", function(event, d) {
1266
+ // Highlight the link
1267
+ d3.select(this.previousSibling)
1268
+ .attr("stroke", "#22c55e")
1269
+ .attr("stroke-width", 3);
1270
+
1271
+ // Show hover tooltip
1272
+ showLinkTooltip(event, d.eventJson, false, d.changes);
1273
+ })
1274
+ .on("mouseout", function(event, d) {
1275
+ // Reset link style
1276
+ d3.select(this.previousSibling)
1277
+ .attr("stroke", "#6b7280")
1278
+ .attr("stroke-width", 2);
1279
+
1280
+ // Hide hover tooltip immediately
1281
+ hideLinkTooltip();
1282
+ });
1283
+
1284
+ // Create node groups (no drag behavior since positions are fixed)
1285
+ const node = container.append("g")
1286
+ .selectAll("g")
1287
+ .data(graphData.nodes)
1288
+ .enter().append("g");
1289
+
1290
+ // Add shapes to nodes (circles for regular, hexagons for decision points)
1291
+ node.each(function(d) {
1292
+ const nodeGroup = d3.select(this);
1293
+
1294
+ // Check for parsing failures ADDED by this node
1295
+ let hasFailure = false;
1296
+ let failureTags = [];
1297
+ if (d.eventJson && !d.isConditional && d.changes) {
1298
+ try {
1299
+ // Check if this plugin ADDED any failure tags
1300
+ const changes = typeof d.changes === 'string' ? JSON.parse(d.changes) : d.changes;
1301
+
1302
+ // Check if tags were added
1303
+ if (changes.added && changes.added.tags) {
1304
+ const addedTags = Array.isArray(changes.added.tags) ? changes.added.tags : [changes.added.tags];
1305
+ const failureCheck = checkForParsingFailures({ tags: addedTags });
1306
+ if (failureCheck.hasFailure) {
1307
+ hasFailure = true;
1308
+ failureTags = failureCheck.failureTags;
1309
+ }
1310
+ }
1311
+
1312
+ // Check if tags were modified (from old value to new value)
1313
+ if (!hasFailure && changes.modified && changes.modified.tags) {
1314
+ const modifiedTags = changes.modified.tags;
1315
+ const oldTags = Array.isArray(modifiedTags.from) ? modifiedTags.from : [];
1316
+ const newTags = Array.isArray(modifiedTags.to) ? modifiedTags.to : [];
1317
+
1318
+ // Find tags that were added (in new but not in old)
1319
+ const addedInModification = newTags.filter(tag => !oldTags.includes(tag));
1320
+
1321
+ if (addedInModification.length > 0) {
1322
+ const failureCheck = checkForParsingFailures({ tags: addedInModification });
1323
+ if (failureCheck.hasFailure) {
1324
+ hasFailure = true;
1325
+ failureTags = failureCheck.failureTags;
1326
+ }
1327
+ }
1328
+ }
1329
+
1330
+ // Store failure info on the node for tooltip
1331
+ d.hasFailure = hasFailure;
1332
+ d.failureTags = failureTags;
1333
+ } catch (e) {
1334
+ console.error('Error checking for failure tags in changes:', e);
1335
+ }
1336
+ }
1337
+
1338
+ if (d.isConditional && d.isDecisionPoint) {
1339
+ // Hexagon shape for decision point nodes (path taken)
1340
+ const size = 20;
1341
+ const hexPath = `M ${size},0 L ${size/2},${size*0.866} L ${-size/2},${size*0.866} L ${-size},0 L ${-size/2},${-size*0.866} L ${size/2},${-size*0.866} Z`;
1342
+
1343
+ nodeGroup.append("path")
1344
+ .attr("d", hexPath)
1345
+ .attr("fill", "#eab308")
1346
+ .attr("stroke", "#fbbf24")
1347
+ .attr("stroke-width", 2)
1348
+ .style("cursor", "pointer")
1349
+ .on("mouseover", function(event, d) {
1350
+ d3.select(this)
1351
+ .attr("stroke-width", 3)
1352
+ .attr("fill", "#fbbf24");
1353
+ showNodeTooltip(event, d);
1354
+ })
1355
+ .on("mouseout", function(event, d) {
1356
+ d3.select(this)
1357
+ .attr("stroke-width", 2)
1358
+ .attr("fill", "#eab308");
1359
+ hideNodeTooltip();
1360
+ });
1361
+ } else {
1362
+ // Circle for regular plugin nodes
1363
+ // Color based on failure status, then changes
1364
+ let fillColor, strokeColor;
1365
+ if (hasFailure) {
1366
+ fillColor = "#dc2626"; // Red for failures
1367
+ strokeColor = "#ef4444";
1368
+ } else if (d.hasChanges) {
1369
+ fillColor = "#16a34a"; // Green for changes
1370
+ strokeColor = "#22c55e";
1371
+ } else {
1372
+ fillColor = "#4b5563"; // Gray for no changes
1373
+ strokeColor = "#6b7280";
1374
+ }
1375
+
1376
+ nodeGroup.append("circle")
1377
+ .attr("r", 18)
1378
+ .attr("fill", fillColor)
1379
+ .attr("stroke", strokeColor)
1380
+ .attr("stroke-width", hasFailure ? 3 : 2)
1381
+ .style("cursor", "pointer")
1382
+ .style("filter", hasFailure ? "drop-shadow(0 0 8px rgba(220, 38, 38, 0.8))" : "none")
1383
+ .on("mouseover", function(event, d) {
1384
+ const isSlowest = d.isSlowest;
1385
+ d3.select(this)
1386
+ .attr("stroke-width", hasFailure ? 4 : 3)
1387
+ .attr("stroke", isSlowest ? "#60a5fa" : (hasFailure ? strokeColor : strokeColor))
1388
+ .attr("r", 22);
1389
+ showNodeTooltip(event, d);
1390
+ })
1391
+ .on("mouseout", function(event, d) {
1392
+ d3.select(this)
1393
+ .attr("stroke-width", hasFailure ? 3 : 2)
1394
+ .attr("stroke", strokeColor)
1395
+ .attr("r", 18);
1396
+ hideNodeTooltip();
1397
+ });
1398
+ }
1399
+ });
1400
+
1401
+ // Add text labels to nodes
1402
+ node.append("text")
1403
+ .text(d => d.label)
1404
+ .attr("text-anchor", "middle")
1405
+ .attr("dy", ".35em")
1406
+ .attr("fill", "white")
1407
+ .attr("font-size", "10px")
1408
+ .attr("font-weight", "bold")
1409
+ .style("pointer-events", "none");
1410
+
1411
+ // Find the slowest plugin (highest execution time)
1412
+ let slowestNode = null;
1413
+ let maxExecutionTime = 0;
1414
+ graphData.nodes.forEach(n => {
1415
+ if (n.executionTimeMs && parseFloat(n.executionTimeMs) > maxExecutionTime) {
1416
+ maxExecutionTime = parseFloat(n.executionTimeMs);
1417
+ slowestNode = n;
1418
+ }
1419
+ });
1420
+
1421
+ // Mark slowest node for later reference
1422
+ if (slowestNode) {
1423
+ slowestNode.isSlowest = true;
1424
+ }
1425
+
1426
+ // Add execution time text below nodes (if available, skip for drop plugins)
1427
+ node.each(function(d) {
1428
+ if (d.executionTimeMs) {
1429
+ // Check if this is a drop plugin
1430
+ const component = findComponentById(d.id);
1431
+ const isDropPlugin = component && component.plugin === 'drop';
1432
+
1433
+ // Skip timing display for drop plugins
1434
+ if (!isDropPlugin) {
1435
+ const isSlowest = d.isSlowest;
1436
+ const nodeGroup = d3.select(this);
1437
+
1438
+ nodeGroup.append("text")
1439
+ .text(`${d.executionTimeMs}ms`)
1440
+ .attr("text-anchor", "middle")
1441
+ .attr("dy", "3.2em")
1442
+ .attr("fill", isSlowest ? "#60a5fa" : "#fbbf24")
1443
+ .attr("font-size", "9px")
1444
+ .attr("font-weight", "600")
1445
+ .style("pointer-events", "none");
1446
+ }
1447
+ }
1448
+ });
1449
+
1450
+ // Manually position all elements since we have no simulation
1451
+ link
1452
+ .attr("x1", d => d.source.x)
1453
+ .attr("y1", d => d.source.y)
1454
+ .attr("x2", d => d.target.x)
1455
+ .attr("y2", d => d.target.y);
1456
+
1457
+ linkHover
1458
+ .attr("x1", d => d.source.x)
1459
+ .attr("y1", d => d.source.y)
1460
+ .attr("x2", d => d.target.x)
1461
+ .attr("y2", d => d.target.y);
1462
+
1463
+ node.attr("transform", d => `translate(${d.x},${d.y})`);
1464
+
1465
+ // Add click handlers to scroll to component in editor
1466
+ node.on("click", function(event, d) {
1467
+ event.stopPropagation();
1468
+
1469
+ // Special handling for "Start" node - scroll to Original Event
1470
+ if (d.id === 'start') {
1471
+ const originalEventElement = document.querySelector('.simulation-data-flow');
1472
+ if (originalEventElement) {
1473
+ originalEventElement.scrollIntoView({
1474
+ behavior: 'smooth',
1475
+ block: 'center'
1476
+ });
1477
+
1478
+ // Apply the same glowing animation
1479
+ originalEventElement.classList.add('newly-added');
1480
+
1481
+ // Remove the animation class after it completes
1482
+ setTimeout(() => {
1483
+ originalEventElement.classList.remove('newly-added');
1484
+ }, 2000);
1485
+ }
1486
+ return;
1487
+ }
1488
+
1489
+ // Special handling for "End" node - scroll to the pinned output event
1490
+ if (d.id === 'end') {
1491
+ const outputEventElement = document.querySelector('.simulation-output-event');
1492
+ if (outputEventElement) {
1493
+ outputEventElement.scrollIntoView({
1494
+ behavior: 'smooth',
1495
+ block: 'center'
1496
+ });
1497
+
1498
+ // Apply the same glowing animation
1499
+ outputEventElement.classList.add('newly-added');
1500
+
1501
+ // Remove the animation class after it completes
1502
+ setTimeout(() => {
1503
+ outputEventElement.classList.remove('newly-added');
1504
+ }, 2000);
1505
+ }
1506
+ return;
1507
+ }
1508
+
1509
+ // Extract the component ID from the node
1510
+ let componentId = d.id;
1511
+
1512
+ // For decision point nodes, find the first plugin in the taken branch instead
1513
+ if (d.isDecisionPoint) {
1514
+ // Find the next node in the graph that is NOT a decision point
1515
+ // This will be the first plugin in the condition branch
1516
+ const currentStep = d.step;
1517
+ const nextPlugin = graphData.nodes.find(node =>
1518
+ node.step > currentStep && !node.isDecisionPoint && node.id !== 'start'
1519
+ );
1520
+
1521
+ if (nextPlugin) {
1522
+ componentId = nextPlugin.id;
1523
+ } else {
1524
+ // Fallback to the condition block if no plugin found
1525
+ componentId = d.conditionalId;
1526
+ }
1527
+ }
1528
+
1529
+ // Find the component in the editor using data-id
1530
+ const componentElement = document.querySelector(`[data-id="${componentId}"]`);
1531
+
1532
+ if (componentElement) {
1533
+ // Scroll to the component
1534
+ componentElement.scrollIntoView({
1535
+ behavior: 'smooth',
1536
+ block: 'center'
1537
+ });
1538
+
1539
+ // Apply the same glowing animation used when adding plugins
1540
+ componentElement.classList.add('newly-added');
1541
+
1542
+ // Remove the animation class after it completes
1543
+ setTimeout(() => {
1544
+ componentElement.classList.remove('newly-added');
1545
+ }, 2000);
1546
+ } else {
1547
+ console.warn(`Component not found: ${componentId}`);
1548
+ }
1549
+ });
1550
+
1551
+ // Create tooltip container for links
1552
+ const linkTooltip = d3.select("body").append("div")
1553
+ .attr("class", "d3-link-tooltip")
1554
+ .style("position", "absolute")
1555
+ .style("visibility", "hidden")
1556
+ .style("background-color", "#1f2937")
1557
+ .style("border", "1px solid #4b5563")
1558
+ .style("border-radius", "0.5rem")
1559
+ .style("padding", "0.75rem")
1560
+ .style("max-width", "600px")
1561
+ .style("max-height", "400px")
1562
+ .style("overflow", "auto")
1563
+ .style("z-index", "10000")
1564
+ .style("box-shadow", "0 10px 25px rgba(0, 0, 0, 0.5)")
1565
+ .style("font-family", "monospace")
1566
+ .style("font-size", "11px")
1567
+ .style("color", "#d1d5db")
1568
+ .style("pointer-events", "none");
1569
+
1570
+ function showLinkTooltip(event, eventJson, sticky = false, changes = null) {
1571
+ // Apply syntax highlighting with change context
1572
+ const highlightedJSON = highlightJSON(eventJson, changes);
1573
+
1574
+ if (sticky) {
1575
+ // Make tooltip interactive and draggable when pinned
1576
+ linkTooltip.style("pointer-events", "auto")
1577
+ .style("cursor", "move");
1578
+
1579
+ // Add close button for sticky tooltips
1580
+ const content = `
1581
+ <div style="position: relative; padding-right: 24px;">
1582
+ <button onclick="d3.select('.d3-link-tooltip').style('visibility', 'hidden').style('pointer-events', 'none')"
1583
+ style="position: absolute; top: -8px; right: -8px; background: transparent; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 0; width: 20px; height: 20px;"
1584
+ onmouseover="this.style.color='#fff'" onmouseout="this.style.color='#9ca3af'">✕</button>
1585
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.5rem;">Event State:</div>
1586
+ <pre style="margin: 0; white-space: pre-wrap;">${highlightedJSON}</pre>
1587
+ </div>
1588
+ `;
1589
+ linkTooltip.html(content);
1590
+
1591
+ // Make draggable
1592
+ makeDraggable(linkTooltip.node());
1593
+ } else {
1594
+ linkTooltip.html(`
1595
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.5rem;">Event State:</div>
1596
+ <pre style="margin: 0; white-space: pre-wrap;">${highlightedJSON}</pre>
1597
+ `);
1598
+ }
1599
+
1600
+ linkTooltip
1601
+ .style("visibility", "visible")
1602
+ .style("left", (event.clientX + 10) + "px")
1603
+ .style("top", (event.clientY - 10) + "px");
1604
+ }
1605
+
1606
+ function hideLinkTooltip() {
1607
+ linkTooltip.style("visibility", "hidden")
1608
+ .style("pointer-events", "none")
1609
+ .style("cursor", "default");
1610
+ }
1611
+
1612
+ // Create tooltip container for nodes
1613
+ const nodeTooltip = d3.select("body").append("div")
1614
+ .attr("class", "d3-node-tooltip")
1615
+ .style("position", "absolute")
1616
+ .style("visibility", "hidden")
1617
+ .style("background-color", "#1f2937")
1618
+ .style("border", "1px solid #4b5563")
1619
+ .style("border-radius", "0.5rem")
1620
+ .style("padding", "0.75rem")
1621
+ .style("max-width", "600px")
1622
+ .style("max-height", "400px")
1623
+ .style("overflow", "auto")
1624
+ .style("z-index", "1000")
1625
+ .style("box-shadow", "0 10px 15px -3px rgba(0, 0, 0, 0.3)")
1626
+ .style("font-size", "11px")
1627
+ .style("color", "#d1d5db");
1628
+
1629
+
1630
+ function showNodeTooltip(event, d) {
1631
+ let title, content;
1632
+
1633
+ if (d.isConditional && d.isDecisionPoint) {
1634
+ // Decision point node - show which branch was taken
1635
+ title = `<div style="font-weight: 600; color: #fbbf24; margin-bottom: 0.5rem;">
1636
+ 🔀 Conditional Decision Point
1637
+ <br/><span style="font-weight: 400; font-size: 10px; color: #9ca3af;">${d.id}</span>
1638
+ </div>`;
1639
+ content = `<div style="margin-bottom: 0.5rem;">
1640
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem;">Branch taken:</div>
1641
+ <div style="color: #fbbf24; font-weight: 600;">${d.label}</div>
1642
+ </div>
1643
+ <div style="margin-bottom: 0.5rem;">
1644
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem;">Total branches available:</div>
1645
+ <div style="color: #d1d5db;">${d.totalBranches}</div>
1646
+ </div>
1647
+ <div>
1648
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem;">Condition:</div>
1649
+ <pre style="color: #86efac; white-space: pre-wrap; margin: 0; font-size: 10px;">${d.condition}</pre>
1650
+ </div>`;
1651
+ } else {
1652
+ // Regular plugin node - show changes and failure status
1653
+ let titleColor = d.hasFailure ? '#ef4444' : '#9ca3af';
1654
+ let failureWarning = '';
1655
+ let slowestWarning = '';
1656
+
1657
+ if (d.hasFailure) {
1658
+ failureWarning = `<div style="background: rgba(220, 38, 38, 0.2); border: 2px solid #dc2626; border-radius: 6px; padding: 8px; margin-bottom: 0.5rem;">
1659
+ <div style="font-weight: 700; color: #fca5a5; margin-bottom: 0.25rem; font-size: 12px;">⚠ PARSING FAILURE DETECTED</div>
1660
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem; font-size: 10px;">Failed tags:</div>
1661
+ <div style="color: #ef4444; font-weight: 600; font-size: 11px;">${d.failureTags.join(', ')}</div>
1662
+ </div>`;
1663
+ }
1664
+
1665
+ if (d.isSlowest) {
1666
+ slowestWarning = `<div style="background: rgba(96, 165, 250, 0.15); border: 2px solid #60a5fa; border-radius: 6px; padding: 8px; margin-bottom: 0.5rem;">
1667
+ <div style="font-weight: 700; color: #60a5fa; margin-bottom: 0.25rem; font-size: 12px;">🐌 Slowest Plugin</div>
1668
+ <div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem; font-size: 10px;">Execution time:</div>
1669
+ <div style="color: #60a5fa; font-weight: 600; font-size: 11px;">${d.executionTimeMs}ms</div>
1670
+ </div>`;
1671
+ }
1672
+
1673
+ title = `<div style="font-weight: 600; color: ${titleColor}; margin-bottom: 0.5rem;">Step ${d.step}: ${d.label}<br/><span style="font-weight: 400; font-size: 10px;">${d.id}</span></div>`;
1674
+ content = slowestWarning + failureWarning + (d.hasChanges
1675
+ ? `<div style="font-weight: 600; color: #9ca3af; margin-bottom: 0.25rem;">Changes:</div><pre style="color: #86efac; white-space: pre-wrap; margin: 0;">${d.changesText}</pre>`
1676
+ : `<div style="color: #6b7280; font-style: italic;">No changes</div>`);
1677
+ }
1678
+
1679
+ nodeTooltip.html(`
1680
+ <div style="position: relative;">
1681
+ <button id="closeNodeTooltipBtn"
1682
+ style="position: absolute; top: 0; right: 0; background: transparent; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 4px; width: 20px; height: 20px; z-index: 100; line-height: 1; pointer-events: auto;"
1683
+ onmouseover="this.style.color='#fff'" onmouseout="this.style.color='#9ca3af'">✕</button>
1684
+ <div style="padding-right: 20px;">
1685
+ ${title}${content}
1686
+ </div>
1687
+ </div>
1688
+ `)
1689
+ .style("visibility", "visible")
1690
+ .style("pointer-events", "auto")
1691
+ .style("left", (event.pageX + 10) + "px")
1692
+ .style("top", (event.pageY - 10) + "px");
1693
+
1694
+ // Add click handler directly to the button after it's added to DOM
1695
+ setTimeout(() => {
1696
+ const closeBtn = document.getElementById('closeNodeTooltipBtn');
1697
+ if (closeBtn) {
1698
+ closeBtn.addEventListener('click', function(e) {
1699
+ e.stopPropagation();
1700
+ nodeTooltip.style("visibility", "hidden");
1701
+ });
1702
+ }
1703
+ }, 0);
1704
+ }
1705
+
1706
+ window.hideNodeTooltip = function() {
1707
+ nodeTooltip.style("visibility", "hidden");
1708
+ };
1709
+ }
1710
+
1711
+ /**
1712
+ * Deep diff two objects and return only the changes
1713
+ * Returns an object with added, modified, and deleted fields
1714
+ */
1715
+ function diffObjects(prev, curr, path = '') {
1716
+ const changes = {
1717
+ added: {},
1718
+ modified: {},
1719
+ deleted: {}
1720
+ };
1721
+
1722
+ // Handle null/undefined cases
1723
+ if (prev === null || prev === undefined) {
1724
+ if (curr !== null && curr !== undefined) {
1725
+ changes.added[path || 'root'] = curr;
1726
+ }
1727
+ return changes;
1728
+ }
1729
+ if (curr === null || curr === undefined) {
1730
+ changes.deleted[path || 'root'] = prev;
1731
+ return changes;
1732
+ }
1733
+
1734
+ // If both are primitives or arrays, compare directly
1735
+ if (typeof prev !== 'object' || typeof curr !== 'object' || Array.isArray(prev) || Array.isArray(curr)) {
1736
+ if (JSON.stringify(prev) !== JSON.stringify(curr)) {
1737
+ changes.modified[path] = { from: prev, to: curr };
1738
+ }
1739
+ return changes;
1740
+ }
1741
+
1742
+ // Get all keys from both objects
1743
+ const prevKeys = new Set(Object.keys(prev));
1744
+ const currKeys = new Set(Object.keys(curr));
1745
+
1746
+ // Check for deleted keys
1747
+ prevKeys.forEach(key => {
1748
+ if (!currKeys.has(key)) {
1749
+ const fullPath = path ? `${path}.${key}` : key;
1750
+ changes.deleted[fullPath] = prev[key];
1751
+ }
1752
+ });
1753
+
1754
+ // Check for added and modified keys
1755
+ currKeys.forEach(key => {
1756
+ const fullPath = path ? `${path}.${key}` : key;
1757
+
1758
+ if (!prevKeys.has(key)) {
1759
+ // Key was added
1760
+ changes.added[fullPath] = curr[key];
1761
+ } else {
1762
+ // Key exists in both, check if modified
1763
+ const prevVal = prev[key];
1764
+ const currVal = curr[key];
1765
+
1766
+ if (typeof prevVal === 'object' && prevVal !== null &&
1767
+ typeof currVal === 'object' && currVal !== null &&
1768
+ !Array.isArray(prevVal) && !Array.isArray(currVal)) {
1769
+ // Recursively diff nested objects
1770
+ const nestedChanges = diffObjects(prevVal, currVal, fullPath);
1771
+ Object.assign(changes.added, nestedChanges.added);
1772
+ Object.assign(changes.modified, nestedChanges.modified);
1773
+ Object.assign(changes.deleted, nestedChanges.deleted);
1774
+ } else if (JSON.stringify(prevVal) !== JSON.stringify(currVal)) {
1775
+ changes.modified[fullPath] = { from: prevVal, to: currVal };
1776
+ }
1777
+ }
1778
+ });
1779
+
1780
+ return changes;
1781
+ }
1782
+
1783
+ // Global function to switch between overlay views
1784
+ window.switchOverlayView = function(mode) {
1785
+ const resultsContainer = document.getElementById('results-container');
1786
+ const textViewContainer = document.getElementById('textViewContainer');
1787
+ const textViewContent = document.getElementById('textViewContent');
1788
+
1789
+ if (mode === 'debugger') {
1790
+ resultsContainer.style.display = 'block';
1791
+ textViewContainer.style.display = 'none';
1792
+ } else if (mode === 'text') {
1793
+ resultsContainer.style.display = 'none';
1794
+ textViewContainer.style.display = 'block';
1795
+
1796
+ // Generate text view if we have simulation data
1797
+ if (window.simulationData && textViewContent) {
1798
+ textViewContent.innerHTML = generateTextView(window.simulationData);
1799
+ }
1800
+ }
1801
+ };
1802
+
1803
+ // Global function to generate text view HTML from simulation data
1804
+ window.generateTextView = function(data) {
1805
+ if (!data || !data.nodes) return '<div class="text-gray-500 text-center py-8">No simulation data available</div>';
1806
+
1807
+ let html = '';
1808
+
1809
+ // Filter out the 'start' node and sort by step
1810
+ const pluginNodes = data.nodes.filter(n => n.id !== 'start').sort((a, b) => a.step - b.step);
1811
+
1812
+ pluginNodes.forEach((node, index) => {
1813
+ const stepNum = index + 1;
1814
+ const pluginName = node.label;
1815
+ const hasChanges = node.hasChanges;
1816
+ const changesText = node.changesText || 'No changes';
1817
+ const eventJson = node.eventJson || 'No event data';
1818
+
1819
+ // Apply syntax highlighting to the event JSON
1820
+ const highlightedEventJson = highlightJSON(eventJson);
1821
+
1822
+ html += `
1823
+ <div class="border border-gray-700 rounded-lg p-4 bg-gray-800">
1824
+ <div class="text-lg font-bold text-blue-400 mb-3 pb-2 border-b border-gray-700">
1825
+ ~~~ Step ${stepNum}: ${pluginName} ~~~
1826
+ </div>
1827
+
1828
+ <div class="mb-4">
1829
+ <div class="text-sm font-semibold text-gray-400 mb-2">Plugin Changes:</div>
1830
+ <pre class="text-xs ${hasChanges ? 'text-green-300' : 'text-gray-500'} bg-gray-900 p-3 rounded border border-gray-700 overflow-x-auto">${changesText}</pre>
1831
+ </div>
1832
+
1833
+ <div>
1834
+ <div class="text-sm font-semibold text-gray-400 mb-2">Event After Plugin Execution:</div>
1835
+ <pre class="text-xs bg-gray-900 p-3 rounded border border-gray-700 overflow-x-auto">${highlightedEventJson}</pre>
1836
+ </div>
1837
+ </div>
1838
+ `;
1839
+ });
1840
+
1841
+ return html || '<div class="text-gray-500 text-center py-8">No simulation data available</div>';
1842
+ };
1843
+
1844
+ // Global function to toggle overlay expansion
1845
+ window.toggleOverlayExpand = function() {
1846
+ const overlay = document.getElementById('simulation-overlay');
1847
+ const expandBtn = document.getElementById('expandOverlayBtn');
1848
+
1849
+ if (!overlay) return;
1850
+
1851
+ const isExpanded = overlay.style.height === '100vh' || overlay.style.height === '100%';
1852
+
1853
+ if (isExpanded) {
1854
+ // Collapse back to 150px
1855
+ overlay.style.height = '150px';
1856
+ if (expandBtn) {
1857
+ expandBtn.title = 'Expand to full screen';
1858
+ expandBtn.innerHTML = `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1859
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"></path>
1860
+ </svg>`;
1861
+ }
1862
+ } else {
1863
+ // Expand to full screen
1864
+ overlay.style.height = '100vh';
1865
+ if (expandBtn) {
1866
+ expandBtn.title = 'Collapse';
1867
+ expandBtn.innerHTML = `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1868
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
1869
+ </svg>`;
1870
+ }
1871
+ }
1872
+ };
1873
+
1874
+ // Document cycling functions
1875
+ window.previousDocument = function() {
1876
+ if (!window.simulationDocuments || window.simulationDocuments.length <= 1) return;
1877
+
1878
+ window.currentDocumentIndex--;
1879
+ if (window.currentDocumentIndex < 0) {
1880
+ window.currentDocumentIndex = window.simulationDocuments.length - 1;
1881
+ }
1882
+
1883
+ switchToDocument(window.currentDocumentIndex);
1884
+ };
1885
+
1886
+ window.nextDocument = function() {
1887
+ if (!window.simulationDocuments || window.simulationDocuments.length <= 1) return;
1888
+
1889
+ window.currentDocumentIndex++;
1890
+ if (window.currentDocumentIndex >= window.simulationDocuments.length) {
1891
+ window.currentDocumentIndex = 0;
1892
+ }
1893
+
1894
+ switchToDocument(window.currentDocumentIndex);
1895
+ };
1896
+
1897
+ function switchToDocument(index) {
1898
+ // Check if we have a run_id for this document
1899
+ if (!window.simulationRunIds || !window.simulationRunIds[index]) {
1900
+ console.error('No run_id available for document', index);
1901
+ console.error('Available run_ids:', window.simulationRunIds);
1902
+ ConfirmationModal.show(
1903
+ 'Document ' + (index + 1) + ' is still being submitted. Please wait a moment and try again.',
1904
+ 'Please Wait',
1905
+ 'OK',
1906
+ null,
1907
+ true
1908
+ );
1909
+ return;
1910
+ }
1911
+
1912
+ const runId = window.simulationRunIds[index];
1913
+
1914
+ // Initialize results cache if needed
1915
+ if (!window.simulationResultsCache) {
1916
+ window.simulationResultsCache = {};
1917
+ }
1918
+
1919
+ // Check if we have cached results for this run_id
1920
+ if (window.simulationResultsCache[runId]) {
1921
+ renderCachedResults(runId, index);
1922
+ } else {
1923
+ // Clear existing simulation artifacts
1924
+ clearSimulationArtifacts();
1925
+
1926
+ // Update counter
1927
+ updateDocumentCounter();
1928
+
1929
+ // Show loading indicator
1930
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
1931
+ if (loadingIndicator) {
1932
+ loadingIndicator.style.display = 'flex';
1933
+ } else {
1934
+ console.error('Loading indicator not found');
1935
+ }
1936
+
1937
+ // Hide view mode selector during reload
1938
+ const viewModeSelector = document.getElementById('viewModeSelector');
1939
+ if (viewModeSelector) {
1940
+ viewModeSelector.style.display = 'none';
1941
+ }
1942
+
1943
+ // Start polling for this run_id
1944
+ initSimulationResults(runId);
1945
+ }
1946
+ }
1947
+
1948
+ function renderCachedResults(runId, index) {
1949
+ const cachedData = window.simulationResultsCache[runId];
1950
+
1951
+ // Clear existing simulation artifacts
1952
+ clearSimulationArtifacts();
1953
+
1954
+ // Update counter
1955
+ updateDocumentCounter();
1956
+
1957
+ // Check if this document had no plugins executed
1958
+ if (cachedData.noPluginsExecuted) {
1959
+ // Show the "No Plugins Executed" banner
1960
+ const resultsContainer = document.getElementById('results-container');
1961
+ if (resultsContainer) {
1962
+ resultsContainer.innerHTML = `
1963
+ <div class="w-full p-4 bg-yellow-900/30 border-y border-yellow-600">
1964
+ <div class="flex items-center gap-3">
1965
+ <svg class="w-6 h-6 text-yellow-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1966
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
1967
+ </svg>
1968
+ <div>
1969
+ <h3 class="text-base font-semibold text-yellow-400">No Plugins Executed</h3>
1970
+ <p class="text-sm text-yellow-200">
1971
+ No plugins were triggered during this execution.
1972
+ </p>
1973
+ </div>
1974
+ </div>
1975
+ </div>
1976
+ `;
1977
+ }
1978
+
1979
+ // Hide loading indicator
1980
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
1981
+ if (loadingIndicator) {
1982
+ loadingIndicator.style.display = 'none';
1983
+ }
1984
+
1985
+ return;
1986
+ }
1987
+
1988
+ // Re-render the graph and badges with cached data
1989
+ if (cachedData.nodes && cachedData.links) {
1990
+ window.simulationData = {
1991
+ nodes: cachedData.nodes,
1992
+ links: cachedData.links,
1993
+ originalEvent: cachedData.originalEvent,
1994
+ outputEvent: cachedData.outputEvent,
1995
+ totalExecutionTimeMs: cachedData.totalExecutionTimeMs
1996
+ };
1997
+
1998
+ // Mark executed plugins
1999
+ if (cachedData.originalEvent) {
2000
+ markExecutedPlugins(cachedData.nodes, cachedData.originalEvent, cachedData.outputEvent);
2001
+ }
2002
+
2003
+ // Create the graph
2004
+ createForceDirectedGraph({ nodes: cachedData.nodes, links: cachedData.links });
2005
+
2006
+ // Display total execution time
2007
+ const totalTimeElement = document.getElementById('totalExecutionTime');
2008
+ if (totalTimeElement && cachedData.totalExecutionTimeMs) {
2009
+ totalTimeElement.textContent = `⏱ ${cachedData.totalExecutionTimeMs}ms`;
2010
+ totalTimeElement.style.display = 'inline';
2011
+ }
2012
+
2013
+ // Show view mode selector
2014
+ const viewModeSelector = document.getElementById('viewModeSelector');
2015
+ if (viewModeSelector) {
2016
+ viewModeSelector.style.display = 'flex';
2017
+ }
2018
+
2019
+ // Hide loading indicator
2020
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2021
+ if (loadingIndicator) {
2022
+ loadingIndicator.style.display = 'none';
2023
+ }
2024
+
2025
+ } else {
2026
+ console.error('Cached data missing nodes or links');
2027
+ }
2028
+ }
2029
+
2030
+ function clearSimulationArtifacts() {
2031
+ // Clear graph
2032
+ const svg = d3.select("#pipeline-graph");
2033
+ if (svg) {
2034
+ svg.selectAll("*").remove();
2035
+ }
2036
+
2037
+ // Remove all simulation badges and indicators from pipeline editor
2038
+ document.querySelectorAll('.simulation-executed-badge').forEach(badge => badge.remove());
2039
+ document.querySelectorAll('.simulation-timing-badge').forEach(badge => badge.remove());
2040
+ document.querySelectorAll('.simulation-data-indicator').forEach(indicator => indicator.remove());
2041
+ document.querySelectorAll('.simulation-data-flow').forEach(flow => flow.remove());
2042
+
2043
+ // Remove dimming effect
2044
+ document.querySelectorAll('.simulation-dimmed').forEach(el => {
2045
+ el.classList.remove('simulation-dimmed');
2046
+ });
2047
+
2048
+ // Close any open tooltips
2049
+ const dataFlowTooltip = document.getElementById('data-flow-tooltip');
2050
+ if (dataFlowTooltip) {
2051
+ dataFlowTooltip.remove();
2052
+ }
2053
+
2054
+ const linkTooltip = document.querySelector('.d3-link-tooltip');
2055
+ if (linkTooltip) {
2056
+ linkTooltip.remove();
2057
+ }
2058
+
2059
+ // Clear text view
2060
+ const textViewContent = document.getElementById('textViewContent');
2061
+ if (textViewContent) {
2062
+ textViewContent.innerHTML = '';
2063
+ }
2064
+
2065
+ // Clear results container (removes banners) and recreate SVG
2066
+ const resultsContainer = document.getElementById('results-container');
2067
+ if (resultsContainer) {
2068
+ resultsContainer.innerHTML = '';
2069
+
2070
+ // Recreate the SVG element
2071
+ const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2072
+ svgElement.id = "pipeline-graph";
2073
+ svgElement.setAttribute("width", "100%");
2074
+ svgElement.setAttribute("height", "100");
2075
+ svgElement.setAttribute("class", "bg-gray-900");
2076
+ svgElement.style.display = "block";
2077
+ resultsContainer.appendChild(svgElement);
2078
+ }
2079
+ }
2080
+
2081
+ function updateDocumentCounter() {
2082
+ const counter = document.getElementById('documentCounter');
2083
+ const prevBtn = document.getElementById('prevDocBtn');
2084
+ const nextBtn = document.getElementById('nextDocBtn');
2085
+
2086
+ if (counter && window.simulationDocuments) {
2087
+ const total = window.simulationDocuments.length;
2088
+ const current = window.currentDocumentIndex + 1;
2089
+ counter.textContent = `${current} / ${total}`;
2090
+
2091
+ // Enable/disable buttons
2092
+ if (prevBtn) prevBtn.disabled = total <= 1;
2093
+ if (nextBtn) nextBtn.disabled = total <= 1;
2094
+ }
2095
+ }
2096
+
2097
+ // Global cleanup function
2098
+ window.cleanupSimulation = function() {
2099
+ // Clear all active pollers to stop any ongoing polling
2100
+ if (window.activePollers) {
2101
+ console.log('cleanupSimulation: Clearing', window.activePollers.size, 'active pollers');
2102
+ window.activePollers.clear();
2103
+ }
2104
+
2105
+ // Remove loading block
2106
+ hideOverlayLoadingBlock();
2107
+
2108
+ // Remove overlay
2109
+ const overlay = document.getElementById('simulation-overlay');
2110
+ if (overlay) {
2111
+ overlay.remove();
2112
+ }
2113
+
2114
+ // Remove all simulation artifacts
2115
+ clearSimulationArtifacts();
2116
+
2117
+ // Clear document storage
2118
+ window.simulationDocuments = [];
2119
+ window.currentDocumentIndex = 0;
2120
+ };
2121
+
2122
+ function initSimulationResults(runId) {
2123
+ // Initialize active pollers set if it doesn't exist
2124
+ if (!window.activePollers) {
2125
+ window.activePollers = new Set();
2126
+ }
2127
+
2128
+ // Prevent double polling for the same run_id
2129
+ if (window.activePollers.has(runId)) {
2130
+ return;
2131
+ }
2132
+ window.activePollers.add(runId);
2133
+
2134
+ // Add loading overlay to block interaction with the overlay bar
2135
+ showOverlayLoadingBlock();
2136
+
2137
+ let pollCount = 0;
2138
+ const maxPolls = 240; // Poll for 240 * 250ms = 60 seconds max (handles Logstash restarts)
2139
+ const pollInterval = 250; // Poll every 250ms for faster updates
2140
+ let receivedFinal = false; // Track if we've received the final event
2141
+ let originalEvent = null; // Store the original event for baseline comparison
2142
+ // If we see a final with no snapshots, hold briefly in case a better event arrives
2143
+ // (GetSimulationResults already consumed the empty final from the queue).
2144
+ let emptyFinalGracePolls = 0;
2145
+ const EMPTY_FINAL_GRACE = 8; // ~2s at 250ms
2146
+
2147
+
2148
+ // Add a 10-second timeout to show a warning message
2149
+ const loadingTimeout = setTimeout(() => {
2150
+ if (!receivedFinal) {
2151
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2152
+ if (loadingIndicator) {
2153
+ // Check if warning doesn't already exist
2154
+ if (!document.getElementById('loading-timeout-warning')) {
2155
+ const warning = document.createElement('span');
2156
+ warning.id = 'loading-timeout-warning';
2157
+ warning.className = 'text-xs text-yellow-400 ml-2';
2158
+
2159
+ // Check if user is in embedded mode (simulationMode is defined globally in pipeline_editor.html)
2160
+ if (typeof simulationMode !== 'undefined' && simulationMode === 'embedded') {
2161
+ warning.textContent = "This is taking a while. You're using embedded mode. Consider switching to host mode, or view logs by clicking the button on the right.";
2162
+ } else {
2163
+ warning.textContent = 'This is taking a while, you should check the logs using the button to the right.';
2164
+ }
2165
+
2166
+ loadingIndicator.appendChild(warning);
2167
+ }
2168
+ }
2169
+ }
2170
+ }, 10000); // 10 seconds
2171
+
2172
+ function pollResults() {
2173
+ // Stop if we've received the final event
2174
+ if (receivedFinal) {
2175
+ return;
2176
+ }
2177
+
2178
+ if (pollCount >= maxPolls) {
2179
+ console.warn('Polling timeout reached for run_id:', runId);
2180
+
2181
+ // Clean up active pollers
2182
+ if (window.activePollers) {
2183
+ window.activePollers.delete(runId);
2184
+ console.log('Removed timed-out runId from activePollers. Remaining:', window.activePollers.size);
2185
+ }
2186
+
2187
+ // Clear the loading timeout
2188
+ if (loadingTimeout) {
2189
+ clearTimeout(loadingTimeout);
2190
+ }
2191
+
2192
+ // Hide loading indicator
2193
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2194
+ if (loadingIndicator) {
2195
+ loadingIndicator.style.display = 'none';
2196
+ }
2197
+
2198
+ // Remove loading block if no more active pollers
2199
+ if (!window.activePollers || window.activePollers.size === 0) {
2200
+ console.log('No more active pollers after timeout, hiding loading block');
2201
+ hideOverlayLoadingBlock();
2202
+ }
2203
+
2204
+ // Show timeout error message
2205
+ const resultsContainer = document.getElementById('results-container');
2206
+ if (resultsContainer) {
2207
+ resultsContainer.innerHTML = `
2208
+ <div class="w-full p-4 bg-red-900/30 border-y border-red-600">
2209
+ <div class="flex items-center gap-3">
2210
+ <svg class="w-6 h-6 text-red-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2211
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
2212
+ </svg>
2213
+ <div>
2214
+ <h3 class="text-base font-semibold text-red-400">Simulation Timeout</h3>
2215
+ <p class="text-sm text-red-200">
2216
+ No results received after 60 seconds. The pipeline may have failed or encountered an error.
2217
+ Use "Logs" in the Simulation controls to check for errors.
2218
+ </p>
2219
+ </div>
2220
+ </div>
2221
+ </div>
2222
+ `;
2223
+ }
2224
+
2225
+ return;
2226
+ }
2227
+
2228
+ fetch(`/ConnectionManager/GetSimulationResults/?run_id=${encodeURIComponent(runId)}`)
2229
+ .then(response => response.json())
2230
+ .then(data => {
2231
+ if (data.results && data.results.length > 0) {
2232
+ const snapshotCounts = data.results.map(e => e.snapshots ? Object.keys(e.snapshots).length : 0);
2233
+ const snapshotKeys = data.results.map(e => e.snapshots ? Object.keys(e.snapshots) : []);
2234
+ console.log(`[BE->FE] Received ${data.results.length} events, snapshot counts: ${JSON.stringify(snapshotCounts)}, keys: ${JSON.stringify(snapshotKeys)}`);
2235
+ }
2236
+
2237
+ if (data.results && data.results.length > 0) {
2238
+
2239
+ data.results.forEach(event => {
2240
+ const simMeta = event.simulation || {};
2241
+ const snapCount = event.snapshots && typeof event.snapshots === 'object'
2242
+ ? Object.keys(event.snapshots).length
2243
+ : 0;
2244
+ // Check if this is the original event
2245
+ if (simMeta.id === 'original') {
2246
+ originalEvent = event;
2247
+ }
2248
+ // Final event: id='final', drop final flag, OR any non-original
2249
+ // event that already carries plugin snapshots (defensive).
2250
+ else if (
2251
+ simMeta.id === 'final' ||
2252
+ simMeta.final === 'true' ||
2253
+ (snapCount > 0 && simMeta.id !== 'original')
2254
+ ) {
2255
+ const hasSnapshots = snapCount > 0;
2256
+
2257
+ // Empty final: wait a short grace for a later event with
2258
+ // snapshots (same run_id). Drop-plugin terminal is immediate.
2259
+ if (!hasSnapshots && simMeta.final !== 'true') {
2260
+ emptyFinalGracePolls = EMPTY_FINAL_GRACE;
2261
+ return;
2262
+ }
2263
+
2264
+ receivedFinal = true;
2265
+ emptyFinalGracePolls = 0;
2266
+
2267
+ if (!hasSnapshots) {
2268
+ // This document had no plugins executed
2269
+ // In multi-document simulations, don't overwrite other documents' results
2270
+ const isMultiDocument = window.simulationDocuments && window.simulationDocuments.length > 1;
2271
+
2272
+ // Cache empty result for this document
2273
+ if (!window.simulationResultsCache) {
2274
+ window.simulationResultsCache = {};
2275
+ }
2276
+ window.simulationResultsCache[runId] = {
2277
+ nodes: [],
2278
+ links: [],
2279
+ originalEvent: originalEvent,
2280
+ totalExecutionTimeMs: '0',
2281
+ noPluginsExecuted: true
2282
+ };
2283
+
2284
+ // Hide loading indicator
2285
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2286
+ if (loadingIndicator) {
2287
+ loadingIndicator.style.display = 'none';
2288
+ }
2289
+
2290
+ // Remove loading block only if no more active pollers
2291
+ if (!window.activePollers || window.activePollers.size === 0) {
2292
+ hideOverlayLoadingBlock();
2293
+ }
2294
+
2295
+ // Only show the banner in single-document simulations
2296
+ // In multi-document simulations, just cache the result and let user navigate to it
2297
+ if (!isMultiDocument) {
2298
+ const resultsContainer = document.getElementById('results-container');
2299
+ if (resultsContainer) {
2300
+ resultsContainer.innerHTML = `
2301
+ <div class="w-full p-4 bg-yellow-900/30 border-y border-yellow-600">
2302
+ <div class="flex items-center gap-3">
2303
+ <svg class="w-6 h-6 text-yellow-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2304
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
2305
+ </svg>
2306
+ <div>
2307
+ <h3 class="text-base font-semibold text-yellow-400">No Plugins Executed</h3>
2308
+ <p class="text-sm text-yellow-200">
2309
+ No plugins were triggered during this execution.
2310
+ </p>
2311
+ </div>
2312
+ </div>
2313
+ </div>
2314
+ `;
2315
+ }
2316
+ }
2317
+
2318
+ // Clear loading timeout
2319
+ if (loadingTimeout) {
2320
+ clearTimeout(loadingTimeout);
2321
+ }
2322
+
2323
+ // Remove from active pollers
2324
+ if (window.activePollers) {
2325
+ window.activePollers.delete(runId);
2326
+ }
2327
+
2328
+ return;
2329
+ }
2330
+
2331
+ // Access the components variable from the page
2332
+ if (typeof components !== 'undefined' && components.filter && event.snapshots) {
2333
+ let previousSnapshot = originalEvent; // Start with original event as baseline
2334
+
2335
+ // Build graph data structure
2336
+ const nodes = [];
2337
+ const links = [];
2338
+
2339
+ // Add starting node
2340
+ nodes.push({
2341
+ id: 'start',
2342
+ label: 'Start',
2343
+ step: 0,
2344
+ hasChanges: false,
2345
+ changesText: 'Original event',
2346
+ isConditional: false
2347
+ });
2348
+
2349
+ // Track the last node ID that was actually added
2350
+ let lastNodeId = 'start';
2351
+ let stepNumber = 0;
2352
+
2353
+ // Get conditional branches taken from the final event
2354
+ const conditionalBranches = event.simulation?.conditional_branches || {};
2355
+ const conditionalConditions = event.simulation?.conditional_conditions || {};
2356
+
2357
+ // Helper function to recursively process plugins and conditionals
2358
+ function processPlugins(pluginsList, parentNodeId) {
2359
+ let currentNodeId = parentNodeId;
2360
+
2361
+ pluginsList.forEach((filterPlugin) => {
2362
+ if (filterPlugin.plugin === 'if') {
2363
+ // This is a conditional - only show the path that was taken
2364
+ const conditionalId = filterPlugin.id;
2365
+ const branchTaken = conditionalBranches[conditionalId];
2366
+
2367
+ // Find which branch was taken and get its details
2368
+ let takenBranchInfo = null;
2369
+ let takenBranchPlugins = null;
2370
+
2371
+ if (branchTaken === 'if') {
2372
+ takenBranchInfo = {
2373
+ label: 'if',
2374
+ condition: filterPlugin.config.condition || '',
2375
+ branchType: 'if'
2376
+ };
2377
+ takenBranchPlugins = filterPlugin.config.plugins;
2378
+ } else if (branchTaken && branchTaken.startsWith('else_if_')) {
2379
+ const elseIfIdx = parseInt(branchTaken.split('_')[2]);
2380
+ const elseIf = filterPlugin.config.else_ifs[elseIfIdx];
2381
+ takenBranchInfo = {
2382
+ label: `else if #${elseIfIdx + 1}`,
2383
+ condition: elseIf.condition || '',
2384
+ branchType: branchTaken
2385
+ };
2386
+ takenBranchPlugins = elseIf.plugins;
2387
+ } else if (branchTaken === 'else') {
2388
+ takenBranchInfo = {
2389
+ label: 'else',
2390
+ condition: 'default branch',
2391
+ branchType: 'else'
2392
+ };
2393
+ takenBranchPlugins = filterPlugin.config.else.plugins;
2394
+ }
2395
+
2396
+ // Create a single "decision point" node showing which branch was taken
2397
+ if (takenBranchInfo) {
2398
+ stepNumber++;
2399
+ const decisionNodeId = `${conditionalId}_decision`;
2400
+
2401
+ // Count total branches for context
2402
+ let totalBranches = 1; // if
2403
+ if (filterPlugin.config.else_ifs) totalBranches += filterPlugin.config.else_ifs.length;
2404
+ if (filterPlugin.config.else) totalBranches += 1;
2405
+
2406
+ nodes.push({
2407
+ id: decisionNodeId,
2408
+ label: `✓ ${takenBranchInfo.label}`,
2409
+ step: stepNumber,
2410
+ hasChanges: false,
2411
+ changesText: `Conditional evaluated (${totalBranches} branches)\nTook: ${takenBranchInfo.label}\nCondition: ${takenBranchInfo.condition}`,
2412
+ condition: takenBranchInfo.condition,
2413
+ isConditional: true,
2414
+ isDecisionPoint: true,
2415
+ conditionalId: conditionalId,
2416
+ branchType: takenBranchInfo.branchType,
2417
+ wasTaken: true,
2418
+ totalBranches: totalBranches
2419
+ });
2420
+
2421
+ // Connect from previous node
2422
+ links.push({
2423
+ source: currentNodeId,
2424
+ target: decisionNodeId,
2425
+ eventJson: 'Conditional evaluation',
2426
+ isConditional: true
2427
+ });
2428
+
2429
+ // Process plugins from the taken branch
2430
+ if (takenBranchPlugins) {
2431
+ currentNodeId = processPlugins(takenBranchPlugins, decisionNodeId);
2432
+ } else {
2433
+ currentNodeId = decisionNodeId;
2434
+ }
2435
+ }
2436
+ } else {
2437
+ // Regular plugin
2438
+ // Skip comment plugins - they don't execute in Logstash
2439
+ if (filterPlugin.plugin !== 'comment') {
2440
+ const pluginId = filterPlugin.id;
2441
+ const snapshot = event.snapshots[pluginId];
2442
+
2443
+ if (snapshot) {
2444
+ stepNumber++;
2445
+
2446
+ // Filter metadata from both snapshots before comparing
2447
+ const filteredPrevious = filterMetadata(previousSnapshot);
2448
+ const filteredCurrent = filterMetadata(snapshot);
2449
+
2450
+ // Compare with previous snapshot (or original) and show only changes
2451
+ const changes = diffObjects(filteredPrevious, filteredCurrent);
2452
+
2453
+ // Check if there are any changes
2454
+ const hasChanges = Object.keys(changes.added).length > 0 ||
2455
+ Object.keys(changes.modified).length > 0 ||
2456
+ Object.keys(changes.deleted).length > 0;
2457
+
2458
+ // Format changes for tooltip
2459
+ let changesText = 'No changes';
2460
+ if (hasChanges) {
2461
+ const changesObj = {};
2462
+ if (Object.keys(changes.added).length > 0) changesObj.added = changes.added;
2463
+ if (Object.keys(changes.modified).length > 0) changesObj.modified = changes.modified;
2464
+ if (Object.keys(changes.deleted).length > 0) changesObj.deleted = changes.deleted;
2465
+ changesText = JSON.stringify(changesObj, null, 2);
2466
+ }
2467
+
2468
+ // Filter snapshot before storing
2469
+ const filteredSnap = filterMetadata(snapshot);
2470
+
2471
+ // Extract timing data if available
2472
+ let executionTimeMs = null;
2473
+ if (snapshot.simulation && snapshot.simulation.timing && snapshot.simulation.timing.execution_ns) {
2474
+ // Convert nanoseconds to milliseconds, rounded to 3 decimal places
2475
+ executionTimeMs = (snapshot.simulation.timing.execution_ns / 1000000).toFixed(3);
2476
+ }
2477
+
2478
+ // Add node with changes for context-aware highlighting
2479
+ nodes.push({
2480
+ id: pluginId,
2481
+ label: filterPlugin.plugin,
2482
+ step: stepNumber,
2483
+ hasChanges: hasChanges,
2484
+ changesText: changesText,
2485
+ eventJson: JSON.stringify(filteredSnap, null, 2),
2486
+ changes: changes, // Store changes for highlighting
2487
+ isConditional: false,
2488
+ executionTimeMs: executionTimeMs // Store execution time in milliseconds
2489
+ });
2490
+
2491
+ // Add link from the last actual node that was added
2492
+ // Include the snapshot (event state) for this link
2493
+ links.push({
2494
+ source: currentNodeId,
2495
+ target: pluginId,
2496
+ eventJson: JSON.stringify(filteredSnap, null, 2),
2497
+ changes: changes, // Store changes for highlighting in tooltips
2498
+ isConditional: false
2499
+ });
2500
+
2501
+ // Update current node ID for next iteration
2502
+ currentNodeId = pluginId;
2503
+
2504
+ // Update previous snapshot for next iteration
2505
+ previousSnapshot = snapshot;
2506
+ }
2507
+ }
2508
+ }
2509
+ });
2510
+
2511
+ return currentNodeId;
2512
+ }
2513
+
2514
+ // Process all filter plugins
2515
+ const finalNodeId = processPlugins(components.filter, lastNodeId);
2516
+
2517
+ // Add ending node
2518
+ stepNumber++;
2519
+ nodes.push({
2520
+ id: 'end',
2521
+ label: 'End',
2522
+ step: stepNumber,
2523
+ hasChanges: false,
2524
+ changesText: 'Pipeline complete',
2525
+ isConditional: false
2526
+ });
2527
+
2528
+ // Connect final plugin to end node
2529
+ links.push({
2530
+ source: finalNodeId,
2531
+ target: 'end',
2532
+ eventJson: 'Pipeline complete',
2533
+ isConditional: false
2534
+ });
2535
+
2536
+ // Calculate total execution time from all nodes
2537
+ let totalExecutionTimeMs = 0;
2538
+ nodes.forEach(node => {
2539
+ if (node.executionTimeMs) {
2540
+ totalExecutionTimeMs += parseFloat(node.executionTimeMs);
2541
+ }
2542
+ });
2543
+
2544
+ // Store simulation data globally for view switching
2545
+ window.simulationData = {
2546
+ nodes,
2547
+ links,
2548
+ originalEvent,
2549
+ outputEvent: event,
2550
+ totalExecutionTimeMs: totalExecutionTimeMs.toFixed(3)
2551
+ };
2552
+
2553
+ // Cache results for this run_id
2554
+ if (!window.simulationResultsCache) {
2555
+ window.simulationResultsCache = {};
2556
+ }
2557
+ window.simulationResultsCache[runId] = {
2558
+ nodes: nodes,
2559
+ links: links,
2560
+ originalEvent: originalEvent,
2561
+ outputEvent: event,
2562
+ totalExecutionTimeMs: totalExecutionTimeMs.toFixed(3)
2563
+ };
2564
+
2565
+ // Check if we're in text mode (modal-based) or overlay mode
2566
+ const viewModeRadio = document.querySelector('input[name="viewMode"]:checked');
2567
+ const isTextMode = viewModeRadio && viewModeRadio.value === 'text';
2568
+
2569
+ if (isTextMode) {
2570
+ // Text Mode: Skip graph creation, just dispatch event for modal
2571
+ window.dispatchEvent(new CustomEvent('simulationDataReady', {
2572
+ detail: { nodes, links }
2573
+ }));
2574
+ } else {
2575
+ // Overlay Mode: Mark plugins and create graph
2576
+ markExecutedPlugins(nodes, originalEvent, event);
2577
+
2578
+ // Use requestAnimationFrame to ensure DOM is fully rendered before creating graph
2579
+ requestAnimationFrame(() => {
2580
+ createForceDirectedGraph({ nodes, links });
2581
+ });
2582
+
2583
+ // Display total execution time
2584
+ const totalTimeElement = document.getElementById('totalExecutionTime');
2585
+ if (totalTimeElement && totalExecutionTimeMs > 0) {
2586
+ totalTimeElement.textContent = `⏱ ${totalExecutionTimeMs.toFixed(3)}ms`;
2587
+ totalTimeElement.style.display = 'inline';
2588
+ }
2589
+
2590
+ // Show view mode selector in overlay
2591
+ const viewModeSelector = document.getElementById('viewModeSelector');
2592
+ if (viewModeSelector) {
2593
+ viewModeSelector.style.display = 'flex';
2594
+ } else {
2595
+ console.error('viewModeSelector element not found in DOM');
2596
+ }
2597
+
2598
+ // Show document navigation if multiple documents
2599
+ if (window.simulationDocuments && window.simulationDocuments.length > 1) {
2600
+ const docNav = document.getElementById('documentNavigation');
2601
+ if (docNav) {
2602
+ docNav.style.display = 'flex';
2603
+ updateDocumentCounter();
2604
+ }
2605
+ }
2606
+
2607
+ // Hide loading indicator
2608
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2609
+ if (loadingIndicator) {
2610
+ loadingIndicator.style.display = 'none';
2611
+ }
2612
+
2613
+ // Clear the loading timeout
2614
+ if (loadingTimeout) {
2615
+ clearTimeout(loadingTimeout);
2616
+ }
2617
+
2618
+ // Remove from active pollers
2619
+ if (window.activePollers) {
2620
+ window.activePollers.delete(runId);
2621
+ console.log('Removed runId from activePollers. Remaining:', window.activePollers.size);
2622
+ }
2623
+
2624
+ // Remove loading block only if no more active pollers
2625
+ if (!window.activePollers || window.activePollers.size === 0) {
2626
+ console.log('No more active pollers, hiding loading block');
2627
+ hideOverlayLoadingBlock();
2628
+ } else {
2629
+ console.log('Still have active pollers:', window.activePollers.size);
2630
+ }
2631
+ }
2632
+ } else {
2633
+ console.error('Components variable not accessible or snapshots missing');
2634
+ }
2635
+ }
2636
+ });
2637
+ }
2638
+
2639
+ // Stop polling if we received the final event
2640
+ if (receivedFinal) {
2641
+ if (window.activePollers) {
2642
+ window.activePollers.delete(runId);
2643
+ }
2644
+ return;
2645
+ }
2646
+
2647
+ // Grace after empty final: no better event arrived → treat as no plugins
2648
+ if (emptyFinalGracePolls > 0) {
2649
+ emptyFinalGracePolls -= 1;
2650
+ if (emptyFinalGracePolls === 0) {
2651
+ receivedFinal = true;
2652
+ const isMultiDocument = window.simulationDocuments && window.simulationDocuments.length > 1;
2653
+ if (!window.simulationResultsCache) {
2654
+ window.simulationResultsCache = {};
2655
+ }
2656
+ window.simulationResultsCache[runId] = {
2657
+ nodes: [],
2658
+ links: [],
2659
+ originalEvent: originalEvent,
2660
+ totalExecutionTimeMs: '0',
2661
+ noPluginsExecuted: true
2662
+ };
2663
+ const loadingIndicator = document.getElementById('simulation-loading-indicator');
2664
+ if (loadingIndicator) {
2665
+ loadingIndicator.style.display = 'none';
2666
+ }
2667
+ if (loadingTimeout) {
2668
+ clearTimeout(loadingTimeout);
2669
+ }
2670
+ if (window.activePollers) {
2671
+ window.activePollers.delete(runId);
2672
+ }
2673
+ if (!window.activePollers || window.activePollers.size === 0) {
2674
+ hideOverlayLoadingBlock();
2675
+ }
2676
+ if (!isMultiDocument) {
2677
+ const resultsContainer = document.getElementById('results-container');
2678
+ if (resultsContainer) {
2679
+ resultsContainer.innerHTML = `
2680
+ <div class="w-full p-4 bg-yellow-900/30 border-y border-yellow-600">
2681
+ <div class="flex items-center gap-3">
2682
+ <svg class="w-6 h-6 text-yellow-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2683
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
2684
+ </svg>
2685
+ <div>
2686
+ <h3 class="text-base font-semibold text-yellow-400">No Plugins Executed</h3>
2687
+ <p class="text-sm text-yellow-200">
2688
+ No plugins were triggered during this execution.
2689
+ </p>
2690
+ </div>
2691
+ </div>
2692
+ </div>
2693
+ `;
2694
+ }
2695
+ }
2696
+ return;
2697
+ }
2698
+ }
2699
+
2700
+ pollCount++;
2701
+ setTimeout(pollResults, pollInterval);
2702
+ })
2703
+ .catch(error => {
2704
+ console.error('Error polling results:', error);
2705
+ pollCount++;
2706
+ setTimeout(pollResults, pollInterval);
2707
+ });
2708
+ }
2709
+
2710
+ // Start polling immediately
2711
+ setTimeout(pollResults, 100);
2712
+ }
2713
+
2714
+ /**
2715
+ * Show a loading block overlay over the simulation overlay bar to prevent interaction
2716
+ * during multi-simulation updates
2717
+ */
2718
+ function showOverlayLoadingBlock() {
2719
+ // Remove any existing block first
2720
+ hideOverlayLoadingBlock();
2721
+
2722
+ const resultsContainer = document.getElementById('results-container');
2723
+ if (!resultsContainer) {
2724
+ console.error('showOverlayLoadingBlock: results-container not found');
2725
+ return;
2726
+ }
2727
+
2728
+ console.log('showOverlayLoadingBlock: Creating loading block in results-container');
2729
+
2730
+ // Ensure results-container has position: relative
2731
+ resultsContainer.style.position = 'relative';
2732
+
2733
+ // Create a blocking overlay that covers only the canvas area (not the header)
2734
+ const block = document.createElement('div');
2735
+ block.id = 'overlay-loading-block';
2736
+ block.style.cssText = `
2737
+ position: absolute;
2738
+ top: 0;
2739
+ left: 0;
2740
+ right: 0;
2741
+ bottom: 0;
2742
+ background: rgba(17, 24, 39, 0.5);
2743
+ z-index: 50;
2744
+ pointer-events: auto;
2745
+ cursor: wait;
2746
+ `;
2747
+
2748
+ resultsContainer.appendChild(block);
2749
+ console.log('showOverlayLoadingBlock: Loading block appended to results-container');
2750
+ }
2751
+
2752
+ /**
2753
+ * Hide the overlay loading block
2754
+ */
2755
+ function hideOverlayLoadingBlock() {
2756
+ const block = document.getElementById('overlay-loading-block');
2757
+ if (block) {
2758
+ console.log('hideOverlayLoadingBlock: Removing loading block');
2759
+ block.remove();
2760
+ } else {
2761
+ console.log('hideOverlayLoadingBlock: No loading block found to remove');
2762
+ }
2763
+ }
2764
+
2765
+ // Global cleanup for tooltips - hide any open tooltips when clicking outside
2766
+ document.addEventListener('click', function(e) {
2767
+ // Only hide if click is outside tooltip and not on a trigger
2768
+ const tooltip = document.getElementById('data-flow-tooltip');
2769
+ if (tooltip && !tooltip.contains(e.target) && !e.target.closest('.simulation-data-flow')) {
2770
+ hideDataFlowTooltip();
2771
+ }
2772
+
2773
+ // Also clean up any D3 link tooltips
2774
+ const linkTooltip = document.querySelector('.d3-link-tooltip');
2775
+ if (linkTooltip && !linkTooltip.contains(e.target)) {
2776
+ linkTooltip.remove();
2777
+ }
2778
+ });