@nocobase/plugin-workflow 0.17.0-alpha.2 → 0.17.0-alpha.4

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 (133) hide show
  1. package/dist/client/WorkflowPane.d.ts +2 -0
  2. package/dist/client/components/index.d.ts +5 -0
  3. package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
  4. package/dist/client/index.d.ts +14 -6
  5. package/dist/client/index.js +136 -186
  6. package/dist/client/nodes/calculation.d.ts +8 -62
  7. package/dist/client/nodes/condition.d.ts +9 -9
  8. package/dist/client/nodes/create.d.ts +3 -5
  9. package/dist/client/nodes/destroy.d.ts +3 -4
  10. package/dist/client/nodes/index.d.ts +2 -6
  11. package/dist/client/nodes/query.d.ts +3 -5
  12. package/dist/client/nodes/update.d.ts +4 -4
  13. package/dist/client/triggers/collection.d.ts +3 -4
  14. package/dist/client/triggers/index.d.ts +2 -11
  15. package/dist/client/triggers/schedule/index.d.ts +3 -4
  16. package/dist/client/utils.d.ts +1 -0
  17. package/dist/externalVersion.js +11 -13
  18. package/dist/locale/{en-US.js → en-US.json} +41 -94
  19. package/dist/locale/es-ES.json +98 -0
  20. package/dist/locale/fr-FR.json +98 -0
  21. package/dist/locale/ja-JP.json +82 -0
  22. package/dist/locale/pt-BR.json +98 -0
  23. package/dist/locale/ru-RU.json +82 -0
  24. package/dist/locale/tr-TR.json +82 -0
  25. package/dist/locale/zh-CN.json +176 -0
  26. package/dist/node_modules/cron-parser/package.json +1 -1
  27. package/dist/node_modules/lru-cache/package.json +1 -1
  28. package/dist/server/Plugin.d.ts +12 -2
  29. package/dist/server/Plugin.js +31 -7
  30. package/dist/server/Processor.d.ts +1 -1
  31. package/dist/server/index.d.ts +1 -1
  32. package/dist/server/index.js +2 -0
  33. package/dist/server/instructions/CalculationInstruction.d.ts +15 -0
  34. package/dist/server/instructions/{calculation.js → CalculationInstruction.js} +13 -6
  35. package/dist/server/instructions/ConditionInstruction.d.ts +19 -0
  36. package/dist/server/instructions/{condition.js → ConditionInstruction.js} +11 -7
  37. package/dist/server/instructions/CreateInstruction.d.ts +10 -0
  38. package/dist/server/instructions/{create.js → CreateInstruction.js} +13 -6
  39. package/dist/server/instructions/DestroyInstruction.d.ts +10 -0
  40. package/dist/server/instructions/{destroy.js → DestroyInstruction.js} +13 -6
  41. package/dist/server/instructions/{update.d.ts → QueryInstruction.d.ts} +5 -4
  42. package/dist/server/instructions/{query.js → QueryInstruction.js} +13 -6
  43. package/dist/server/instructions/{aggregate.d.ts → UpdateInstruction.d.ts} +5 -4
  44. package/dist/server/instructions/{update.js → UpdateInstruction.js} +13 -6
  45. package/dist/server/instructions/index.d.ts +10 -14
  46. package/dist/server/instructions/index.js +9 -39
  47. package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +4 -0
  48. package/dist/server/migrations/20231122143143-split-to-plugins.js +87 -0
  49. package/dist/server/triggers/{collection.d.ts → CollectionTrigger.d.ts} +1 -1
  50. package/dist/server/triggers/{collection.js → CollectionTrigger.js} +15 -5
  51. package/dist/server/triggers/{schedule.d.ts → ScheduleTrigger.d.ts} +2 -1
  52. package/dist/server/triggers/{schedule.js → ScheduleTrigger.js} +5 -5
  53. package/dist/server/triggers/index.d.ts +2 -6
  54. package/dist/server/triggers/index.js +1 -21
  55. package/package.json +3 -2
  56. package/dist/client/WorkflowProvider.d.ts +0 -5
  57. package/dist/client/components/Duration.d.ts +0 -5
  58. package/dist/client/components/DynamicExpression.d.ts +0 -6
  59. package/dist/client/components/NullRender.d.ts +0 -1
  60. package/dist/client/interfaces/expression.d.ts +0 -3
  61. package/dist/client/nodes/aggregate.d.ts +0 -196
  62. package/dist/client/nodes/delay.d.ts +0 -35
  63. package/dist/client/nodes/loop.d.ts +0 -33
  64. package/dist/client/nodes/manual/AssigneesSelect.d.ts +0 -6
  65. package/dist/client/nodes/manual/DetailsBlockProvider.d.ts +0 -2
  66. package/dist/client/nodes/manual/FormBlockInitializer.d.ts +0 -2
  67. package/dist/client/nodes/manual/FormBlockProvider.d.ts +0 -2
  68. package/dist/client/nodes/manual/ModeConfig.d.ts +0 -5
  69. package/dist/client/nodes/manual/SchemaConfig.d.ts +0 -49
  70. package/dist/client/nodes/manual/WorkflowTodo.d.ts +0 -5
  71. package/dist/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -2
  72. package/dist/client/nodes/manual/forms/create.d.ts +0 -3
  73. package/dist/client/nodes/manual/forms/custom.d.ts +0 -5
  74. package/dist/client/nodes/manual/forms/update.d.ts +0 -3
  75. package/dist/client/nodes/manual/index.d.ts +0 -86
  76. package/dist/client/nodes/manual/utils.d.ts +0 -2
  77. package/dist/client/nodes/parallel.d.ts +0 -32
  78. package/dist/client/nodes/request.d.ts +0 -183
  79. package/dist/client/nodes/sql.d.ts +0 -35
  80. package/dist/client/triggers/form.d.ts +0 -52
  81. package/dist/locale/en-US.d.ts +0 -130
  82. package/dist/locale/es-ES.d.ts +0 -130
  83. package/dist/locale/es-ES.js +0 -151
  84. package/dist/locale/fr-FR.d.ts +0 -130
  85. package/dist/locale/fr-FR.js +0 -151
  86. package/dist/locale/ja-JP.d.ts +0 -88
  87. package/dist/locale/ja-JP.js +0 -109
  88. package/dist/locale/pt-BR.d.ts +0 -130
  89. package/dist/locale/pt-BR.js +0 -151
  90. package/dist/locale/ru-RU.d.ts +0 -88
  91. package/dist/locale/ru-RU.js +0 -109
  92. package/dist/locale/tr-TR.d.ts +0 -88
  93. package/dist/locale/tr-TR.js +0 -109
  94. package/dist/locale/zh-CN.d.ts +0 -249
  95. package/dist/locale/zh-CN.js +0 -270
  96. package/dist/server/fields/expression-field.d.ts +0 -7
  97. package/dist/server/fields/expression-field.js +0 -32
  98. package/dist/server/fields/index.d.ts +0 -1
  99. package/dist/server/fields/index.js +0 -28
  100. package/dist/server/instructions/aggregate.js +0 -54
  101. package/dist/server/instructions/calculation.d.ts +0 -3
  102. package/dist/server/instructions/condition.d.ts +0 -6
  103. package/dist/server/instructions/create.d.ts +0 -8
  104. package/dist/server/instructions/delay.d.ts +0 -15
  105. package/dist/server/instructions/delay.js +0 -104
  106. package/dist/server/instructions/destroy.d.ts +0 -8
  107. package/dist/server/instructions/loop.d.ts +0 -15
  108. package/dist/server/instructions/loop.js +0 -94
  109. package/dist/server/instructions/manual/actions.d.ts +0 -2
  110. package/dist/server/instructions/manual/actions.js +0 -94
  111. package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
  112. package/dist/server/instructions/manual/collecions/jobs.js +0 -39
  113. package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
  114. package/dist/server/instructions/manual/collecions/users.js +0 -37
  115. package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
  116. package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
  117. package/dist/server/instructions/manual/forms/create.d.ts +0 -5
  118. package/dist/server/instructions/manual/forms/create.js +0 -41
  119. package/dist/server/instructions/manual/forms/index.d.ts +0 -6
  120. package/dist/server/instructions/manual/forms/index.js +0 -38
  121. package/dist/server/instructions/manual/forms/update.d.ts +0 -6
  122. package/dist/server/instructions/manual/forms/update.js +0 -41
  123. package/dist/server/instructions/manual/index.d.ts +0 -29
  124. package/dist/server/instructions/manual/index.js +0 -179
  125. package/dist/server/instructions/parallel.d.ts +0 -12
  126. package/dist/server/instructions/parallel.js +0 -124
  127. package/dist/server/instructions/query.d.ts +0 -9
  128. package/dist/server/instructions/request.d.ts +0 -18
  129. package/dist/server/instructions/request.js +0 -92
  130. package/dist/server/instructions/sql.d.ts +0 -12
  131. package/dist/server/instructions/sql.js +0 -43
  132. package/dist/server/triggers/form.d.ts +0 -11
  133. package/dist/server/triggers/form.js +0 -116
