plugin-document-understanding 1.1.16 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +19 -25
  3. package/dist/client/169.6888909107c553c3.js +10 -0
  4. package/dist/client/379.e29f5ced467ce23d.js +10 -0
  5. package/dist/client/867.3ed3b814115181ca.js +10 -0
  6. package/dist/client/index.js +1 -1
  7. package/dist/client-v2/169.53bf1be2ec192f0c.js +10 -0
  8. package/dist/client-v2/379.e75c4829567cdb89.js +10 -0
  9. package/dist/client-v2/867.66d7291e95f1de78.js +10 -0
  10. package/dist/client-v2/index.js +1 -1
  11. package/dist/externalVersion.js +9 -7
  12. package/dist/locale/en-US.json +126 -0
  13. package/dist/locale/vi-VN.json +130 -2
  14. package/dist/locale/zh-CN.json +127 -1
  15. package/dist/node_modules/form-data/package.json +1 -1
  16. package/dist/node_modules/mime-types/package.json +1 -1
  17. package/dist/server/actions.js +211 -11
  18. package/dist/server/collections/api-keys.js +55 -0
  19. package/dist/server/collections/artifacts.js +59 -0
  20. package/dist/server/collections/config.js +9 -3
  21. package/dist/server/collections/endpoints.js +3 -0
  22. package/dist/server/collections/jobs.js +7 -4
  23. package/dist/server/collections/operations.js +76 -0
  24. package/dist/server/contracts/du-contracts.js +828 -0
  25. package/dist/server/dugate-seed.js +98 -340
  26. package/dist/server/plugin.js +49 -7
  27. package/dist/server/routes/du-gateway-router.js +443 -0
  28. package/dist/server/services/ArtifactStorageService.js +459 -0
  29. package/dist/server/services/AsyncJobManager.js +1 -1
  30. package/dist/server/services/BuiltinBusinessEngine.js +1223 -0
  31. package/dist/server/services/DocumentUnderstandingService.js +151 -25
  32. package/dist/server/services/ExternalDuReworkClient.js +210 -0
  33. package/dist/server/services/OperationOrchestrator.js +1087 -0
  34. package/dist/server/services/PipelineExecutor.js +164 -43
  35. package/dist/server/tools/document-understanding-tool.js +49 -24
  36. package/dist/server/workflow/DocumentUnderstandingInstruction.js +292 -0
  37. package/package.json +8 -4
  38. package/src/client/index.tsx +11 -0
  39. package/src/client-v2/components/ApiKeysTab.tsx +198 -0
  40. package/src/client-v2/components/EndpointsTab.tsx +39 -2
  41. package/src/client-v2/components/JobsTab.tsx +136 -21
  42. package/src/client-v2/components/OperationsTab.tsx +586 -0
  43. package/src/client-v2/components/PluginSettings.tsx +12 -0
  44. package/src/client-v2/components/ServiceConfigTab.tsx +225 -65
  45. package/src/client-v2/components/__tests__/PluginSettings.test.tsx +4 -0
  46. package/src/client-v2/locale.ts +1 -8
  47. package/src/client-v2/models/index.ts +1 -8
  48. package/src/client-v2/plugin.tsx +12 -8
  49. package/src/client-v2/types.ts +13 -1
  50. package/src/client-v2/workflow/DocumentUnderstandingFieldset.tsx +122 -0
  51. package/src/client-v2/workflow/DocumentUnderstandingInstruction.tsx +49 -0
  52. package/src/locale/en-US.json +126 -0
  53. package/src/locale/vi-VN.json +130 -2
  54. package/src/locale/zh-CN.json +127 -1
  55. package/src/server/__tests__/actions.test.ts +1 -8
  56. package/src/server/__tests__/du-rework-gateway.test.ts +462 -0
  57. package/src/server/__tests__/dugate-integration.test.ts +79 -42
  58. package/src/server/__tests__/smoke.test.ts +1 -8
  59. package/src/server/__tests__/upload-security.test.ts +1 -8
  60. package/src/server/actions.ts +252 -36
  61. package/src/server/collections/api-keys.ts +35 -0
  62. package/src/server/collections/artifacts.ts +39 -0
  63. package/src/server/collections/config.ts +18 -2
  64. package/src/server/collections/endpoints.ts +12 -0
  65. package/src/server/collections/jobs.ts +16 -4
  66. package/src/server/collections/operations.ts +56 -0
  67. package/src/server/contracts/du-contracts.ts +1026 -0
  68. package/src/server/dugate-seed.ts +126 -453
  69. package/src/server/plugin.ts +64 -14
  70. package/src/server/routes/du-gateway-router.ts +465 -0
  71. package/src/server/services/ArtifactStorageService.ts +596 -0
  72. package/src/server/services/AsyncJobManager.ts +10 -1
  73. package/src/server/services/BuiltinBusinessEngine.ts +1544 -0
  74. package/src/server/services/DocumentUnderstandingService.ts +186 -44
  75. package/src/server/services/ExternalDuReworkClient.ts +222 -0
  76. package/src/server/services/OperationOrchestrator.ts +1359 -0
  77. package/src/server/services/PipelineExecutor.ts +245 -108
  78. package/src/server/tools/document-understanding-tool.ts +63 -45
  79. package/src/server/types.ts +101 -16
  80. package/src/server/workflow/DocumentUnderstandingInstruction.ts +308 -0
  81. package/dist/client/345.277fbb2b97424db5.js +0 -10
  82. package/dist/client-v2/345.2fa9834b46dd4531.js +0 -10
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -2,28 +2,22 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- Document Understanding configures external document processing services and chains their endpoints into reusable pipelines. Pipelines can process uploaded files or file references, track asynchronous jobs, receive webhook callbacks, and expose enabled pipelines as AI tools when `@nocobase/plugin-ai` is available.
6
-
7
- ## Features
8
-
9
- - **Service configuration**: Configure the base URL, authentication, request timeout, retries, polling defaults, and webhook secret for an external document processing service.
10
- - **Endpoint registry**: Define reusable HTTP endpoints with request/response schemas, file input mode, custom headers, and sync/polling/webhook execution settings.
11
- - **Pipeline orchestration**: Chain endpoints into ordered steps with input mappings, output aliases, conditions, retry/skip/fail behavior, and final output mapping.
12
- - **Job history**: Track pipeline executions, current step, step results, final result, external task IDs, and errors.
13
- - **AI tools**: Register enabled pipelines dynamically as AI tools so other AI features can invoke document processing workflows.
14
-
15
- ## Usage
16
-
17
- 1. Enable the plugin.
18
- 2. Open the Document Understanding settings page in the NocoBase v2 admin UI.
19
- 3. Configure the service connection and authentication.
20
- 4. Add endpoints for OCR, classification, extraction, or other external document APIs.
21
- 5. Create pipelines that call those endpoints in order and map step outputs into later step inputs.
22
- 6. Run a pipeline from the settings playground, an API request, or an AI tool invocation.
23
- 7. Inspect job history to review status, results, and errors.
24
-
25
- ## Notes
26
-
27
- - Local file references are limited to files under the configured uploads storage path.
28
- - Webhook callbacks require a matching HMAC-SHA256 signature when a webhook secret is configured.
29
- - Polling and webhook modes depend on the external API returning the configured task ID and status/result fields.
5
+ `plugin-document-understanding` (`v2.0.0`) provides an asynchronous **Document Understanding Service, Public API Gateway, and Pipeline Orchestrator** directly inside NocoBase, compatible with the `du-rework` specification.
6
+
7
+ It runs document parsing, OCR/Vision, structured extraction, compliance/risk analysis, comparison, and domain workflows natively using NocoBase's isolated document loader (`@nocobase/ai`) and LLM services (`@nocobase/plugin-ai`), while also supporting optional API delegation to an external `du-rework` orchestrator or custom HTTP endpoints.
8
+
9
+ ## Key Capabilities
10
+
11
+ - **Public `du-rework` API Gateway (`/api/du/v1/*` & `/api/v1/*`)**:
12
+ - 2-step Upload Gateway (`POST /uploads` -> `PUT /uploads/{artifactId}/content` with `x-content-sha256` verification & `Idempotency-Key` replay).
13
+ - Canonical action execution (`POST /businesses/{businessId}/actions/{action}`) with `Idempotency-Key` conflict detection (`409`), `documentSelection` page-range planning & `documentInputCoverage` (DI-06), and `application/problem+json` error envelopes.
14
+ - 12-state Operation lifecycle (`GET /operations`, `GET /operations/{id}?wait=`, `POST .../cancel`, `POST .../resume` with CAS `expectedStateVersion`, `GET .../result` `ResultEnvelope`, `GET /artifacts/{id}/download`, `GET /usage/summary` & `/usage/events`).
15
+ - Legacy compatibility facade (`POST /docs/{action}` & `POST /docs/workflows`).
16
+ - Multi-tenant SHA-256 `x-api-key` issuance & revocation with fail-closed `404` tenant isolation and outbound HMAC `x-du-signature` webhooks.
17
+ - **Built-in Business Engine (36 Profiles)**:
18
+ - **`document-core@2.0.0`**: 6 core actions / 31 variants (`ingest`, `extract`, `analyze`, `transform`, `generate`, `compare`) + 3 workflows (`disbursement`, `doc-compare`, `schema-workflow`).
19
+ - **`lc-checker@1.2.0`**: 5-step Trade Finance L/C examination against versioned UCP 600 / ISBP 821 rules (`ucp600-isbp821-v1`) with mandatory rule citations and `humanSignOffRequired`.
20
+ - **`example-review@1.0.0`**: Multi-document compliance review with optional HITL approval.
21
+ - **Ecosystem Integrations**:
22
+ - **NocoBase Workflow Node (`document-understanding`)** for both modern (`client-v2`) and legacy (`client`) workflow canvases.
23
+ - **Dynamic AI Tools (`@nocobase/plugin-ai`)** exposing enabled pipelines with typed JSON Schemas and page selection.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_document_understanding=self.webpackChunkplugin_document_understanding||[]).push([["169"],{328:function(e,n,t){t.d(n,{DocumentUnderstandingFieldset:function(){return f}});var a=t(155),r=t.n(a),l=t(59),i=t(694),o=t(197),c=t(585),u=t(832),m=t(650);function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}var p=[{value:"document-core",label:"document-core (v2.0.0)"},{value:"lc-checker",label:"lc-checker (v1.2.0 - UCP 600 / ISBP 821)"},{value:"example-review",label:"example-review (v1.0.0)"}],f=function(){var e,n=(0,m.k)(),t=(0,i.useFlowContext)(),f=l.Form.useFormInstance(),d=l.Form.useWatch(["config","mode"],f)||"business_action",g=l.Form.useWatch(["config","businessId"],f)||"document-core",b=l.Form.useWatch(["config","action"],f)||"extract",v=function(e){if(Array.isArray(e))return e}(e=(0,a.useState)([]))||function(e){var n,t,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var r=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(n=a.next()).done)&&(r.push(n.value),2!==r.length);l=!0);}catch(e){i=!0,t=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw t}}return r}}(e)||function(e){if(e){if("string"==typeof e)return s(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=v[0],E=v[1];(0,a.useEffect)(function(){if("pipeline"===d&&(null==t?void 0:t.api)){var e=!1;return t.api.request({url:"docUnderstanding:listPipelines"}).then(function(n){e||E((0,u.mT)(n,[]))}).catch(function(){}),function(){e=!0}}},[null==t?void 0:t.api,d]);var I=Array.from(new Set(c.VQ.filter(function(e){return e.businessId===g}).map(function(e){return e.action}))),F=c.VQ.filter(function(e){return e.businessId===g&&e.action===b&&e.discriminatorValue});return r().createElement("div",null,r().createElement(l.Form.Item,{name:["config","mode"],label:n("Execution Mode"),initialValue:"business_action"},r().createElement(l.Select,{options:[{value:"business_action",label:n("Canonical Business Action (du-rework)")},{value:"pipeline",label:n("Configured Pipeline")}]})),"pipeline"===d?r().createElement(l.Form.Item,{name:["config","pipelineId"],label:n("Pipeline"),rules:[{required:!0,message:n("Select a pipeline")}]},r().createElement(l.Select,{placeholder:n("Select pipeline"),options:h.map(function(e){return{value:e.id,label:e.name}})})):r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:["config","businessId"],label:n("Business"),initialValue:"document-core"},r().createElement(l.Select,{options:p})),r().createElement(l.Form.Item,{name:["config","action"],label:n("Action"),initialValue:"extract"},r().createElement(l.Select,{options:I.map(function(e){return{value:e,label:e}})})),F.length>0&&r().createElement(l.Form.Item,{name:["config","variant"],label:n("Variant / Mode")},r().createElement(l.Select,{allowClear:!0,placeholder:n("Select variant"),options:F.map(function(e){return{value:e.discriminatorValue,label:"".concat(e.discriminatorValue," — ").concat(e.description)}})}))),r().createElement(l.Form.Item,{name:["config","files"],label:n("Document Files / Attachment Variable"),extra:n("Bind an attachment field, file URL, or comma-separated upload paths from upstream nodes")},r().createElement(o.WorkflowVariableInput,{placeholder:"uploads/invoice.pdf"})),r().createElement(l.Form.Item,{name:["config","pages"],label:n("Page Selection (DI-06)"),extra:n('Optional page ranges, e.g. "1-3, 5" (leave empty for all pages)')},r().createElement(o.WorkflowVariableInput,{placeholder:"1-3"})),r().createElement(l.Form.Item,{name:["config","inputJson"],label:n("Input Parameters (JSON)"),extra:n("Additional action parameters (e.g. referenceData, questions, targetLanguage, ruleSetVersion)")},r().createElement(o.WorkflowVariableJsonTextArea,{rows:4,placeholder:'{ "outputFormat": "json" }'})),r().createElement(l.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},r().createElement(l.Checkbox,null,n("Continue workflow even if document processing fails"))))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_document_understanding=self.webpackChunkplugin_document_understanding||[]).push([["379"],{832:function(e,t,i){function n(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function a(e,t){var i,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(i=null==(n=e.data)?void 0:n.data)?i:t:t}function r(e){return n(e,Error)?e.message:String(e)}function s(e){if(!e)return"-";var t=n(e,Date)?e:new Date(e);return Number.isNaN(t.getTime())?"-":t.toLocaleString()}i.d(t,{gJ:function(){return r},mT:function(){return a},r6:function(){return s}})},585:function(e,t,i){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}i.d(t,{VQ:function(){return c},Xm:function(){return r},vZ:function(){return s}});var r=["PENDING_INGESTION","ACCEPTED","QUEUED","RUNNING","WAITING_CHILDREN","WAITING_INPUT","RETRY_PENDING","CANCEL_REQUESTED","SUCCEEDED","FAILED","CANCELLED","TIMED_OUT"];function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,i=e.trim();if(!i||"all"===i.toLowerCase())return[];var n=[],a=0,r=!0,s=!1,o=void 0;try{for(var c,d=i.split(",")[Symbol.iterator]();!(r=(c=d.next()).done);r=!0){var m=c.value.trim();if(m){var u=/^(\d+)(?:\s*-\s*(\d+))?$/.exec(m);if(!u)throw Error('Invalid page range segment "'.concat(m,'". Expected "1-5" or "1,3-5".'));var l=Number(u[1]),p=u[2]?Number(u[2]):l;if(!Number.isSafeInteger(l)||!Number.isSafeInteger(p)||l<1||p<l)throw Error('Invalid page range "'.concat(m,'": page numbers must be >= 1 and from <= to.'));if((a+=p-l+1)>t)throw Error("Selected page count (".concat(a,") exceeds maximum allowed (").concat(t,")."));n.push({from:l,to:p})}}}catch(e){s=!0,o=e}finally{try{r||null==d.return||d.return()}finally{if(s)throw o}}return n}function o(e,t,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return{type:"object",properties:function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){a(e,t,i[t])})}return e}(a({},e,{type:"string",enum:[t],default:t}),i),required:[e].concat(function(e){if(Array.isArray(e))return n(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e){if(e){if("string"==typeof e)return n(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return n(e,void 0)}}(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}[{ruleId:"UCP600-ART14-A",standard:"UCP 600",title:"Standard for Examination of Documents",description:"Nominated/issuing bank must determine on the basis of the documents alone whether they appear on their face to constitute a complying presentation."},{ruleId:"UCP600-ART14-D",standard:"UCP 600",title:"Non-conflicting Data Across Documents",description:"Data in a document, when read in context with the credit, the document itself and international standard banking practice, need not be identical to, but must not conflict with, data in that document, any other stipulated document or the credit."},{ruleId:"UCP600-ART14-E",standard:"UCP 600",title:"Description of Goods in Non-Invoice Documents",description:"In documents other than the commercial invoice, the description of the goods, services or performance, if stated, may be in general terms not conflicting with their description in the credit."},{ruleId:"UCP600-ART14-I",standard:"UCP 600",title:"Document Dates vs Presentation Date",description:"A document may be dated prior to the issuance date of the credit, but must not be dated later than its date of presentation."},{ruleId:"UCP600-ART18-A",standard:"UCP 600",title:"Commercial Invoice Issuer & Beneficiary",description:"A commercial invoice must appear to have been issued by the beneficiary, made out in the name of the applicant, and in the same currency as the credit."},{ruleId:"UCP600-ART18-B",standard:"UCP 600",title:"Commercial Invoice Amount Within Credit Limit",description:"Commercial invoice amount must not exceed the amount permitted by the credit."},{ruleId:"UCP600-ART18-C",standard:"UCP 600",title:"Exact Goods Description in Commercial Invoice",description:"The description of the goods, services or performance in a commercial invoice must correspond with that appearing in the credit."},{ruleId:"UCP600-ART20-A-I",standard:"UCP 600",title:"Bill of Lading Carrier Identification & Signature",description:"A bill of lading must indicate the name of the carrier and be signed by the carrier, master, or named agent.",requiresVisualCheck:!0},{ruleId:"UCP600-ART20-A-II",standard:"UCP 600",title:"Bill of Lading Shipped On Board Notation & Date",description:"Bill of lading must indicate that the goods have been shipped on board a named vessel at the port of loading stated in the credit with an on-board date."},{ruleId:"UCP600-ART20-A-III",standard:"UCP 600",title:"Port of Loading and Discharge Match",description:"Bill of lading must indicate shipment from the port of loading to the port of discharge stated in the credit."},{ruleId:"UCP600-ART27",standard:"UCP 600",title:"Clean Transport Document",description:"A bank will only accept a clean transport document bearing no clause or notation expressly declaring a defective condition of the goods or packaging."},{ruleId:"UCP600-ART28-A",standard:"UCP 600",title:"Insurance Document Signature & Coverage",description:"Insurance document must appear to be issued and signed by an insurance company, underwriter or their agent/proxy, and cover at least 110% of CIF/CIP value when unspecified.",requiresVisualCheck:!0},{ruleId:"ISBP821-A35",standard:"ISBP 821",title:"Signatures, Stamps and Endorsements",description:"Required manual/facsimile signatures, stamps, or bill of lading endorsements must be visually verifiable when stipulated.",requiresVisualCheck:!0},{ruleId:"ISBP821-C3",standard:"ISBP 821",title:"Invoice Value & Trade Terms Consistency",description:"Incoterms and invoice line items/totals must match the credit terms without unpermitted charges."}].map(function(e){return e.ruleId});var c=[{endpointName:"du-ingest-parse",legacyEndpointName:"dugate-ingest-parse",pipelineName:"Ingest Parse",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"parse",maxFiles:10,description:"Parse digital documents (PDF, DOCX, XLSX, PPTX, TXT, CSV, HTML) into clean Markdown/text.",inputSchema:o("mode","parse",{language:{type:"string",default:"vi"},pages:{type:"string",description:'Page ranges, e.g. "1-5" or "all"'},outputFormat:{type:"string",enum:["md","text","json"],default:"md"}})},{endpointName:"du-ingest-ocr",legacyEndpointName:"dugate-ingest-ocr",pipelineName:"Ingest Ocr",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"ocr",maxFiles:10,description:"OCR scanned PDFs and images into Markdown and plain text.",inputSchema:o("mode","ocr",{language:{type:"string",default:"vi"},pages:{type:"string",description:'Page ranges, e.g. "1-5"'},outputFormat:{type:"string",enum:["md","text"],default:"md"}})},{endpointName:"du-ingest-digitize",legacyEndpointName:"dugate-ingest-digitize",pipelineName:"Ingest Digitize",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"digitize",maxFiles:5,description:"Digitize handwritten forms, checkboxes, and structured form fields.",inputSchema:o("mode","digitize",{language:{type:"string",default:"vi"},outputFormat:{type:"string",enum:["md","json"],default:"json"}})},{endpointName:"du-ingest-split",legacyEndpointName:"dugate-ingest-split",pipelineName:"Ingest Split",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"split",maxFiles:1,description:"Split a multi-page document by page ranges (up to 500 selected pages) into separate output artifacts.",inputSchema:o("mode","split",{pages:{type:"string",default:"1-2",description:'Comma-separated page ranges, e.g. "1-2,3-5"'}})},{endpointName:"du-extract-invoice",legacyEndpointName:"dugate-extract-invoice",pipelineName:"Extract Invoice",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"invoice",maxFiles:5,description:"Extract structured VAT/commercial invoice data (supplier, buyer, invoiceNumber, lineItems, totals).",inputSchema:o("type","invoice",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-contract",legacyEndpointName:"dugate-extract-contract",pipelineName:"Extract Contract",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"contract",maxFiles:5,description:"Extract parties, effectiveDate, value, obligations, and penaltyClauses from contracts.",inputSchema:o("type","contract",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-id-card",legacyEndpointName:"dugate-extract-id-card",pipelineName:"Extract Id Card",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"id-card",maxFiles:5,description:"Extract identity information (ID number, fullName, dateOfBirth, address, expiryDate) from CCCD/Passport.",inputSchema:o("type","id-card",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-receipt",legacyEndpointName:"dugate-extract-receipt",pipelineName:"Extract Receipt",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"receipt",maxFiles:5,description:"Extract merchant, receipt date, items, payment method, and total from receipts.",inputSchema:o("type","receipt",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-table",legacyEndpointName:"dugate-extract-table",pipelineName:"Extract Table",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"table",maxFiles:5,description:"Extract all tables from documents as structured JSON headers and rows.",inputSchema:o("type","table",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-custom",legacyEndpointName:"dugate-extract-custom",pipelineName:"Extract Custom",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"custom",maxFiles:5,description:"Extract custom entities matching a caller-supplied JSON Schema or field list.",inputSchema:o("type","custom",{fields:{type:"array",items:{type:"string"},description:"Field names when schema is omitted"},schema:{type:"object",description:"Target JSON Schema for structured output"},outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-analyze-classify",legacyEndpointName:"dugate-analyze-classify",pipelineName:"Analyze Classify",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"classify",maxFiles:5,description:"Classify documents into categories with 0-1 confidence scores.",inputSchema:o("task","classify",{categories:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-sentiment",legacyEndpointName:"dugate-analyze-sentiment",pipelineName:"Analyze Sentiment",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"sentiment",maxFiles:5,description:"Analyze sentiment polarity, confidence, and key phrases.",inputSchema:o("task","sentiment",{})},{endpointName:"du-analyze-compliance",legacyEndpointName:"dugate-analyze-compliance",pipelineName:"Analyze Compliance",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"compliance",maxFiles:5,description:"Check regulatory/policy compliance (PASS/FAIL/WARNING + violations).",inputSchema:o("task","compliance",{criteria:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-fact-check",legacyEndpointName:"dugate-analyze-fact-check",pipelineName:"Analyze Fact Check",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"fact-check",maxFiles:5,description:"Cross-check document facts against authoritative referenceData.",inputSchema:o("task","fact-check",{referenceData:{type:"object",description:"Expected key-value facts to verify against"}})},{endpointName:"du-analyze-quality",legacyEndpointName:"dugate-analyze-quality",pipelineName:"Analyze Quality",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"quality",maxFiles:5,description:"Score document completeness and writing quality from 0 to 100.",inputSchema:o("task","quality",{criteria:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-risk",legacyEndpointName:"dugate-analyze-risk",pipelineName:"Analyze Risk",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"risk",maxFiles:5,description:"Assess legal/financial contract risk level (LOW, MEDIUM, HIGH, CRITICAL) and risk factors.",inputSchema:o("task","risk",{focus:{type:"string"}})},{endpointName:"du-analyze-summarize-eval",legacyEndpointName:"dugate-analyze-summarize-eval",pipelineName:"Analyze Summarize Eval",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"summarize-eval",maxFiles:5,description:"Summarize document and evaluate author perspective, strengths, and gaps.",inputSchema:o("task","summarize-eval",{})},{endpointName:"du-transform-convert",legacyEndpointName:"dugate-transform-convert",pipelineName:"Transform Convert",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"convert",maxFiles:1,description:"Convert document content locally between Markdown, HTML, plain text, and JSON.",inputSchema:o("variant","convert",{outputFormat:{type:"string",enum:["md","html","text","json"],default:"md"}})},{endpointName:"du-transform-translate",legacyEndpointName:"dugate-transform-translate",pipelineName:"Transform Translate",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"translate",maxFiles:1,description:"Translate document into targetLanguage while preserving formatting.",inputSchema:o("variant","translate",{targetLanguage:{type:"string",default:"en"},tone:{type:"string",default:"professional"}})},{endpointName:"du-transform-rewrite",legacyEndpointName:"dugate-transform-rewrite",pipelineName:"Transform Rewrite",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"rewrite",maxFiles:1,description:"Rewrite document in academic, executive, simplified, or bullet_points style.",inputSchema:o("variant","rewrite",{style:{type:"string",enum:["academic","executive","simplified","bullet_points"],default:"executive"},tone:{type:"string"}})},{endpointName:"du-transform-redact",legacyEndpointName:"dugate-transform-redact",pipelineName:"Transform Redact",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"redact",maxFiles:1,description:"Mask PII (CCCD, PHONE_NUMBER, EMAIL, BANK_ACCOUNT, TAX_ID, or custom patterns) in text/documents.",inputSchema:o("variant","redact",{text:{type:"string"},redactPatterns:{type:"array",items:{type:"string"},default:["CCCD","PHONE_NUMBER","EMAIL"]},useAi:{type:"boolean",default:!1},outputFormat:{type:"string",enum:["text","md"],default:"text"}})},{endpointName:"du-transform-template",legacyEndpointName:"dugate-transform-template",pipelineName:"Transform Template",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"template",maxFiles:1,description:"Merge structured JSON variables into a {{placeholder}} document template.",inputSchema:o("variant","template",{templateText:{type:"string"},variables:{type:"object",description:"Key-value map merged into {{key}} placeholders"}})},{endpointName:"du-generate-summary",legacyEndpointName:"dugate-generate-summary",pipelineName:"Generate Summary",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"summary",maxFiles:5,description:"Generate a concise summary constrained by maxWords, format, and target audience.",inputSchema:o("task","summary",{format:{type:"string",enum:["paragraph","bullets","numbered","table","mind_map"],default:"bullets"},maxWords:{type:"integer",default:300},audience:{type:"string"}})},{endpointName:"du-generate-outline",legacyEndpointName:"dugate-generate-outline",pipelineName:"Generate Outline",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"outline",maxFiles:5,description:"Extract hierarchical H1/H2/H3 outline and section structure.",inputSchema:o("task","outline",{})},{endpointName:"du-generate-report",legacyEndpointName:"dugate-generate-report",pipelineName:"Generate Report",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"report",maxFiles:10,description:"Synthesize an executive analytical report across uploaded documents.",inputSchema:o("task","report",{focus:{type:"string"},language:{type:"string",default:"vi"}})},{endpointName:"du-generate-email",legacyEndpointName:"dugate-generate-email",pipelineName:"Generate Email",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"email",maxFiles:5,description:"Draft a professional email based on the uploaded documents.",inputSchema:o("task","email",{tone:{type:"string",default:"formal"},recipientRole:{type:"string"}})},{endpointName:"du-generate-minutes",legacyEndpointName:"dugate-generate-minutes",pipelineName:"Generate Minutes",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"minutes",maxFiles:5,description:"Generate structured meeting minutes with decisions, action items, and owners.",inputSchema:o("task","minutes",{format:{type:"string",enum:["md","json"],default:"json"}})},{endpointName:"du-generate-qa",legacyEndpointName:"dugate-generate-qa",pipelineName:"Generate Qa",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"qa",maxFiles:5,description:"Answer questions grounded in the document with verbatim evidence quotes and confidence.",inputSchema:o("task","qa",{questions:{type:"array",items:{type:"string"}}})},{endpointName:"du-compare-diff",legacyEndpointName:"dugate-compare-diff",pipelineName:"Compare Diff",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"diff",maxFiles:2,description:"Compute deterministic line-by-line lexical diff between source and target documents.",inputSchema:o("mode","diff",{outputFormat:{type:"string",enum:["unified","json"],default:"json"}})},{endpointName:"du-compare-semantic",legacyEndpointName:"dugate-compare-semantic",pipelineName:"Compare Semantic",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"semantic",maxFiles:2,description:"Compare two documents semantically and assess legal significance (NEGLIGIBLE, MODERATE, HIGH).",inputSchema:o("mode","semantic",{focus:{type:"string"}})},{endpointName:"du-compare-version",legacyEndpointName:"dugate-compare-version",pipelineName:"Compare Version",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"version",maxFiles:2,description:"Generate a structured version changelog between two document revisions.",inputSchema:o("mode","version",{})},{endpointName:"du-workflow-disbursement",legacyEndpointName:"dugate-workflow-disbursement",pipelineName:"Workflow Disbursement",businessId:"document-core",businessVersion:"2.0.0",action:"disbursement",maxFiles:20,description:"Credit disbursement appraisal: parallel classify & extract, optional HITL approval (WAITING_INPUT), cross-check against referenceData, and memo generation.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"disbursement-input-v1"},referenceData:{type:"array",items:{type:"object",properties:{key:{type:"string"},expected:{}}}},maxConcurrency:{type:"integer",default:4,minimum:1,maximum:8},requireApproval:{type:"boolean",default:!1},failurePolicy:{type:"string",enum:["fail-closed","continue"],default:"fail-closed"}}}},{endpointName:"du-workflow-doc-compare",legacyEndpointName:"dugate-workflow-doc-compare",pipelineName:"Workflow Doc Compare",businessId:"document-core",businessVersion:"2.0.0",action:"doc-compare",maxFiles:2,description:"Long-document deep comparison: section chunking, structureClaims & referenceClaims verification, optional HITL review.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"doc-compare-input-v1"},chunkSizeChars:{type:"integer",default:8e3,minimum:200,maximum:2e5},requireHumanReview:{type:"boolean",default:!1},focus:{type:"string"}}}},{endpointName:"du-workflow-schema",pipelineName:"Workflow Schema",businessId:"document-core",businessVersion:"2.0.0",action:"schema-workflow",maxFiles:10,description:"Execute a provisioned dynamic pipeline/DAG workflow by pipelineName or pipelineId.",inputSchema:{type:"object",properties:{pipelineName:{type:"string"},pipelineId:{type:"integer"},parameters:{type:"object"}}}},{endpointName:"du-lc-checker",legacyEndpointName:"dugate-workflow-lc-checker",pipelineName:"Workflow Lc Checker",businessId:"lc-checker",businessVersion:"1.2.0",action:"lc-checker",maxFiles:50,description:"5-step Trade Finance L/C examination (OCR -> Screen -> Visual -> Adjudicate UCP 600 / ISBP 821 -> Vietnamese Report) with mandatory rule citations and humanSignOffRequired.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"lc-checker-input-v1"},ruleSetVersion:{type:"string",default:"ucp600-isbp821-v1"},maxConcurrency:{type:"integer",default:4,minimum:1,maximum:8},failurePolicy:{type:"string",enum:["fail-closed","continue"],default:"fail-closed"}}}},{endpointName:"du-example-review",pipelineName:"Example Review",businessId:"example-review",businessVersion:"1.0.0",action:"review",maxFiles:10,description:"Multi-document compliance review (1..10 PDF/DOCX/XLSX/JSON files) with fan-out item review and optional HITL approval.",inputSchema:{type:"object",properties:{reviewId:{type:"string"},requireApproval:{type:"boolean",default:!1},useAi:{type:"boolean",default:!0},criteria:{type:"array",items:{type:"string"}}}}}]}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_document_understanding=self.webpackChunkplugin_document_understanding||[]).push([["867"],{742:function(e,t,n){n.r(t),n.d(t,{PluginSettings:function(){return eh},default:function(){return eb}});var r=n(155),a=n.n(r),l=n(59),o=n(650),i=n(375),c=n(694),u=n(832);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){m(l,r,a,o,i,"next",e)}function i(e){m(l,r,a,o,i,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var y=function(){var e=p(l.Form.useForm(),1)[0],t=(0,c.useFlowContext)().api,n=(0,o.k)(),s=p((0,r.useState)(!0),2),m=s[0],y=s[1],h=p((0,r.useState)(!1),2),b=h[0],g=h[1],E=p((0,r.useState)(!1),2),v=E[0],S=E[1],w=p((0,r.useState)(!1),2),I=w[0],k=w[1],O=p((0,r.useState)(),2),T=O[0],C=O[1],F=p((0,r.useState)([]),2),x=F[0],P=F[1],A=p((0,r.useState)(null),2),B=A[0],j=A[1],N=l.Form.useWatch("engineMode",e)||"builtin",R=l.Form.useWatch("llmService",e);if((0,r.useEffect)(function(){var n=!1;return d(function(){var r,a,l,o;return f(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,Promise.all([t.request({url:"docUnderstanding:getConfig"}),t.request({url:"docUnderstanding:listLlmServices"}).catch(function(){return null})])];case 1:if(a=(r=p.apply(void 0,[i.sent(),2]))[0],l=r[1],n)return[2];return e.setFieldsValue(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({engineMode:"builtin",publicGatewayEnabled:!0,maxFileSizeBytes:0xa00000,maxFilesPerRequest:20},(0,u.mT)(a,{}))),l&&P((0,u.mT)(l,[])),[3,4];case 2:return o=i.sent(),n||C((0,u.gJ)(o)),[3,4];case 3:return n||y(!1),[7];case 4:return[2]}})})(),function(){n=!0}},[t,e]),m)return a().createElement(l.Spin,{style:{marginTop:40}});var D=x.find(function(e){return e.llmService===R});return a().createElement(l.Form,{form:e,layout:"vertical",onFinish:function(e){return d(function(){var r;return f(this,function(a){switch(a.label){case 0:g(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:updateConfig",method:"POST",data:e})];case 2:return a.sent(),l.message.success(n("Configuration saved successfully")),[3,5];case 3:return r=a.sent(),l.message.error("".concat(n("Failed to save config"),": ").concat((0,u.gJ)(r))),[3,5];case 4:return g(!1),[7];case 5:return[2]}})})()},style:{maxWidth:760}},T&&a().createElement(l.Alert,{message:T,type:"error",showIcon:!0,style:{marginBottom:16}}),a().createElement(l.Alert,{message:n("Document Understanding Service & Public API Gateway"),description:a().createElement("div",null,a().createElement("div",null,n("Provides built-in Document Understanding APIs (/api/du/v1/* and /api/v1/*) compatible with du-rework, with optional delegation to an external gateway.")),a().createElement(l.Space,{style:{marginTop:8},wrap:!0},a().createElement(l.Tag,{color:"blue"},"POST /api/du/v1/uploads"),a().createElement(l.Tag,{color:"blue"},"POST /api/du/v1/businesses/:id/actions/:action"),a().createElement(l.Tag,{color:"blue"},"GET /api/du/v1/operations/:id"),a().createElement(l.Tag,{color:"blue"},"GET /api/du/v1/artifacts/:id/download"))),type:"info",showIcon:!0,style:{marginBottom:16}}),a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Button,{icon:a().createElement(i.CheckCircleOutlined,null),onClick:function(){return d(function(){var e,r;return f(this,function(a){switch(a.label){case 0:S(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:getHealth"})];case 2:return e=a.sent(),j((0,u.mT)(e,{})),l.message.success(n("Health check succeeded")),[3,5];case 3:return r=a.sent(),l.message.error("".concat(n("Health check failed"),": ").concat((0,u.gJ)(r))),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()},loading:v},n("Check Service Health")),a().createElement(l.Button,{icon:a().createElement(i.SyncOutlined,null),onClick:function(){return d(function(){var e,r,a,o,i;return f(this,function(c){switch(c.label){case 0:k(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:syncCatalog",method:"POST"})];case 2:return a=c.sent(),o=(0,u.mT)(a,{}),l.message.success("".concat(n("Catalog synchronized"),": ").concat(null!=(e=o.endpoints)?e:36," endpoints / ").concat(null!=(r=o.pipelines)?r:36," pipelines")),[3,5];case 3:return i=c.sent(),l.message.error((0,u.gJ)(i)),[3,5];case 4:return k(!1),[7];case 5:return[2]}})})()},loading:I},n("Sync du-rework Catalog (36 profiles)"))),B&&a().createElement(l.Card,{size:"small",style:{marginBottom:16},title:n("Runtime Health")},a().createElement("pre",{style:{margin:0,fontSize:12,overflow:"auto"}},JSON.stringify(B,null,2))),a().createElement(l.Card,{size:"small",title:n("Execution Engine & Gateway Policy"),style:{marginBottom:16}},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"engineMode",label:n("Execution Engine Mode"),initialValue:"builtin"},a().createElement(l.Select,{options:[{value:"builtin",label:n("Built-in NocoBase AI & Document Parser Engine")},{value:"hybrid",label:n("Hybrid (Built-in first, fallback to External Gateway)")},{value:"du_rework",label:n("External du-rework API Gateway")}]})),a().createElement(l.Form.Item,{name:"publicGatewayEnabled",label:n("Public API Gateway"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,{checkedChildren:n("Enabled"),unCheckedChildren:n("Disabled")}))),"du_rework"!==N&&a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"llmService",label:n("Reasoning LLM Service (@nocobase/plugin-ai)"),help:n("Leave blank to auto-select the first enabled LLM service")},a().createElement(l.Select,{allowClear:!0,placeholder:n("Auto-select active LLM service"),options:x.map(function(e){return{value:e.llmService,label:"".concat(e.llmServiceTitle||e.llmService," (").concat(e.provider,")")}})})),a().createElement(l.Form.Item,{name:"llmModel",label:n("Reasoning Model")},D?a().createElement(l.Select,{allowClear:!0,placeholder:n("Auto-select default model"),options:D.enabledModels}):a().createElement(l.Input,{placeholder:"gpt-4o / gemini-2.5-pro"})),a().createElement(l.Form.Item,{name:"visionLlmService",label:n("Vision / OCR LLM Service (Optional)")},a().createElement(l.Select,{allowClear:!0,placeholder:n("Same as Reasoning LLM Service"),options:x.map(function(e){return{value:e.llmService,label:"".concat(e.llmServiceTitle||e.llmService," (").concat(e.provider,")")}})})),a().createElement(l.Form.Item,{name:"visionLlmModel",label:n("Vision / OCR Model (Optional)")},a().createElement(l.Input,{placeholder:"gemini-2.5-flash / gpt-4o"}))),a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"maxFilesPerRequest",label:n("Max Files per Operation (DI-06)"),initialValue:20},a().createElement(l.InputNumber,{style:{width:"100%"},min:1,max:50})),a().createElement(l.Form.Item,{name:"maxFileSizeBytes",label:n("Max File Size (bytes)"),initialValue:0xa00000},a().createElement(l.InputNumber,{style:{width:"100%"},min:102400,step:1048576})))),a().createElement(l.Card,{size:"small",title:n("External Gateway & Webhook Connection"),style:{marginBottom:16}},a().createElement(l.Form.Item,{name:"baseUrl",label:n("Base URL"),rules:[{required:!0,message:n("Base URL is required")}],help:n("Used when delegating to an external du-rework gateway or custom REST endpoints")},a().createElement(l.Input,{prefix:a().createElement(i.LinkOutlined,null),placeholder:"http://du-orchestrator:3000"})),a().createElement(l.Form.Item,{name:"authType",label:n("Authentication Type"),initialValue:"none"},a().createElement(l.Select,{options:[{value:"none",label:n("None")},{value:"api_key",label:n("API Key (x-api-key)")},{value:"bearer",label:n("Bearer Token")},{value:"custom_header",label:n("Custom Header")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["authType"]},function(){var t=e.getFieldValue("authType");return t&&"none"!==t?a().createElement(a().Fragment,null,"custom_header"===t&&a().createElement(l.Form.Item,{name:"authHeaderName",label:n("Custom Header Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"x-api-key"})),a().createElement(l.Form.Item,{name:"authKey",label:"bearer"===t?n("Bearer Token"):n("API Key")},a().createElement(l.Input.Password,{placeholder:n("Leave blank to keep existing secret")}))):null}),a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"defaultTimeout",label:n("Request Timeout (ms)"),initialValue:3e4},a().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),a().createElement(l.Form.Item,{name:"defaultRetries",label:n("Default Retries"),initialValue:2},a().createElement(l.InputNumber,{style:{width:"100%"},min:0,max:10})),a().createElement(l.Form.Item,{name:"pollInterval",label:n("Poll Interval (ms)"),initialValue:5e3},a().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),a().createElement(l.Form.Item,{name:"pollTimeout",label:n("Poll Timeout (ms)"),initialValue:3e5},a().createElement(l.InputNumber,{style:{width:"100%"},min:5e3,step:5e3}))),a().createElement(l.Form.Item,{name:"webhookSecret",label:n("Webhook Secret"),help:n("Signs outbound x-du-signature callbacks and verifies incoming webhooks")},a().createElement(l.Input.Password,{placeholder:n("Optional: secret for HMAC-SHA256 webhook signature")}))),a().createElement(l.Form.Item,null,a().createElement(l.Button,{type:"primary",htmlType:"submit",icon:a().createElement(i.SaveOutlined,null),loading:b},n("Save Configuration"))))},h=n(585);function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){g(l,r,a,o,i,"next",e)}function i(e){g(l,r,a,o,i,"throw",e)}o(void 0)})}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var w=l.Input.TextArea,I={PENDING_INGESTION:"default",ACCEPTED:"cyan",QUEUED:"blue",RUNNING:"processing",WAITING_CHILDREN:"processing",WAITING_INPUT:"warning",RETRY_PENDING:"orange",CANCEL_REQUESTED:"orange",SUCCEEDED:"success",FAILED:"error",CANCELLED:"default",TIMED_OUT:"error"},k=function(){var e,t,n,s=(0,c.useFlowContext)().api,m=(0,o.k)(),d=v((0,r.useState)([]),2),p=d[0],f=d[1],y=v((0,r.useState)(null),2),b=y[0],g=y[1],k=v((0,r.useState)(!1),2),O=k[0],T=k[1],C=v((0,r.useState)(),2),F=C[0],x=C[1],P=v((0,r.useState)(),2),A=P[0],B=P[1],j=v((0,r.useState)(!1),2),N=j[0],R=j[1],D=v((0,r.useState)(!1),2),U=D[0],z=D[1],M=v(l.Form.useForm(),1)[0],J=v((0,r.useState)([]),2),V=J[0],q=J[1],_=v((0,r.useState)(!1),2),L=_[0],H=_[1],G=v((0,r.useState)(null),2),W=G[0],K=G[1],$=v((0,r.useState)(!1),2),Q=$[0],Y=$[1],X=v((0,r.useState)(!1),2),Z=X[0],ee=X[1],et=v(l.Form.useForm(),1)[0],en=l.Form.useWatch("businessId",M)||"document-core",er=l.Form.useWatch("action",M)||"extract",ea=(0,r.useCallback)(function(){return E(function(){var e,t,n,r;return S(this,function(a){switch(a.label){case 0:T(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),e={},F&&(e.state=F),A&&(e.businessId=A),[4,Promise.all([s.request({url:"docUnderstanding:listOperations",params:{filter:Object.keys(e).length>0?e:void 0}}),s.request({url:"docUnderstanding:getUsageSummary"}).catch(function(){return null})])];case 2:return n=(t=v.apply(void 0,[a.sent(),2]))[0],r=t[1],f((0,u.mT)(n,[])),r&&g((0,u.mT)(r,null)),[3,4];case 3:return T(!1),[7];case 4:return[2]}})})()},[s,F,A]);(0,r.useEffect)(function(){ea();var e=setInterval(ea,8e3);return function(){return clearInterval(e)}},[ea]);var el=function(e){return E(function(){var t,n;return S(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,s.request({url:"docUnderstanding:getOperation",params:{filterByTk:e}})];case 1:return t=r.sent(),K((0,u.mT)(t,null)),H(!0),[3,3];case 2:return n=r.sent(),l.message.error((0,u.gJ)(n)),[3,3];case 3:return[2]}})})()},eo=function(e){K(e),et.setFieldsValue({approved:!0,note:""}),Y(!0)},ei=Array.from(new Set(h.VQ.filter(function(e){return e.businessId===en}).map(function(e){return e.action}))),ec=h.VQ.filter(function(e){return e.businessId===en&&e.action===er&&e.discriminatorValue}),eu=[{title:m("Operation ID"),dataIndex:"id",width:150,render:function(e){return a().createElement("code",{style:{fontSize:11}},e.slice(0,12),"...")}},{title:m("Business / Action"),width:190,render:function(e,t){return a().createElement(l.Space,{size:4},a().createElement(l.Tag,{color:"geekblue"},t.businessId),a().createElement("span",null,t.action))}},{title:m("State"),dataIndex:"state",width:150,render:function(e){return a().createElement(l.Tag,{color:I[e]||"default"},e)}},{title:m("Progress"),width:130,render:function(e,t){var n,r;return a().createElement(l.Progress,{percent:null!=(n=null==(r=t.progress)?void 0:r.percent)?n:0,size:"small"})}},{title:m("Tokens / Cost"),width:150,render:function(e,t){return t.usage?a().createElement("span",{style:{fontSize:12}},t.usage.inputTokens+t.usage.outputTokens," tok ($",(t.usage.costMicrousd/1e6).toFixed(4),")"):"-"}},{title:m("Created"),dataIndex:"createdAt",width:165,render:function(e){return(0,u.r6)(e)}},{title:m("Action"),width:210,render:function(e,t){var n=["SUCCEEDED","FAILED","CANCELLED","TIMED_OUT"].includes(t.state);return a().createElement(l.Space,{size:4},a().createElement(l.Button,{size:"small",icon:a().createElement(i.EyeOutlined,null),onClick:function(){return el(t.id)},"aria-label":"".concat(m("View")," ").concat(t.id)},m("View")),"WAITING_INPUT"===t.state&&a().createElement(l.Button,{size:"small",type:"primary",icon:a().createElement(i.CheckOutlined,null),onClick:function(){return eo(t)},"aria-label":"".concat(m("Approve / Resume")," ").concat(t.id)},m("Resume")),!n&&a().createElement(l.Popconfirm,{title:m("Cancel this operation?"),onConfirm:function(){var e;return e=t.id,E(function(){var t;return S(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s.request({url:"docUnderstanding:cancelOperation",method:"POST",params:{filterByTk:e}})];case 1:return n.sent(),l.message.success(m("Operation cancellation requested")),ea(),(null==W?void 0:W.id)===e&&el(e),[3,3];case 2:return t=n.sent(),l.message.error((0,u.gJ)(t)),[3,3];case 3:return[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(m("Cancel")," ").concat(t.id)})))}}];return a().createElement("div",null,b&&a().createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16}},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Operations (30d)"),value:b.totalOperations})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Input Tokens"),value:b.inputTokens})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Output Tokens"),value:b.outputTokens})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Estimated Cost (USD)"),value:(b.costMicrousd/1e6).toFixed(4),prefix:"$"}))),a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlayCircleOutlined,null),onClick:function(){M.resetFields(),q([]),R(!0)}},m("Run Business Action")),a().createElement(l.Select,{allowClear:!0,placeholder:m("Filter by state"),"aria-label":m("Filter by state"),value:F,onChange:x,style:{width:180},options:h.Xm.map(function(e){return{value:e,label:e}})}),a().createElement(l.Select,{allowClear:!0,placeholder:m("Filter by business"),"aria-label":m("Filter by business"),value:A,onChange:B,style:{width:180},options:[{value:"document-core",label:"document-core"},{value:"lc-checker",label:"lc-checker"},{value:"example-review",label:"example-review"}]}),a().createElement(l.Button,{icon:a().createElement(i.ReloadOutlined,null),onClick:ea},m("Refresh"))),a().createElement(l.Table,{rowKey:"id",columns:eu,dataSource:p,loading:O,size:"small",pagination:{pageSize:15}}),a().createElement(l.Modal,{title:m("Run Document Understanding Action"),open:N,onOk:function(){return E(function(){var e,t,n,r,a,o,i,c,d,p,f,y,b,g,E;return S(this,function(v){switch(v.label){case 0:z(!0),v.label=1;case 1:return v.trys.push([1,4,5,6]),[4,M.validateFields()];case 2:r=(null==(e=(n=v.sent()).inputJson)?void 0:e.trim())?JSON.parse(n.inputJson):{},(null==(a=h.VQ.find(function(e){return e.businessId===n.businessId&&e.action===n.action&&(!n.variant||e.discriminatorValue===n.variant)}))?void 0:a.discriminatorField)&&n.variant&&(r[a.discriminatorField]=n.variant),(null==(t=n.pages)?void 0:t.trim())&&((0,h.vZ)(n.pages),r.pages=n.pages.trim()),(o=new FormData).append("businessId",n.businessId),o.append("action",n.action),o.append("input",JSON.stringify(r)),i=!0,c=!1,d=void 0;try{for(p=V[Symbol.iterator]();!(i=(f=p.next()).done);i=!0)(y=f.value).originFileObj&&o.append("files",y.originFileObj,y.name)}catch(e){c=!0,d=e}finally{try{i||null==p.return||p.return()}finally{if(c)throw d}}return[4,s.request({url:"docUnderstanding:submitOperation",method:"POST",data:o})];case 3:return b=v.sent(),g=(0,u.mT)(b,{}),l.message.success("".concat(m("Operation submitted"),": ").concat(g.operationId||"")),R(!1),q([]),ea(),g.operationId&&el(g.operationId),[3,6];case 4:return E=v.sent(),l.message.error((0,u.gJ)(E)),[3,6];case 5:return z(!1),[7];case 6:return[2]}})})()},onCancel:function(){return R(!1)},confirmLoading:U,okText:m("Submit Operation"),cancelText:m("Cancel"),width:640,destroyOnClose:!0},a().createElement(l.Form,{form:M,layout:"vertical",initialValues:{businessId:"document-core",action:"extract",variant:"invoice",inputJson:"{}"}},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"businessId",label:m("Business"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{value:"document-core",label:"document-core (v2.0.0)"},{value:"lc-checker",label:"lc-checker (v1.2.0)"},{value:"example-review",label:"example-review (v1.0.0)"}]})),a().createElement(l.Form.Item,{name:"action",label:m("Action"),rules:[{required:!0}]},a().createElement(l.Select,{options:ei.map(function(e){return{value:e,label:e}})}))),ec.length>0&&a().createElement(l.Form.Item,{name:"variant",label:m("Variant / Mode")},a().createElement(l.Select,{options:ec.map(function(e){return{value:e.discriminatorValue,label:"".concat(e.discriminatorValue," — ").concat(e.description)}})})),a().createElement(l.Form.Item,{label:m("Upload Input Documents")},a().createElement(l.Upload,{multiple:!0,beforeUpload:function(){return!1},fileList:V,onChange:function(e){return q(e.fileList)}},a().createElement(l.Button,{icon:a().createElement(i.UploadOutlined,null)},m("Select Files")))),a().createElement(l.Form.Item,{name:"pages",label:m("Page Selection (DI-06)"),help:m('Optional page ranges, e.g. "1-2, 5" (leave blank for all pages)')},a().createElement(l.Input,{placeholder:"1-2"})),a().createElement(l.Form.Item,{name:"inputJson",label:m("Input JSON")},a().createElement(w,{rows:4,style:{fontFamily:"monospace",fontSize:12}})))),a().createElement(l.Modal,{title:"".concat(m("Human-in-the-Loop Approval")," — ").concat((null==W?void 0:W.id.slice(0,12))||""),open:Q,onOk:function(){return E(function(){var e,t,n;return S(this,function(r){switch(r.label){case 0:if(!W)return[2];ee(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,et.validateFields()];case 2:return t=r.sent(),[4,s.request({url:"docUnderstanding:resumeOperation",method:"POST",params:{filterByTk:W.id},data:{waitId:null==(e=W.wait)?void 0:e.waitId,expectedStateVersion:W.stateVersion,input:t}})];case 3:return r.sent(),l.message.success(m("Operation resumed")),Y(!1),ea(),el(W.id),[3,6];case 4:return n=r.sent(),l.message.error((0,u.gJ)(n)),[3,6];case 5:return ee(!1),[7];case 6:return[2]}})})()},onCancel:function(){return Y(!1)},confirmLoading:Z,okText:m("Submit Decision"),cancelText:m("Cancel"),destroyOnClose:!0},(null==W||null==(e=W.wait)?void 0:e.prompt)&&a().createElement(l.Alert,{message:W.wait.prompt,type:"warning",showIcon:!0,style:{marginBottom:16}}),(null==W||null==(t=W.wait)?void 0:t.previewData)!==void 0&&a().createElement("pre",{style:{background:"#fafafa",padding:10,borderRadius:6,maxHeight:200,overflow:"auto",fontSize:11,marginBottom:16}},JSON.stringify(W.wait.previewData,null,2)),a().createElement(l.Form,{form:et,layout:"vertical",initialValues:{approved:!0}},a().createElement(l.Form.Item,{name:"approved",label:m("Approve & Proceed"),valuePropName:"checked"},a().createElement(l.Switch,{checkedChildren:m("Approve"),unCheckedChildren:m("Reject")})),a().createElement(l.Form.Item,{name:"note",label:m("Reviewer Note")},a().createElement(w,{rows:3,placeholder:m("Enter verification note...")})))),a().createElement(l.Drawer,{title:W?"".concat(m("Operation")," ").concat(W.id):m("Operation Details"),width:680,open:L,onClose:function(){return H(!1)}},W&&a().createElement("div",null,a().createElement(l.Space,{wrap:!0,style:{marginBottom:16}},a().createElement(l.Tag,{color:I[W.state]||"default"},W.state),a().createElement(l.Tag,{color:"geekblue"},W.businessId,"@",W.businessVersion," / ",W.action),a().createElement("span",null,"v",W.stateVersion),"WAITING_INPUT"===W.state&&a().createElement(l.Button,{size:"small",type:"primary",onClick:function(){return eo(W)}},m("Approve / Resume"))),(null==(n=W.outputPayload)?void 0:n.humanSignOffRequired)===!0&&a().createElement(l.Alert,{type:"warning",showIcon:!0,message:m("Human Sign-off Required (Trade Finance L/C Policy)"),description:m("Automated UCP 600 / ISBP 821 findings require an authorized specialist signature."),style:{marginBottom:16}}),W.error&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:"".concat(W.error.code,": ").concat(W.error.title),description:W.error.detail,style:{marginBottom:16}}),W.usage&&a().createElement(a().Fragment,null,a().createElement("h4",null,m("Token & Cost Usage")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:12}},JSON.stringify(W.usage,null,2))),W.documentInputCoverage&&a().createElement(a().Fragment,null,a().createElement("h4",null,m("Document Input Coverage (DI-06)")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:11,maxHeight:160,overflow:"auto"}},JSON.stringify(W.documentInputCoverage,null,2))),a().createElement("h4",null,m("Output Payload")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:360,overflow:"auto"}},W.outputPayload?JSON.stringify(W.outputPayload,null,2):m("(not yet available)")))))};function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){T(l,r,a,o,i,"next",e)}function i(e){T(l,r,a,o,i,"throw",e)}o(void 0)})}}function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var P=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=F((0,r.useState)([]),2),s=n[0],m=n[1],d=F((0,r.useState)(!1),2),p=d[0],f=d[1],y=F((0,r.useState)(!1),2),h=y[0],b=y[1],g=F((0,r.useState)(!1),2),E=g[0],v=g[1],S=F((0,r.useState)(null),2),w=S[0],I=S[1],k=F(l.Form.useForm(),1)[0],O=(0,r.useCallback)(function(){return C(function(){var t;return x(this,function(n){switch(n.label){case 0:f(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,e.request({url:"docUnderstanding:listApiKeys"})];case 2:return t=n.sent(),m((0,u.mT)(t,[])),[3,4];case 3:return f(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){O()},[O]);var T=[{title:t("Name"),dataIndex:"name",width:180},{title:t("Key Prefix"),dataIndex:"keyPrefix",width:160,render:function(e){return a().createElement("code",null,e,"...")}},{title:t("Tenant"),dataIndex:"tenantId",width:120,render:function(e){return a().createElement(l.Tag,null,e)}},{title:t("Allowed Businesses"),dataIndex:"allowedBusinesses",width:220,render:function(e){return(e||["*"]).map(function(e){return a().createElement(l.Tag,{key:e},e)})}},{title:t("Status"),dataIndex:"status",width:100,render:function(e){return a().createElement(l.Tag,{color:"active"===e?"success":"error"},e)}},{title:t("Last Used"),dataIndex:"lastUsedAt",width:165,render:function(e){return(0,u.r6)(e)}},{title:t("Action"),width:110,render:function(n,r){return"active"===r.status?a().createElement(l.Popconfirm,{title:t("Revoke this API key?"),onConfirm:function(){var n;return n=r.id,C(function(){return x(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:revokeApiKey",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("API key revoked")),O(),[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(t("Revoke")," ").concat(r.name)},t("Revoke"))):null}}];return a().createElement("div",null,a().createElement(l.Alert,{type:"info",showIcon:!0,icon:a().createElement(i.KeyOutlined,null),message:t("Gateway API Keys (x-api-key)"),description:t("External integrations pass x-api-key to call /api/du/v1/* or /api/v1/{uploads,businesses,operations,artifacts,usage}. Keys are stored as one-way SHA-256 hashes and isolated by Tenant ID."),style:{marginBottom:16}}),w&&a().createElement(l.Alert,{type:"success",showIcon:!0,closable:!0,onClose:function(){return I(null)},message:t("Copy your new x-api-key now — it will never be shown again"),description:a().createElement(l.Typography.Paragraph,{copyable:!0,style:{margin:"8px 0 0",fontFamily:"monospace"}},w.rawKey),style:{marginBottom:16}}),a().createElement(l.Space,{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){k.resetFields(),b(!0)}},t("Issue API Key"))),a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:p,size:"small"}),a().createElement(l.Modal,{title:t("Issue Gateway API Key"),open:h,onOk:function(){return C(function(){var n,r,a,o,i;return x(this,function(c){switch(c.label){case 0:v(!0),c.label=1;case 1:return c.trys.push([1,4,5,6]),[4,k.validateFields()];case 2:return a=c.sent(),[4,e.request({url:"docUnderstanding:issueApiKey",method:"POST",data:{name:a.name,tenantId:a.tenantId||"default",allowedBusinesses:(null==(n=a.allowedBusinesses)?void 0:n.length)?a.allowedBusinesses:["*"],allowedActions:(null==(r=a.allowedActions)?void 0:r.length)?a.allowedActions:["*"]}})];case 3:return o=c.sent(),I((0,u.mT)(o,null)),b(!1),O(),l.message.success(t("API key issued")),[3,6];case 4:return i=c.sent(),l.message.error((0,u.gJ)(i)),[3,6];case 5:return v(!1),[7];case 6:return[2]}})})()},onCancel:function(){return b(!1)},confirmLoading:E,okText:t("Issue Key"),cancelText:t("Cancel"),destroyOnClose:!0},a().createElement(l.Form,{form:k,layout:"vertical",initialValues:{tenantId:"default",allowedBusinesses:["*"]}},a().createElement(l.Form.Item,{name:"name",label:t("Key Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"ERP Invoice Integration"})),a().createElement(l.Form.Item,{name:"tenantId",label:t("Tenant ID"),help:t("Operations and artifacts are isolated per Tenant ID (cross-tenant lookups return 404)")},a().createElement(l.Input,{placeholder:"default"})),a().createElement(l.Form.Item,{name:"allowedBusinesses",label:t("Allowed Businesses")},a().createElement(l.Select,{mode:"multiple",options:[{value:"*",label:t("All Businesses (*)")},{value:"document-core",label:"document-core"},{value:"lc-checker",label:"lc-checker"},{value:"example-review",label:"example-review"}]})))))};function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function B(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){B(l,r,a,o,i,"next",e)}function i(e){B(l,r,a,o,i,"throw",e)}o(void 0)})}}function N(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||D(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||D(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e,t){if(e){if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}}function U(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var z=l.Input.TextArea,M=function(e){var t=e.value,n=e.onChange,c=(0,o.k)(),u=N((0,r.useState)([]),2),s=u[0],m=u[1],d=(0,r.useRef)(),p=JSON.stringify(null!=t?t:{});(0,r.useEffect)(function(){d.current!==p&&(d.current=p,m(Object.entries(JSON.parse(p)).map(function(e,t){var n=N(e,2),r=n[0],a=n[1];return{id:"".concat(r,"_").concat(t),key:r,value:String(null!=a?a:"")}})))},[p]);var f=function(e){m(e);var t=e.reduce(function(e,t){var n=t.key.trim();return n&&(e[n]=t.value),e},{});d.current=JSON.stringify(t),null==n||n(t)},y=function(e,t,n){var r,a,l=R(s);l[e]=(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},l[e]),a=a={key:t,value:n},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(a)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(a,e))}),r),f(l)},h=function(e){f(s.filter(function(t,n){return n!==e}))};return a().createElement("div",null,s.map(function(e,t){return a().createElement(l.Space,{key:e.id,style:{display:"flex",marginBottom:4}},a().createElement(l.Input,{placeholder:c("Header name"),"aria-label":c("Header name"),value:e.key,onChange:function(n){return y(t,n.target.value,e.value)},style:{width:180}}),a().createElement(l.Input,{placeholder:c("Value"),"aria-label":c("Value"),value:e.value,onChange:function(n){return y(t,e.key,n.target.value)},style:{width:220}}),a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),onClick:function(){return h(t)},"aria-label":"".concat(c("Delete")," ").concat(e.key||c("Header name"))}))}),a().createElement(l.Button,{size:"small",type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:function(){return m(R(s).concat([{id:"new_".concat(Date.now(),"_").concat(Math.random()),key:"",value:""}]))}},c("Add Header")))},J=function(e){var t=e.value,n=e.onChange,l=e.placeholder,i=(0,o.k)(),c=N((0,r.useState)(""),2),u=c[0],s=c[1],m=N((0,r.useState)(""),2),d=m[0],p=m[1];return(0,r.useEffect)(function(){if(!t)return void s("");try{s("string"==typeof t?JSON.stringify(JSON.parse(t),null,2):JSON.stringify(t,null,2))}catch(e){s("string"==typeof t?t:"")}},[t]),a().createElement("div",null,a().createElement(z,{rows:6,value:u,onChange:function(e){return s(e.target.value)},onBlur:function(){if(!u.trim()){p(""),null==n||n(null);return}try{var e=JSON.parse(u);p(""),null==n||n(e)}catch(e){p(i("Invalid JSON"))}},placeholder:l||"{}",status:d?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),d&&a().createElement("div",{role:"alert",style:{color:"#ff4d4f",fontSize:12}},d))},V=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=N((0,r.useState)([]),2),s=n[0],m=n[1],d=N((0,r.useState)(!1),2),p=d[0],f=d[1],y=N((0,r.useState)(!1),2),h=y[0],b=y[1],g=N(l.Form.useForm(),1)[0],E=N((0,r.useState)(null),2),v=E[0],S=E[1],w={sync:t("Synchronous"),polling:t("Polling"),webhook:t("Webhook")},I={multipart:t("Multipart Upload"),base64:t("Base64 in JSON")},k=(0,r.useCallback)(function(){return j(function(){var t;return U(this,function(n){switch(n.label){case 0:f(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,e.request({url:"docUnderstanding:listEndpoints"})];case 2:return t=n.sent(),m((0,u.mT)(t,[])),[3,4];case 3:return f(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){k()},[k]);var O=function(e){S(e.id),g.setFieldsValue(e),b(!0)},T=[{title:t("Name"),dataIndex:"name",width:170},{title:t("Protocol"),dataIndex:"protocolMode",width:130,render:function(e){return"builtin_du"===e?a().createElement(l.Tag,{color:"geekblue"},"du-rework (Built-in)"):"du_rework_v1"===e?a().createElement(l.Tag,{color:"blue"},"du-rework (Remote)"):a().createElement(l.Tag,null,t("Custom REST"))}},{title:t("Subpath"),dataIndex:"subpath",width:220},{title:t("Method"),dataIndex:"method",width:80,render:function(e){return a().createElement(l.Tag,null,e)}},{title:t("Execution"),dataIndex:"executionMode",width:130,render:function(e){return a().createElement(l.Tag,{color:{sync:"green",polling:"blue",webhook:"purple"}[e]},w[e]||e)}},{title:t("File"),dataIndex:"fileInputMode",width:130,render:function(e){return"none"===e?"-":I[e]||e}},{title:t("Enabled"),dataIndex:"enabled",width:70,render:function(e){return e?a().createElement(l.Tag,{color:"success"},t("Yes")):a().createElement(l.Tag,null,t("No"))}},{title:t("Action"),width:120,render:function(n,r){return a().createElement(l.Space,null,a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.EditOutlined,null),onClick:function(){return O(r)},"aria-label":"".concat(t("Edit")," ").concat(r.name)},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this endpoint?"),okText:t("Delete"),onConfirm:function(){var n;return n=r.id,j(function(){return U(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:deleteEndpoint",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("Deleted")),k(),[2]}})})()}},a().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":"".concat(t("Delete")," ").concat(r.name)},t("Delete"))))}}];return a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){S(null),g.resetFields(),b(!0)}},t("Add Endpoint"))),a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:p,size:"small"}),a().createElement(l.Modal,{title:v?t("Edit Endpoint"):t("Add Endpoint"),open:h,onOk:function(){return j(function(){var n;return U(this,function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),[4,g.validateFields()];case 1:if((n=r.sent()).customHeaders=Object.entries(n.customHeaders||{}).reduce(function(e,t){var n=N(t,2),r=n[0],a=n[1],l=r.trim();return l&&(e[l]=a),e},{}),!v)return[3,3];return[4,e.request({url:"docUnderstanding:updateEndpoint",method:"POST",params:{filterByTk:v},data:n})];case 2:return r.sent(),[3,5];case 3:return[4,e.request({url:"docUnderstanding:createEndpoint",method:"POST",data:n})];case 4:r.sent(),r.label=5;case 5:return l.message.success(t("Saved")),b(!1),k(),[3,7];case 6:return r.sent(),[3,7];case 7:return[2]}})})()},onCancel:function(){return b(!1)},okText:t("Save"),cancelText:t("Cancel"),width:680,destroyOnClose:!0},a().createElement(l.Form,{form:g,layout:"vertical",preserve:!1},a().createElement(l.Tabs,{size:"small",items:[{key:"basic",label:t("Basic"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"name",label:t("Unique Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"ocr, classify, extract..."})),a().createElement(l.Form.Item,{name:"subpath",label:t("Subpath"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"/api/v1/ocr"})),a().createElement(l.Form.Item,{name:"description",label:t("Description")},a().createElement(z,{rows:2,placeholder:t("What this endpoint does")})),a().createElement(l.Space,{size:"large"},a().createElement(l.Form.Item,{name:"method",label:t("HTTP Method"),initialValue:"POST"},a().createElement(l.Select,{style:{width:120},options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"}]})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,null))))},{key:"file",label:t("File Input"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"fileInputMode",label:t("File Input Mode"),initialValue:"none"},a().createElement(l.Select,{style:{width:200},options:[{value:"none",label:t("None")},{value:"multipart",label:t("Multipart Upload")},{value:"base64",label:t("Base64 in JSON")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["fileInputMode"]},function(){return"none"!==g.getFieldValue("fileInputMode")?a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"fileFieldName",label:t("File Field Name"),initialValue:"file"},a().createElement(l.Input,{placeholder:"file",style:{width:200}})),a().createElement(l.Form.Item,{name:"maxFiles",label:t("Max Files"),initialValue:1},a().createElement(l.InputNumber,{min:1,max:20,style:{width:120}}))):null}))},{key:"gateway",label:t("Gateway / Discriminator"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"protocolMode",label:t("Protocol Mode"),initialValue:"legacy_rest"},a().createElement(l.Select,{style:{width:280},options:[{value:"builtin_du",label:t("Canonical du-rework (Built-in / Hybrid)")},{value:"du_rework_v1",label:t("Canonical du-rework (External Gateway)")},{value:"legacy_rest",label:t("Legacy / Generic HTTP REST")}]})),a().createElement(l.Space,{size:"middle"},a().createElement(l.Form.Item,{name:"businessId",label:t("Business ID")},a().createElement(l.Input,{placeholder:"document-core",style:{width:180}})),a().createElement(l.Form.Item,{name:"actionName",label:t("Action Name")},a().createElement(l.Input,{placeholder:"extract",style:{width:180}}))),a().createElement(l.Form.Item,{name:"discriminatorField",label:t("Discriminator Field"),help:t("Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.")},a().createElement(l.Input,{placeholder:"mode",style:{width:200}})),a().createElement(l.Form.Item,{name:"discriminatorValue",label:t("Discriminator Value"),help:t("Value sent in the discriminator field (e.g. parse, invoice, disbursement).")},a().createElement(l.Input,{placeholder:"parse",style:{width:200}})),a().createElement(l.Form.Item,{name:"syncQueryParam",label:t("Sync Query Param"),help:t("When set, the request appends ?<param>=true to ask for a synchronous response (e.g. sync).")},a().createElement(l.Input,{placeholder:"sync",style:{width:200}})),a().createElement(l.Form.Item,{name:"taskIdExtractPath",label:t("Task ID Extract Path"),help:t("JSON path of the async task id in the 202 response (e.g. name). Used when the response is 202 even in sync mode.")},a().createElement(l.Input,{placeholder:"name",style:{width:200}})),a().createElement(l.Form.Item,{name:"taskIdExtractRegex",label:t("Task ID Extract Regex"),help:t("Regex with one capture group to pull the task id from the extracted path value (e.g. operations/([^/]+)).")},a().createElement(l.Input,{placeholder:"operations/([^/]+)",style:{width:240}})))},{key:"async",label:t("Async Config"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"executionMode",label:t("Execution Mode"),initialValue:"sync"},a().createElement(l.Select,{style:{width:200},options:[{value:"sync",label:t("Synchronous")},{value:"polling",label:t("Polling")},{value:"webhook",label:t("Webhook")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["executionMode"]},function(){var e=g.getFieldValue("executionMode");return"sync"===e?null:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"pollTaskIdField",label:t("Task ID Field"),help:t("Field in response containing the async task ID"),initialValue:"task_id"},a().createElement(l.Input,{placeholder:"task_id"})),"polling"===e&&a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"pollResultSubpath",label:t("Poll Result Subpath"),help:t("URL to poll for result. Use {taskId} as placeholder."),rules:[{required:!0,message:t("Required for polling mode")}]},a().createElement(l.Input,{placeholder:"/api/v1/tasks/{taskId}/result"})),a().createElement(l.Form.Item,{name:"pollResultField",label:t("Result Field"),help:t("Field in poll response containing the actual result")},a().createElement(l.Input,{placeholder:"result"})),a().createElement(l.Form.Item,{name:"pollStatusField",label:t("Status Field (optional)"),help:t("Field to check completion status. If empty, any non-null result = complete.")},a().createElement(l.Input,{placeholder:"status"})),a().createElement(l.Form.Item,{name:"pollCompletedValue",label:t("Completed Value"),help:t("Value of status field that means 'done'"),initialValue:"completed"},a().createElement(l.Input,{placeholder:"completed"})),a().createElement(l.Space,{size:"large"},a().createElement(l.Form.Item,{name:"pollInterval",label:t("Poll Interval (ms)"),help:t("Override default")},a().createElement(l.InputNumber,{min:1e3,step:1e3,placeholder:"5000",style:{width:150}})),a().createElement(l.Form.Item,{name:"pollTimeout",label:t("Poll Timeout (ms)"),help:t("Override default")},a().createElement(l.InputNumber,{min:5e3,step:5e3,placeholder:"300000",style:{width:150}})))))}))},{key:"schema",label:t("Schema"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"requestBodySchema",label:t("Request Body Schema (JSON Schema)")},a().createElement(J,{placeholder:'{ "type": "object", "properties": { ... } }'})),a().createElement(l.Form.Item,{name:"responseSchema",label:t("Response Schema (JSON Schema)")},a().createElement(J,{placeholder:'{ "type": "object", "properties": { ... } }'})))},{key:"headers",label:t("Custom Headers"),children:a().createElement(l.Form.Item,{name:"customHeaders",label:t("Additional Headers")},a().createElement(M,null))}]}))))};function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function L(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){_(l,r,a,o,i,"next",e)}function i(e){_(l,r,a,o,i,"throw",e)}o(void 0)})}}function H(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){H(e,t,n[t])})}return e}function W(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function K(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||Q(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Q(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){if(e){if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return q(e,t)}}function Y(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var X=l.Input.TextArea,Z=l.Collapse.Panel,ee={pending:"default",running:"processing",polling:"processing",completed:"success",failed:"error",timeout:"error"},et=["completed","failed","timeout"],en=function(e){return!!e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&!Array.isArray(e)},er=function(e){return JSON.stringify(null!=e?e:{},null,2)},ea=function(e){return en(e)?Object.prototype.hasOwnProperty.call(e,"default")?e.default:"object"===e.type||e.properties?Object.entries(e.properties||{}).reduce(function(e,t){var n=K(t,2),r=n[0],a=ea(n[1]);return void 0!==a&&(e[r]=a),e},{}):"array"===e.type?[]:void 0:{}},el=function(e,t){return en(e)&&en(t)?Object.entries(e).reduce(function(e,t){var n=K(t,2),r=n[0],a=n[1];return W(G({},e),H({},r,el(a,e[r])))},G({},t)):void 0===t?e:t},eo=function(e){var t=e.value,n=e.onChange,l=e.placeholder,i=e.rows,c=(0,o.k)(),u=K((0,r.useState)(""),2),s=u[0],m=u[1],d=K((0,r.useState)(""),2),p=d[0],f=d[1];return(0,r.useEffect)(function(){if(!t)return void m("");try{m("string"==typeof t?JSON.stringify(JSON.parse(t),null,2):JSON.stringify(t,null,2))}catch(e){m("string"==typeof t?t:"")}},[t]),a().createElement("div",null,a().createElement(X,{rows:void 0===i?5:i,value:s,onChange:function(e){return m(e.target.value)},onBlur:function(){if(!s.trim()){f(""),null==n||n(null);return}try{var e=JSON.parse(s);f(""),null==n||n(e)}catch(e){f(c("Invalid JSON"))}},placeholder:l||"{}",status:p?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),p&&a().createElement("div",{role:"alert",style:{color:"#ff4d4f",fontSize:12}},p))},ei=function(e){var t=e.steps,n=e.endpoints,r=e.onChange,c=(0,o.k)(),u=function(e,n){var a,l=$(t),o=e+n;o<0||o>=l.length||(a=[l[o],l[e]],l[e]=a[0],l[o]=a[1],l.forEach(function(e,t){return e.stepOrder=t+1}),r(l))},s=function(e,n,a){var l=$(t);l[e]=W(G({},l[e]),H({},n,a)),r(l)},m=function(e){var n=t.filter(function(t,n){return n!==e});n.forEach(function(e,t){return e.stepOrder=t+1}),r(n)},d=function(){var e;r($(t).concat([(e=t.length+1,{_key:"new_".concat(Date.now(),"_").concat(Math.random()),stepOrder:e,name:"",endpointId:null,inputMapping:null,outputAlias:"",condition:null,onError:"fail",retryCount:0})]))};return 0===t.length?a().createElement("div",{style:{textAlign:"center",padding:"20px 0"}},a().createElement(l.Empty,{description:c("No steps yet"),imageStyle:{height:40}}),a().createElement(l.Button,{type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:d,style:{marginTop:8}},c("Add First Step"))):a().createElement("div",null,a().createElement(l.Collapse,{size:"small",defaultActiveKey:t.map(function(e){return e._key})},t.map(function(e,r){var o=n.find(function(t){return t.id===e.endpointId}),d=a().createElement(l.Space,{size:4,onClick:function(e){return e.stopPropagation()}},a().createElement(l.Button,{size:"small",disabled:0===r,icon:a().createElement(i.ArrowUpOutlined,null),onClick:function(){return u(r,-1)},"aria-label":c("Move step up")}),a().createElement(l.Button,{size:"small",disabled:r===t.length-1,icon:a().createElement(i.ArrowDownOutlined,null),onClick:function(){return u(r,1)},"aria-label":c("Move step down")}),a().createElement(l.Popconfirm,{title:c("Remove step?"),okText:c("Delete"),onConfirm:function(){return m(r)}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":c("Remove step?")}))),p=a().createElement(l.Space,null,a().createElement(l.Badge,{count:e.stepOrder,style:{backgroundColor:"#1677ff"}}),a().createElement("span",null,e.name||c("(unnamed)")),o&&a().createElement(l.Tag,null,o.name),"skip"===e.onError&&a().createElement(l.Tooltip,{title:c("Step can be skipped on error")},a().createElement(l.Tag,{color:"orange"},c("skip on error"))),e.condition&&a().createElement(l.Tooltip,{title:c("Has condition")},a().createElement(l.Tag,{color:"purple"},c("conditional")))),f="step-name-".concat(e._key),y="step-endpoint-".concat(e._key),h="step-alias-".concat(e._key);return a().createElement(Z,{key:e._key,header:p,extra:d},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement("div",null,a().createElement("label",{htmlFor:f,style:{fontWeight:500,display:"block",marginBottom:4}},c("Step Name")," *"),a().createElement(l.Input,{id:f,value:e.name,onChange:function(e){return s(r,"name",e.target.value)},placeholder:"OCR, Classify, Extract..."})),a().createElement("div",null,a().createElement("label",{htmlFor:y,style:{fontWeight:500,display:"block",marginBottom:4}},c("Endpoint")," *"),a().createElement(l.Select,{id:y,value:e.endpointId,onChange:function(e){return s(r,"endpointId",e)},placeholder:c("Select endpoint"),style:{width:"100%"},options:n.map(function(e){return{value:e.id,label:"".concat(e.name," (").concat(e.method," ").concat(e.subpath,")")}})})),a().createElement("div",null,a().createElement("label",{htmlFor:h,style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},c("Output Alias")),a().createElement(l.Input,{id:h,value:e.outputAlias,onChange:function(e){return s(r,"outputAlias",e.target.value)},placeholder:"ocr_result"}),a().createElement("div",{style:{color:"#888",fontSize:11}},c("Other steps reference this as"),": $step[",e.outputAlias||e.stepOrder,"].response.field")),a().createElement("div",null,a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},c("On Error")),a().createElement(l.Space,null,a().createElement(l.Select,{value:e.onError,onChange:function(e){return s(r,"onError",e)},style:{width:120},"aria-label":c("On Error"),options:[{value:"fail",label:c("Fail")},{value:"skip",label:c("Skip")},{value:"retry",label:c("Retry")}]}),"retry"===e.onError&&a().createElement(l.InputNumber,{value:e.retryCount,onChange:function(e){return s(r,"retryCount",e||0)},min:1,max:10,addonBefore:"x",style:{width:100},"aria-label":c("Retry")})))),a().createElement("div",{style:{marginTop:12}},a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},c("Input Mapping (JSON)"),a().createElement(l.Tooltip,{title:c("Map endpoint input fields. Use $input.field, $step[alias].response.field, $files, or literal values.")},a().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),a().createElement(eo,{value:e.inputMapping,onChange:function(e){return s(r,"inputMapping",e)},placeholder:'{ "text": "$step[ocr_result].response.text", "lang": "vi" }',rows:3})),a().createElement("div",{style:{marginTop:12}},a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},c("Condition (optional JSON)"),a().createElement(l.Tooltip,{title:c("Only run this step if the condition matches.")},a().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),a().createElement(eo,{value:e.condition,onChange:function(e){return s(r,"condition",e)},placeholder:'{ "field": "$step[classify].response.type", "op": "eq", "value": "invoice" }',rows:2})))})),a().createElement(l.Button,{type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:d,style:{marginTop:8,width:"100%"}},c("Add Step")))},ec=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=K((0,r.useState)([]),2),s=n[0],m=n[1],d=K((0,r.useState)([]),2),p=d[0],f=d[1],y=K((0,r.useState)(!1),2),h=y[0],b=y[1],g=K((0,r.useState)(!1),2),E=g[0],v=g[1],S=K(l.Form.useForm(),1)[0],w=K((0,r.useState)(null),2),I=w[0],k=w[1],O=K((0,r.useState)([]),2),T=O[0],C=O[1],F=K((0,r.useState)(!1),2),x=F[0],P=F[1],A=K((0,r.useState)(null),2),B=A[0],j=A[1],N=K((0,r.useState)("{}"),2),R=N[0],D=N[1],U=K((0,r.useState)(""),2),z=U[0],M=U[1],J=K((0,r.useState)(null),2),V=J[0],q=J[1],_=K((0,r.useState)(!1),2),H=_[0],Q=_[1],en=(0,r.useRef)(null),ec={pending:t("Pending"),running:t("Running"),polling:t("Polling"),completed:t("Completed"),failed:t("Failed"),timeout:t("Timeout")},eu=(0,r.useCallback)(function(){return L(function(){var t,n,r;return Y(this,function(a){switch(a.label){case 0:b(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all([e.request({url:"docUnderstanding:listPipelines"}),e.request({url:"docUnderstanding:listEndpoints"})])];case 2:return n=(t=K.apply(void 0,[a.sent(),2]))[0],r=t[1],m((0,u.mT)(n,[])),f((0,u.mT)(r,[])),[3,4];case 3:return b(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){eu()},[eu]),(0,r.useEffect)(function(){return function(){en.current&&clearInterval(en.current)}},[]);var es=function(e){k(e.id),S.setFieldsValue({name:e.name,description:e.description,enabled:e.enabled,inputSchema:e.inputSchema,outputMapping:e.outputMapping}),C($(e.steps||[]).sort(function(e,t){return e.stepOrder-t.stepOrder}).map(function(e){var t;return{_key:"srv_".concat(e.id),id:e.id,stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:null!=(t=e.inputMapping)?t:null,outputAlias:e.outputAlias||"",condition:e.condition,onError:e.onError||"fail",retryCount:e.retryCount||0}})),v(!0)},em=(0,r.useCallback)(function(){en.current&&(clearInterval(en.current),en.current=null)},[]),ed=(0,r.useCallback)(function(t){return L(function(){var n,r;return Y(this,function(a){switch(a.label){case 0:return[4,e.request({url:"docUnderstanding:getJobStatus",params:{filterByTk:t}})];case 1:return n=a.sent(),q(r=(0,u.mT)(n,null)),r&&et.includes(r.status)&&(em(),Q(!1)),[2,r]}})})()},[e,em]),ep=(0,r.useCallback)(function(e){em(),en.current=setInterval(function(){ed(e).catch(function(e){em(),Q(!1),l.message.error((0,u.gJ)(e)||t("Failed to refresh test job"))})},1500)},[ed,em,t]),ef=function(e){em(),j(e),q(null),Q(!1),M(""),D(er(ea(e.inputSchema))),P(!0)},ey=function(){em(),P(!1),j(null),q(null),Q(!1)},eh=[{title:t("Name"),dataIndex:"name",width:200},{title:t("Steps"),dataIndex:"steps",width:300,render:function(e){if(!e||0===e.length)return a().createElement(l.Tag,null,"0 ",t("steps"));var n=$(e).sort(function(e,t){return e.stepOrder-t.stepOrder});return a().createElement(l.Space,{size:2,wrap:!0},n.map(function(e,n){return a().createElement(a().Fragment,{key:e.id},n>0&&a().createElement("span",{style:{color:"#ccc"}},"→"),a().createElement(l.Tag,null,e.name||"".concat(t("Step")," ").concat(e.stepOrder)))}))}},{title:t("Enabled"),dataIndex:"enabled",width:80,render:function(e){return e?a().createElement(l.Tag,{color:"success"},t("Yes")):a().createElement(l.Tag,null,t("No"))}},{title:t("AI Tool"),width:100,render:function(e,n){var r;return n.enabled?a().createElement(l.Tooltip,{title:"".concat(t("Registered as"),": doc_understanding.").concat(null==(r=n.name)?void 0:r.toLowerCase().replace(/[^a-z0-9_]/g,"_"))},a().createElement(l.Tag,{color:"blue",icon:a().createElement(i.ThunderboltOutlined,null)},t("Active"))):a().createElement(l.Tag,null,t("Inactive"))}},{title:t("Action"),width:190,render:function(n,r){return a().createElement(l.Space,null,a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.PlayCircleOutlined,null),disabled:!r.enabled,onClick:function(){return ef(r)},"aria-label":"".concat(t("Test")," ").concat(r.name)},t("Test")),a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.EditOutlined,null),onClick:function(){return es(r)},"aria-label":"".concat(t("Edit")," ").concat(r.name)},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this pipeline?"),okText:t("Delete"),onConfirm:function(){var n;return n=r.id,L(function(){return Y(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:deletePipeline",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("Deleted")),eu(),[2]}})})()}},a().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":"".concat(t("Delete")," ").concat(r.name)},t("Delete"))))}}];return a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){k(null),S.resetFields(),C([]),v(!0)}},t("Add Pipeline"))),a().createElement(l.Table,{rowKey:"id",columns:eh,dataSource:s,loading:h,size:"small"}),a().createElement(l.Modal,{title:I?t("Edit Pipeline"):t("New Pipeline"),open:E,onOk:function(){return L(function(){var n,r,a,o,i,c,u,s,m;return Y(this,function(d){switch(d.label){case 0:return d.trys.push([0,6,,7]),[4,S.validateFields()];case 1:n=d.sent(),r=!0,a=!1,o=void 0;try{for(i=T[Symbol.iterator]();!(r=(c=i.next()).done);r=!0){if(!(u=c.value).name)return l.message.error(t("All steps must have a name")),[2];if(!u.endpointId)return l.message.error("".concat(t("Step"),' "').concat(u.name||u.stepOrder,'" ').concat(t("must have an endpoint"))),[2]}}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}if(new Set(s=T.map(function(e){return e.outputAlias}).filter(Boolean)).size!==s.length)return l.message.error(t("Step output aliases must be unique")),[2];if(m=W(G({},n),{steps:T.map(function(e){return W(G({},e.id?{id:e.id}:{}),{stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:e.inputMapping,outputAlias:e.outputAlias||void 0,condition:e.condition,onError:e.onError,retryCount:"retry"===e.onError?e.retryCount:0})})}),!I)return[3,3];return[4,e.request({url:"docUnderstanding:updatePipeline",method:"POST",params:{filterByTk:I},data:m})];case 2:return d.sent(),[3,5];case 3:return[4,e.request({url:"docUnderstanding:createPipeline",method:"POST",data:m})];case 4:d.sent(),d.label=5;case 5:return l.message.success(t("Saved")),v(!1),eu(),[3,7];case 6:return d.sent(),[3,7];case 7:return[2]}})})()},onCancel:function(){return v(!1)},okText:t("Save"),cancelText:t("Cancel"),width:800,destroyOnClose:!0},a().createElement(l.Form,{form:S,layout:"vertical",preserve:!1},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"name",label:t("Pipeline Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"full_document_processing"})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,null))),a().createElement(l.Form.Item,{name:"description",label:t("Description")},a().createElement(X,{rows:2,placeholder:t("What this pipeline does")})),a().createElement(l.Card,{title:t("Pipeline Steps"),size:"small",style:{marginBottom:16},extra:a().createElement(l.Tag,{color:"blue"},T.length," ",t("step(s)"))},a().createElement(ei,{steps:T,endpoints:p,onChange:C})),a().createElement(l.Collapse,{size:"small",ghost:!0},a().createElement(Z,{header:t("Advanced: Input Schema & Output Mapping"),key:"advanced"},a().createElement(l.Form.Item,{name:"inputSchema",label:t("Input Schema (JSON Schema)"),help:t("Defines what input this pipeline accepts. Used by AI tool schema.")},a().createElement(eo,{placeholder:'{ "type": "object", "properties": { "document_url": { "type": "string" } }, "required": ["document_url"] }'})),a().createElement(l.Form.Item,{name:"outputMapping",label:t("Output Mapping (JSON)"),help:t("Map final step results to pipeline output. If empty, all step results are returned.")},a().createElement(eo,{placeholder:'{ "text": "$step[ocr_result].response.text", "category": "$step[classify].response.category" }'})))))),a().createElement(l.Modal,{title:B?"".concat(t("Test Playground"),": ").concat(B.name):t("Test Playground"),open:x,onCancel:ey,width:860,destroyOnClose:!0,footer:[a().createElement(l.Button,{key:"close",onClick:ey},t("Close")),(null==V?void 0:V.id)&&a().createElement(l.Button,{key:"refresh",icon:a().createElement(i.ReloadOutlined,null),disabled:H,onClick:function(){return ed(V.id)}},t("Refresh")),a().createElement(l.Button,{key:"run",type:"primary",icon:a().createElement(i.PlayCircleOutlined,null),loading:H,onClick:function(){return L(function(){var n,r,a,o,i,c;return Y(this,function(s){switch(s.label){case 0:if(!B)return[2];try{r=R.trim()?JSON.parse(R):{},n=el(ea(B.inputSchema),r),M("")}catch(e){return M(t("Invalid JSON input")),[2]}em(),Q(!0),q(null),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,e.request({url:"docUnderstanding:executePipeline",method:"POST",data:{pipelineId:B.id,input:n}})];case 2:if(a=s.sent(),!(o=(0,u.mT)(a,{}).jobId))throw Error(t("Pipeline did not return a job ID"));return[4,ed(o)];case 3:return(i=s.sent())&&et.includes(i.status)||ep(o),l.message.success("".concat(t("Test job started"),": #").concat(o)),[3,5];case 4:return c=s.sent(),Q(!1),l.message.error((0,u.gJ)(c)||t("Failed to run pipeline test")),[3,5];case 5:return[2]}})})()}},t("Run test"))].filter(Boolean)},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:16}},a().createElement("div",null,a().createElement("label",{htmlFor:"playground-input",style:{fontWeight:500,marginBottom:6,display:"block"}},t("Input JSON")),a().createElement(X,{id:"playground-input",rows:16,value:R,onChange:function(e){D(e.target.value),z&&M("")},placeholder:'{ "document_url": "https://..." }',status:z?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),z&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:z,style:{marginTop:8}}),a().createElement(l.Collapse,{size:"small",ghost:!0,style:{marginTop:12}},a().createElement(Z,{header:t("Input Schema"),key:"schema"},a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:220,overflow:"auto"}},er(null==B?void 0:B.inputSchema))))),a().createElement("div",null,a().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6}},a().createElement("span",{style:{fontWeight:500}},t("Result")),(null==V?void 0:V.status)&&a().createElement(l.Tag,{color:ee[V.status]||"default"},ec[V.status]||V.status)),V?a().createElement("div",null,a().createElement(l.Space,{style:{marginBottom:8},wrap:!0},a().createElement(l.Tag,null,t("Job")," #",V.id),V.currentStep&&a().createElement(l.Tag,null,t("Step")," ",V.currentStep)),V.error&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:t("Pipeline error"),description:a().createElement("pre",{style:{margin:0,whiteSpace:"pre-wrap"}},V.error),style:{marginBottom:12}}),a().createElement("div",{style:{fontWeight:500,marginBottom:4}},t("Final Result")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:220,overflow:"auto"}},void 0!==V.finalResult&&null!==V.finalResult?er(V.finalResult):t("(not yet available)")),a().createElement("div",{style:{fontWeight:500,margin:"12px 0 4px"}},t("Step Results")),a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:260,overflow:"auto"}},V.stepResults?er(V.stepResults):"{}")):a().createElement(l.Empty,{description:t("Run a test to see job output"),imageStyle:{height:48}})))))};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function em(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){es(l,r,a,o,i,"next",e)}function i(e){es(l,r,a,o,i,"throw",e)}o(void 0)})}}function ed(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ep(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ef={pending:"default",running:"processing",polling:"processing",waiting_input:"warning",completed:"success",failed:"error",cancelled:"default",timeout:"error"},ey=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=ed((0,r.useState)([]),2),s=n[0],m=n[1],d=ed((0,r.useState)([]),2),p=d[0],f=d[1],y=ed((0,r.useState)(!1),2),h=y[0],b=y[1],g=ed((0,r.useState)(!1),2),E=g[0],v=g[1],S=ed((0,r.useState)(null),2),w=S[0],I=S[1],k=ed((0,r.useState)(void 0),2),O=k[0],T=k[1],C=ed((0,r.useState)(void 0),2),F=C[0],x=C[1],P=ed((0,r.useState)(!1),2),A=P[0],B=P[1],j=ed((0,r.useState)(!1),2),N=j[0],R=j[1],D=ed(l.Form.useForm(),1)[0],U={pending:t("Pending"),running:t("Running"),polling:t("Polling"),waiting_input:t("Waiting Input"),completed:t("Completed"),failed:t("Failed"),cancelled:t("Cancelled"),timeout:t("Timeout")},z=(0,r.useCallback)(function(){return em(function(){var t,n;return ep(this,function(r){switch(r.label){case 0:b(!0),r.label=1;case 1:return r.trys.push([1,,3,4]),t={},O&&(t.status=O),F&&(t.pipelineId=F),[4,e.request({url:"docUnderstanding:listJobs",params:{filter:Object.keys(t).length>0?t:void 0}})];case 2:return n=r.sent(),m((0,u.mT)(n,[])),[3,4];case 3:return b(!1),[7];case 4:return[2]}})})()},[e,O,F]),M=(0,r.useCallback)(function(){return em(function(){var t;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:listPipelines"})];case 1:return t=n.sent(),f((0,u.mT)(t,[])),[3,3];case 2:return n.sent(),[3,3];case 3:return[2]}})})()},[e]);(0,r.useEffect)(function(){M()},[M]),(0,r.useEffect)(function(){z();var e=setInterval(z,1e4);return function(){return clearInterval(e)}},[z]);var J=new Map(p.map(function(e){return[e.id,e.name]})),V=function(t){return em(function(){var n;return ep(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:getJobStatus",params:{filterByTk:t.id}})];case 1:return n=r.sent(),I((0,u.mT)(n,t)),[3,3];case 2:return r.sent(),I(t),[3,3];case 3:return v(!0),[2]}})})()},q=[{title:t("ID"),dataIndex:"id",width:60},{title:t("Pipeline"),dataIndex:"pipelineId",width:180,render:function(e){return J.get(e)||"#".concat(e)}},{title:t("Status"),dataIndex:"status",width:120,render:function(e){return a().createElement(l.Tag,{color:ef[e]||"default"},U[e]||e)}},{title:t("Current Step"),dataIndex:"currentStep",width:100,render:function(e,n){return"completed"===n.status?a().createElement(l.Tag,{color:"success"},t("Done")):"failed"===n.status||"cancelled"===n.status?a().createElement(l.Tag,{color:"error"},"".concat(t("Step")," ").concat(e)):a().createElement(l.Badge,{status:"processing",text:"".concat(t("Step")," ").concat(e)})}},{title:t("Started"),dataIndex:"startedAt",width:160,render:function(e){return(0,u.r6)(e)}},{title:t("Completed"),dataIndex:"completedAt",width:160,render:function(e){return(0,u.r6)(e)}},{title:t("Action"),width:190,render:function(n,r){var o=["completed","failed","cancelled","timeout"].includes(r.status);return a().createElement(l.Space,{size:4},a().createElement(l.Button,{size:"small",icon:a().createElement(i.EyeOutlined,null),onClick:function(){return V(r)},"aria-label":"".concat(t("View")," #").concat(r.id)},t("View")),"waiting_input"===r.status&&a().createElement(l.Button,{size:"small",type:"primary",icon:a().createElement(i.CheckOutlined,null),onClick:function(){I(r),D.setFieldsValue({approved:!0,note:""}),B(!0)},"aria-label":"".concat(t("Resume")," #").concat(r.id)},t("Resume")),!o&&a().createElement(l.Popconfirm,{title:t("Cancel this job?"),onConfirm:function(){var n;return n=r.id,em(function(){var r;return ep(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:cancelJob",method:"POST",params:{filterByTk:n}})];case 1:return a.sent(),l.message.success(t("Job cancelled")),z(),[3,3];case 2:return r=a.sent(),l.message.error((0,u.gJ)(r)),[3,3];case 3:return[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(t("Cancel")," #").concat(r.id)})))}}];return a().createElement("div",null,a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Select,{allowClear:!0,placeholder:t("Filter by status"),"aria-label":t("Filter by status"),value:O,onChange:T,style:{width:170},options:Object.keys(ef).map(function(e){return{value:e,label:U[e]}})}),a().createElement(l.Select,{allowClear:!0,placeholder:t("Filter by pipeline"),"aria-label":t("Filter by pipeline"),value:F,onChange:x,style:{width:200},options:p.map(function(e){return{value:e.id,label:e.name}})}),a().createElement(l.Button,{icon:a().createElement(i.ReloadOutlined,null),onClick:z},t("Refresh"))),a().createElement(l.Table,{rowKey:"id",columns:q,dataSource:s,loading:h,size:"small",pagination:{pageSize:20}}),a().createElement(l.Modal,{title:"".concat(t("Approve / Resume")," #").concat((null==w?void 0:w.id)||""),open:A,onOk:function(){return em(function(){var n,r;return ep(this,function(a){switch(a.label){case 0:if(!w)return[2];R(!0),a.label=1;case 1:return a.trys.push([1,4,5,6]),[4,D.validateFields()];case 2:return n=a.sent(),[4,e.request({url:"docUnderstanding:resumeJob",method:"POST",params:{filterByTk:w.id},data:n})];case 3:return a.sent(),l.message.success(t("Job resumed")),B(!1),z(),V(w),[3,6];case 4:return r=a.sent(),l.message.error((0,u.gJ)(r)),[3,6];case 5:return R(!1),[7];case 6:return[2]}})})()},onCancel:function(){return B(!1)},confirmLoading:N,okText:t("Submit Decision"),cancelText:t("Cancel"),destroyOnClose:!0},a().createElement(l.Form,{form:D,layout:"vertical",initialValues:{approved:!0}},a().createElement(l.Form.Item,{name:"approved",label:t("Approve & Proceed"),valuePropName:"checked"},a().createElement(l.Switch,{checkedChildren:t("Approve"),unCheckedChildren:t("Reject")})),a().createElement(l.Form.Item,{name:"note",label:t("Reviewer Note")},a().createElement(l.Input.TextArea,{rows:3})))),a().createElement(l.Drawer,{title:w?"".concat(t("Job")," #").concat(w.id," — ").concat(J.get(w.pipelineId)||t("Unknown")):t("Job Details"),width:640,open:E,onClose:function(){return v(!1)}},w&&a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Space,{wrap:!0},a().createElement(l.Tag,{color:ef[w.status]||"default"},U[w.status]||w.status),w.startedAt&&a().createElement("span",null,t("Started"),": ",(0,u.r6)(w.startedAt)),w.completedAt&&a().createElement("span",null,t("Completed"),": ",(0,u.r6)(w.completedAt)))),w.error&&a().createElement("div",{style:{background:"#fff2f0",border:"1px solid #ffccc7",borderRadius:6,padding:12,marginBottom:16}},a().createElement("strong",{style:{color:"#cf1322"}},t("Error"),":"),a().createElement("pre",{style:{margin:"4px 0 0",whiteSpace:"pre-wrap",color:"#cf1322"}},w.error)),w.usage&&a().createElement(a().Fragment,null,a().createElement("h4",null,t("Token & Cost Usage")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:12}},JSON.stringify(w.usage,null,2))),a().createElement("h4",null,t("Input")),a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:200,overflow:"auto"}},JSON.stringify(w.input,null,2)),a().createElement("h4",{style:{marginTop:16}},t("Step Results")),w.stepResults&&Object.keys(w.stepResults).length>0?Object.entries(w.stepResults).map(function(e){var t=ed(e,2),n=t[0],r=t[1];return a().createElement("div",{key:n,style:{marginBottom:8}},a().createElement(l.Tag,{color:"blue"},n),a().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11,maxHeight:150,overflow:"auto",marginTop:4}},JSON.stringify(r,null,2)))}):a().createElement("div",{style:{color:"#999"}},t("No step results yet")),a().createElement("h4",{style:{marginTop:16}},t("Final Result")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:300,overflow:"auto"}},w.finalResult?JSON.stringify(w.finalResult,null,2):t("(not yet available)")),w.externalTaskIds&&Object.keys(w.externalTaskIds).length>0&&a().createElement(a().Fragment,null,a().createElement("h4",{style:{marginTop:16}},t("External Task IDs")),a().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11}},JSON.stringify(w.externalTaskIds,null,2))))))},eh=function(e){var t=e.embedded,n=void 0!==t&&t,r=(0,o.k)();return a().createElement("div",{style:{backgroundColor:"var(--nb-box-bg)",minHeight:n?void 0:"100vh"}},!n&&a().createElement("div",{style:{padding:"16px 24px",backgroundColor:"#fff",borderBottom:"1px solid #f0f0f0"}},a().createElement("h2",{style:{margin:0,fontSize:20,fontWeight:500}},r("Document Understanding - Pipeline Orchestrator"))),a().createElement("div",{style:{padding:n?0:"0 24px 24px"}},a().createElement(l.Tabs,{defaultActiveKey:"config",items:[{key:"config",label:r("Service Config"),children:a().createElement(y,null)},{key:"operations",label:r("Operations"),children:a().createElement(k,null)},{key:"api-keys",label:r("API Keys"),children:a().createElement(P,null)},{key:"endpoints",label:r("Endpoints"),children:a().createElement(V,null)},{key:"pipelines",label:r("Pipelines"),children:a().createElement(ec,null)},{key:"jobs",label:r("Jobs history"),children:a().createElement(ey,null)}]})))},eb=eh}}]);