@@ -1,45 +1,4 @@
1
- (function(S,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","antd","react","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client"],r):(S=typeof globalThis!="undefined"?globalThis:S||self,r(S["@nocobase/plugin-workflow"]={},S.jsxRuntime,S["@ant-design/icons"],S["@nocobase/client"],S.antd,S.react,S["react-i18next"],S["@formily/core"],S["@formily/react"],S.lodash,S["@nocobase/utils"],S["react-router-dom"],S.dayjs,S["@formily/antd-v5"],S["@nocobase/evaluators"]))})(this,function(S,r,I,l,b,y,R,le,A,fe,K,ue,zo,be,je){"use strict";var Os=Object.defineProperty,Is=Object.defineProperties;var Ts=Object.getOwnPropertyDescriptors;var xo=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var jo=(S,r,I)=>r in S?Os(S,r,{enumerable:!0,configurable:!0,writable:!0,value:I}):S[r]=I,x=(S,r)=>{for(var I in r||(r={}))Rt.call(r,I)&&jo(S,I,r[I]);if(xo)for(var I of xo(r))en.call(r,I)&&jo(S,I,r[I]);return S},C=(S,r)=>Is(S,Ts(r));var on=S=>typeof S=="symbol"?S:S+"",W=(S,r)=>{var I={};for(var l in S)Rt.call(S,l)&&r.indexOf(l)<0&&(I[l]=S[l]);if(S!=null&&xo)for(var l of xo(S))r.indexOf(l)<0&&en.call(S,l)&&(I[l]=S[l]);return I};var bo=(S,r,I)=>(jo(S,typeof r!="symbol"?r+"":r,I),I);var G=(S,r,I)=>new Promise((l,b)=>{var y=A=>{try{le(I.next(A))}catch(fe){b(fe)}},R=A=>{try{le(I.throw(A))}catch(fe){b(fe)}},le=A=>A.done?l(A.value):Promise.resolve(A.value).then(y,R);le((I=I.apply(S,r)).next())});const ze=y.createContext({});function U(){return y.useContext(ze)}const u="workflow";function $(e,o={}){return l.i18n.t(e,C(x({},o),{ns:u}))}function vo(){return R.useTranslation(u)}const tn=l.createStyles(({css:e,token:o})=>({container:e`
2
- margin-bottom: 1.5em;
3
- padding: 1em;
4
- background-color: ${o.colorFillAlter};
5
-
6
- > *:last-child {
7
- margin-bottom: 0;
8
- }
9
-
10
- dl {
11
- display: flex;
12
- align-items: baseline;
13
-
14
- dt {
15
- color: ${o.colorText};
16
- &:after {
17
- content: ':';
18
- margin-right: 0.5em;
19
- }
20
- }
21
- }
22
-
23
- p {
24
- color: ${o.colorTextDescription};
25
- }
26
- `}));function Lo(e){const{label:o,title:n,description:t}=e,{styles:s}=tn();return r.jsxs("div",{className:l.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:n})})]}),t?r.jsx("p",{children:t}):null]})}function nn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wo={exports:{}};/*!
27
- Copyright (c) 2018 Jed Watson.
28
- Licensed under the MIT License (MIT), see
29
- http://jedwatson.github.io/classnames
30
- */(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var t=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var a=typeof i;if(a==="string"||a==="number")t.push(i);else if(Array.isArray(i)){if(i.length){var c=n.apply(null,i);c&&t.push(c)}}else if(a==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){t.push(i.toString());continue}for(var d in i)o.call(i,d)&&i[d]&&t.push(d)}}}return t.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Wo);var rn=Wo.exports;const sn=nn(rn),ln=l.createStyles(({css:e,token:o})=>({statusButtonClass:e`
31
- border: none;
32
- .ant-tag {
33
- width: 100%;
34
- height: 100%;
35
- padding: 0;
36
- margin-right: 0;
37
- border-radius: 50%;
38
- text-align: center;
39
- }
40
- `,noStatusButtonClass:e`
41
- border-width: 2px;
42
- `}));function Le(e){var t;const{styles:o}=ln();let n=null;if(typeof e.status!="undefined"&&((t=e.statusMap)!=null&&t[e.status])){const{icon:s,color:i}=e.statusMap[e.status];n=r.jsx(b.Tag,{color:i,children:s})}return r.jsx(b.Button,C(x({},e),{shape:"circle",size:"small",className:sn(n?o.statusButtonClass:o.noStatusButtonClass,e.className),children:n}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Qe=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${u}" })}}`,color:"blue",icon:r.jsx(I.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${u}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(I.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${u}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${u}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${u}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${u}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${u}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${u}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${u}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${u}" })}}`}],Xe=Qe.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),ee={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Re=[{value:ee.PENDING,label:`{{t("Pending", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(I.ClockCircleOutlined,{})},{value:ee.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{})},{value:ee.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{})},{value:ee.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{})},{value:ee.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90})},{value:ee.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45})},{value:ee.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{})},{value:ee.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{})}],We=Re.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),Co=(e,o)=>({getAriaLabel:y.useCallback(t=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,o!=null?String(o):"",t].filter(Boolean).join("-"),[o,e==null?void 0:e.title,e==null?void 0:e.type])}),oe=l.createStyles(({css:e,token:o})=>({workflowPageClass:e`
1
+ (function(y,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react"),require("antd"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react","antd","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(y=typeof globalThis!="undefined"?globalThis:y||self,r(y["@nocobase/plugin-workflow"]={},y.jsxRuntime,y["@ant-design/icons"],y["@nocobase/client"],y.react,y.antd,y["react-i18next"],y["@formily/core"],y["@formily/react"],y.lodash,y["@nocobase/utils"],y["react-router-dom"],y.dayjs,y["@nocobase/evaluators"],y["@formily/antd-v5"]))})(this,function(y,r,T,a,g,v,oe,ge,V,we,ae,ie,Bo,$e,Vo){"use strict";var or=Object.defineProperty,nr=Object.defineProperties;var rr=Object.getOwnPropertyDescriptors;var dt=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable;var Dt=(y,r,T)=>r in y?or(y,r,{enumerable:!0,configurable:!0,writable:!0,value:T}):y[r]=T,C=(y,r)=>{for(var T in r||(r={}))Mo.call(r,T)&&Dt(y,T,r[T]);if(dt)for(var T of dt(r))Io.call(r,T)&&Dt(y,T,r[T]);return y},A=(y,r)=>nr(y,rr(r));var Po=y=>typeof y=="symbol"?y:y+"",q=(y,r)=>{var T={};for(var a in y)Mo.call(y,a)&&r.indexOf(a)<0&&(T[a]=y[a]);if(y!=null&&dt)for(var a of dt(y))r.indexOf(a)<0&&Io.call(y,a)&&(T[a]=y[a]);return T};var w=(y,r,T)=>(Dt(y,typeof r!="symbol"?r+"":r,T),T);var K=(y,r,T)=>new Promise((a,g)=>{var v=V=>{try{ge(T.next(V))}catch(we){g(we)}},oe=V=>{try{ge(T.throw(V))}catch(we){g(we)}},ge=V=>V.done?a(V.value):Promise.resolve(V.value).then(v,oe);ge((T=T.apply(y,r)).next())});const ze=g.createContext({});function Z(){return g.useContext(ze)}const m="workflow";function E(e,t={}){return a.i18n.t(e,A(C({},t),{ns:m}))}function ut(){return oe.useTranslation(m)}const ee=a.createStyles(({css:e,token:t})=>({workflowPageClass:e`
43
2
  flex-grow: 1;
44
3
  overflow: hidden;
45
4
  display: flex;
@@ -51,8 +10,8 @@
51
10
  justify-content: space-between;
52
11
  position: relative;
53
12
  padding: 0.5rem 1rem;
54
- background: ${o.colorBgContainer};
55
- border-bottom: 1px solid ${o.colorBorderSecondary};
13
+ background: ${t.colorBgContainer};
14
+ border-bottom: 1px solid ${t.colorBorderSecondary};
56
15
 
57
16
  header {
58
17
  display: flex;
@@ -87,7 +46,7 @@
87
46
  height: 10em;
88
47
  padding: 1em 0;
89
48
  border-radius: 0.5em;
90
- background: ${o.colorBgContainer};
49
+ background: ${t.colorBgContainer};
91
50
  }
92
51
 
93
52
  .workflow-canvas {
@@ -158,7 +117,7 @@
158
117
  bottom: 0;
159
118
  left: calc(50% - 0.5px);
160
119
  width: 1px;
161
- background-color: ${o.colorBgLayout};
120
+ background-color: ${t.colorBgLayout};
162
121
  }
163
122
  `,branchClass:e`
164
123
  display: flex;
@@ -177,7 +136,7 @@
177
136
  top: 0;
178
137
  bottom: 0;
179
138
  width: 1px;
180
- background-color: ${o.colorBorder};
139
+ background-color: ${t.colorBorder};
181
140
  }
182
141
 
183
142
  :before,
@@ -185,7 +144,7 @@
185
144
  content: '';
186
145
  position: absolute;
187
146
  height: 1px;
188
- background-color: ${o.colorBorder};
147
+ background-color: ${t.colorBorder};
189
148
  }
190
149
 
191
150
  :before {
@@ -229,7 +188,7 @@
229
188
  width: 0;
230
189
  height: 4em;
231
190
  padding: 1em 0;
232
- border-left: 1px dashed ${o.colorBgLayout};
191
+ border-left: 1px dashed ${t.colorBgLayout};
233
192
 
234
193
  .anticon {
235
194
  font-size: 1.5em;
@@ -251,15 +210,15 @@
251
210
  `,nodeCardClass:e`
252
211
  position: relative;
253
212
  width: 20em;
254
- background: ${o.colorBgContainer};
213
+ background: ${t.colorBgContainer};
255
214
  padding: 1em;
256
- box-shadow: ${o.boxShadowTertiary};
257
- border-radius: ${o.borderRadiusLG}px;
215
+ box-shadow: ${t.boxShadowTertiary};
216
+ border-radius: ${t.borderRadiusLG}px;
258
217
  cursor: pointer;
259
218
  transition: box-shadow 0.3s ease;
260
219
 
261
220
  &:hover {
262
- box-shadow: ${o.boxShadow};
221
+ box-shadow: ${t.boxShadow};
263
222
 
264
223
  .workflow-node-remove-button {
265
224
  display: block;
@@ -267,7 +226,7 @@
267
226
  }
268
227
 
269
228
  &.configuring {
270
- box-shadow: ${o.boxShadow};
229
+ box-shadow: ${t.boxShadow};
271
230
  }
272
231
 
273
232
  .workflow-node-remove-button {
@@ -275,14 +234,14 @@
275
234
  position: absolute;
276
235
  right: 0.5em;
277
236
  top: 0.5em;
278
- color: ${o.colorText};
237
+ color: ${t.colorText};
279
238
 
280
239
  &[disabled] {
281
240
  display: none;
282
241
  }
283
242
 
284
243
  &:hover {
285
- color: ${o.colorErrorHover};
244
+ color: ${t.colorErrorHover};
286
245
  }
287
246
  }
288
247
 
@@ -293,15 +252,15 @@
293
252
  transition:
294
253
  background-color 0.3s ease,
295
254
  border-color 0.3s ease;
296
- border-color: ${o.colorBorderBg};
297
- background-color: ${o.colorBgContainerDisabled};
255
+ border-color: ${t.colorBorderBg};
256
+ background-color: ${t.colorBgContainerDisabled};
298
257
 
299
258
  &:not(:disabled):hover {
300
- border-color: ${o.colorPrimaryBorderHover};
259
+ border-color: ${t.colorPrimaryBorderHover};
301
260
  }
302
261
 
303
262
  &:disabled:hover {
304
- border-color: ${o.colorBorderBg};
263
+ border-color: ${t.colorBorderBg};
305
264
  }
306
265
  }
307
266
  }
@@ -324,14 +283,14 @@
324
283
  right: 1em;
325
284
  justify-content: center;
326
285
  align-items: center;
327
- color: ${o.colorTextLightSolid};
286
+ color: ${t.colorTextLightSolid};
328
287
  `,nodeHeaderClass:e`
329
288
  position: relative;
330
289
  `,nodeMetaClass:e`
331
290
  margin-bottom: 0.5em;
332
291
 
333
292
  .workflow-node-id {
334
- color: ${o.colorTextDescription};
293
+ color: ${t.colorTextDescription};
335
294
 
336
295
  &:before {
337
296
  content: '#';
@@ -342,7 +301,7 @@
342
301
  align-items: center;
343
302
  font-weight: normal;
344
303
  .workflow-node-id {
345
- color: ${o.colorTextDescription};
304
+ color: ${t.colorTextDescription};
346
305
  }
347
306
  `,nodeSubtreeClass:e`
348
307
  display: flex;
@@ -351,7 +310,7 @@
351
310
  margin: auto;
352
311
  `,nodeJobResultClass:e`
353
312
  padding: 1em;
354
- background-color: ${o.colorBgContainer};
313
+ background-color: ${t.colorBgContainer};
355
314
  `,addButtonClass:e`
356
315
  flex-shrink: 0;
357
316
  padding: 2em 0;
@@ -369,8 +328,8 @@
369
328
  position: absolute;
370
329
  top: calc(1.5em - 1px);
371
330
  line-height: 1em;
372
- color: ${o.colorTextSecondary};
373
- background-color: ${o.colorBgLayout};
331
+ color: ${t.colorTextSecondary};
332
+ background-color: ${t.colorBgLayout};
374
333
  padding: 1px;
375
334
  }
376
335
  `,loopLineClass:e`
@@ -390,22 +349,115 @@
390
349
  width: 4em;
391
350
  height: 4em;
392
351
  border-radius: 50%;
393
- background-color: ${o.colorText};
394
- color: ${o.colorBgContainer};
395
- `}));function an(){return!0}const wo=A.observer(e=>{const c=e,{filter:o=an}=c,n=W(c,["filter"]),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),{values:i}=A.useForm(),a=s(i==null?void 0:i.collection);return r.jsx(b.Select,C(x({popupMatchSelectWidth:!1},n),{options:a.filter(o).map(d=>{var p;return{label:t((p=d.uiSchema)==null?void 0:p.title),value:d.name}})}))},{displayName:"FieldsSelect"});function ko(e,o){o(e),e.properties&&Object.keys(e.properties).forEach(n=>{ko(e.properties[n],o)})}function ve(e,o,n=!1){const t=[];return e?o(e)&&(!n||!e.properties)?(t.push(e),t):(e.properties&&Object.keys(e.properties).forEach(s=>{t.push(...ve(e.properties[s],o))}),t):t}function cn(t){var s=t,{collection:e,dataSource:o}=s,n=W(s,["collection","dataSource"]);const{insert:i}=l.useSchemaInitializer(),{getTemplateSchemaByMode:a}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager(),d=l.useRecordCollectionDataSourceItems("FormItem"),p=c(e);function f(v){return G(this,arguments,function*({item:g}){const h=g.template?yield a(g):null,m={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:o},"x-component":"CardItem","x-component-props":{title:n.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};ko(m,k=>{k["x-uid"]&&delete k["x-uid"]}),i(m)})}return r.jsx(l.SchemaInitializerItem,C(x({},n),{onClick:f,items:d}))}function Ie(){const e=l.useSchemaInitializerItem();return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(cn,x({},e))})}const ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Uo={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
352
+ background-color: ${t.colorText};
353
+ color: ${t.colorBgContainer};
354
+ `}));function Nt(e){var p;const{upstream:t,branchIndex:o=null}=e,{instructions:n}=a.usePlugin(ce),s=a.useCompile(),i=a.useAPIClient(),{workflow:l,refresh:c}=(p=Z())!=null?p:{},d=Array.from(n.getValues()),{styles:u}=ee(),f=g.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${m}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${m}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${m}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${m}" })}}`}].filter(k=>d.filter(F=>F.group===k.key).length).map(k=>{const F=d.filter(D=>D.group===k.key&&(D.isAvailable?D.isAvailable({workflow:l,upstream:t,branchIndex:o}):!0));return A(C({},k),{type:"group",children:F.map(D=>({role:"button","aria-label":D.type,key:D.type,label:D.title,type:D.options?"subMenu":null,children:D.options?D.options.map(S=>({role:"button","aria-label":S.key,key:S.key,label:S.label})):null}))})}),[o,d,t,l]),b=g.useMemo(()=>l?i.resource("workflows.nodes",l.id):null,[l==null?void 0:l.id]),O=g.useCallback(F=>K(this,[F],function*({keyPath:k}){var H,J,L;const D=k.pop(),S={},[M]=k,z=n.get(D);if(M){const{value:x}=(J=(H=z.options)==null?void 0:H.find(N=>N.key===M))!=null?J:{};Object.assign(S,typeof x=="function"?x():x)}b&&(yield b.create({values:{type:D,upstreamId:(L=t==null?void 0:t.id)!=null?L:null,branchIndex:o,title:s(z.title),config:S}}),c())}),[o,b==null?void 0:b.create,t==null?void 0:t.id]),h=g.useMemo(()=>({onClick:O,items:s(f)}),[f,O]);return l?r.jsx("div",{className:u.addButtonClass,children:r.jsx(v.Dropdown,{trigger:["click"],menu:h,disabled:l.executed,overlayClassName:a.css`
355
+ .ant-dropdown-menu-root {
356
+ max-height: 30em;
357
+ overflow-y: auto;
358
+ }
359
+ `,children:r.jsx(v.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(T.PlusOutlined,{})})})}):null}const pt=(e,t)=>({getAriaLabel:g.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),jo=a.createStyles(({css:e,token:t})=>({container:e`
360
+ margin-bottom: 1.5em;
361
+ padding: 1em;
362
+ background-color: ${t.colorFillAlter};
363
+
364
+ > *:last-child {
365
+ margin-bottom: 0;
366
+ }
367
+
368
+ dl {
369
+ display: flex;
370
+ align-items: baseline;
371
+
372
+ dt {
373
+ color: ${t.colorText};
374
+ &:after {
375
+ content: ':';
376
+ margin-right: 0.5em;
377
+ }
378
+ }
379
+ }
380
+
381
+ p {
382
+ color: ${t.colorTextDescription};
383
+ }
384
+ `}));function Et(e){const{label:t,title:o,description:n}=e,{styles:s}=jo();return r.jsxs("div",{className:a.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(v.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}function Lo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mt={exports:{}};/*!
385
+ Copyright (c) 2018 Jed Watson.
386
+ Licensed under the MIT License (MIT), see
387
+ http://jedwatson.github.io/classnames
388
+ */(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var l=typeof i;if(l==="string"||l==="number")n.push(i);else if(Array.isArray(i)){if(i.length){var c=o.apply(null,i);c&&n.push(c)}}else if(l==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){n.push(i.toString());continue}for(var d in i)t.call(i,d)&&i[d]&&n.push(d)}}}return n.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(Mt);var Wo=Mt.exports;const zo=Lo(Wo),Jo=a.createStyles(({css:e,token:t})=>({statusButtonClass:e`
389
+ border: none;
390
+ .ant-tag {
391
+ width: 100%;
392
+ height: 100%;
393
+ padding: 0;
394
+ margin-right: 0;
395
+ border-radius: 50%;
396
+ text-align: center;
397
+ }
398
+ `,noStatusButtonClass:e`
399
+ border-width: 2px;
400
+ `}));function De(e){var n;const{styles:t}=Jo();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:i}=e.statusMap[e.status];o=r.jsx(v.Tag,{color:i,children:s})}return r.jsx(v.Button,A(C({},e),{shape:"circle",size:"small",className:zo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const le={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Je=[{value:le.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(T.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:le.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(T.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:le.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:le.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:le.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:le.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:le.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:le.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:le.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],He=Je.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),pe={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:pe.PENDING,label:`{{t("Pending", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(T.ClockCircleOutlined,{})},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{})},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{})},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{})},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90})},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45})},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{})},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{})}],Ue=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class be{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components")}}function Ho(){const e=V.useForm(),t=a.useAPIClient(),o=a.useActionContext(),{refresh:n}=a.useResourceActionContext(),s=Ce(),{workflow:i}=Z();return{run(){return K(this,null,function*(){var c,d;if(i.executed){v.message.error(E("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=g.createContext({});function Ce(){return g.useContext(ft)}function It(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}function Pt(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function Bt({data:e}){const{styles:t}=ee(),{getAriaLabel:o}=pt(e),n=a.usePlugin(ce),{Component:s=ht}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:a.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),r.jsx(Nt,{"aria-label":o(),upstream:e})]})})}function Vt(){var u;const{t:e}=oe.useTranslation(),t=a.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(u=Z())!=null?u:{},i=Ce(),{modal:l}=v.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return K(this,null,function*(){function f(){return K(this,null,function*(){var p;yield(p=c.destroy)==null?void 0:p.call(c,{filterByTk:i.id}),s()})}const b=n.filter(p=>p===i?!1:ae.parse(p.config).parameters.filter(({key:D})=>D.startsWith(`$jobsMapByNodeKey.${i.key}.`)||D===`$jobsMapByNodeKey.${i.key}`).length);if(b.length){l.error({title:E("Can not delete"),content:E("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:b.map(p=>`#${p.id}`).join(", ")})});return}const h=!n.find(p=>p.upstream===i&&p.branchIndex!=null)?e("Are you sure you want to delete it?"):E("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:h,onOk:f})})}return o.executed?null:r.jsx(v.Button,{type:"text",shape:"circle",icon:r.jsx(T.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function jt(){var i;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(i=Ce())!=null?i:{},{styles:n}=ee();if(!e)return null;if(!o.length)return r.jsx(De,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(d=>d.id==l);t(c)}return o.length>1?r.jsx(v.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(De,{statusMap:Ue,status:l.status}),r.jsx("time",{children:ae.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(De,{statusMap:Ue,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(De,{statusMap:Ue,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Uo(){return{form:V.useForm()}}function ht(e){var J,L;const{data:t,children:o}=e,n=a.useCompile(),s=a.useAPIClient(),{workflow:i,refresh:l}=(J=Z())!=null?J:{},{styles:c}=ee(),u=a.usePlugin(ce).instructions.get(t.type),f=i.executed?'{{t("View")}}':'{{t("Configure")}}',b=n(u.title),[O,h]=g.useState((L=t.title)!=null?L:b),[p,k]=g.useState(!1),[F,D]=g.useState(!1),S=g.useMemo(()=>{const x=we.cloneDeep(t.config);return ge.createForm({initialValues:x,disabled:i.executed})},[t,i]),M=g.useCallback(x=>{k(x),x||S.reset()},[S]),z=g.useCallback(function(x){return K(this,null,function*(){var j,I;const N=x||b;h(N),N!==t.title&&(yield(I=(j=s.resource("flow_nodes")).update)==null?void 0:I.call(j,{filterByTk:t.id,values:{title:N}}),l())})},[t]),H=g.useCallback(function(x){if(x.target===x.currentTarget){k(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let j=x.target;j&&j!==x.currentTarget&&j!==document.documentElement;j=j.parentNode)if(Array.from(j.classList).some(I=>N.has(I))){k(!0),x.stopPropagation();return}},[]);return r.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${b}-${O}`,className:a.cx(c.nodeCardClass,{configuring:p}),onClick:H,children:[r.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(v.Tag,{children:b}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(v.Input.TextArea,{disabled:i.executed,value:O,onChange:x=>h(x.target.value),onBlur:x=>z(x.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:p,setVisible:M,formValueChanged:F,setFormValueChanged:D},children:r.jsx(a.FormProvider,{form:S,children:r.jsx(a.SchemaComponent,{scope:A(C({},u.scope),{useFormProviderProps:Uo}),components:u.components,schema:{type:"void",properties:A(C({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":f,"x-component":v.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${u.type}_${t.id}`]:{type:"void",title:r.jsxs("div",{className:a.css`
401
+ display: flex;
402
+ justify-content: space-between;
403
+
404
+ strong {
405
+ font-weight: bold;
406
+ }
407
+
408
+ .ant-tag {
409
+ margin-inline-end: 0;
410
+ }
411
+
412
+ code {
413
+ font-weight: normal;
414
+ }
415
+ `,children:[r.jsx("strong",{children:t.title}),r.jsx(v.Tooltip,{title:E("Variable key of node"),children:r.jsx(v.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:A(C({},u.description?{description:{type:"void","x-component":Et,"x-component-props":{label:E("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
416
+ .ant-input,
417
+ .ant-select,
418
+ .ant-cascader-picker,
419
+ .ant-picker,
420
+ .ant-input-number,
421
+ .ant-input-affix-wrapper {
422
+ &.auto-width {
423
+ width: auto;
424
+ min-width: 6em;
425
+ }
426
+ }
427
+ `},properties:u.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Ho}}}}})}})}})})})]}),o]})}function Ye({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:i}){const{styles:l}=ee(),{getAriaLabel:c}=pt(e,o),d=[];for(let u=t;u;u=u.downstream)d.push(u);return r.jsxs("div",{className:a.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Nt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(u=>r.jsx(Bt,{data:u},u.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})}):null]})}function Yo(){var i;const e=V.useForm(),t=a.useAPIClient(),{workflow:o}=(i=Z())!=null?i:{},n=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return K(this,null,function*(){var c,d;if(o.executed){v.message.error(E("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("workflows")).update)==null?void 0:d.call(c,{filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class yt{constructor(){w(this,"title");w(this,"type");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"useActionTriggerable")}}function Go(){const e=a.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=ee(),s=gt();return o?r.jsx(a.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(T.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:a.cx(n.nodeTitleClass),children:[r.jsx(v.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:a.css`
428
+ padding: 1em;
429
+ background-color: #eee;
430
+ `},"x-read-pretty":!0}}}}}}):null}function _o(){return{form:V.useForm()}}const qo=()=>{const e=a.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=g.useState(""),[i,l]=g.useState(!1),[c,d]=g.useState(!1),{styles:u}=ee(),f=a.useCompile(),b=gt(),{title:O,executed:h}=t,p=f(b.title),{fieldset:k,scope:F,components:D}=b,S=h?'{{t("View")}}':'{{t("Configure")}}',M=E("Trigger");g.useEffect(()=>{var x;t&&s((x=t.title)!=null?x:p)},[t]);const z=g.useMemo(()=>{const x=we.cloneDeep(t==null?void 0:t.config);return ge.createForm({initialValues:x,disabled:t==null?void 0:t.executed})},[t]),H=g.useCallback(x=>{l(x),x||z.reset()},[z]),J=g.useCallback(function(x){return K(this,null,function*(){var j,I;const N=x||p;s(N),N!==O&&(yield(I=(j=e.resource("workflows")).update)==null?void 0:I.call(j,{filterByTk:t.id,values:{title:N}}),o())})},[t]),L=g.useCallback(function(x){var j;if(x.target===x.currentTarget){l(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=x.target;I&&I!==x.currentTarget;I=I.parentNode)if(Array.from((j=I.classList)!=null?j:[]).some(ne=>N.has(ne))){l(!0),x.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:a.cx(u.nodeCardClass),onClick:L,children:[r.jsx("div",{className:a.cx(u.nodeMetaClass,"workflow-node-meta"),children:r.jsx(v.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(v.Input.TextArea,{value:n,onChange:x=>s(x.target.value),onBlur:x=>J(x.target.value),autoSize:!0})}),r.jsx(Go,{}),r.jsx(a.ActionContextProvider,{value:{visible:i,setVisible:H,formValueChanged:c,setFormValueChanged:d},children:r.jsx(a.FormProvider,{form:z,children:r.jsx(a.SchemaComponent,{scope:A(C({},F),{useFormProviderProps:_o}),components:D,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":S,"x-component":v.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:A(C({},b.description?{description:{type:"void","x-component":Et,"x-component-props":{label:E("Trigger type"),title:b.title,description:b.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
431
+ .ant-select.auto-width {
432
+ width: auto;
433
+ min-width: 6em;
434
+ }
435
+ `},properties:k},actions:C({},h?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Yo}}}})})}}}})})})]})};function gt(){const e=a.usePlugin(ce),{workflow:t}=Z();return e.triggers.get(t.type)}const Ne={label:"label",value:"value",children:"children"},Lt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=a.usePlugin(ce),o=Ce(),n=It(o),s=[];return n.forEach(i=>{var d;const l=t.get(i.type),c=(d=l.useVariables)==null?void 0:d.call(l,i,e);c&&s.push(c)}),s}},Wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var s,i;const{triggers:t}=a.usePlugin(ce),{workflow:o}=Z(),n=t.get(o.type);return(i=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?i:null}},zt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Ne,current:o}=e,{instructions:n}=a.usePlugin(ce),s=Ce(),i=o!=null?o:s,l=Pt(i),c=[];return l.forEach(d=>{var b,O;const u=n.get(d.type),f=(b=u.useScopeVariables)==null?void 0:b.call(u,d,e);f&&c.push({key:d.key,[t.value]:d.key,[t.label]:(O=d.title)!=null?O:`#${d.id}`,[t.children]:f})}),c}},Jt={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Ne}){return[...!e||e.includes("date")?[{key:"now",[t.label]:E("System time"),[t.value]:"now"}]:[]]}},Ge={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Ht(e,t){var n,s,i,l,c,d;const o=typeof t;return o==="string"?(n=Ge[t])==null?void 0:n.has(e.interface):o==="object"&&t.type==="reference"?bt(e)?((s=t.options)==null?void 0:s.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((l=t.options)==null?void 0:l.collection)==="*"):e.isForeignKey?e.collectionName===((c=t.options)==null?void 0:c.collection)&&e.name==="id"||e.target===((d=t.options)==null?void 0:d.collection):!1:o==="function"?t(e):!1}function bt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function xt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function vt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Ht(l,d)):!0;if(bt(l)){if(o===null)return n?c||vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:i}):!1;const d=xt(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,appends:d,compile:s,getCollectionFields:i}).length}else return c})}function _e(e,t){var i,l;const o=a.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},Ne,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[_e(zt,o),_e(Lt,o),_e(Wt,o),_e(Jt,o)]}function wt(e,{compile:t,getCollectionFields:o}){var l,c,d,u,f,b,O;const n=o(e),s=[],i=[];n.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const p=i[h];if(p.type==="belongsTo"){const k=s.find(F=>F.name===p.foreignKey);k?i.splice(h,0,A(C(C({},p),k),{uiSchema:A(C({},p.uiSchema),{title:(l=p.uiSchema)!=null&&l.title?`${t((c=p.uiSchema)==null?void 0:c.title)} ID`:k.name})})):i.splice(h,0,A(C({},p),{name:p.foreignKey,type:"bigInt",isForeignKey:!0,interface:p.interface,uiSchema:A(C({},p.uiSchema),{title:(d=p.uiSchema)!=null&&d.title?`${t((u=p.uiSchema)==null?void 0:u.title)} ID`:p.name})}))}else if(p.type==="context"&&p.collectionName==="users"){const k=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===p.name))!=null?f:{};i.splice(h,0,A(C({},p),{type:p.dataType,interface:k.interface,uiSchema:A(C({},k.uiSchema),{title:(b=k.uiSchema)!=null&&b.title?`${t((O=k.uiSchema)==null?void 0:O.title)} ID`:p.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Ko(e){const t=xt(e.field,e.appends),o=ke(C({collection:e.field.target,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>Ht(e.field,s))||(e.disabled=!0))}function ke(e){const{fields:t,collection:o,types:n,appends:s=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:d=Ne}=e,u=wt(o,{compile:l,getCollectionFields:c}),f=t!=null?t:u,b=Ko.bind({compile:l,getCollectionFields:c,fieldNames:d});return vt({fields:f,types:n,depth:i,appends:s,compile:l,getCollectionFields:c}).map(h=>{var D;const p=l(((D=h.uiSchema)==null?void 0:D.title)||h.name),k=xt(h,s),F=!bt(h)||k&&!k.length&&!s.includes(h.name)||!1;return{[d.label]:p,key:h.name,[d.value]:h.name,isLeaf:F,loadChildren:F?null:b,field:h,depth:i,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=me(e);return r.jsx(a.Variable.Input,C({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=me(e);return r.jsx(a.Variable.TextArea,C({scope:s},t))}function Zo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=me(e);return r.jsx(a.Variable.RawTextArea,C({scope:s},t))}function Qo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=me(e);return r.jsx(a.Variable.JSON,C({scope:s},t))}function kt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function qe(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return qe(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}function St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function Xo(n){var s=n,{collection:e,dataSource:t}=s,o=q(s,["collection","dataSource"]);const{insert:i}=a.useSchemaInitializer(),{getTemplateSchemaByMode:l}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager(),d=a.useRecordCollectionDataSourceItems("FormItem"),u=c(e);function f(O){return K(this,arguments,function*({item:b}){const h=b.template?yield l(b):null,p={type:"void",name:u.name,title:u.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};St(p,k=>{k["x-uid"]&&delete k["x-uid"]}),i(p)})}return r.jsx(a.SchemaInitializerItem,A(C({},o),{onClick:f,items:d}))}function Ee(){const e=a.useSchemaInitializerItem();return r.jsx(a.CollectionProvider,{collection:e.collection,children:r.jsx(Xo,C({},e))})}function Ro(){return!0}const Ot=V.observer(e=>{const c=e,{filter:t=Ro}=c,o=q(c,["filter"]),n=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager(),{values:i}=V.useForm(),l=s(i==null?void 0:i.collection);return r.jsx(v.Select,A(C({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(d=>{var u;return{label:n((u=d.uiSchema)==null?void 0:u.title),value:d.name}})}))},{displayName:"FieldsSelect"});function Ke({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(a.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ze(e){const s=e,{options:t=[]}=s,o=q(s,["options"]),n=a.useCompile();return r.jsx(v.Radio.Group,A(C({},o),{children:t.map(i=>r.jsxs(v.Radio,{value:i.value,children:[r.jsx("span",{className:a.css`
436
+ & + .anticon {
437
+ margin-left: 0.25em;
438
+ }
439
+ `,children:n(i.label)}),i.tooltip&&r.jsx(v.Tooltip,{title:n(i.tooltip),children:r.jsx(T.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))}))}const Me=()=>null;function en(){const i=a.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=q(i,["node","resultTitle"]),{insert:s}=a.useSchemaInitializer();return r.jsx(a.SchemaInitializerItem,A(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function tn({dataSource:e}){var s;const t=V.useFieldSchema(),{execution:o}=Z();if(!o)return t.title;const n=ae.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((i,l)=>Object.assign(i,{[l.nodeId]:l.result}),{})});return r.jsx("pre",{className:a.css`
440
+ margin: 0;
441
+ `,children:JSON.stringify(n,null,2)})}Me.Initializer=en,Me.Result=tn;function Yt({entry:e}){const{styles:t}=ee(),{workflow:o}=Z(),[n,s]=g.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:a.cx(t.branchBlockClass,a.css`
442
+ margin-top: 0 !important;
443
+ `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(v.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:a.css`
444
+ margin-bottom: 1em;
445
+ `}):null,r.jsx(qo,{}),r.jsx("div",{className:a.cx(t.branchBlockClass,a.css`
446
+ margin-top: 0 !important;
447
+ `),children:r.jsx(Ye,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:E("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(v.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}const Se=e=>`/admin/workflow/workflows/${e}`,At=e=>`/admin/workflow/executions/${e}`;function on(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,i)=>s.id-i.id)})}function nn(){const{instructions:e}=a.usePlugin(ce),t=a.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=ee(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(a.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(v.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function rn(e){const{execution:t}=Z(),o=a.useAPIClient(),n=ie.useNavigate(),{styles:s}=ee(),[i,l]=g.useState([]),[c,d]=g.useState([]);g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[t]);const u=g.useCallback(({key:f})=>{f!=t.id&&n(At(f))},[t]);return t?r.jsx(v.Dropdown,{menu:{onClick:u,defaultSelectedKeys:[`${t.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ae.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(De,{statusMap:He,status:f.status})})}))},children:r.jsxs(v.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(T.DownOutlined,{})]})}):null}function sn(){var p;const e=a.useCompile(),{data:t,loading:o}=a.useResourceActionContext(),{setTitle:n}=a.useDocumentTitle(),[s,i]=g.useState(null),l=a.useApp();if(g.useEffect(()=>{var M;const{workflow:S}=(M=t==null?void 0:t.data)!=null?M:{};n==null||n(`${S!=null&&S.title?`${S.title} - `:""}${E("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?r.jsx(v.Spin,{}):r.jsx(v.Result,{status:"404",title:"Not found"});const k=(p=t==null?void 0:t.data)!=null?p:{},{jobs:c=[],workflow:F={}}=k,D=F,{nodes:d=[],revisions:u=[]}=D,f=q(D,["nodes","revisions"]),b=q(k,["jobs","workflow"]);kt(d),on(d,c);const O=d.find(S=>!S.upstream),h=He[b.status];return r.jsxs(ze.Provider,{value:{workflow:f.type?f:null,nodes:d,execution:b,viewJob:s,setViewJob:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(v.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:l.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(ie.Link,{to:Se(f.id),children:f.title})},{title:r.jsx(rn,{})}]})}),r.jsxs("aside",{children:[r.jsx(v.Tag,{color:h.color,children:e(h.label)}),r.jsx("time",{children:ae.str2moment(b.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Yt,{entry:O}),r.jsx(nn,{})]})}const Gt=()=>{const e=ie.useParams(),{styles:t}=ee();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:sn}})})},_t=()=>{const{t:e}=oe.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext();return r.jsx(ie.Link,{to:At(t),onClick:()=>o(!1),children:e("View")})},ln={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=a.useActionContext();return r.jsx(ie.Link,{to:Se(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Je}}]},qt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:ln,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=oe.useTranslation(),{refresh:t,defaultRequest:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return K(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),v.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${m}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function an(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:i}=Z(),l=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,C({},l))}function cn(){var J;const e=ie.useNavigate(),{t}=oe.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:i}=a.useResourceActionContext(),{resource:l}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[d,u]=g.useState(!1),{styles:f}=ee(),{modal:b}=v.App.useApp();if(g.useEffect(()=>{var N;const{title:x}=(N=n==null?void 0:n.data)!=null?N:{};c==null||c(`${E("Workflow")}${x?`: ${x}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(v.Spin,{}):r.jsx(v.Result,{status:"404",title:"Not found"});const L=(J=n==null?void 0:n.data)!=null?J:{},{nodes:O=[],revisions:h=[]}=L,p=q(L,["nodes","revisions"]);kt(O);const k=O.find(x=>!x.upstream);function F({key:x}){x!=p.id&&e(Se(x))}function D(x){return K(this,null,function*(){yield l.update({filterByTk:p.id,values:{enabled:x}}),s()})}function S(){return K(this,null,function*(){const{data:{data:x}}=yield l.revision({filterByTk:p.id,filter:{key:p.key}});v.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${x.id}`)})}function M(){return K(this,null,function*(){const x=p.current?E("Delete a main version will cause all other revisions to be deleted too."):"";b.confirm({title:t("Are you sure you want to delete it?"),content:x,onOk(){return K(this,null,function*(){var j;yield l.destroy({filterByTk:p.id}),v.message.success(t("Operation succeeded")),e(p.current?o.pluginSettingsManager.getRoutePath("workflow"):Se((j=h.find(I=>I.current))==null?void 0:j.id))})}})})}function z(N){return K(this,arguments,function*({key:x}){switch(x){case"history":u(!0);return;case"revision":return S();case"delete":return M()}})}const H=p.executed&&!h.find(x=>!x.executed&&new Date(x.createdAt)>new Date(p.createdAt));return r.jsxs(ze.Provider,{value:{workflow:p,nodes:O,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(v.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:p.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(v.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${p.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((x,N)=>N.id-x.id).map((x,N)=>({role:"button","aria-label":`version-${N}`,key:`${x.id}`,icon:x.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:x.executed,unexecuted:!x.executed,enabled:x.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${x.id}`}),r.jsx("time",{children:ae.str2moment(x.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(v.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:E("Version")}),r.jsx("span",{children:p!=null&&p.id?`#${p.id}`:null}),r.jsx(T.DownOutlined,{})]})})}),r.jsx(v.Switch,{checked:p.enabled,onChange:D,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(v.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!p.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:E("Copy to new version"),disabled:!H},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(v.Button,{"aria-label":"more",type:"text",icon:r.jsx(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(a.SchemaComponent,{schema:qt,components:{ExecutionResourceProvider:an,ExecutionLink:_t}})})]})]}),r.jsx(Yt,{entry:k})]})}const Kt=()=>{const e=ie.useParams(),{styles:t}=ee();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:cn}})})},dn=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const i=a.useRecord(),l=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,C({},l))},un=()=>{const{t:e}=oe.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext(),{getAriaLabel:n}=a.useGetAriaLabelOfAction("Configure");return r.jsx(ie.Link,{"aria-label":n(),to:Se(t),onClick:()=>o(!1),children:e("Configure")})};function pn(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[i,l]=g.useState(!1),c=V.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[g.createElement(e,A(C({},o),{onClick(){l(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Zt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},mn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Zt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Zt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:he.title,type:he.type,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=a.useRecord();return g.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:qt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:he.title,enabled:he.enabled,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=oe.useTranslation(),{refresh:t}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:i}=a.useRecord(),{values:l}=V.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:i,values:l}),v.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Qt(e){var i;const o=a.useCompile()(e.label),n=g.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(i=He[e.value])!=null?i:{};return r.jsx(v.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function fn(e){const t=a.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Qt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function hn(t){var e=q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(v.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Qt,children:Je.filter(n=>!!n.value&&n.value!==le.ABORTED).map(n=>r.jsx(v.Select.Option,A(C({},n),{children:r.jsx(fn,C({},n))}),n.value))}))}function yn(){const e=g.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(v.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:mn,components:{WorkflowLink:un,ExecutionResourceProvider:dn,ExecutionLink:_t,OpenDrawer:pn,ExecutionStatusSelect:hn},scope:{getTriggersOptions:t}})})})}const ye={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Xt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
396
448
  flex-direction: column;
397
- `},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${u}" })}}`},Te={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=A.useForm();return{options:l.useCollectionFilterOptions(e==null?void 0:e.collection),className:l.css`
449
+ `},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`},Ie={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=V.useForm();return{options:a.useCollectionFilterOptions(e==null?void 0:e.collection),className:a.css`
398
450
  position: relative;
399
451
  width: 100%;
400
- `}},dynamicComponent:"FilterDynamicComponent"}},dn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},un={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},$e={type:"array",title:`{{t("Preload associations", { ns: "${u}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},De={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},pn=[{label:`{{t("After record added", { ns: "${u}" })}}`,value:De.CREATED},{label:`{{t("After record updated", { ns: "${u}" })}}`,value:De.UPDATED},{label:`{{t("After record added or updated", { ns: "${u}" })}}`,value:De.SAVED},{label:`{{t("After record deleted", { ns: "${u}" })}}`,value:De.DELETED}],qo={title:`{{t("Collection event", { ns: "${u}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${u}" })}}`,fieldset:{collection:C(x({},ae),{"x-reactions":[...ae["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${u}" })}}`,className:"auto-width"},enum:pn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${u}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${De.UPDATED})}}`}}}]},condition:C(x({},Te),{title:`{{t("Only triggers when match conditions", { ns: "${u}" })}}`,"x-component-props":{useProps:Te["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(x({},$e),{"x-reactions":[...$e["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${De.DELETED})}}`}}}]})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FieldsSelect:wo},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}}];return he(C(x({appends:["data",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}},Jo={title:`{{t("Form event", { ns: "${u}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${u}" })}}`,fieldset:{collection:C(x({},ae),{title:`{{t("Form data model", { ns: "${u}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${u}" })}}`,"x-reactions":[...ae["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(x({},$e),{title:`{{t("Associations to use", { ns: "${u}" })}}`})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:$("User submitted form")}}];return he(C(x({appends:["data","user",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function mn(){const e=l.useAPIClient(),o=A.useForm(),{field:n,__parent:t}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),i=ue.useNavigate(),a=A.useFieldSchema(),c=A.useField(),d=l.useCompile(),{modal:p}=b.App.useApp(),f=l.useCollectValuesToSubmit(),g=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var O,w,T;const{onSuccess:h,skipValidator:m,triggerWorkflows:k}=(O=a==null?void 0:a["x-action-settings"])!=null?O:{};m||(yield o.submit());const F=yield f();c.data=n.data||{},c.data.loading=!0;try{const P=yield e.resource("workflows").trigger({values:F,filterKeys:g,triggerWorkflows:k!=null&&k.length?k.map(B=>[B.workflowKey,B.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=P,(T=(w=t==null?void 0:t.service)==null?void 0:w.refresh)==null||T.call(w),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:d(h==null?void 0:h.successMessage),onOk:()=>G(this,null,function*(){yield o.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(K.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(P){c.data.loading=!1}})}}}const Fe={STATIC:0,COLLECTION_FIELD:1};function fn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Ho({value:e,onChange:o}){const{t:n}=R.useTranslation(),[t,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:l.css`
452
+ `}},dynamicComponent:"FilterDynamicComponent"}},gn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},bn={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Pe={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=V.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Oe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},xn=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Oe.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Oe.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Oe.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Oe.DELETED}];class vn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);w(this,"type","collection");w(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:A(C({},ye),{"x-reactions":[...ye["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:xn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Oe.UPDATED})}}`}}}]},condition:A(C({},Ie),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{useProps:Ie["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(C({},Pe),{"x-reactions":[...Pe["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Oe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{FieldsSelect:Ot})}useVariables(o,n){var d;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}];return ke(A(C({appends:["data",...((d=o.appends)==null?void 0:d.map(u=>`data.${u}`))||[]]},n),{fields:l,compile:s,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ee,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,COLLECTION_FIELD:1};function wn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Rt({value:e,onChange:t}){const{t:o}=oe.useTranslation(),[n,s]=g.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:a.css`
401
453
  display: flex;
402
454
  gap: 0.5em;
403
- `,children:[r.jsx(wo,{value:e.field,onChange:i=>o(C(x({},e),{field:i})),filter:fn,placeholder:n("Select field")}),e.field?r.jsx(b.Select,{value:t,onChange:i=>{s(i),o(C(x({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:$("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}]}):null,t?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(e.offset),onChange:i=>o(C(x({},e),{offset:(i!=null?i:0)*t}))}),r.jsx(b.Select,{value:e.unit||864e5,onChange:i=>o(C(x({},e),{unit:i})),options:[{value:864e5,label:$("Days")},{value:36e5,label:$("Hours")},{value:6e4,label:$("Minutes")},{value:1e3,label:$("Seconds")}]})]}):null]})}function hn({value:e,onChange:o}){const{t:n}=vo(),t=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:l.css`
455
+ `,children:[r.jsx(Ot,{value:e.field,onChange:i=>t(A(C({},e),{field:i})),filter:wn,placeholder:o("Select field")}),e.field?r.jsx(v.Select,{value:n,onChange:i=>{s(i),t(A(C({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:E("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(v.InputNumber,{value:Math.abs(e.offset),onChange:i=>t(A(C({},e),{offset:(i!=null?i:0)*n}))}),r.jsx(v.Select,{value:e.unit||864e5,onChange:i=>t(A(C({},e),{unit:i})),options:[{value:864e5,label:E("Days")},{value:36e5,label:E("Hours")},{value:6e4,label:E("Minutes")},{value:1e3,label:E("Seconds")}]})]}):null]})}function Cn({value:e,onChange:t}){const{t:o}=ut(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:a.css`
404
456
  display: flex;
405
457
  gap: 0.5em;
406
- `,children:[r.jsxs(b.Select,{value:t,onChange:s=>{o(s?s==="field"?{}:new Date:null)},children:[r.jsx(b.Select.Option,{value:null,children:n("No end")}),r.jsx(b.Select.Option,{value:"field",children:n("By field")}),r.jsx(b.Select.Option,{value:"date",children:n("By custom date")})]}),t==="field"?r.jsx(Ho,{value:e,onChange:o}):null,t==="date"?r.jsx(b.DatePicker,{showTime:!0,value:zo(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var se=function(){return se=Object.assign||function(e){for(var o,n=1,t=arguments.length;n<t;n++)for(var s in o=arguments[n])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},se.apply(this,arguments)};function Go(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(t=Object.getOwnPropertySymbols(e);s<t.length;s++)o.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(e,t[s])&&(n[t[s]]=e[t[s]])}return n}function eo(e,o,n){if(n||arguments.length===2)for(var t,s=0,i=o.length;s<i;s++)!t&&s in o||(t||(t=Array.prototype.slice.call(o,0,s)),t[s]=o[s]);return e.concat(t||Array.prototype.slice.call(o))}var yn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ae=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function _o(e,o){for(var n=[],t=e;t<=o;t++)n.push(t);return n}function oo(e){return e.sort(function(o,n){return o-n}),e}function Yo(e){var o=[];return e.forEach(function(n){o.indexOf(n)<0&&o.push(n)}),o}function de(e){return Object.entries(e).filter(function(o){var n=o[0],t=o[1];return n&&t}).map(function(o){return o[0]}).join(" ")}function Ko(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||V.errorInvalidCron})}function to(e){var o=parseInt(e,10),n=Number(e);return o===n?n:NaN}function Zo(e,o,n,t,s,i,a,c,d,p,f,g,v,h){n&&n(void 0),o(!1);var m=!1;if(!e){if(t==="always"||i&&t==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=yn.find(function(w){return w.name===e});k&&(e=k.value)}try{var F=function(w){if(typeof w!="string")throw new Error("Invalid cron string");var T=w.replace(/\s+/g," ").trim().split(" ");if(T.length===5)return T.map(function(P,B){return function(z,M){if(z==="*"||z==="*/1")return[];var N=oo(Yo(et(function(J,H,_){if(_){J=J.toUpperCase();for(var E=0;E<_.length;E++)J=J.replace(_[E],"".concat(E+H))}return J}(z,M.min,M.alt).split(",").map(function(J){var H,_=J.split("/");if(_.length>2)throw new Error('Invalid value "'.concat(z,' for "').concat(M.type,'"'));var E=_[0],j=_[1];H=E==="*"?_o(M.min,M.max):function(Y,Z,te){var ne=Y.split("-");if(ne.length===1){var _e=to(ne[0]);if(isNaN(_e))throw new Error('Invalid value "'.concat(Z,'" for ').concat(te.type));return[_e]}if(ne.length===2){var ye=to(ne[0]),Be=to(ne[1]);if(isNaN(ye)||isNaN(Be))throw new Error('Invalid value "'.concat(Z,'" for ').concat(te.type));if(Be<ye)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(te.type));return _o(ye,Be)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(te.type))}(E,z,M);var L=function(Y,Z){if(Y!==void 0){var te=to(Y);if(isNaN(te)||te<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(Z.type));return te}}(j,M),ie=function(Y,Z){if(Z){var te=Y[0];Y=Y.filter(function(ne){return ne%Z==te%Z||ne===te})}return Y}(H,L);return ie}).flat(),M))),D=ot(N,M);if(D!==void 0)throw new Error('Value "'.concat(D,'" out of range for ').concat(M.type));return N.length===M.total?[]:N}(P,Ae[B])});throw new Error("Invalid cron string format")}(e),O=function(w){return w[3].length>0?"year":w[2].length>0?"month":w[4].length>0?"week":w[1].length>0?"day":w[0].length>0?"hour":"minute"}(F);h(O),d(F[0]),p(F[1]),f(F[2]),g(F[3]),v(F[4])}catch(w){m=!0}}m&&(s.current=e,o(!0),Ko(n,a))}function Qo(e,o,n,t,s,i,a){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(f,g){var v=Ae[g];return Xo(Ro(f,v),v,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!n?[]:n,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!t?[]:t],a);return c.join(" ")}function Xo(e,o,n,t,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,o)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=a&&function(c,d){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==d)return!1}return!0}(e,a)?function(c,d,p){var f=tt(c),g=nt(c),v=c.length===(g-f)/p+1;return!!(f===d.min&&g+p>d.max&&v)}(e,o,a)?"*/".concat(a):"".concat(Ne(tt(e),o,n,t,s),"-").concat(Ne(nt(e),o,n,t,s),"/").concat(a):function(c){var d=[],p=null;return c.forEach(function(f,g,v){f!==v[g+1]-1?p!==null?(d.push([p,f]),p=null):d.push(f):p===null&&(p=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ne(c[0],o,n,t,s),"-").concat(Ne(c[1],o,n,t,s)):Ne(c,o,n,t,s)}).join(",")}return i}function Ne(e,o,n,t,s){var i=e.toString(),a=o.type,c=o.alt,d=o.min,p=t&&(t===!0||t.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(n&&a==="week-days"||n&&a==="months"?i=c[e-d]:e<10&&(p||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var g=e>=12?"PM":"AM",v=e%12||12;v<10&&p&&(v=v.toString().padStart(2,"0")),i="".concat(v).concat(g)}return i}function Ro(e,o){var n=oo(Yo(et(e,o)));if(n.length===0)return n;var t=ot(n,o);if(t!==void 0)throw new Error('Value "'.concat(t,'" out of range for ').concat(o.type));return n}function et(e,o){return o.type==="week-days"&&(e=e.map(function(n){return n===7?0:n})),e}function ot(e,o){var n=e[0],t=e[e.length-1];return n<o.min?n:t>o.max?t:void 0}function tt(e){return e[0]}function nt(e){return e[e.length-1]}function Ue(e){var o=e.value,n=e.grid,t=n===void 0||n,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,f=e.readOnly,g=e.leadingZero,v=e.clockFormat,h=e.period,m=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,O=Go(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),w=y.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(E){return E.toString()})},[o]),T=y.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):eo([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Ne(L,m,d,g,v)}})},[s,g,d,v]),P=JSON.stringify(a),B=y.useCallback(function(E){var j=E.value;if(!o||o[0]!==Number(j))return r.jsx(r.Fragment,{});var L=Xo(Ro(o,m),m,d,g,v),ie=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ie[1]?"".concat(a.everyText||V.everyText," ").concat(ie[1]):L})},[o,P,d,g,v]),z=y.useCallback(function(E){var j=Array.isArray(E)?oo(E):[E],L=j;o&&(L=F==="single"?[]:eo([],o,!0),j.forEach(function(ie){var Y=Number(ie);L=o.some(function(Z){return Z===Y})?L.filter(function(Z){return Z!==Y}):oo(eo(eo([],L,!0),[Y],!1))})),L.length===m.total?i([]):i(L)},[i,o]),M=y.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ie=m.min;ie<j;ie++)ie%E==0&&L.push(ie);var Y=o&&L&&o.length===L.length&&o.every(function(te,ne){return te===L[ne]}),Z=L.length===T.length;i(Z||Y?[]:L)}else i([])},[o,T,i]),N=y.useRef([]),D=y.useCallback(function(E){if(!f){var j=N.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){k&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?M(Number(E)):z([j[j.length-2].value,j[j.length-1].value]):z(Number(E)),N.current=[]},300);return function(){window.clearTimeout(L)}}},[N,z,M,f,k]),J=y.useCallback(function(){f||i([])},[i,f]),H=y.useMemo(function(){var E;return de(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),_=y.useMemo(function(){var E;return de(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!t,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,t,v,h]);return r.jsx(b.Select,se({mode:F!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:w,onClear:J,tagRender:B,className:H,popupClassName:_,options:T,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:D,onDeselect:D,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},O))}function gn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[t.prefixHours!==""&&r.jsx("span",{children:t.prefixHours||V.prefixHours}),r.jsx(Ue,{placeholder:t.emptyHours||V.emptyHours,value:o,unit:Ae[1],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:g})]}))}function xn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[p==="hour"?t.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):t.prefixMinutes!==""&&r.jsx("span",{children:t.prefixMinutes||V.prefixMinutes}),r.jsx(Ue,{placeholder:p==="hour"?t.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:t.emptyMinutes||V.emptyMinutes,value:o,unit:Ae[0],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:g}),p==="hour"&&t.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function bn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=!i||i.length===0,h=y.useMemo(function(){var F;return de(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),m=JSON.stringify(t),k=y.useMemo(function(){return v?t.emptyMonthDays||V.emptyMonthDays:t.emptyMonthDaysShort||V.emptyMonthDaysShort},[v,m]);return!c||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0)?r.jsxs("div",se({className:h},{children:[t.prefixMonthDays!==""&&r.jsx("span",{children:t.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ue,{placeholder:k,value:o,setValue:n,unit:Ae[2],locale:t,className:s,disabled:a,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function vn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,f=e.mode,g=t.months||V.months,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[t.prefixMonths!==""&&r.jsx("span",{children:t.prefixMonths||V.prefixMonths}),r.jsx(Ue,{placeholder:t.emptyMonths||V.emptyMonths,optionsList:g,grid:!1,value:o,unit:se(se({},Ae[3]),{alt:t.altMonths||V.altMonths}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:f})]}))}function Cn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:t.yearOption||V.yearOption}),d.includes("month")&&p.push({value:"month",label:t.monthOption||V.monthOption}),d.includes("week")&&p.push({value:"week",label:t.weekOption||V.weekOption}),d.includes("day")&&p.push({value:"day",label:t.dayOption||V.dayOption}),d.includes("hour")&&p.push({value:"hour",label:t.hourOption||V.hourOption}),d.includes("minute")&&p.push({value:"minute",label:t.minuteOption||V.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:t.rebootOption||V.rebootOption});var f=y.useCallback(function(m){a||n(m)},[n,a]),g=y.useMemo(function(){var m;return de(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=y.useMemo(function(){var m;return de(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":t.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,t.prefixPeriod]),h=y.useMemo(function(){var m;return de(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",se({className:g},{children:[t.prefixPeriod!==""&&r.jsx("span",{children:t.prefixPeriod||V.prefixPeriod}),r.jsx(b.Select,{defaultValue:o,value:o,onChange:f,options:p,className:v,popupClassName:h,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(t))]}))}function wn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=t.weekDays||V.weekDays,h=p==="week"||!a||a.length===0,m=y.useMemo(function(){var T;return de(((T={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,T["".concat(s,"-week-days")]=!!s,T))},[s,h]),k=JSON.stringify(t),F=y.useMemo(function(){return h?t.emptyWeekDays||V.emptyWeekDays:t.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,k]),O=p==="week"||!d||o&&o.length>0||(!o||o.length===0)&&(!a||a.length===0),w=!d||a&&a.length>0||(!a||a.length===0)&&(!o||o.length===0);return O?r.jsxs("div",se({className:m},{children:[t.prefixWeekDays!==""&&(p==="week"||!w)&&r.jsx("span",{children:t.prefixWeekDays||V.prefixWeekDays}),t.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&w&&r.jsx("span",{children:t.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ue,{placeholder:F,optionsList:v,grid:!1,value:o,unit:se(se({},Ae[4]),{alt:t.altWeekDays||V.altWeekDays}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function kn(e){var o=e.clearButton,n=o===void 0||o,t=e.clearButtonProps,s=t===void 0?{}:t,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?V:c,p=e.value,f=p===void 0?"":p,g=e.setValue,v=e.displayError,h=v===void 0||v,m=e.onError,k=e.className,F=e.defaultPeriod,O=F===void 0?"day":F,w=e.allowEmpty,T=w===void 0?"for-default-value":w,P=e.humanizeLabels,B=P===void 0||P,z=e.humanizeValue,M=z!==void 0&&z,N=e.disabled,D=N!==void 0&&N,J=e.readOnly,H=J!==void 0&&J,_=e.leadingZero,E=_!==void 0&&_,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ie=e.clockFormat,Y=e.periodicityOnDoubleClick,Z=Y===void 0||Y,te=e.mode,ne=te===void 0?"multiple":te,_e=e.allowedDropdowns,ye=_e===void 0?["period","months","month-days","week-days","hours","minutes"]:_e,Be=e.allowedPeriods,ks=Be===void 0?["year","month","week","day","hour","minute","reboot"]:Be,Ve=y.useRef(f),Po=y.useRef(O),zt=y.useState(),xe=zt[0],lo=zt[1],Lt=y.useState(),Ye=Lt[0],ao=Lt[1],Wt=y.useState(),co=Wt[0],uo=Wt[1],Ut=y.useState(),Ke=Ut[0],po=Ut[1],qt=y.useState(),mo=qt[0],fo=qt[1],Jt=y.useState(),ho=Jt[0],yo=Jt[1],Ht=y.useState(!1),Bo=Ht[0],Ze=Ht[1],Gt=y.useState(!1),go=Gt[0],_t=Gt[1],Ss=function(Q){var ge=y.useRef(Q);return y.useEffect(function(){ge.current=Q},[Q]),ge.current}(go),Yt=JSON.stringify(d);y.useEffect(function(){Zo(f,Ze,m,T,Ve,!0,d,L,yo,fo,ao,uo,po,lo)},[]),y.useEffect(function(){f!==Ve.current&&Zo(f,Ze,m,T,Ve,!1,d,L,yo,fo,ao,uo,po,lo)},[f,Ve,Yt,T,L]),y.useEffect(function(){if(!(xe||ho||co||Ye||Ke||mo)||go||Ss)go&&_t(!1);else{var Q=xe||Po.current,ge=Qo(Q,co,Ye,Ke,mo,ho,M);g(ge,{selectedPeriod:Q}),Ve.current=ge,m&&m(void 0),Ze(!1)}},[xe,Ye,co,Ke,mo,ho,M,go]);var Kt=y.useCallback(function(){ao(void 0),uo(void 0),po(void 0),fo(void 0),yo(void 0);var Q="",ge=xe!=="reboot"&&xe?xe:Po.current;ge!==xe&&lo(ge),a==="fill-with-every"&&(Q=Qo(ge,void 0,void 0,void 0,void 0,void 0)),g(Q,{selectedPeriod:ge}),Ve.current=Q,_t(!0),T==="never"&&a==="empty"?(Ze(!0),Ko(m,d)):(m&&m(void 0),Ze(!1))},[xe,g,m,a]),Fs=y.useMemo(function(){var Q;return de(((Q={"react-js-cron":!0,"react-js-cron-error":Bo&&h,"react-js-cron-disabled":D,"react-js-cron-read-only":H})["".concat(k)]=!!k,Q["".concat(k,"-error")]=Bo&&h&&!!k,Q["".concat(k,"-disabled")]=D&&!!k,Q["".concat(k,"-read-only")]=H&&!!k,Q))},[k,Bo,h,D,H]),Vo=s.className,Zt=Go(s,["className"]),Qt=y.useMemo(function(){var Q;return de(((Q={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,Q["".concat(Vo)]=!!Vo,Q))},[k,Vo]),As=JSON.stringify(Zt),Xt=y.useMemo(function(){return n&&!H?r.jsx(b.Button,se({className:Qt,danger:!0,type:"primary",disabled:D},Zt,{onClick:Kt},{children:d.clearButtonText||V.clearButtonText})):null},[n,H,Yt,Qt,D,As,Kt]),re=xe||Po.current;return r.jsxs("div",se({className:Fs},{children:[ye.includes("period")&&r.jsx(Cn,{value:re,setValue:lo,locale:d,className:k,disabled:D,readOnly:H,shortcuts:L,allowedPeriods:ks}),re==="reboot"?Xt:r.jsxs(r.Fragment,{children:[re==="year"&&ye.includes("months")&&r.jsx(vn,{value:co,setValue:uo,locale:d,className:k,humanizeLabels:B,disabled:D,readOnly:H,period:re,periodicityOnDoubleClick:Z,mode:ne}),(re==="year"||re==="month")&&ye.includes("month-days")&&r.jsx(bn,{value:Ye,setValue:ao,locale:d,className:k,weekDays:Ke,disabled:D,readOnly:H,leadingZero:E,period:re,periodicityOnDoubleClick:Z,mode:ne}),(re==="year"||re==="month"||re==="week")&&ye.includes("week-days")&&r.jsx(wn,{value:Ke,setValue:po,locale:d,className:k,humanizeLabels:B,monthDays:Ye,disabled:D,readOnly:H,period:re,periodicityOnDoubleClick:Z,mode:ne}),r.jsxs("div",{children:[re!=="minute"&&re!=="hour"&&ye.includes("hours")&&r.jsx(gn,{value:mo,setValue:fo,locale:d,className:k,disabled:D,readOnly:H,leadingZero:E,clockFormat:ie,period:re,periodicityOnDoubleClick:Z,mode:ne}),re!=="minute"&&ye.includes("minutes")&&r.jsx(xn,{value:ho,setValue:yo,locale:d,period:re,className:k,disabled:D,readOnly:H,leadingZero:E,clockFormat:ie,periodicityOnDoubleClick:Z,mode:ne}),Xt]})]})]}))}const Sn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},rt=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function st(e){return rt.filter(n=>typeof n.value=="number").reverse().find(n=>!(e%n.value))}function Fn(e){let o;switch(typeof e){case"number":return o=st(e),o?o.value:"none";case"string":return"cron"}return"none"}function An({value:e,onChange:o}){const{t:n}=vo(),t=st(e);return r.jsx(b.InputNumber,{value:e/t.value,onChange:s=>o(s*t.value),min:1,addonBefore:n("Every"),addonAfter:n(t.unitText),className:"auto-width"})}function On({value:e=null,onChange:o}){const{t:n}=vo(),t=Fn(e);function s(a){if(a==="none"){o(null);return}if(a==="cron"){o("0 * * * * *");return}o(a)}const i=Sn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:l.css`
458
+ `,children:[r.jsxs(v.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(v.Select.Option,{value:null,children:o("No end")}),r.jsx(v.Select.Option,{value:"field",children:o("By field")}),r.jsx(v.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Rt,{value:e,onChange:t}):null,n==="date"?r.jsx(v.DatePicker,{showTime:!0,value:Bo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var te=function(){return te=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},te.apply(this,arguments)};function eo(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,i=t.length;s<i;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var kn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],ve=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],P={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function to(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function oo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function se(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function no(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||P.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function ro(e,t,o,n,s,i,l,c,d,u,f,b,O,h){o&&o(void 0),t(!1);var p=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;p=!0}if(!p){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=kn.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var M=S.replace(/\s+/g," ").trim().split(" ");if(M.length===5)return M.map(function(z,H){return function(J,L){if(J==="*"||J==="*/1")return[];var x=Xe(oo(ao(function(j,I,ne){if(ne){j=j.toUpperCase();for(var $=0;$<ne.length;$++)j=j.replace(ne[$],"".concat($+I))}return j}(J,L.min,L.alt).split(",").map(function(j){var I,ne=j.split("/");if(ne.length>2)throw new Error('Invalid value "'.concat(J,' for "').concat(L.type,'"'));var $=ne[0],B=ne[1];I=$==="*"?to(L.min,L.max):function(U,Y,Q){var X=U.split("-");if(X.length===1){var Ve=Re(X[0]);if(isNaN(Ve))throw new Error('Invalid value "'.concat(Y,'" for ').concat(Q.type));return[Ve]}if(X.length===2){var de=Re(X[0]),Te=Re(X[1]);if(isNaN(de)||isNaN(Te))throw new Error('Invalid value "'.concat(Y,'" for ').concat(Q.type));if(Te<de)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(Q.type));return to(de,Te)}throw new Error('Invalid value "'.concat(U,'" for ').concat(Q.type))}($,J,L);var W=function(U,Y){if(U!==void 0){var Q=Re(U);if(isNaN(Q)||Q<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return Q}}(B,L),re=function(U,Y){if(Y){var Q=U[0];U=U.filter(function(X){return X%Y==Q%Y||X===Q})}return U}(I,W);return re}).flat(),L))),N=co(x,L);if(N!==void 0)throw new Error('Value "'.concat(N,'" out of range for ').concat(L.type));return x.length===L.total?[]:x}(z,ve[H])});throw new Error("Invalid cron string format")}(e),D=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);h(D),d(F[0]),u(F[1]),f(F[2]),b(F[3]),O(F[4])}catch(S){p=!0}}p&&(s.current=e,t(!0),no(o,l))}function so(e,t,o,n,s,i,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(f,b){var O=ve[b];return io(lo(f,O),O,u)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function io(e,t,o,n,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=l&&function(c,d){for(var u=1;u<c.length;u++){var f=c[u-1];if(c[u]-f!==d)return!1}return!0}(e,l)?function(c,d,u){var f=uo(c),b=po(c),O=c.length===(b-f)/u+1;return!!(f===d.min&&b+u>d.max&&O)}(e,t,l)?"*/".concat(l):"".concat(Ae(uo(e),t,o,n,s),"-").concat(Ae(po(e),t,o,n,s),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(f,b,O){f!==O[b+1]-1?u!==null?(d.push([u,f]),u=null):d.push(f):u===null&&(u=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ae(c[0],t,o,n,s),"-").concat(Ae(c[1],t,o,n,s)):Ae(c,t,o,n,s)}).join(",")}return i}function Ae(e,t,o,n,s){var i=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=c[e-d]:e<10&&(u||f)&&(i=i.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var b=e>=12?"PM":"AM",O=e%12||12;O<10&&u&&(O=O.toString().padStart(2,"0")),i="".concat(O).concat(b)}return i}function lo(e,t){var o=Xe(oo(ao(e,t)));if(o.length===0)return o;var n=co(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function ao(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function co(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function uo(e){return e[0]}function po(e){return e[e.length-1]}function Be(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,i=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,f=e.readOnly,b=e.leadingZero,O=e.clockFormat,h=e.period,p=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,D=eo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=g.useMemo(function(){if(t&&Array.isArray(t))return t.map(function($){return $.toString()})},[t]),M=g.useMemo(function(){return s?s.map(function($,B){return{value:(p.min===0?B:B+1).toString(),label:$}}):Qe([],Array(p.total),!0).map(function($,B){var W=p.min===0?B:B+1;return{value:W.toString(),label:Ae(W,p,d,b,O)}})},[s,b,d,O]),z=JSON.stringify(l),H=g.useCallback(function($){var B=$.value;if(!t||t[0]!==Number(B))return r.jsx(r.Fragment,{});var W=io(lo(t,p),p,d,b,O),re=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:re[1]?"".concat(l.everyText||P.everyText," ").concat(re[1]):W})},[t,z,d,b,O]),J=g.useCallback(function($){var B=Array.isArray($)?Xe($):[$],W=B;t&&(W=F==="single"?[]:Qe([],t,!0),B.forEach(function(re){var U=Number(re);W=t.some(function(Y){return Y===U})?W.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],W,!0),[U],!1))})),W.length===p.total?i([]):i(W)},[i,t]),L=g.useCallback(function($){if($!==0&&$!==1){for(var B=p.total+p.min,W=[],re=p.min;re<B;re++)re%$==0&&W.push(re);var U=t&&W&&t.length===W.length&&t.every(function(Q,X){return Q===W[X]}),Y=W.length===M.length;i(Y||U?[]:W)}else i([])},[t,M,i]),x=g.useRef([]),N=g.useCallback(function($){if(!f){var B=x.current;B.push({time:new Date().getTime(),value:Number($)});var W=window.setTimeout(function(){k&&B.length>1&&B[B.length-1].time-B[B.length-2].time<300?B[B.length-1].value===B[B.length-2].value?L(Number($)):J([B[B.length-2].value,B[B.length-1].value]):J(Number($)),x.current=[]},300);return function(){window.clearTimeout(W)}}},[x,J,L,f,k]),j=g.useCallback(function(){f||i([])},[i,f]),I=g.useMemo(function(){var $;return se((($={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,$))},[c]),ne=g.useMemo(function(){var $;return se((($={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(p.type)]=!0,$["react-js-cron-custom-select-dropdown"]=!0,$["react-js-cron-custom-select-dropdown-".concat(p.type)]=!0,$["react-js-cron-custom-select-dropdown-minutes-large"]=p.type==="minutes"&&h!=="hour"&&h!=="day",$["react-js-cron-custom-select-dropdown-minutes-medium"]=p.type==="minutes"&&(h==="day"||h==="hour"),$["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=p.type==="hours"&&O==="12-hour-clock",$["react-js-cron-custom-select-dropdown-grid"]=!!n,$["".concat(c,"-select-dropdown")]=!!c,$["".concat(c,"-select-dropdown-").concat(p.type)]=!!c,$))},[c,n,O,h]);return r.jsx(v.Select,te({mode:F!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:j,tagRender:H,className:I,popupClassName:ne,options:M,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:N,onDeselect:N,disabled:u,dropdownAlign:p.type!=="minutes"&&p.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(p.type)},D))}function Sn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,b=e.mode,O=g.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",te({className:O},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||P.prefixHours}),r.jsx(Be,{placeholder:n.emptyHours||P.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:b})]}))}function On(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,b=e.mode,O=g.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",te({className:O},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||P.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||P.prefixMinutes}),r.jsx(Be,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||P.emptyMinutesForHourPeriod:n.emptyMinutes||P.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:b}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||P.suffixMinutesForHourPeriod})]}))}function An(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,f=e.periodicityOnDoubleClick,b=e.mode,O=!i||i.length===0,h=g.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!O})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,O]),p=JSON.stringify(n),k=g.useMemo(function(){return O?n.emptyMonthDays||P.emptyMonthDays:n.emptyMonthDaysShort||P.emptyMonthDaysShort},[O,p]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",te({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||P.prefixMonthDays}),r.jsx(Be,{placeholder:k,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:f,mode:b})]})):null}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,b=n.months||P.months,O=g.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",te({className:O},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||P.prefixMonths}),r.jsx(Be,{placeholder:n.emptyMonths||P.emptyMonths,optionsList:b,grid:!1,value:t,unit:te(te({},ve[3]),{alt:n.altMonths||P.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:f})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||P.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||P.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||P.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||P.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||P.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||P.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||P.rebootOption});var f=g.useCallback(function(p){l||o(p)},[o,l]),b=g.useMemo(function(){var p;return se(((p={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,p["".concat(s,"-period")]=!!s,p))},[s]),O=g.useMemo(function(){var p;return se(((p={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,p))},[s,n.prefixPeriod]),h=g.useMemo(function(){var p;return se(((p={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,p["".concat(s,"-select-dropdown-period")]=!!s,p))},[s]);return r.jsxs("div",te({className:b},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||P.prefixPeriod}),r.jsx(v.Select,{defaultValue:t,value:t,onChange:f,options:u,className:O,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,f=e.periodicityOnDoubleClick,b=e.mode,O=n.weekDays||P.weekDays,h=u==="week"||!l||l.length===0,p=g.useMemo(function(){var M;return se(((M={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,M["".concat(s,"-week-days")]=!!s,M))},[s,h]),k=JSON.stringify(n),F=g.useMemo(function(){return h?n.emptyWeekDays||P.emptyWeekDays:n.emptyWeekDaysShort||P.emptyWeekDaysShort},[h,k]),D=u==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return D?r.jsxs("div",te({className:p},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||P.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||P.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Be,{placeholder:F,optionsList:O,grid:!1,value:t,unit:te(te({},ve[4]),{alt:n.altWeekDays||P.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:f,mode:b})]})):null}function Dn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?P:c,u=e.value,f=u===void 0?"":u,b=e.setValue,O=e.displayError,h=O===void 0||O,p=e.onError,k=e.className,F=e.defaultPeriod,D=F===void 0?"day":F,S=e.allowEmpty,M=S===void 0?"for-default-value":S,z=e.humanizeLabels,H=z===void 0||z,J=e.humanizeValue,L=J!==void 0&&J,x=e.disabled,N=x!==void 0&&x,j=e.readOnly,I=j!==void 0&&j,ne=e.leadingZero,$=ne!==void 0&&ne,B=e.shortcuts,W=B===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:B,re=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,Q=e.mode,X=Q===void 0?"multiple":Q,Ve=e.allowedDropdowns,de=Ve===void 0?["period","months","month-days","week-days","hours","minutes"]:Ve,Te=e.allowedPeriods,Xn=Te===void 0?["year","month","week","day","hour","minute","reboot"]:Te,Fe=g.useRef(f),Tt=g.useRef(D),xo=g.useState(),fe=xo[0],et=xo[1],vo=g.useState(),je=vo[0],tt=vo[1],wo=g.useState(),ot=wo[0],nt=wo[1],Co=g.useState(),Le=Co[0],rt=Co[1],ko=g.useState(),st=ko[0],it=ko[1],So=g.useState(),lt=So[0],at=So[1],Oo=g.useState(!1),Ft=Oo[0],We=Oo[1],Ao=g.useState(!1),ct=Ao[0],To=Ao[1],Rn=function(G){var ue=g.useRef(G);return g.useEffect(function(){ue.current=G},[G]),ue.current}(ct),Fo=JSON.stringify(d);g.useEffect(function(){ro(f,We,p,M,Fe,!0,d,W,at,it,tt,nt,rt,et)},[]),g.useEffect(function(){f!==Fe.current&&ro(f,We,p,M,Fe,!1,d,W,at,it,tt,nt,rt,et)},[f,Fe,Fo,M,W]),g.useEffect(function(){if(!(fe||lt||ot||je||Le||st)||ct||Rn)ct&&To(!1);else{var G=fe||Tt.current,ue=so(G,ot,je,Le,st,lt,L);b(ue,{selectedPeriod:G}),Fe.current=ue,p&&p(void 0),We(!1)}},[fe,je,ot,Le,st,lt,L,ct]);var $o=g.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),it(void 0),at(void 0);var G="",ue=fe!=="reboot"&&fe?fe:Tt.current;ue!==fe&&et(ue),l==="fill-with-every"&&(G=so(ue,void 0,void 0,void 0,void 0,void 0)),b(G,{selectedPeriod:ue}),Fe.current=G,To(!0),M==="never"&&l==="empty"?(We(!0),no(p,d)):(p&&p(void 0),We(!1))},[fe,b,p,l]),er=g.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":N,"react-js-cron-read-only":I})["".concat(k)]=!!k,G["".concat(k,"-error")]=Ft&&h&&!!k,G["".concat(k,"-disabled")]=N&&!!k,G["".concat(k,"-read-only")]=I&&!!k,G))},[k,Ft,h,N,I]),$t=s.className,Do=eo(s,["className"]),No=g.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,G["".concat($t)]=!!$t,G))},[k,$t]),tr=JSON.stringify(Do),Eo=g.useMemo(function(){return o&&!I?r.jsx(v.Button,te({className:No,danger:!0,type:"primary",disabled:N},Do,{onClick:$o},{children:d.clearButtonText||P.clearButtonText})):null},[o,I,Fo,No,N,tr,$o]),R=fe||Tt.current;return r.jsxs("div",te({className:er},{children:[de.includes("period")&&r.jsx(Fn,{value:R,setValue:et,locale:d,className:k,disabled:N,readOnly:I,shortcuts:W,allowedPeriods:Xn}),R==="reboot"?Eo:r.jsxs(r.Fragment,{children:[R==="year"&&de.includes("months")&&r.jsx(Tn,{value:ot,setValue:nt,locale:d,className:k,humanizeLabels:H,disabled:N,readOnly:I,period:R,periodicityOnDoubleClick:Y,mode:X}),(R==="year"||R==="month")&&de.includes("month-days")&&r.jsx(An,{value:je,setValue:tt,locale:d,className:k,weekDays:Le,disabled:N,readOnly:I,leadingZero:$,period:R,periodicityOnDoubleClick:Y,mode:X}),(R==="year"||R==="month"||R==="week")&&de.includes("week-days")&&r.jsx($n,{value:Le,setValue:rt,locale:d,className:k,humanizeLabels:H,monthDays:je,disabled:N,readOnly:I,period:R,periodicityOnDoubleClick:Y,mode:X}),r.jsxs("div",{children:[R!=="minute"&&R!=="hour"&&de.includes("hours")&&r.jsx(Sn,{value:st,setValue:it,locale:d,className:k,disabled:N,readOnly:I,leadingZero:$,clockFormat:re,period:R,periodicityOnDoubleClick:Y,mode:X}),R!=="minute"&&de.includes("minutes")&&r.jsx(On,{value:lt,setValue:at,locale:d,period:R,className:k,disabled:N,readOnly:I,leadingZero:$,clockFormat:re,periodicityOnDoubleClick:Y,mode:X}),Eo]})]})]}))}const Nn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},mo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function fo(e){return mo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function En(e){let t;switch(typeof e){case"number":return t=fo(e),t?t.value:"none";case"string":return"cron"}return"none"}function Mn({value:e,onChange:t}){const{t:o}=ut(),n=fo(e);return r.jsx(v.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function In({value:e=null,onChange:t}){const{t:o}=ut(),n=En(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=Nn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
407
459
  display: flex;
408
- flex-direction: ${t==="cron"?"column":"row"};
460
+ flex-direction: ${n==="cron"?"column":"row"};
409
461
  align-items: flex-start;
410
462
  gap: 0.5em;
411
463
 
@@ -432,7 +484,7 @@
432
484
  }
433
485
  }
434
486
  }
435
- `,children:[r.jsx(b.Select,{value:t,onChange:s,className:"auto-width",children:rt.map(a=>r.jsx(b.Select.Option,{value:a.value,children:n(a.text)},a.value))}),typeof t=="number"?r.jsx(An,{value:e,onChange:o}):null,t==="cron"?r.jsx(kn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:a=>o(`0 ${a}`),clearButton:!1,locale:i}):null]})}const In={[Fe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}}},[Fe.COLLECTION_FIELD]:{collection:C(x({},ae),{"x-reactions":[...ae["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}},appends:C(x({},$e),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Fe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Tn=[{value:Fe.STATIC,label:`{{t("Based on certain date", { ns: "${u}" })}}`},{value:Fe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${u}" })}}`}],$n=()=>{const{values:e={},clearFormGraph:o}=A.useForm(),[n,t]=y.useState(e.mode);return A.useFormEffects(()=>{le.onFieldValueChange("mode",s=>{t(s.value),o("collection"),o("startsOn"),o("repeat"),o("endsOn"),o("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${u}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Tn},required:!0,default:Fe.STATIC}}),r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${n}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
487
+ `,children:[r.jsx(v.Select,{value:n,onChange:s,className:"auto-width",children:mo.map(l=>r.jsx(v.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Mn,{value:e,onChange:t}):null,n==="cron"?r.jsx(Dn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Pn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[xe.COLLECTION_FIELD]:{collection:A(C({},ye),{"x-reactions":[...ye["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:A(C({},Pe),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Bn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:xe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Vn=()=>{const{values:e={},clearFormGraph:t}=V.useForm(),[o,n]=g.useState(e.mode);return V.useFormEffects(()=>{ge.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(a.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Bn},required:!0,default:xe.STATIC}}),r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
436
488
  .ant-input-number {
437
489
  width: auto;
438
490
  min-width: 6em;
@@ -441,37 +493,23 @@
441
493
  .ant-picker {
442
494
  width: auto;
443
495
  }
444
- `},properties:In[n]}}},components:{OnField:Ho,RepeatField:On,EndsByField:hn}})]})},it={title:`{{t("Schedule event", { ns: "${u}" })}}`,type:"schedule",description:`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${u}" })}}`,fieldset:{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{ScheduleConfig:$n},useVariables(e,o){var i;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&s.push({key:"date",value:"date",label:$("Trigger time")}),e.mode===Fe.COLLECTION_FIELD){const[a]=he(C(x({appends:["data",...((i=e.appends)==null?void 0:i.map(c=>`data.${c}`))||[]]},o),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}}],compile:n,getCollectionFields:t}));a&&s.push(a)}return s},useInitializers(e){return e.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Dn(){var i;const e=A.useForm(),o=l.useAPIClient(),{workflow:n}=(i=U())!=null?i:{},t=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return G(this,null,function*(){var c,d;if(n.executed){b.message.error($("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("workflows")).update)==null?void 0:d.call(c,{filterByTk:n.id,values:{config:e.values}}),t.setFormValueChanged(!1),t.setVisible(!1),s()})}}}const me=new K.Registry;me.register(Jo.type,Jo),me.register(qo.type,qo),me.register(it.type,it);function Nn(){const e=l.useCompile(),{workflow:o,execution:n}=U(),{styles:t}=oe();if(!n)return null;const s=me.get(o.type);return r.jsx(l.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(I.InfoOutlined,{}),shape:"circle",size:"small",className:t.nodeJobButtonClass,type:"primary"},properties:{[n.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:n},"x-component":"Action.Modal",title:r.jsxs("div",{className:l.cx(t.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(s.title)}),r.jsx("strong",{children:o.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",n.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
445
- padding: 1em;
446
- background-color: #eee;
447
- `},"x-read-pretty":!0}}}}}})}function Mn(){return{form:A.useForm()}}const En=()=>{const e=l.useAPIClient(),{workflow:o,refresh:n}=U(),[t,s]=y.useState(""),[i,a]=y.useState(!1),[c,d]=y.useState(!1),{styles:p}=oe(),f=l.useCompile(),{title:g,type:v,executed:h}=o,m=me.get(v),k=f(m.title),{fieldset:F,scope:O,components:w}=m,T=h?'{{t("View")}}':'{{t("Configure")}}',P=$("Trigger");y.useEffect(()=>{var D;o&&s((D=o.title)!=null?D:k)},[o]);const B=y.useMemo(()=>{const D=fe.cloneDeep(o==null?void 0:o.config);return le.createForm({initialValues:D,disabled:o==null?void 0:o.executed})},[o]),z=y.useCallback(D=>{a(D),D||B.reset()},[B]),M=y.useCallback(function(D){return G(this,null,function*(){var H,_;const J=D||k;s(J),J!==g&&(yield(_=(H=e.resource("workflows")).update)==null?void 0:_.call(H,{filterByTk:o.id,values:{title:J}}),n())})},[o]),N=y.useCallback(function(D){var H;if(D.target===D.currentTarget){a(!0);return}const J=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let _=D.target;_&&_!==D.currentTarget;_=_.parentNode)if(Array.from((H=_.classList)!=null?H:[]).some(E=>J.has(E))){a(!0),D.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${P}-${t}`,className:l.cx(p.nodeCardClass),onClick:N,children:[r.jsx("div",{className:l.cx(p.nodeMetaClass,"workflow-node-meta"),children:r.jsx(b.Tag,{color:"gold",children:P})}),r.jsx("div",{children:r.jsx(b.Input.TextArea,{value:t,onChange:D=>s(D.target.value),onBlur:D=>M(D.target.value),autoSize:!0})}),r.jsx(Nn,{}),r.jsx(l.ActionContextProvider,{value:{visible:i,setVisible:z,formValueChanged:c,setFormValueChanged:d},children:r.jsx(l.FormProvider,{form:B,children:r.jsx(l.SchemaComponent,{scope:C(x({},O),{useFormProviderProps:Mn}),components:w,schema:{name:`workflow-trigger-${o.id}`,type:"void",properties:{config:{type:"void","x-content":T,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:P,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:C(x({},m.description?{description:{type:"void","x-component":Lo,"x-component-props":{label:$("Trigger type"),title:m.title,description:m.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
448
- .ant-select.auto-width {
449
- width: auto;
450
- min-width: 6em;
451
- }
452
- `},properties:F},actions:x({},h?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Dn}}}})})}}}})})})]})};function lt(){const{workflow:e}=U();return me.get(e.type)}function So(){return Array.from(me.getEntities()).map(t=>{var[e,s]=t,i=s,{title:o}=i,n=W(i,["title"]);return{value:e,label:o,color:"gold",options:n}})}const Ce={label:"label",value:"value",children:"children"},no={label:`{{t("Node result", { ns: "${u}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const o=ke(),n=He(o),t=[];return n.forEach(s=>{var c;const i=q.get(s.type),a=(c=i.useVariables)==null?void 0:c.call(i,s,e);a&&t.push(a)}),t}},ro={label:`{{t("Trigger variables", { ns: "${u}" })}}`,value:"$context",useOptions(e){var t,s;const{workflow:o}=U(),n=me.get(o.type);return(s=(t=n==null?void 0:n.useVariables)==null?void 0:t.call(n,o.config,e))!=null?s:null}},Fo={label:`{{t("Scope variables", { ns: "${u}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:o=Ce,current:n}=e,t=ke(),s=n!=null?n:t,i=At(s),a=[];return i.forEach(c=>{var f,g;const d=q.get(c.type),p=(f=d.useScopeVariables)==null?void 0:f.call(d,c,e);p&&a.push({key:c.key,[o.value]:c.key,[o.label]:(g=c.title)!=null?g:`#${c.id}`,[o.children]:p})}),a}},at={label:`{{t("System variables", { ns: "${u}" })}}`,value:"$system",useOptions({types:e,fieldNames:o=Ce}){return[...!e||e.includes("date")?[{key:"now",[o.label]:$("System time"),[o.value]:"now"}]:[]]}},Me={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function ct(e,o){var t,s,i,a,c,d;const n=typeof o;return n==="string"?(t=Me[o])==null?void 0:t.has(e.interface):n==="object"&&o.type==="reference"?Ao(e)?((s=o.options)==null?void 0:s.entity)&&(e.collectionName===((i=o.options)==null?void 0:i.collection)||((a=o.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((c=o.options)==null?void 0:c.collection)&&e.name==="id"||e.target===((d=o.options)==null?void 0:d.collection):!1:n==="function"?o(e):!1}function Ao(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Oo(e,o){if(o==null)return null;const n=`${e.name}.`;return o.filter(t=>t.startsWith(n)).map(t=>t.replace(n,""))}function Io({fields:e,types:o,appends:n,depth:t=1,compile:s,getCollectionFields:i}){return e.filter(a=>{const c=o!=null&&o.length?o.some(d=>ct(a,d)):!0;if(Ao(a)){if(n===null)return t?c||Io({fields:To(a.target,{compile:s,getCollectionFields:i}),types:o,depth:t-1,appends:n,compile:s,getCollectionFields:i}):!1;const d=Oo(a,n),p=n.includes(a.name);return c?p:((d==null?void 0:d.length)||p)&&Io({fields:To(a.target,{compile:s,getCollectionFields:i}),types:o,appends:d,compile:s,getCollectionFields:i}).length}else return c})}function so(e,o){var i,a;const n=l.useCompile(),t=(a=(i=e.useOptions)==null?void 0:i.call(e,o))==null?void 0:a.filter(Boolean),{fieldNames:s}=o;return{[s.label]:n(e.label),[s.value]:e.value,key:e[s.value],[s.children]:t,disabled:!t||!t.length}}function ce(e={}){var s;const o=Object.assign({},Ce,(s=e.fieldNames)!=null?s:{}),n=Object.assign(e,{fieldNames:o});return[so(Fo,n),so(no,n),so(ro,n),so(at,n)]}function To(e,{compile:o,getCollectionFields:n}){var a,c,d,p,f,g,v;const t=n(e),s=[],i=[];t.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const m=i[h];if(m.type==="belongsTo"){const k=s.find(F=>F.name===m.foreignKey);k?i.splice(h,0,C(x(x({},m),k),{uiSchema:C(x({},m.uiSchema),{title:(a=m.uiSchema)!=null&&a.title?`${o((c=m.uiSchema)==null?void 0:c.title)} ID`:k.name})})):i.splice(h,0,C(x({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:C(x({},m.uiSchema),{title:(d=m.uiSchema)!=null&&d.title?`${o((p=m.uiSchema)==null?void 0:p.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const k=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};i.splice(h,0,C(x({},m),{type:m.dataType,interface:k.interface,uiSchema:C(x({},k.uiSchema),{title:(g=k.uiSchema)!=null&&g.title?`${o((v=k.uiSchema)==null?void 0:v.title)} ID`:m.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Pn(e){const o=Oo(e.field,e.appends),n=he(x({collection:e.field.target,types:e.types,appends:o,depth:e.depth-1},this));e.loadChildren=null,n.length?e.children=n:(e.isLeaf=!0,!e.types||e.types.some(s=>ct(e.field,s))||(e.disabled=!0))}function he(e){const{fields:o,collection:n,types:t,appends:s=[],depth:i=1,compile:a,getCollectionFields:c,fieldNames:d=Ce}=e,p=To(n,{compile:a,getCollectionFields:c}),f=o!=null?o:p,g=Pn.bind({compile:a,getCollectionFields:c,fieldNames:d});return Io({fields:f,types:t,depth:i,appends:s,compile:a,getCollectionFields:c}).map(h=>{var O;const m=a(((O=h.uiSchema)==null?void 0:O.title)||h.name),k=Oo(h,s),F=!Ao(h)||k&&!k.length&&!s.includes(h.name)||!1;return{[d.label]:m,key:h.name,[d.value]:h.name,isLeaf:F,loadChildren:F?null:g,field:h,depth:i,appends:s,types:t}})}function qe(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.Input,x({scope:s},o))}function dt(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.TextArea,x({scope:s},o))}function ut(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.RawTextArea,x({scope:s},o))}function pt(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.JSON,x({scope:s},o))}function Je({value:e,onChange:o,renderSchemaComponent:n}){const t=ce();return r.jsx(l.Variable.Input,{value:e,onChange:o,scope:t,children:n()})}const Ee=()=>null;function Bn(){const i=l.useSchemaInitializerItem(),{node:o,resultTitle:n}=i,t=W(i,["node","resultTitle"]),{insert:s}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({},t),{onClick:()=>{var a;s({type:"void",name:o.id,title:o.title,"x-component":"CardItem","x-component-props":{title:(a=o.title)!=null?a:`#${o.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:n,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}})}}))}function Vn({dataSource:e}){var s;const o=A.useFieldSchema(),{execution:n}=U();if(!n)return o.title;const t=K.parse(e)({$jobsMapByNodeKey:((s=n.jobs)!=null?s:[]).reduce((i,a)=>Object.assign(i,{[a.nodeId]:a.result}),{})});return r.jsx("pre",{className:l.css`
453
- margin: 0;
454
- `,children:JSON.stringify(t,null,2)})}Ee.Initializer=Bn,Ee.Result=Vn;function jn(e){return["hasMany","belongsToMany"].includes(e.type)}function zn(){const e=l.useCompile();return[no,ro].map(o=>{var t;const n=(t=o.useOptions({types:[jn],appends:null,depth:4}))==null?void 0:t.filter(Boolean);return{label:e(o.label),value:o.value,key:o.value,children:e(n),disabled:n&&!n.length}})}function Ln(t){var s=t,{value:e,onChange:o}=s,n=W(s,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:a}=l.useCollectionManager(),c=zn(),[d,p]=y.useState(c),{associatedKey:f="",name:g}=e!=null?e:{};let v=[];const h=f.match(/^{{(.*)}}$/);h&&(v=[...h[1].trim().split(".").slice(0,-1),g]);const m=F=>G(this,null,function*(){var w;const O=F[F.length-1];!((w=O.children)!=null&&w.length)&&!O.isLeaf&&O.loadChildren&&(yield O.loadChildren(O),p(T=>[...T]))});y.useEffect(()=>{(()=>G(this,null,function*(){var w;if(!v||d.length<=1)return;let O=null;for(let T=0;T<v.length;T++){const P=v[T];try{T===0?O=d.find(B=>B.value===P):(O.loadChildren&&!((w=O.children)!=null&&w.length)&&(yield O.loadChildren(O)),O=O.children.find(B=>B.value===P))}catch(B){console.error(B)}}p([...d])}))()},[e,d.length]);const k=y.useCallback((F,O)=>{if(!(F!=null&&F.length)){i("collection",null),o({});return}const{field:w}=O.pop();if(!w||!["hasMany","belongsToMany"].includes(w.type))return;const{collectionName:T,target:P,name:B}=w,M=a(T).fields.find(N=>N.primaryKey);i("collection",P),o({name:B,associatedKey:`{{${F.slice(0,-1).join(".")}.${M.name}}}`,associatedCollection:T})},[o]);return r.jsx(b.Cascader,C(x({},n),{value:v,options:d,onChange:k,loadData:m}))}const Wn={title:`{{t("Aggregate", { ns: "${u}" })}}`,type:"aggregate",group:"collection",description:`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${u}" })}}`,fieldset:{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${u}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${u}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:C(x({},ae),{title:`{{t("Data of collection", { ns: "${u}" })}}`,"x-component-props":C(x({},ae["x-component-props"]),{className:null}),"x-reactions":[...ae["x-reactions"],{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]}),association:{type:"object",title:`{{t("Data of associated collection", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:C(x({},Te),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{SchemaComponentContext:l.SchemaComponentContext,FilterDynamicComponent:Je,FieldsSelect:wo,ValueBlock:Ee,AssociatedConfig:Ln},useVariables({key:e,title:o},{types:n,fieldNames:t=Ce}){return n&&!n.some(s=>s in Me||Object.values(Me).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o,n;return e.config.collection?{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ee.Initializer,node:e,resultTitle:$("Query result")}:null}};function io(e){const s=e,{options:o=[]}=s,n=W(s,["options"]),t=l.useCompile();return r.jsx(b.Radio.Group,C(x({},n),{children:o.map(i=>r.jsxs(b.Radio,{value:i.value,children:[r.jsx("span",{className:l.css`
455
- & + .anticon {
456
- margin-left: 0.25em;
457
- }
458
- `,children:t(i.label)}),i.tooltip&&r.jsx(b.Tooltip,{title:t(i.tooltip),children:r.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))}))}const mt=e=>{const o=je.evaluators.get(e);return o&&o.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:l.css`
496
+ `},properties:Pn[o]}}},components:{OnField:Rt,RepeatField:In,EndsByField:Cn}})]})};class jn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);w(this,"type","schedule");w(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{ScheduleConfig:Vn})}useVariables(o,n){var c;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:E("Trigger time")}),o.mode===xe.COLLECTION_FIELD){const[d]=ke(A(C({appends:["data",...((c=o.appends)==null?void 0:c.map(u=>`data.${u}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}],compile:s,getCollectionFields:i}));d&&l.push(d)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ee,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const ho=e=>{const t=$e.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
459
497
  &:after {
460
498
  content: ':';
461
499
  }
462
500
  & + a {
463
501
  margin-left: 0.25em;
464
502
  }
465
- `,children:l.i18n.t("Syntax references")}),r.jsx("a",{href:o.link,target:"_blank",rel:"noreferrer",children:o.label})]}):null};function Un(e){var n;return["belongsTo","hasOne"].includes(e.type)?((n=this.getCollection(e.collectionName))==null?void 0:n.template)==="expression"?!0:this.getCollectionFields(e.target).some(t=>t.interface==="expression"):!1}const qn=({value:e,onChange:o})=>{const{t:n}=R.useTranslation(),{getCollectionFields:t,getCollection:s}=l.useCollectionManager(),i=ce({types:[Un.bind({getCollectionFields:t,getCollection:s})]});return r.jsxs(be.FormLayout,{layout:"vertical",children:[r.jsx(be.FormItem,{colon:!0,label:n("Expression type",{ns:u}),children:r.jsxs(b.Radio.Group,{value:e===!1?!1:e||"",onChange:a=>{o(a.target.value)},children:[r.jsx(b.Radio,{value:!1,children:n("Static",{ns:u})}),r.jsx(b.Radio,{value:e||"",children:n("Dynamic",{ns:u})})]})}),e!==!1?r.jsx(be.FormItem,{label:n("Select dynamic expression",{ns:u}),extra:n("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:u}),children:r.jsx(l.Variable.Input,{value:e||"",onChange:a=>o(a),scope:i})}):null]})},Jn={title:`{{t("Calculation", { ns: "${u}" })}}`,type:"calculation",group:"control",description:`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression can be static or dynamic one from an expression collections.", { ns: "${u}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:je.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return $("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:mt},components:{WorkflowVariableInput:qe,WorkflowVariableTextArea:dt,RadioWithTooltip:io,DynamicConfig:qn,ValueBlock:Ee},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return n&&!n.some(s=>s in Me||Object.values(Me).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o,n;return{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ee.Initializer,node:e,resultTitle:$("Calculation result")}}},X=new K.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${u}" })}}`,type:"string",group:"string"});const Hn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${u}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${u}" })}}`},{value:"date",title:`{{t("Date", { ns: "${u}" })}}`}];function ft(e){return Array.from(X.getEntities()).filter(([o,n])=>n.group===e)}function Gn({calculator:e,operands:o=[],onChange:n}){const t=l.useCompile(),s=ce();return r.jsxs("fieldset",{className:l.css`
503
+ `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Ln extends be{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${m}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:$e.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:i}=s,{evaluate:l}=$e.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return E("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:ho});w(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ze,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:i=a.defaultFieldNames}){return s&&!s.some(l=>l in Ge||Object.values(Ge).some(c=>c.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me.Initializer,node:o,resultTitle:E("Calculation result")}}}const _=new ae.Registry;_.register("equal",{name:"=",type:"boolean",group:"boolean"}),_.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),_.register("gt",{name:">",type:"boolean",group:"boolean"}),_.register("gte",{name:"≥",type:"boolean",group:"boolean"}),_.register("lt",{name:"<",type:"boolean",group:"boolean"}),_.register("lte",{name:"≤",type:"boolean",group:"boolean"}),_.register("add",{name:"+",type:"number",group:"number"}),_.register("minus",{name:"-",type:"number",group:"number"}),_.register("multiple",{name:"*",type:"number",group:"number"}),_.register("divide",{name:"/",type:"number",group:"number"}),_.register("mod",{name:"%",type:"number",group:"number"}),_.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),_.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),_.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),_.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),_.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),_.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),_.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"});const Wn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`}];function yo(e){return Array.from(_.getEntities()).filter(([t,o])=>o.group===e)}function zn({calculator:e,operands:t=[],onChange:o}){const n=a.useCompile(),s=me();return r.jsxs("fieldset",{className:a.css`
466
504
  display: flex;
467
505
  gap: 0.5em;
468
506
  align-items: center;
469
507
  flex-wrap: wrap;
470
- `,children:[r.jsx(l.Variable.Input,{value:o[0],onChange:i=>n({calculator:e,operands:[i,o[1]]}),scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>n({operands:o,calculator:i}),placeholder:$("Calculator"),popupMatchSelectWidth:!1,children:Hn.filter(i=>!!ft(i.value).length).map(i=>r.jsx(b.Select.OptGroup,{label:t(i.title),children:ft(i.value).map(([a,{name:c}])=>r.jsx(b.Select.Option,{value:a,children:t(c)},a))},i.value))}),r.jsx(l.Variable.Input,{value:o[1],onChange:i=>n({calculator:e,operands:[o[0],i]}),scope:s,useTypedConstant:!0})]})}function _n({value:e,onChange:o,onRemove:n}){if(!e)return null;const{calculator:t,operands:s=[]}=e;return r.jsxs("div",{className:l.css`
508
+ `,children:[r.jsx(a.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(v.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:E("Calculator"),popupMatchSelectWidth:!1,children:Wn.filter(i=>!!yo(i.value).length).map(i=>r.jsx(v.Select.OptGroup,{label:n(i.title),children:yo(i.value).map(([l,{name:c}])=>r.jsx(v.Select.Option,{value:l,children:n(c)},l))},i.value))}),r.jsx(a.Variable.Input,{value:t[1],onChange:i=>o({calculator:e,operands:[t[0],i]}),scope:s,useTypedConstant:!0})]})}function Jn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:a.css`
471
509
  display: flex;
472
510
  position: relative;
473
511
  margin: 0.5em 0;
474
- `,children:[e.group?r.jsx(ht,{value:e.group,onChange:i=>o(C(x({},e),{group:i}))}):r.jsx(Gn,{operands:s,calculator:t,onChange:o}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:n,type:"link",icon:r.jsx(I.CloseCircleOutlined,{})})]})}function ht({value:e,onChange:o}){const{t:n}=R.useTranslation(),{type:t="and",calculations:s=[]}=e;function i(){o(C(x({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function a(){o(C(x({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),o(C(x({},e),{calculations:[...s]}))}function d(p,f){s.splice(p,1,f),o(C(x({},e),{calculations:[...s]}))}return r.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
512
+ `,children:[e.group?r.jsx(go,{value:e.group,onChange:i=>t(A(C({},e),{group:i}))}):r.jsx(zn,{operands:s,calculator:n,onChange:t}),r.jsx(v.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(T.CloseCircleOutlined,{})})]})}function go({value:e,onChange:t}){const{t:o}=oe.useTranslation(),{type:n="and",calculations:s=[]}=e;function i(){t(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){s.splice(u,1),t(A(C({},e),{calculations:[...s]}))}function d(u,f){s.splice(u,1,f),t(A(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:a.cx("node-type-condition-group",a.css`
475
513
  position: relative;
476
514
  width: 100%;
477
515
  .node-type-condition-group {
@@ -482,7 +520,7 @@
482
520
  position: absolute;
483
521
  right: 0;
484
522
  }
485
- `),children:[r.jsx("div",{className:l.css`
523
+ `),children:[r.jsx("div",{className:a.css`
486
524
  display: flex;
487
525
  align-items: center;
488
526
  gap: 0.5em;
@@ -490,14 +528,14 @@
490
528
  width: auto;
491
529
  min-width: 6em;
492
530
  }
493
- `,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:t,onChange:p=>o(C(x({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((p,f)=>r.jsx(_n,{value:p,onChange:d.bind(this,f),onRemove:()=>c(f)},`${p.calculator}_${f}`))}),r.jsxs("div",{className:l.css`
531
+ `,children:r.jsxs(oe.Trans,{children:["Meet ",r.jsxs(v.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(A(C({},e),{type:u})),children:[r.jsx(v.Select.Option,{value:"and",children:"All"}),r.jsx(v.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((u,f)=>r.jsx(Jn,{value:u,onChange:d.bind(this,f),onRemove:()=>c(f)},`${u.calculator}_${f}`))}),r.jsxs("div",{className:a.css`
494
532
  button {
495
533
  padding: 0;
496
534
  &:not(:last-child) {
497
535
  margin-right: 1em;
498
536
  }
499
537
  }
500
- `,children:[r.jsx(b.Button,{type:"link",onClick:i,children:n("Add condition")}),r.jsx(b.Button,{type:"link",onClick:a,children:n("Add condition group")})]})]})}function Yn({value:e,onChange:o}){const n=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(ht,{value:n.group,onChange:t=>o(C(x({},n),{group:t}))})}const Kn={title:`{{t("Condition", { ns: "${u}" })}}`,type:"condition",group:"control",description:`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${u}" })}}`,fieldset:{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${u}" })}}`}],...Array.from(je.evaluators.getEntities())].reduce((e,[o,n])=>e.concat(x({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return $("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},view:{},options:[{label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],component:function({data:o}){const{t:n}=R.useTranslation(),{nodes:t}=U(),{styles:s}=oe(),{id:i,config:{rejectOnFalse:a}}=o,c=t.find(p=>p.upstreamId===i&&p.branchIndex===1),d=t.find(p=>p.upstreamId===i&&p.branchIndex===0);return r.jsx(Ge,{data:o,children:a?null:r.jsxs("div",{className:s.nodeSubtreeClass,children:[r.jsxs("div",{className:s.branchBlockClass,children:[r.jsx(Oe,{from:o,entry:d,branchIndex:0}),r.jsx(Oe,{from:o,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})},scope:{renderEngineReference:mt,useWorkflowVariableOptions:ce},components:{CalculationConfig:Yn,CalculationExpression(e){const o=ce();return r.jsx(l.Variable.TextArea,x({scope:o},e))},RadioWithTooltip:io}};function Zn(e){const{getCollectionFields:o}=l.useCollectionManager(),{path:n}=A.useField(),t=n.segments[n.segments.length-1],{values:s}=A.useForm(),i=o(s==null?void 0:s.collection),{type:a}=i.find(p=>p.name===t),c=Array.isArray(e.value)?e.value.join(","):e.value;function d(p){const f=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(a)?f:f.split(/[,\s]+/))}return r.jsx(b.Input,C(x({},e),{value:c,onChange:d}))}const yt=A.observer(({value:e,disabled:o,onChange:n,filter:t})=>{const{token:s}=l.useToken(),{t:i}=R.useTranslation(),a=l.useCompile(),c=A.useForm(),{getCollection:d,getCollectionFields:p}=l.useCollectionManager(),f=ce(),{values:g}=c,v=g==null?void 0:g.collection,h=p(v).filter(w=>w.uiSchema),m=t?h.filter(t.bind(g)):h,k=y.useMemo(()=>m.filter(w=>!e||!(w.name in e)),[m,e]),F=o||c.disabled,O=y.useMemo(()=>({onClick:({key:w})=>{n(C(x({},e),{[w]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(w=>{var T,P;return{key:w.name,label:a((P=(T=w.uiSchema)==null?void 0:T.title)!=null?P:w.name)}})}),[n,k,e]);return r.jsx("fieldset",{className:l.css`
538
+ `,children:[r.jsx(v.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(v.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Hn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(go,{value:o.group,onChange:n=>t(A(C({},o),{group:n}))})}class Un extends be{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${m}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from($e.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(C({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(o,n,{form:s}){const{values:i}=s,{evaluate:l}=$e.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return E("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:ho,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:Hn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ze})}Component({data:o}){const{t:n}=oe.useTranslation(),{nodes:s}=Z(),{styles:i}=ee(),{id:l,config:{rejectOnFalse:c}}=o,d=s.find(f=>f.upstreamId===l&&f.branchIndex===1),u=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Ye,{from:o,entry:u,branchIndex:0}),r.jsx(Ye,{from:o,entry:d,branchIndex:1})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class Yn extends be{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${m}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:ye,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Ie,sort:gn,pagination:bn,appends:Pe},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const o=a.useCompile(),{getCollectionFields:n,getInterface:s}=a.useCollectionManager(),{values:i}=V.useForm();return n(i.collection).filter(c=>{if(!c.interface)return!1;const d=s(c.interface);return!!(d!=null&&d.sortable)}).map(c=>{var d,u;return{value:c.name,label:(d=c==null?void 0:c.uiSchema)!=null&&d.title?o((u=c==null?void 0:c.uiSchema)==null?void 0:u.title):c.name}})}});w(this,"components",{ArrayItems:Vo.ArrayItems,FilterDynamicComponent:Ke,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},i){var u,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[d]=ke(A(C({appends:[o,...((f=(u=s.params)==null?void 0:u.appends)==null?void 0:f.map(b=>`${o}.${b}`))||[]]},i),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return d}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ee,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Gn(e){const{getCollectionFields:t}=a.useCollectionManager(),{path:o}=V.useField(),n=o.segments[o.segments.length-1],{values:s}=V.useForm(),i=t(s==null?void 0:s.collection),{type:l}=i.find(u=>u.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function d(u){const f=u.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?f:f.split(/[,\s]+/))}return r.jsx(v.Input,A(C({},e),{value:c,onChange:d}))}const bo=V.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=a.useToken(),{t:i}=oe.useTranslation(),l=a.useCompile(),c=V.useForm(),{getCollection:d,getCollectionFields:u}=a.useCollectionManager(),f=me(),{values:b}=c,O=b==null?void 0:b.collection,h=u(O).filter(S=>S.uiSchema),p=n?h.filter(n.bind(b)):h,k=g.useMemo(()=>p.filter(S=>!e||!(S.name in e)),[p,e]),F=t||c.disabled,D=g.useMemo(()=>({onClick:({key:S})=>{o(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var M,z;return{key:S.name,label:l((z=(M=S.uiSchema)==null?void 0:M.title)!=null?z:S.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:a.css`
501
539
  margin-top: 0.5em;
502
540
 
503
541
  > .ant-formily-item {
@@ -507,96 +545,8 @@
507
545
  line-height: 32px;
508
546
  }
509
547
  }
510
- `,children:m.length?r.jsxs(l.CollectionProvider,{collection:d(v),children:[m.filter(w=>e&&w.name in e).map(w=>{var P,B;const T=["belongsTo","hasOne","hasMany","belongsToMany"].includes(w.type)?Zn:l.CollectionField;return r.jsxs(b.Form.Item,{label:a((B=(P=w.uiSchema)==null?void 0:P.title)!=null?B:w.name),labelAlign:"left",className:l.css`
548
+ `,children:p.length?r.jsxs(a.CollectionProvider,{collection:d(O),children:[p.filter(S=>e&&S.name in e).map(S=>{var z,H;const M=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?Gn:a.CollectionField;return r.jsxs(v.Form.Item,{label:l((H=(z=S.uiSchema)==null?void 0:z.title)!=null?H:S.name),labelAlign:"left",className:a.css`
511
549
  .ant-form-item-control-input-content {
512
550
  display: flex;
513
551
  }
514
- `,children:[r.jsx(l.Variable.Input,{scope:f,value:e[w.name],changeOnSelect:!0,onChange:z=>{n(C(x({},e),{[w.name]:z}))},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[w.name]:{"x-component":T,"x-validator"(){return""}}}}})}),F?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(I.CloseCircleOutlined,{}),onClick:()=>{var N;const D=e,{[N=w.name]:z}=D,M=W(D,[on(N)]);n(M)}})]},w.name)}),k.length?r.jsx(b.Dropdown,{menu:O,children:r.jsx(b.Button,{icon:r.jsx(I.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:$("Please select collection first")})})},{displayName:"CollectionFieldSet"}),Qn={title:`{{t("Create record", { ns: "${u}" })}}`,type:"create",group:"collection",description:`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{values:Uo,appends:$e}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{CollectionFieldset:yt},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=he(C(x({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o,n;return e.config.collection?{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ie,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}:null},initializers:{}},gt=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Xn(e){return gt.slice().reverse().find(o=>!(e%o.value))}function Rn({value:e=6e4,onChange:o}){const n=Xn(e),t=Math.round(e/n.value);return r.jsxs("fieldset",{className:l.css`
515
- display: flex;
516
- gap: 0.5em;
517
- `,children:[r.jsx(b.InputNumber,{min:1,value:t,onChange:s=>o(Math.round(s*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:s=>o(Math.round(t*s)),className:"auto-width",children:gt.map(s=>r.jsx(b.Select.Option,{value:s.value,children:$(s.label)},s.value))})]})}const er={title:`{{t("Delay", { ns: "${u}" })}}`,type:"delay",group:"control",description:`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${u}" })}}`,fieldset:{duration:{type:"number",title:`{{t("Duration", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${u}" })}}`,value:ee.RESOLVED},{label:`{{t("Fail and exit", { ns: "${u}" })}}`,value:ee.FAILED}],required:!0,default:ee.RESOLVED}},view:{},scope:{},components:{Duration:Rn}};function $o(e){const o=new Map;e.forEach(n=>o.set(n.id,n));for(const n of o.values())n.upstreamId&&(n.upstream=o.get(n.upstreamId)),n.downstreamId&&(n.downstream=o.get(n.downstreamId))}function Do(e){const o=e.$and||e.$or;return o?o.some(n=>{if(n.$and||n.$or)return Do(n);const[t]=Object.keys(n);if(!t||!n[t])return!1;const[s]=Object.keys(n[t]);return!(!s||typeof n[t][s]=="undefined")}):!1}const or={title:'{{t("Delete record")}}',type:"destroy",group:"collection",description:`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{filter:C(x({},Te),{"x-validator"(e){return Do(e)?"":`{{t("Please add at least one condition", { ns: "${u}" })}}`}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Je}};function tr(e,o){let n=e,t=null;for(let s=0;s<o.length;s++){const i=o[s],a=n.find(c=>c.value===i);if(!a)return null;t=a,!a.isLeaf&&a.loadChildren&&a.loadChildren(a),a.children&&(n=a.children)}return t}const nr={title:`{{t("Loop", { ns: "${u}" })}}`,type:"loop",group:"control",description:`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${u}" })}}`,fieldset:{target:{type:"string",title:`{{t("Loop target", { ns: "${u}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:l.css`
518
- width: 100%;
519
-
520
- .variable {
521
- flex: 1;
522
- }
523
-
524
- .ant-input.null-value {
525
- width: 100%;
526
- }
527
- `},required:!0}},view:{},component:function({data:o}){var i;const{nodes:n}=U(),{styles:t}=oe(),s=n.find(a=>a.upstreamId===o.id&&a.branchIndex!=null);return r.jsx(Ge,{data:o,children:r.jsx("div",{className:t.nodeSubtreeClass,children:r.jsxs("div",{className:l.cx(t.branchBlockClass,l.css`
528
- padding-left: 20em;
529
- `),children:[r.jsx(Oe,{from:o,entry:s,branchIndex:(i=s==null?void 0:s.branchIndex)!=null?i:0}),r.jsxs("div",{className:t.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:l.cx(t.addButtonClass,t.loopLineClass),children:r.jsx(I.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:qe},useScopeVariables(e,o){const n=l.useCompile(),{target:t}=e.config;if(!t)return null;const{fieldNames:s=Ce}=o;let i={key:"item",[s.value]:"item",[s.label]:$("Loop target")};if(typeof t=="string"&&t.startsWith("{{")&&t.endsWith("}}")){const a=t.slice(2,-2).split(".").map(p=>p.trim()),c=[Fo,no,ro].map(p=>{const f=p.useOptions(C(x({},o),{current:e})).filter(Boolean);return{[s.label]:n(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),d=tr(c,a);i=Object.assign({},d,i)}return[i,{key:"index",[s.value]:"index",[s.label]:$("Loop index")},{key:"length",[s.value]:"length",[s.label]:$("Loop length")}]}};function rr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function sr({multiple:e=!1,value:o=[],onChange:n}){const t=ce({types:[rr]});return r.jsx(l.Variable.Input,{scope:t,value:o[0],onChange:s=>{n([s])},children:r.jsx(l.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:o[0],onChange:s=>{n(s!=null?[s]:[])}})})}function ir({value:e,onChange:o}){return r.jsxs("fieldset",{className:l.css`
530
- .ant-radio-group {
531
- .anticon {
532
- margin-left: 0.5em;
533
- }
534
- }
535
- `,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),o(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:$("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:$("Separately")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:$("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:$("Collaboratively")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(be.FormLayout,{layout:"vertical",children:r.jsx(l.FormItem,{label:$("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:o,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:$("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:$("All pass")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:$("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:$("Any pass")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function lr(e){const{execution:o,nodes:n}=U(),t=y.useMemo(()=>n.reduce((a,c)=>Object.assign(a,{[c.id]:c.key}),{}),[n]),s=y.useMemo(()=>{var a;return{$context:o==null?void 0:o.context,$jobsMapByNodeKey:((a=o==null?void 0:o.jobs)!=null?a:[]).reduce((c,d)=>Object.assign(c,{[t[d.nodeId]]:d.result}),{})}},[o]);return y.useMemo(()=>K.parse(e)(s),[o])}function xt(e){const o=A.useField(),n=y.useRef(null),{appends:t,updateAssociationValues:s}=l.useAssociationNames(),i=lr(e.dataSource),a=y.useMemo(()=>le.createForm({values:i,readPretty:!0}),[i]),c={appends:t},d={loading:!1,data:{data:i}},f=l.useAPIClient().resource(e.collection),g=y.useContext(l.BlockRequestContext);return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:i,parent:!1,children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",field:o,service:d,resource:f,__parent:g},children:r.jsx(l.FormBlockContext.Provider,{value:{params:c,form:a,field:o,service:d,updateAssociationValues:s,formBlockRef:n},children:e.children})})})})}function bt(e){var w,T,P;const o=l.useRecord(),n=A.useFieldSchema(),t=A.useField(),s=y.useRef(null),{appends:i,updateAssociationValues:a}=l.useAssociationNames(),[c]=Object.keys((w=n.toJSON().properties)!=null?w:{}),d=(T=o==null?void 0:o.result)==null?void 0:T[c],{findComponent:p}=l.useDesignable(),f=p((P=t.component)==null?void 0:P[0])||y.Fragment,g=y.useMemo(()=>le.createForm({initialValues:d}),[d]),v=y.useMemo(()=>x({appends:i},e.params),[i,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:d}}),[d]),k=l.useAPIClient().resource(e.collection),F=y.useContext(l.BlockRequestContext),O=y.useMemo(()=>({params:v,form:g,field:t,service:h,updateAssociationValues:a,formBlockRef:s}),[t,g,v,h,a]);return!o.status||d?r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:d,parent:!1,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",props:e,field:t,service:h,resource:k,__parent:F},children:r.jsx(l.FormBlockContext.Provider,{value:O,children:r.jsxs(f,C(x({},t.componentProps),{children:[r.jsx(l.FormV2.Templates,{style:{marginBottom:18},form:g}),r.jsx("div",{ref:s,children:r.jsx(A.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})}):null}function ar(n){var t=n,{schema:e}=t,o=W(t,["schema"]);const{getTemplateSchemaByMode:s}=l.useSchemaTemplateManager(),{insert:i}=l.useSchemaInitializer(),a=l.useRecordCollectionDataSourceItems("FormItem");function c(p){return G(this,arguments,function*({item:d}){const f=d.template?yield s(d):null,g=l.createFormBlockSchema(C(x({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:f}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[v]=Object.keys(g.properties);g.properties[v].properties.actions["x-decorator"]="ActionBarProvider",g.properties[v].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ko(g,h=>{h["x-uid"]&&delete h["x-uid"]}),i(g)})}return r.jsx(l.SchemaInitializerItem,C(x({},o),{onClick:c,items:a}))}function vt(){var o;const e=l.useSchemaInitializerItem();return r.jsx(l.CollectionProvider,{collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(ar,x({},e))})}function cr(){const{name:e,title:o}=l.useCollection();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(l.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const dr={title:`{{t("Create record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){const o=y.useMemo(()=>e.map(i=>({name:fe.camelCase(`createRecordForm-child-${i.name}`),type:"item",title:i.title,label:i.label,schema:{collection:i.name,title:`{{t("Create record", { ns: "${u}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:vt})),[e]),[n,t]=y.useState(!1),s=l.useMenuSearch(o,n,!0);return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${u}" })}}`,componentProps:{onOpenChange(i){t(i.length>0)}},children:s}},initializers:{},components:{CreateFormDesigner:cr},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]={type:"create",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:ve(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{}}};function Ct(e){var p,f,g,v;const[o,n]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),t=l.useRecord(),s=A.useField(),i=A.useFieldSchema(),[a]=Object.keys((g=i.toJSON().properties)!=null?g:{}),c=(v=t==null?void 0:t.result)==null?void 0:v[a],d=y.useMemo(()=>le.createForm({initialValues:c}),[c]);return!t.status||c?r.jsx(l.CollectionProvider,{collection:C(x({},e.collection),{fields:o}),children:r.jsx(l.RecordProvider,{record:c,parent:!1,children:r.jsx(l.FormBlockContext.Provider,{value:{form:d,field:s,setCollectionFields:n},children:e.children})})}):null}function ur(){const{insert:e}=l.useSchemaInitializer(),o=l.useSchemaInitializerItem();return r.jsx(l.SchemaInitializerItem,C(x({},o),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:K.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[K.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const wt={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function pr(e){const o={};return Object.keys(e).forEach(n=>{const t=e[n],{group:s="others"}=t;o[s]=o[s]||{},fe.set(o,[s,n],t)}),Object.keys(wt).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:wt[n],children:Object.keys(o[n]||{}).map(t=>{const s=o[n][t];return x({value:t,title:s.title,name:t},o[n][t])}).sort((t,s)=>t.order-s.order)}))}function mr(){const{interfaces:e}=l.useCollectionManager();return pr(e).map(n=>({name:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({name:t.name,type:"item",title:t.title,Component:yr,fieldInterface:t.name}))}))}const kt=y.createContext({}),fr=e=>{const[o,n]=y.useState(null),[t,s]=y.useState(),i=mr(),a=y.useContext(l.CollectionContext),{setCollectionFields:c}=y.useContext(l.FormBlockContext);return r.jsxs(kt.Provider,{value:{onAddField(d){const h=fe.cloneDeep(d),{properties:m}=h,k=m,{unique:p,type:f}=k,g=W(k,["unique","type"]),v=W(h,["properties"]);delete g.name["x-disabled"],n(C(x({},v),{properties:g}))},setCallback:s},children:[r.jsx(l.SchemaInitializerItems,C(x({},e),{items:i})),r.jsx(l.ActionContextProvider,{value:{visible:!!o},children:o?r.jsx(l.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(x({},o.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const d=A.useForm();return{run(){return G(this,null,function*(){s(null),n(null),d.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:d,query:p}=A.useForm();return{run(){return G(this,null,function*(){var k,F,O,w;const{default:g}=o,v=K.uid();if(g.name=(k=d.name)!=null?k:v,g.uiSchema.title=(O=(F=d.uiSchema)==null?void 0:F.title)!=null?O:v,g.interface=o.name,(w=a.fields)==null?void 0:w.find(T=>T.name===g.name)){p("name").take().setFeedback({type:"error",messages:[$("Field name existed in form")]});return}const m=K.merge(g,d);c([...a.fields,m]),t({name:g.name,type:g.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:m},"x-collection-field":`${a.name}.${g.name}`,"x-designer":"FormItem.Designer"}),s(null),n(null)})}}}}}}}})},components:{ArrayTable:be.ArrayTable}}):null})]})},hr=new l.SchemaInitializer({name:"AddCustomFormField",wrap:l.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:fr});function yr(){const e=l.useSchemaInitializerItem(),{insert:o,setVisible:n}=l.useSchemaInitializer(),{onAddField:t,setCallback:s}=y.useContext(kt),{getInterface:i}=l.useCollectionManager(),a=i(e.fieldInterface);return r.jsx(l.SchemaInitializerItem,x({onClick:()=>{s(()=>o),t(a),n(!1)}},e),e.fieldInterface)}const St={title:`{{t("Custom form", { ns: "${u}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${u}" })}}`,Component:ur}},initializers:{},components:{CustomFormBlockProvider:Ct},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var c;const[s]=Object.keys(t.properties),i=t.properties[s],a=ve(i.properties.grid,d=>d["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=a.map(d=>{var p,f;return(f=(p=d["x-component-props"])==null?void 0:p.field)!=null?f:d["x-interface-options"]}),o[s]={type:"custom",title:((c=t["x-component-props"])==null?void 0:c.title)||s,actions:ve(i.properties.actions,d=>d["x-component"]==="Action").map(d=>{var p,f;return{status:d["x-decorator-props"].value,values:(f=(p=d["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:d.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{CustomFormBlockProvider:Ct}}};function gr(){const{name:e,title:o}=l.useCollection(),n=A.useFieldSchema(),{t}=R.useTranslation(),{dn:s}=l.useDesignable();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsActionModalItem,{title:t("Filter settings",{ns:u}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var a;return{options:l.useCollectionFilterOptions((a=n==null?void 0:n["x-decorator-props"])==null?void 0:a.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:i})=>{n["x-decorator-props"].filter=i,s.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),s.refresh()}}),r.jsx(l.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const xr={title:`{{t("Update record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){const o=y.useMemo(()=>e.map(i=>({name:fe.camelCase(`updateRecordForm-child-${i.name}`),type:"item",title:i.title,label:i.label,schema:{collection:i.name,title:`{{t("Update record", { ns: "${u}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:vt})),[e]),[n,t]=y.useState(!1),s=l.useMenuSearch(o,n,!0);return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${u}" })}}`,componentProps:{onOpenChange(i){t(i.length>0)}},children:s}},initializers:{},components:{FilterDynamicComponent:Je,UpdateFormDesigner:gr},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]=C(x({},t["x-decorator-props"]),{type:"update",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:ve(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}})})}),o}},block:{scope:{},components:{}}},we=new K.Registry;we.register("customForm",St),we.register("createForm",dr),we.register("updateForm",xr);function br(){const{workflow:e}=U(),o=lt();return o.useInitializers?o.useInitializers(e.config):null}const vr={customForm:St.title,record:`{{t("Data record", { ns: "${u}" })}}`};function Cr(){var t,s;const e=A.useFieldSchema(),o=(s=vr[(t=e["x-designer-props"])==null?void 0:t.type])!=null?s:'{{t("Block")}}',n=l.useCompile();return r.jsxs(l.GeneralSchemaDesigner,{title:n(o),children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const wr=new l.SchemaInitializer({name:"AddBlockButton",wrap:l.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){const e=ke(),o=He(e),n=[br()].filter(Boolean),t=o.map(i=>{var c;const a=q.get(i.type);return(c=a==null?void 0:a.useInitializers)==null?void 0:c.call(a,i)}).filter(Boolean);return[...n,...t.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${u}" })}}`,children:t}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const{collections:e}=l.useCollectionManager();return Array.from(we.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({collections:e})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});function kr(){var F,O,w;const e=y.useContext(l.SchemaComponentContext),{t:o}=R.useTranslation(),n=A.useFieldSchema(),t=ce(),[s,i]=y.useState(!1),[a,c]=y.useState((w=(O=(F=n==null?void 0:n["x-action-settings"])==null?void 0:F.assignedValues)==null?void 0:O.schema)!=null?w:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[d,p]=y.useState(null),{components:f}=l.useSchemaOptionsContext();y.useEffect(()=>{p(new A.Schema({properties:{grid:a}}))},[a]);const g=y.useMemo(()=>{var P,B;const T=(B=(P=n==null?void 0:n["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:B.values;return le.createForm({initialValues:K.lodash.cloneDeep(T),values:K.lodash.cloneDeep(T)})},[]),v=l.useFormActiveFields(),h=o("Assign field values");function m(){i(!1)}function k(){n["x-action-settings"]||(n["x-action-settings"]={}),n["x-action-settings"].assignedValues||(n["x-action-settings"].assignedValues={}),n["x-action-settings"].assignedValues.schema=a,n["x-action-settings"].assignedValues.values=g.values,i(!1),setTimeout(()=>{var T;(T=e.refresh)==null||T.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaSettingsItem,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:m,children:o("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:k,children:o("Submit")})]}),children:r.jsx(l.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(l.VariableScopeProvider,{scope:t,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:v==null?void 0:v.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:g,children:r.jsxs(be.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:$("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&d&&r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{refresh(){c(K.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(l.SchemaComponent,{schema:d,components:f})})]})})})})})})]})}function Sr(e){return r.jsxs(l.GeneralSchemaDesigner,C(x({},e),{disableInitializer:!0,children:[r.jsx(l.Action.Designer.ButtonEditor,{}),r.jsx(kr,{}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Fr(){const i=l.useSchemaInitializerItem(),{action:o,actionProps:n}=i,t=W(i,["action","actionProps"]),{insert:s}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({},t),{onClick:()=>{s({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o},"x-component":"Action","x-component-props":C(x({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Ft(){const e=l.useSchemaInitializerItem(),s=e,{action:o,actionProps:n}=s,t=W(s,["action","actionProps"]);return r.jsx(l.InitializerWithSwitch,C(x({},t),{item:e,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o},"x-component":"Action","x-component-props":C(x({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${o}`},type:"x-action"}))}const Ar=new l.SchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${u}" })}}`,Component:Fr,action:ee.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${u}" })}}`,Component:Ft,action:ee.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${u}" })}}`,Component:Ft,action:ee.PENDING}]});function Or(){return{run(){}}}function Ir({value:e,onChange:o}){const n=y.useContext(l.SchemaComponentContext),t=ke(),s=He(t),i=A.useForm(),{workflow:a}=U(),c={},d={};s.forEach(g=>{const v=q.get(g.type);Object.assign(c,v.initializers),Object.assign(d,v.components)});const p=y.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:l.css`
536
- .ant-drawer-body {
537
- background: var(--nb-box-bg);
538
- }
539
- `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${u}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),f=y.useCallback(function(){const{tabs:v}=K.lodash.get(p.toJSON(),"properties.drawer.properties"),h=Array.from(we.getValues()).reduce((m,k)=>Object.assign(m,k.config.parseFormOptions(v)),{});i.setValuesIn("forms",h),o(v.properties)},[i,o,p]);return r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},n),{designable:!a.executed,refresh:f}),children:r.jsx(l.SchemaComponent,{schema:p,components:C(x(x({},d),Array.from(we.getValues()).reduce((g,v)=>Object.assign(g,v.config.components),{})),{FormBlockProvider:bt,DetailsBlockProvider:xt,ManualActionStatusProvider(g){return g.children},ActionBarProvider(g){return g.children},SimpleDesigner:Cr,ManualActionDesigner:Sr}),scope:{useSubmit:Or,useDetailsBlockProps:l.useFormBlockContext}})})}function Tr(e){const{workflow:o}=U(),[n,t]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:o.executed?$("View user interface"):$("Configure user interface")}),r.jsx(l.ActionContextProvider,{value:{visible:n,setVisible:t,formValueChanged:!1},children:e.children})]})}const $r={title:`{{t("Manual", { ns: "${u}" })}}`,type:"manual",group:"manual",description:`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${u}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Tr,SchemaConfig:Ir,ModeConfig:ir,AssigneesSelect:sr},useVariables({key:e,title:o,config:n},{types:t,fieldNames:s=Ce}){var p;const i=l.useCompile(),{getCollectionFields:a}=l.useCollectionManager(),c=Object.keys((p=n.forms)!=null?p:{});if(!c.length)return null;const d=c.map(f=>{var m;const g=n.forms[f],v=he({fields:(m=g.collection)==null?void 0:m.fields,collection:g.collection,types:t,compile:i,getCollectionFields:a}),h=i(g.title)||f;return v.length?{key:f,value:f,label:h,title:h,children:v}:null}).filter(Boolean);return d.length?{[s.value]:e,[s.label]:o,[s.children]:d}:null},useInitializers(e){var s;const{getCollection:o}=l.useCollectionManager(),n=Object.keys((s=e.config.forms)!=null?s:{});if(!n.length||e.config.mode)return null;const t=n.map(i=>{var d,p;const a=e.config.forms[i],{fields:c=[]}=o(a.collection);return c.length?{name:(d=a.title)!=null?d:i,type:"item",title:(p=a.title)!=null?p:i,Component:Ie,collection:a.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${i}}}`}:null}).filter(Boolean);return t.length?{name:"forms",key:"forms",type:"subMenu",title:e.title,children:t}:null},initializers:{}},Dr={title:`{{t("Parallel branch", { ns: "${u}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${u}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${u}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${u}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${u}" })}}`}]},default:"all"}},view:{},component:function({data:o}){const{styles:n}=oe(),{id:t,config:{mode:s}}=o,{workflow:i,nodes:a}=U(),c=a.reduce((h,m)=>m.upstreamId===t&&m.branchIndex!=null?h.concat(m):h,[]).sort((h,m)=>h.branchIndex-m.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:f}=Co(o),g=Array(Math.max(0,d-c.length)).fill(null),v=c[c.length-1];return r.jsx(Ge,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(h=>r.jsx(Oe,{from:o,entry:h,branchIndex:h.branchIndex},h.id)),g.map((h,m)=>r.jsx(Oe,{from:o,branchIndex:(v?v.branchIndex:0)+m+1,controller:c.length+m>1?r.jsx("div",{className:l.css`
540
- padding-top: 2em;
541
-
542
- > button {
543
- .anticon {
544
- transform: rotate(45deg);
545
- }
546
- }
547
- `,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(I.PlusOutlined,{}),onClick:()=>p(d-1),disabled:i.executed})}):null},`temp_${c.length+m}`))]}),r.jsx(b.Tooltip,{title:$("Add branch"),className:l.css`
548
- visibility: ${i.executed?"hidden":"visible"};
549
- `,children:r.jsx(b.Button,{"aria-label":f("add-branch"),icon:r.jsx(I.PlusOutlined,{}),className:l.css`
550
- position: relative;
551
- top: 1em;
552
- transform-origin: center;
553
- transform: rotate(45deg);
554
-
555
- .anticon {
556
- transform-origin: center;
557
- transform: rotate(-45deg);
558
- }
559
- `,onClick:()=>p(d+1),disabled:i.executed})})]})})},components:{RadioWithTooltip:io}},Nr={title:`{{t("Query record", { ns: "${u}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${u}" })}}`,fieldset:{collection:ae,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${u}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${u}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Te,sort:dn,pagination:un,appends:$e},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${u}" })}}`}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const e=l.useCompile(),{getCollectionFields:o,getInterface:n}=l.useCollectionManager(),{values:t}=A.useForm();return o(t.collection).filter(i=>{if(!i.interface)return!1;const a=n(i.interface);return!!(a!=null&&a.sortable)}).map(i=>{var a,c;return{value:i.name,label:(a=i==null?void 0:i.uiSchema)!=null&&a.title?e((c=i==null?void 0:i.uiSchema)==null?void 0:c.title):i.name}})}},components:{ArrayItems:be.ArrayItems,FilterDynamicComponent:Je,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:qe},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=he(C(x({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o,n;return!e.config.collection||e.config.multiple?null:{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ie,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}},initializers:{}},Mr={title:`{{t("HTTP request", { ns: "${u}" })}}`,type:"request",group:"extended",description:`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${u}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${u}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${u}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${u}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${u}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{},components:{ArrayItems:be.ArrayItems,WorkflowVariableInput:qe,WorkflowVariableJSON:pt},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}},Er={title:`{{t("SQL action", { ns: "${u}" })}}`,type:"sql",group:"collection",description:`{{t("Execute a SQL statement in database.", { ns: "${u}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:l.css`
560
- font-size: 80%;
561
- font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
562
- `}}},scope:{},components:{WorkflowVariableRawTextArea:ut},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}};function Pr(n){var t=n,{onChange:e}=t,o=W(t,["onChange"]);const{getCollectionFields:s}=l.useCollectionManager(),i=A.useForm(),{collection:a}=i.values,c=s(a),d=A.useField();function p({target:f}){const g=d.query(".values").take();if(!g)return;const v=c.reduce((h,m)=>(m.name in g.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=g.value[m.name]),h),{});i.setValuesIn("params.values",v),e(f.value)}return r.jsx(io,C(x({},o),{onChange:p}))}const Br={title:`{{t("Update record", { ns: "${u}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${u}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${u}" })}}`},{label:`{{t("Update one by one", { ns: "${u}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${u}" })}}`}]},default:!1},filter:C(x({},Te),{title:`{{t("Only update records matching conditions", { ns: "${u}" })}}`,"x-validator"(e){return Do(e)?"":$("Please add at least one condition")}}),values:C(x({},Uo),{"x-component-props":{filter(e){var o;return((o=this.params)==null?void 0:o.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Je,CollectionFieldset:yt,IndividualHooksRadioWithTooltip:Pr}},q=new K.Registry;q.register("calculation",Jn),q.register("condition",Kn),q.register("parallel",Dr),q.register("loop",nr),q.register("delay",er),q.register("manual",$r),q.register("query",Nr),q.register("create",Qn),q.register("update",Br),q.register("destroy",or),q.register("aggregate",Wn),q.register("request",Mr),q.register("sql",Er);function Vr(){const e=A.useForm(),o=l.useAPIClient(),n=l.useActionContext(),{refresh:t}=l.useResourceActionContext(),s=ke(),{workflow:i}=U();return{run(){return G(this,null,function*(){var c,d;if(i.executed){b.message.error($("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),t()})}}}const No=y.createContext({});function ke(){return y.useContext(No)}function He(e){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)o.push(n);return o}function At(e){const o=[];if(!e)return[];for(let n=e;n;n=n.upstream)n.upstream&&n.branchIndex!=null&&o.push(n.upstream);return o}function Ot({data:e}){const{styles:o}=oe(),{getAriaLabel:n}=Co(e),{component:t=Ge}=q.get(e.type);return r.jsx(No.Provider,{value:e,children:r.jsxs("div",{className:l.cx(o.nodeBlockClass),children:[r.jsx(t,{data:e}),r.jsx($t,{"aria-label":n(),upstream:e})]})})}function It(){var p;const{t:e}=R.useTranslation(),o=l.useAPIClient(),{workflow:n,nodes:t,refresh:s}=(p=U())!=null?p:{},i=ke(),{modal:a}=b.App.useApp();if(!n)return null;const c=o.resource("flow_nodes");function d(){return G(this,null,function*(){function f(){return G(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:i.id}),s()})}const g=t.filter(m=>m===i?!1:K.parse(m.config).parameters.filter(({key:O})=>O.startsWith(`$jobsMapByNodeKey.${i.key}.`)||O===`$jobsMapByNodeKey.${i.key}`).length);if(g.length){a.error({title:$("Can not delete"),content:$("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:g.map(m=>`#${m.id}`).join(", ")})});return}const h=!t.find(m=>m.upstream===i&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):$("This node contains branches, deleting will also be preformed to them, are you sure?");a.confirm({title:e("Delete"),content:h,onOk:f})})}return n.executed?null:r.jsx(b.Button,{type:"text",shape:"circle",icon:r.jsx(I.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function Tt(){var i;const{execution:e,setViewJob:o}=U(),{jobs:n}=(i=ke())!=null?i:{},{styles:t}=oe();if(!e)return null;if(!n.length)return r.jsx(Le,{className:t.nodeJobButtonClass,disabled:!0});function s({key:a}){const c=n.find(d=>d.id==a);o(c)}return n.length>1?r.jsx(b.Dropdown,{menu:{items:n.map(a=>({key:a.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Le,{statusMap:We,status:a.status}),r.jsx("time",{children:K.str2moment(a.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:t.dropdownClass},children:r.jsx(Le,{statusMap:We,status:n[n.length-1].status,className:t.nodeJobButtonClass})}):r.jsx(Le,{statusMap:We,status:n[0].status,onClick:()=>o(n[0]),className:t.nodeJobButtonClass})}function jr(){return{form:A.useForm()}}function Ge(e){var B,z;const{data:o,children:n}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(B=U())!=null?B:{},{styles:c}=oe(),d=q.get(o.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=t(d.title),[g,v]=y.useState((z=o.title)!=null?z:f),[h,m]=y.useState(!1),[k,F]=y.useState(!1),O=y.useMemo(()=>{const M=fe.cloneDeep(o.config);return le.createForm({initialValues:M,disabled:i.executed})},[o,i]),w=y.useCallback(M=>{m(M),M||O.reset()},[O]),T=y.useCallback(function(M){return G(this,null,function*(){var D,J;const N=M||f;v(N),N!==o.title&&(yield(J=(D=s.resource("flow_nodes")).update)==null?void 0:J.call(D,{filterByTk:o.id,values:{title:N}}),a())})},[o]),P=y.useCallback(function(M){if(M.target===M.currentTarget){m(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let D=M.target;D&&D!==M.currentTarget&&D!==document.documentElement;D=D.parentNode)if(Array.from(D.classList).some(J=>N.has(J))){m(!0),M.stopPropagation();return}},[]);return r.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${o.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${f}-${g}`,className:l.cx(c.nodeCardClass,{configuring:h}),onClick:P,children:[r.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(b.Tag,{children:f}),r.jsx("span",{className:"workflow-node-id",children:o.id})]}),r.jsx(b.Input.TextArea,{disabled:i.executed,value:g,onChange:M=>v(M.target.value),onBlur:M=>T(M.target.value),autoSize:!0}),r.jsx(It,{}),r.jsx(Tt,{}),r.jsx(l.ActionContextProvider,{value:{visible:h,setVisible:w,formValueChanged:k,setFormValueChanged:F},children:r.jsx(l.FormProvider,{form:O,children:r.jsx(l.SchemaComponent,{scope:C(x({},d.scope),{useFormProviderProps:jr}),components:d.components,schema:{type:"void",properties:C(x({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":p,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${d.type}_${o.id}`]:{type:"void",title:r.jsxs("div",{className:l.css`
563
- display: flex;
564
- justify-content: space-between;
565
-
566
- strong {
567
- font-weight: bold;
568
- }
569
-
570
- .ant-tag {
571
- margin-inline-end: 0;
572
- }
573
-
574
- code {
575
- font-weight: normal;
576
- }
577
- `,children:[r.jsx("strong",{children:o.title}),r.jsx(b.Tooltip,{title:$("Variable key of node"),children:r.jsx(b.Tag,{children:r.jsx("code",{children:o.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:C(x({},d.description?{description:{type:"void","x-component":Lo,"x-component-props":{label:$("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
578
- .ant-input,
579
- .ant-select,
580
- .ant-cascader-picker,
581
- .ant-picker,
582
- .ant-input-number,
583
- .ant-input-affix-wrapper {
584
- &.auto-width {
585
- width: auto;
586
- min-width: 6em;
587
- }
588
- }
589
- `},properties:d.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Vr}}}}})}})}})})})]}),n]})}function $t(e){var h;const{upstream:o,branchIndex:n=null}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(h=U())!=null?h:{},c=Array.from(q.getValues()),{styles:d}=oe(),p=y.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${u}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${u}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${u}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${u}" })}}`}].filter(m=>c.filter(k=>k.group===m.key).length).map(m=>{const k=c.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({workflow:i,upstream:o,branchIndex:n}):!0));return C(x({},m),{type:"group",children:k.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(O=>({role:"button","aria-label":O.key,key:O.key,label:O.label})):null}))})}),[n,c,o,i]),f=y.useMemo(()=>i?s.resource("workflows.nodes",i.id):null,[i==null?void 0:i.id]),g=y.useCallback(k=>G(this,[k],function*({keyPath:m}){var P,B,z;const F=m.pop(),O={},[w]=m,T=q.get(F);if(w){const{value:M}=(B=(P=T.options)==null?void 0:P.find(N=>N.key===w))!=null?B:{};Object.assign(O,typeof M=="function"?M():M)}f&&(yield f.create({values:{type:F,upstreamId:(z=o==null?void 0:o.id)!=null?z:null,branchIndex:n,title:t(T.title),config:O}}),a())}),[n,f==null?void 0:f.create,o==null?void 0:o.id]),v=y.useMemo(()=>({onClick:g,items:t(p)}),[p,g]);return i?r.jsx("div",{className:d.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],menu:v,disabled:i.executed,overlayClassName:l.css`
590
- .ant-dropdown-menu-root {
591
- max-height: 30em;
592
- overflow-y: auto;
593
- }
594
- `,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(I.PlusOutlined,{})})})}):null}function Oe({from:e=null,entry:o=null,branchIndex:n=null,controller:t=null,className:s,end:i}){const{styles:a}=oe(),{getAriaLabel:c}=Co(e,n),d=[];for(let p=o;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:l.cx("workflow-branch",a.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),t,r.jsx($t,{"aria-label":c(),upstream:e,branchIndex:n}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(Ot,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(I.CloseOutlined,{})}):null]})}function Dt({entry:e}){const{styles:o}=oe(),{workflow:n}=U(),[t,s]=y.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:t/100},children:r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
595
- margin-top: 0 !important;
596
- `),children:r.jsxs("div",{className:o.branchClass,children:[n!=null&&n.executed?r.jsx(b.Alert,{type:"warning",message:$("Executed workflow cannot be modified"),showIcon:!0,className:l.css`
597
- margin-bottom: 1em;
598
- `}):null,r.jsx(En,{}),r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
599
- margin-top: 0 !important;
600
- `),children:r.jsx(Oe,{entry:e})}),r.jsx("div",{className:o.terminalClass,children:$("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:t,onChange:s})})]})}const Pe=e=>`/admin/workflow/workflows/${e}`,Mo=e=>`/admin/workflow/executions/${e}`;function zr(e,o=[]){const n=new Map;e.forEach(t=>{t.jobs=[],n.set(t.id,t)}),o.forEach(t=>{const s=n.get(t.nodeId);s.jobs.push(t),t.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(t=>{t.jobs=t.jobs.sort((s,i)=>s.id-i.id)})}function Lr(){const e=l.useCompile(),{viewJob:o,setViewJob:n}=U(),{styles:t}=oe(),{node:s={}}=o!=null?o:{},i=q.get(s.type);return r.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:t.nodeTitleClass,children:[r.jsx(b.Tag,{children:e(i==null?void 0:i.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Re,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:t.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function Wr(e){const{execution:o}=U(),n=l.useAPIClient(),t=ue.useNavigate(),{styles:s}=oe(),[i,a]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{a(f.data)}).catch(()=>{})},[o]),y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[o]);const p=y.useCallback(({key:f})=>{f!=o.id&&t(Mo(f))},[o]);return o?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${o.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:K.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Le,{statusMap:Xe,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${o.id}`}),r.jsx(I.DownOutlined,{})]})}):null}function Ur(){var m;const e=l.useCompile(),{data:o,loading:n}=l.useResourceActionContext(),{setTitle:t}=l.useDocumentTitle(),[s,i]=y.useState(null),a=l.useApp();if(y.useEffect(()=>{var T;const{workflow:w}=(T=o==null?void 0:o.data)!=null?T:{};t==null||t(`${w!=null&&w.title?`${w.title} - `:""}${$("Execution history")}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const k=(m=o==null?void 0:o.data)!=null?m:{},{jobs:c=[],workflow:F={}}=k,O=F,{nodes:d=[],revisions:p=[]}=O,f=W(O,["nodes","revisions"]),g=W(k,["jobs","workflow"]);$o(d),zr(d,c);const v=d.find(w=>!w.upstream),h=Xe[g.status];return r.jsxs(ze.Provider,{value:{workflow:f.type?f:null,nodes:d,execution:g,viewJob:s,setViewJob:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:a.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx(ue.Link,{to:Pe(f.id),children:f.title})},{title:r.jsx(Wr,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:h.color,children:e(h.label)}),r.jsx("time",{children:K.str2moment(g.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Dt,{entry:v}),r.jsx(Lr,{})]})}const Nt=()=>{const e=ue.useParams(),{styles:o}=oe();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Ur}})})},Mt=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext();return r.jsx(ue.Link,{to:Mo(o),onClick:()=>n(!1),children:e("View")})},qr={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:o}=l.useActionContext();return r.jsx(ue.Link,{to:Pe(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Qe}}]},Et={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:qr,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:o,defaultRequest:n}=l.useResourceActionContext(),{resource:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return G(this,null,function*(){var a;yield t.destroy({filter:(a=n.params)==null?void 0:a.filter}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${u}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function Jr(t){var s=t,{request:e,filter:o={}}=s,n=W(s,["request","filter"]);var c;const{workflow:i}=U(),a=C(x({},n),{request:C(x({},e),{params:C(x({},e==null?void 0:e.params),{filter:C(x({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,x({},a))}function Hr(){var z;const e=ue.useNavigate(),{t:o}=R.useTranslation(),n=l.useApp(),{data:t,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[d,p]=y.useState(!1),{styles:f}=oe(),{modal:g}=b.App.useApp();if(y.useEffect(()=>{var D;const{title:N}=(D=t==null?void 0:t.data)!=null?D:{};c==null||c(`${$("Workflow")}${N?`: ${N}`:""}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const M=(z=t==null?void 0:t.data)!=null?z:{},{nodes:v=[],revisions:h=[]}=M,m=W(M,["nodes","revisions"]);$o(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=m.id&&e(Pe(N))}function O(N){return G(this,null,function*(){yield a.update({filterByTk:m.id,values:{enabled:N}}),s()})}function w(){return G(this,null,function*(){const{data:{data:N}}=yield a.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function T(){return G(this,null,function*(){const N=m.current?$("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:o("Are you sure you want to delete it?"),content:N,onOk(){return G(this,null,function*(){var J;yield a.destroy({filterByTk:m.id}),b.message.success(o("Operation succeeded")),e(m.current?n.pluginSettingsManager.getRoutePath("workflow"):Pe((J=h.find(H=>H.current))==null?void 0:J.id))})}})})}function P(D){return G(this,arguments,function*({key:N}){switch(N){case"history":p(!0);return;case"revision":return w();case"delete":return T()}})}const B=m.executed&&!h.find(N=>!N.executed&&new Date(N.createdAt)>new Date(m.createdAt));return r.jsxs(ze.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:n.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((N,D)=>D.id-N.id).map((N,D)=>({role:"button","aria-label":`version-${D}`,key:`${N.id}`,icon:N.current?r.jsx(I.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${N.id}`}),r.jsx("time",{children:K.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:$("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(I.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:m.enabled,onChange:O,checkedChildren:$("On"),unCheckedChildren:$("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:$("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:$("Copy to new version"),disabled:!B},{role:"button","aria-label":"delete",key:"delete",label:o("Delete")}],onClick:P},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(I.EllipsisOutlined,{})})}),r.jsx(l.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(l.SchemaComponent,{schema:Et,components:{ExecutionResourceProvider:Jr,ExecutionLink:Mt}})})]})]}),r.jsx(Dt,{entry:k})]})}const Pt=()=>{const e=ue.useParams(),{styles:o}=oe();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Hr}})})},Gr=t=>{var s=t,{request:e,filter:o={}}=s,n=W(s,["request","filter"]);var c;const i=l.useRecord(),a=C(x({},n),{request:C(x({},e),{params:C(x({},e==null?void 0:e.params),{filter:C(x({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,x({},a))},_r=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext(),{getAriaLabel:t}=l.useGetAriaLabelOfAction("Configure");return r.jsx(ue.Link,{"aria-label":t(),to:Pe(o),onClick:()=>n(!1),children:e("Configure")})};function Yr(t){var s=t,{component:e="div",children:o}=s,n=W(s,["component","children"]);const[i,a]=y.useState(!1),c=A.useFieldSchema();return r.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[y.createElement(e,C(x({},n),{onClick(){a(!0)}}),o),r.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Kr}=l.interfacesProperties,Zr={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${u}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${u}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:x({},Kr)},Bt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Se={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Qr={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Bt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Bt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Se.title,type:Se.type,description:Se.description,options:Se.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(o){const n=l.useRecord();return y.createElement("a",x({"aria-label":`executed-${n.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Et}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Se.title,enabled:Se.enabled,description:Se.description,options:Se.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=R.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:n,targetKey:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[t]:i}=l.useRecord(),{values:a}=A.useForm();return{run(){return G(this,null,function*(){yield n.revision({filterByTk:i,values:a}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Vt(e){var i;const n=l.useCompile()(e.label),t=y.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Xe[e.value])!=null?i:{};return r.jsx(b.Tag,{color:s,onMouseDown:t,closable:e.closable,onClose:e.onClose,children:n})}function Xr(e){const o=l.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Vt,x({},e)),e.description?r.jsx("span",{children:o(e.description)}):null]})}function Rr(o){var e=W(o,[]);const n=e.multiple?"multiple":null;return r.jsx(b.Select,C(x({role:"button","data-testid":`select-${n||"single"}`},e),{mode:n,optionLabelProp:"label",tagRender:Vt,children:Qe.filter(t=>!!t.value&&t.value!==pe.ABORTED).map(t=>r.jsx(b.Select.Option,C(x({},t),{children:r.jsx(Xr,x({},t))}),t.value))}))}const es=y.createContext({});function os(){const e=y.useContext(l.SchemaComponentContext);return r.jsx(b.Card,{bordered:!1,children:r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{designable:!1}),children:r.jsx(l.SchemaComponent,{schema:Qr,components:{WorkflowLink:_r,ExecutionResourceProvider:Gr,ExecutionLink:Mt,OpenDrawer:Yr,ExecutionStatusSelect:Rr},scope:{getTriggersOptions:So}})})})}const ts=e=>{const o=y.useContext(l.CollectionManagerContext);return r.jsx(l.CollectionManagerContext.Provider,{value:C(x({},o),{interfaces:C(x({},o.interfaces),{expression:Zr})}),children:r.jsx(es.Provider,{value:{triggers:me,instructions:q},children:e.children})})},ns=A.observer(e=>{const{onChange:o}=e,n=A.useField(),t=A.useForm(),i=[...n.path.segments.slice(0,-1),"sourceCollection"].join("."),[a,c]=y.useState(t.getValuesIn(i)),d=l.useCompile(),{getCollectionFields:p}=l.useCollectionManager();A.useFormEffects(()=>{le.onFormInitialValuesChange(g=>{c(g.getValuesIn(i))}),le.onFieldInputValueChange(i,g=>{c(g.value),o(null)})});const f=he({collection:a,compile:d,getCollectionFields:p});return r.jsx(l.Variable.TextArea,C(x({},e),{scope:f}))},{displayName:"InternalExpression"});function rs(e){const{t:o}=R.useTranslation(),n=l.useRecord(),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),i=y.useMemo(()=>he({collection:n.sourceCollection,compile:t,getCollectionFields:s}),[n.sourceCollection,n.sourceCollection]);return e.value?r.jsx(l.Variable.TextArea,C(x({},e),{scope:i})):r.jsx(b.Tag,{children:o("Unconfigured",{ns:u})})}const ss=A.connect(ns,A.mapReadPretty(rs)),is={title:`{{t("Task", { ns: "${u}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},ls={title:`{{t("Workflow", { ns: "${u}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},as={title:`{{t("Workflow todos", { ns: "${u}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-component":"Select",enum:Re}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},cs=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),ds=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),us=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.nickname)!=null?t:(n=e.value)==null?void 0:n.id},{displayName:"UserColumn"}),Eo=()=>r.jsx(l.SchemaComponent,{components:{NodeColumn:cs,WorkflowColumn:ds,UserColumn:us},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${u}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${u}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${u}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function ps(e){var p;const{data:o}=l.useCurrentUserContext(),{userJob:n}=U(),{status:t,result:s,userId:i}=n,a=A.useFieldSchema(),{name:c}=a.parent.toJSON();let{children:d}=e;return t?s[c]||(d=null):((p=o==null?void 0:o.data)==null?void 0:p.id)!==i&&(d=null),d}const ms=y.createContext(null);function fs({value:e,children:o}){const{userJob:n}=U(),t=A.useField(),s=A.useFieldSchema();return y.useEffect(()=>{n.status&&(t.disabled=!0,t.visible=n.status===e&&n.result._===s.name)},[n,e,t]),r.jsx(ms.Provider,{value:e,children:o})}function hs(){const e=l.useAPIClient(),{setVisible:o}=l.useActionContext(),{values:n,submit:t}=A.useForm(),s=A.useFieldSchema(),{service:i}=l.useTableBlockContext(),{userJob:a}=U(),{name:c}=s,{name:d}=s.parent.parent;return{run(){return G(this,null,function*(){a.status||(yield t(),yield e.resource("users_jobs").submit({filterByTk:a.id,values:{result:{[d]:n,_:c}}}),o(!1),i.refresh())})}}}function ys(e){var p;const o=l.useAPIClient(),{id:n}=l.useRecord(),[t,s]=y.useState(null),[i,a]=y.useState(null);y.useEffect(()=>{var f,g;n&&((g=(f=o.resource("users_jobs")).get)==null||g.call(f,{filterByTk:n,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var w;const T=(w=v==null?void 0:v.data)!=null?w:{},{node:h,workflow:P={}}=T,B=P,{nodes:m=[]}=B,k=W(B,["nodes"]),z=T,{execution:F}=z,O=W(z,["node","workflow","execution"]);$o(m),a(h),s({userJob:O,workflow:k,nodes:m,execution:F})}))},[n]);const d=He(t==null?void 0:t.nodes.find(f=>f.id===i.id)).reduce((f,{type:g})=>Object.assign(f,q.get(g).components),{});return i&&t?r.jsx(ze.Provider,{value:t,children:r.jsx(l.SchemaComponent,{components:x(x({FormBlockProvider:bt,DetailsBlockProvider:xt,ActionBarProvider:ps,ManualActionStatusProvider:fs},Array.from(we.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),d),scope:x({useSubmit:hs,useFormBlockProps:gs,useDetailsBlockProps:xs},Array.from(we.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=i.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function gs(){var i;const{userJob:e}=U(),o=l.useRecord(),{data:n}=l.useCurrentUserContext(),{form:t}=l.useFormBlockContext(),s=e.status?o?"readPretty":"disabled":((i=n==null?void 0:n.data)==null?void 0:i.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{t==null||t.setPattern(s)},[s,t]),{form:t}}function xs(){const{form:e}=l.useFormBlockContext();return{form:e}}function bs(){const e=l.useCompile(),{status:o,updatedAt:n}=l.useRecord(),t=We[o];return o?r.jsxs(b.Space,{children:[r.jsx("time",{className:l.css`
601
- margin-right: 0.5em;
602
- `,children:zo(n).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:t.icon,color:t.color,children:e(t.label)})]}):null}function vs(){var i;const e=y.useContext(l.SchemaComponentContext),{id:o,node:n,workflow:t,status:s}=l.useRecord();return r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{reset(){},designable:!1}),children:r.jsx(l.SchemaComponent,{components:{FooterStatus:bs,FlowContextProvider:ys},schema:{type:"void",name:`drawer-${o}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(i=n.title)!=null?i:`#${n.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function Cs({params:e={},children:o}){const i=l.useCollectionManager(),{collections:n}=i,t=W(i,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(x({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(l.CollectionManagerProvider,C(x({},t),{collections:[...n,is,ls,as],children:r.jsx(l.TableBlockProvider,C(x({name:"workflow-todo"},s),{children:o}))}))}Eo.Drawer=vs,Eo.Decorator=Cs;const ws=()=>{const e=l.useSchemaInitializerItem(),{insert:o}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({icon:r.jsx(I.TableOutlined,{})},e),{onClick:()=>{o({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class jt extends l.Plugin{constructor(){super(...arguments);bo(this,"triggers",me);bo(this,"getTriggersOptions",So);bo(this,"instructions",q)}load(){return G(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(ts),this.addSchemaInitializers(),this.app.pluginSettingsManager.add(u,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${u}" })}}`,Component:os,aclSnippet:"pm.workflow.workflows"})})}addSchemaInitializers(){this.app.schemaInitializerManager.add(wr),this.app.schemaInitializerManager.add(Ar),this.app.schemaInitializerManager.add(hr),this.app.schemaInitializerManager.get("BlockInitializers").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${u}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:mn})}addComponents(){this.app.addComponents({WorkflowPage:Pt,ExecutionPage:Nt,WorkflowTodo:Eo,WorkflowTodoBlockInitializer:ws,DynamicExpression:ss})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Pe(":id"),element:r.jsx(Pt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Mo(":id"),element:r.jsx(Nt,{})})}}S.BaseTypeSets=Me,S.Branch=Oe,S.EXECUTION_STATUS=pe,S.ExecutionStatusOptions=Qe,S.ExecutionStatusOptionsMap=Xe,S.FlowContext=ze,S.JOB_STATUS=ee,S.JobButton=Tt,S.JobStatusOptions=Re,S.JobStatusOptionsMap=We,S.Node=Ot,S.NodeContext=No,S.NodeDefaultView=Ge,S.RemoveButton=It,S.WorkflowPlugin=jt,S.WorkflowVariableInput=qe,S.WorkflowVariableJSON=pt,S.WorkflowVariableRawTextArea=ut,S.WorkflowVariableTextArea=dt,S.default=jt,S.defaultFieldNames=Ce,S.getCollectionFieldOptions=he,S.getTriggersOptions=So,S.instructions=q,S.nodesOptions=no,S.scopeOptions=Fo,S.systemOptions=at,S.triggerOptions=ro,S.triggers=me,S.useAvailableUpstreams=He,S.useFlowContext=U,S.useNodeContext=ke,S.useStyles=oe,S.useTrigger=lt,S.useUpstreamScopes=At,S.useWorkflowVariableOptions=ce,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
552
+ `,children:[r.jsx(a.Variable.Input,{scope:f,value:e[S.name],changeOnSelect:!0,onChange:J=>{o(A(C({},e),{[S.name]:J}))},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":M,"x-validator"(){return""}}}}})}),F?null:r.jsx(v.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var x;const N=e,{[x=S.name]:J}=N,L=q(N,[Po(x)]);o(L)}})]},S.name)}),k.length?r.jsx(v.Dropdown,{menu:D,children:r.jsx(v.Button,{icon:r.jsx(T.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:E("Please select collection first")})})},{displayName:"CollectionFieldSet"});class _n extends be{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${m}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:ye,params:{type:"object",properties:{values:Xt,appends:Pe}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{CollectionFieldset:bo})}useVariables({key:o,title:n,config:s},i){var u,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[d]=ke(A(C({appends:[o,...((f=(u=s.params)==null?void 0:u.appends)==null?void 0:f.map(b=>`${o}.${b}`))||[]]},i),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return d}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ee,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function qn(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=a.useCollectionManager(),i=V.useForm(),{collection:l}=i.values,c=s(l),d=V.useField();function u({target:f}){const b=d.query(".values").take();if(!b)return;const O=c.reduce((h,p)=>(p.name in b.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(p.type))&&(h[p.name]=b.value[p.name]),h),{});i.setValuesIn("params.values",O),e(f.value)}return r.jsx(Ze,A(C({},t),{onChange:u}))}class Kn extends be{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${m}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:ye,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:A(C({},Ie),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(o){return qe(o)?"":E("Please add at least one condition")}}),values:A(C({},Xt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Ke,CollectionFieldset:bo,IndividualHooksRadioWithTooltip:qn})}}class Zn extends be{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:ye,params:{type:"object",properties:{filter:A(C({},Ie),{"x-validator"(o){return qe(o)?"":E("Please add at least one condition")}})}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Ke})}}function Qn(){const e=a.useAPIClient(),t=V.useForm(),{field:o,__parent:n}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),i=ie.useNavigate(),l=V.useFieldSchema(),c=V.useField(),d=a.useCompile(),{modal:u}=v.App.useApp(),f=a.useCollectValuesToSubmit(),b=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var D,S,M;const{onSuccess:h,skipValidator:p,triggerWorkflows:k}=(D=l==null?void 0:l["x-action-settings"])!=null?D:{};p||(yield t.submit());const F=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:F,filterKeys:b,triggerWorkflows:k!=null&&k.length?k.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(M=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||M.call(S),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?u.success({title:d(h==null?void 0:h.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ae.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):v.message.success(d(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}class ce extends a.Plugin{constructor(){super(...arguments);w(this,"triggers",new ae.Registry);w(this,"instructions",new ae.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,l]=i,c=l,{title:n}=c,s=q(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}load(){return K(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.pluginSettingsManager.add(m,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:yn,aclSnippet:"pm.workflow.workflows"}),this.triggers.register("collection",new vn),this.triggers.register("schedule",new jn),this.instructions.register("calculation",new Ln),this.instructions.register("condition",new Un),this.instructions.register("query",new Yn),this.instructions.register("create",new _n),this.instructions.register("update",new Kn),this.instructions.register("destroy",new Zn)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:Qn})}addComponents(){this.app.addComponents({WorkflowPage:Kt,ExecutionPage:Gt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Se(":id"),element:r.jsx(Kt,{})}),this.app.router.add("admin.workflow.executions.id",{path:At(":id"),element:r.jsx(Gt,{})})}}y.BaseTypeSets=Ge,y.Branch=Ye,y.CollectionBlockInitializer=Ee,y.EXECUTION_STATUS=le,y.ExecutionStatusOptions=Je,y.ExecutionStatusOptionsMap=He,y.FieldsSelect=Ot,y.FilterDynamicComponent=Ke,y.FlowContext=ze,y.Instruction=be,y.JOB_STATUS=pe,y.JobButton=jt,y.JobStatusOptions=mt,y.JobStatusOptionsMap=Ue,y.Node=Bt,y.NodeContext=ft,y.NodeDefaultView=ht,y.RadioWithTooltip=Ze,y.RemoveButton=Vt,y.Trigger=yt,y.ValueBlock=Me,y.WorkflowVariableInput=Ut,y.WorkflowVariableJSON=Qo,y.WorkflowVariableRawTextArea=Zo,y.WorkflowVariableTextArea=Ct,y.default=ce,y.defaultFieldNames=Ne,y.getCollectionFieldOptions=ke,y.isValidFilter=qe,y.linkNodes=kt,y.nodesOptions=Lt,y.scopeOptions=zt,y.systemOptions=Jt,y.traverseSchema=St,y.triggerOptions=Wt,y.useAvailableUpstreams=It,y.useFlowContext=Z,y.useGetAriaLabelOfAddButton=pt,y.useNodeContext=Ce,y.useStyles=ee,y.useTrigger=gt,y.useUpstreamScopes=Pt,y.useWorkflowVariableOptions=me,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});