@nocobase/plugin-workflow 0.18.0-alpha.1 → 0.18.0-alpha.8

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 (47) hide show
  1. package/dist/client/index.d.ts +8 -0
  2. package/dist/client/index.js +30 -30
  3. package/dist/client/nodes/calculation.d.ts +7 -2
  4. package/dist/client/nodes/index.d.ts +10 -5
  5. package/dist/client/triggers/collection.d.ts +0 -1
  6. package/dist/client/triggers/index.d.ts +2 -3
  7. package/dist/client/triggers/schedule/index.d.ts +0 -1
  8. package/dist/client/variable.d.ts +15 -14
  9. package/dist/externalVersion.js +9 -8
  10. package/dist/locale/en-US.json +1 -1
  11. package/dist/locale/es-ES.json +1 -1
  12. package/dist/locale/fr-FR.json +1 -1
  13. package/dist/locale/pt-BR.json +1 -1
  14. package/dist/locale/zh-CN.json +3 -1
  15. package/dist/node_modules/cron-parser/package.json +1 -1
  16. package/dist/node_modules/lru-cache/package.json +1 -1
  17. package/dist/server/Plugin.d.ts +9 -11
  18. package/dist/server/Plugin.js +38 -24
  19. package/dist/server/Processor.d.ts +9 -5
  20. package/dist/server/Processor.js +8 -33
  21. package/dist/server/actions/workflows.js +4 -4
  22. package/dist/server/collections/executions.js +0 -5
  23. package/dist/server/collections/workflows.js +0 -5
  24. package/dist/server/constants.d.ts +17 -22
  25. package/dist/server/constants.js +0 -7
  26. package/dist/server/instructions/CalculationInstruction.d.ts +4 -2
  27. package/dist/server/instructions/CalculationInstruction.js +2 -10
  28. package/dist/server/instructions/ConditionInstruction.d.ts +10 -2
  29. package/dist/server/instructions/ConditionInstruction.js +7 -0
  30. package/dist/server/instructions/CreateInstruction.d.ts +1 -1
  31. package/dist/server/instructions/CreateInstruction.js +4 -4
  32. package/dist/server/instructions/DestroyInstruction.d.ts +1 -1
  33. package/dist/server/instructions/DestroyInstruction.js +2 -2
  34. package/dist/server/instructions/QueryInstruction.d.ts +4 -1
  35. package/dist/server/instructions/QueryInstruction.js +2 -2
  36. package/dist/server/instructions/UpdateInstruction.d.ts +1 -1
  37. package/dist/server/instructions/UpdateInstruction.js +2 -2
  38. package/dist/server/instructions/index.d.ts +9 -6
  39. package/dist/server/instructions/index.js +2 -2
  40. package/dist/server/triggers/CollectionTrigger.js +3 -3
  41. package/dist/server/triggers/ScheduleTrigger.d.ts +1 -1
  42. package/dist/server/triggers/ScheduleTrigger.js +14 -14
  43. package/dist/server/triggers/index.d.ts +2 -2
  44. package/dist/server/triggers/index.js +2 -2
  45. package/dist/server/types/Execution.d.ts +0 -2
  46. package/dist/server/types/Workflow.d.ts +0 -1
  47. package/package.json +6 -5
@@ -1,4 +1,4 @@
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`
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,x,oe,be,V,we,ae,ie,Bo,De,Vo){"use strict";var or=Object.defineProperty,nr=Object.defineProperties;var rr=Object.getOwnPropertyDescriptors;var dt=Object.getOwnPropertySymbols;var Io=Object.prototype.hasOwnProperty,Mo=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={}))Io.call(r,T)&&Dt(y,T,r[T]);if(dt)for(var T of dt(r))Mo.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)Io.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&&Mo.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 x=V=>{try{be(T.next(V))}catch(we){g(we)}},oe=V=>{try{be(T.throw(V))}catch(we){g(we)}},be=V=>V.done?a(V.value):Promise.resolve(V.value).then(x,oe);be((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`
2
2
  flex-grow: 1;
3
3
  overflow: hidden;
4
4
  display: flex;
@@ -351,12 +351,12 @@
351
351
  border-radius: 50%;
352
352
  background-color: ${t.colorText};
353
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`
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={},[I]=k,z=n.get(D);if(I){const{value:v}=(J=(H=z.options)==null?void 0:H.find(N=>N.key===I))!=null?J:{};Object.assign(S,typeof v=="function"?v():v)}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(x.Dropdown,{trigger:["click"],menu:h,disabled:l.executed,overlayClassName:a.css`
355
355
  .ant-dropdown-menu-root {
356
356
  max-height: 30em;
357
357
  overflow-y: auto;
358
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`
359
+ `,children:r.jsx(x.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
360
  margin-bottom: 1.5em;
361
361
  padding: 1em;
362
362
  background-color: ${t.colorFillAlter};
@@ -381,11 +381,11 @@
381
381
  p {
382
382
  color: ${t.colorTextDescription};
383
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:{}};/*!
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(x.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 It={exports:{}};/*!
385
385
  Copyright (c) 2018 Jed Watson.
386
386
  Licensed under the MIT License (MIT), see
387
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`
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})()})(It);var Wo=It.exports;const zo=Lo(Wo),Jo=a.createStyles(({css:e,token:t})=>({statusButtonClass:e`
389
389
  border: none;
390
390
  .ant-tag {
391
391
  width: 100%;
@@ -397,7 +397,7 @@
397
397
  }
398
398
  `,noStatusButtonClass:e`
399
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`
400
+ `}));function Ne(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(x.Tag,{color:i,children:s})}return r.jsx(x.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 he{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){x.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 Mt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}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}=x.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(x.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(Ne,{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(x.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ne,{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(Ne,{statusMap:Ue,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ne,{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 v=we.cloneDeep(t.config);return be.createForm({initialValues:v,disabled:i.executed})},[t,i]),I=g.useCallback(v=>{k(v),v||S.reset()},[S]),z=g.useCallback(function(v){return K(this,null,function*(){var j,M;const N=v||b;h(N),N!==t.title&&(yield(M=(j=s.resource("flow_nodes")).update)==null?void 0:M.call(j,{filterByTk:t.id,values:{title:N}}),l())})},[t]),H=g.useCallback(function(v){if(v.target===v.currentTarget){k(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let j=v.target;j&&j!==v.currentTarget&&j!==document.documentElement;j=j.parentNode)if(Array.from(j.classList).some(M=>N.has(M))){k(!0),v.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(x.Tag,{children:b}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(x.Input.TextArea,{disabled:i.executed,value:O,onChange:v=>h(v.target.value),onBlur:v=>z(v.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:p,setVisible:I,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":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:a.css`
401
401
  display: flex;
402
402
  justify-content: space-between;
403
403
 
@@ -412,7 +412,7 @@
412
412
  code {
413
413
  font-weight: normal;
414
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`
415
+ `,children:[r.jsx("strong",{children:t.title}),r.jsx(x.Tooltip,{title:E("Variable key of node"),children:r.jsx(x.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
416
  .ant-input,
417
417
  .ant-select,
418
418
  .ant-cascader-picker,
@@ -424,38 +424,38 @@
424
424
  min-width: 6em;
425
425
  }
426
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`
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){x.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,"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(x.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
428
  padding: 1em;
429
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`
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")}}',I=E("Trigger");g.useEffect(()=>{var v;t&&s((v=t.title)!=null?v:p)},[t]);const z=g.useMemo(()=>{const v=we.cloneDeep(t==null?void 0:t.config);return be.createForm({initialValues:v,disabled:t==null?void 0:t.executed})},[t]),H=g.useCallback(v=>{l(v),v||z.reset()},[z]),J=g.useCallback(function(v){return K(this,null,function*(){var j,M;const N=v||p;s(N),N!==O&&(yield(M=(j=e.resource("workflows")).update)==null?void 0:M.call(j,{filterByTk:t.id,values:{title:N}}),o())})},[t]),L=g.useCallback(function(v){var j;if(v.target===v.currentTarget){l(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let M=v.target;M&&M!==v.currentTarget;M=M.parentNode)if(Array.from((j=M.classList)!=null?j:[]).some(ne=>N.has(ne))){l(!0),v.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${I}-${n}`,className:a.cx(u.nodeCardClass),onClick:L,children:[r.jsx("div",{className:a.cx(u.nodeMetaClass,"workflow-node-meta"),children:r.jsx(x.Tag,{color:"gold",children:I})}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{value:n,onChange:v=>s(v.target.value),onBlur:v=>J(v.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":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:I,"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
431
  .ant-select.auto-width {
432
432
  width: auto;
433
433
  min-width: 6em;
434
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`
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 ke={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=Mt(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=ke,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=ke}){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 o,n,s,i,l,c;return typeof t=="string"?(o=Ge[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?bt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="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({},ke,(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=Se(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 Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:d=ke}=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(x.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 i=e,{options:t=[],direction:o}=i,n=q(i,["options","direction"]),s=a.useCompile();return r.jsx(x.Radio.Group,A(C({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.Radio,{value:l.value,children:[r.jsx("span",{className:a.css`
436
+ & + .anticon {
437
+ margin-left: 0.25em;
438
+ }
439
+ `,children:s(l.label)}),l.tooltip&&r.jsx(x.Tooltip,{title:s(l.tooltip),children:r.jsx(T.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}const Ie=()=>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
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`
441
+ `,children:JSON.stringify(n,null,2)})}Ie.Initializer=en,Ie.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
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`
443
+ `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(x.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:a.css`
444
444
  margin-bottom: 1em;
445
445
  `}):null,r.jsx(qo,{}),r.jsx("div",{className:a.cx(t.branchBlockClass,a.css`
446
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`
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(x.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}const Oe=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(x.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(x.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(Ne,{statusMap:He,status:f.status})})}))},children:r.jsxs(x.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 I;const{workflow:S}=(I=t==null?void 0:t.data)!=null?I:{};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(x.Spin,{}):r.jsx(x.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(x.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:l.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(ie.Link,{to:Oe(f.id),children:f.title})},{title:r.jsx(rn,{})}]})}),r.jsxs("aside",{children:[r.jsx(x.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:Oe(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}),x.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}=x.App.useApp();if(g.useEffect(()=>{var N;const{title:v}=(N=n==null?void 0:n.data)!=null?N:{};c==null||c(`${E("Workflow")}${v?`: ${v}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(x.Spin,{}):r.jsx(x.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(v=>!v.upstream);function F({key:v}){v!=p.id&&e(Oe(v))}function D(v){return K(this,null,function*(){yield l.update({filterByTk:p.id,values:{enabled:v}}),s()})}function S(){return K(this,null,function*(){const{data:{data:v}}=yield l.revision({filterByTk:p.id,filter:{key:p.key}});x.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${v.id}`)})}function I(){return K(this,null,function*(){const v=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:v,onOk(){return K(this,null,function*(){var j;yield l.destroy({filterByTk:p.id}),x.message.success(t("Operation succeeded")),e(p.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((j=h.find(M=>M.current))==null?void 0:j.id))})}})})}function z(N){return K(this,arguments,function*({key:v}){switch(v){case"history":u(!0);return;case"revision":return S();case"delete":return I()}})}const H=p.executed&&!h.find(v=>!v.executed&&new Date(v.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(x.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(x.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${p.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((v,N)=>N.id-v.id).map((v,N)=>({role:"button","aria-label":`version-${N}`,key:`${v.id}`,icon:v.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:v.executed,unexecuted:!v.executed,enabled:v.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${v.id}`}),r.jsx("time",{children:ae.str2moment(v.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.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(x.Switch,{checked:p.enabled,onChange:D,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(x.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(x.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:Oe(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"}]},ye={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:ye.title,type:ye.type,description:ye.description,options:ye.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:ye.title,enabled:ye.enabled,description:ye.description,options:ye.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}),x.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(x.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(x.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(x.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(x.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 ge={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`
448
448
  flex-direction: column;
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`
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}" })}}`},Me={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`
450
450
  position: relative;
451
451
  width: 100%;
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`
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]}}"}}}]},Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},xn=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ae.DELETED}];class vn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);w(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);w(this,"fieldset",{collection:A(C({},ge),{"x-reactions":[...ge["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] & ${Ae.UPDATED})}}`}}}]},condition:A(C({},Me),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{useProps:Me["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] & ${Ae.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 Se(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`
453
453
  display: flex;
454
454
  gap: 0.5em;
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`
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(x.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(x.InputNumber,{value:Math.abs(e.offset),onChange:i=>t(A(C({},e),{offset:(i!=null?i:0)*n}))}),r.jsx(x.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`
456
456
  display: flex;
457
457
  gap: 0.5em;
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`
458
+ `,children:[r.jsxs(x.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Rt,{value:e,onChange:t}):null,n==="date"?r.jsx(x.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 I=S.replace(/\s+/g," ").trim().split(" ");if(I.length===5)return I.map(function(z,H){return function(J,L){if(J==="*"||J==="*/1")return[];var v=Xe(oo(ao(function(j,M,ne){if(ne){j=j.toUpperCase();for(var $=0;$<ne.length;$++)j=j.replace(ne[$],"".concat($+M))}return j}(J,L.min,L.alt).split(",").map(function(j){var M,ne=j.split("/");if(ne.length>2)throw new Error('Invalid value "'.concat(J,' for "').concat(L.type,'"'));var $=ne[0],B=ne[1];M=$==="*"?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]),Fe=Re(X[1]);if(isNaN(de)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(Q.type));if(Fe<de)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(Q.type));return to(de,Fe)}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}(M,W);return re}).flat(),L))),N=co(v,L);if(N!==void 0)throw new Error('Value "'.concat(N,'" out of range for ').concat(L.type));return v.length===L.total?[]:v}(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(Te(uo(e),t,o,n,s),"-").concat(Te(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(Te(c[0],t,o,n,s),"-").concat(Te(c[1],t,o,n,s)):Te(c,t,o,n,s)}).join(",")}return i}function Te(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]),I=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:Te(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===I.length;i(Y||U?[]:W)}else i([])},[t,I,i]),v=g.useRef([]),N=g.useCallback(function($){if(!f){var B=v.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($)),v.current=[]},300);return function(){window.clearTimeout(W)}}},[v,J,L,f,k]),j=g.useCallback(function(){f||i([])},[i,f]),M=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(x.Select,te({mode:F!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:j,tagRender:H,className:M,popupClassName:ne,options:I,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(x.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 I;return se(((I={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,I["".concat(s,"-week-days")]=!!s,I))},[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,I=S===void 0?"for-default-value":S,z=e.humanizeLabels,H=z===void 0||z,J=e.humanizeValue,L=J!==void 0&&J,v=e.disabled,N=v!==void 0&&v,j=e.readOnly,M=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,Fe=e.allowedPeriods,Xn=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=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,I,$e,!0,d,W,at,it,tt,nt,rt,et)},[]),g.useEffect(function(){f!==$e.current&&ro(f,We,p,I,$e,!1,d,W,at,it,tt,nt,rt,et)},[f,$e,Fo,I,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}),$e.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}),$e.current=G,To(!0),I==="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":M})["".concat(k)]=!!k,G["".concat(k,"-error")]=Ft&&h&&!!k,G["".concat(k,"-disabled")]=N&&!!k,G["".concat(k,"-read-only")]=M&&!!k,G))},[k,Ft,h,N,M]),$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&&!M?r.jsx(x.Button,te({className:No,danger:!0,type:"primary",disabled:N},Do,{onClick:$o},{children:d.clearButtonText||P.clearButtonText})):null},[o,M,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:M,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:M,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:M,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:M,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:M,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:M,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 In({value:e,onChange:t}){const{t:o}=ut(),n=fo(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Mn({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`
459
459
  display: flex;
460
460
  flex-direction: ${n==="cron"?"column":"row"};
461
461
  align-items: flex-start;
@@ -484,7 +484,7 @@
484
484
  }
485
485
  }
486
486
  }
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`
487
+ `,children:[r.jsx(x.Select,{value:n,onChange:s,className:"auto-width",children:mo.map(l=>r.jsx(x.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(In,{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({},ge),{"x-reactions":[...ge["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(()=>{be.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`
488
488
  .ant-input-number {
489
489
  width: auto;
490
490
  min-width: 6em;
@@ -493,23 +493,23 @@
493
493
  .ant-picker {
494
494
  width: auto;
495
495
  }
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`
496
+ `},properties:Pn[o]}}},components:{OnField:Rt,RepeatField:Mn,EndsByField:Cn}})]})};class jn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);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]=Se(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=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
497
497
  &:after {
498
498
  content: ':';
499
499
  }
500
500
  & + a {
501
501
  margin-left: 0.25em;
502
502
  }
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`
503
+ `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Ln extends he{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:De.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}=De.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:Ie})}useVariables({key:o,title:n},{types:s,fieldNames:i=ke}){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:Ie.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`
504
504
  display: flex;
505
505
  gap: 0.5em;
506
506
  align-items: center;
507
507
  flex-wrap: wrap;
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`
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(x.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:E("Operator"),popupMatchSelectWidth:!1,children:Wn.filter(i=>!!yo(i.value).length).map(i=>r.jsx(x.Select.OptGroup,{label:n(i.title),children:yo(i.value).map(([l,{name:c}])=>r.jsx(x.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`
509
509
  display: flex;
510
510
  position: relative;
511
511
  margin: 0.5em 0;
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`
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(x.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`
513
513
  position: relative;
514
514
  width: 100%;
515
515
  .node-type-condition-group {
@@ -528,14 +528,14 @@
528
528
  width: auto;
529
529
  min-width: 6em;
530
530
  }
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`
531
+ `,children:r.jsxs(oe.Trans,{children:["Meet ",r.jsxs(x.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(A(C({},e),{type:u})),children:[r.jsx(x.Select.Option,{value:"and",children:"All"}),r.jsx(x.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`
532
532
  button {
533
533
  padding: 0;
534
534
  &:not(:last-child) {
535
535
  margin-right: 1em;
536
536
  }
537
537
  }
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`
538
+ `,children:[r.jsx(x.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(x.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 he{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(De.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}=De.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 he{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:ge,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:Me,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]=Se(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(x.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 I,z;return{key:S.name,label:l((z=(I=S.uiSchema)==null?void 0:I.title)!=null?z:S.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:a.css`
539
539
  margin-top: 0.5em;
540
540
 
541
541
  > .ant-formily-item {
@@ -545,8 +545,8 @@
545
545
  line-height: 32px;
546
546
  }
547
547
  }
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`
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 I=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?Gn:a.CollectionField;return r.jsxs(x.Form.Item,{label:l((H=(z=S.uiSchema)==null?void 0:z.title)!=null?H:S.name),labelAlign:"left",className:a.css`
549
549
  .ant-form-item-control-input-content {
550
550
  display: flex;
551
551
  }
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"}})});
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":I,"x-validator"(){return""}}}}})}),F?null:r.jsx(x.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var v;const N=e,{[v=S.name]:J}=N,L=q(N,[Po(v)]);o(L)}})]},S.name)}),k.length?r.jsx(x.Dropdown,{menu:D,children:r.jsx(x.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 he{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:ge,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]=Se(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 he{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:ge,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({},Me),{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 he{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:ge,params:{type:"object",properties:{filter:A(C({},Me),{"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}=x.App.useApp(),f=a.useCollectValuesToSubmit(),b=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var D,S,I;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,(I=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||I.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))})}):x.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}}))}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof he)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}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.registerTrigger("collection",vn),this.registerTrigger("schedule",jn),this.registerInstruction("calculation",Ln),this.registerInstruction("condition",Un),this.registerInstruction("query",Yn),this.registerInstruction("create",_n),this.registerInstruction("update",Kn),this.registerInstruction("destroy",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:Oe(":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=he,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=Ie,y.WorkflowVariableInput=Ut,y.WorkflowVariableJSON=Qo,y.WorkflowVariableRawTextArea=Zo,y.WorkflowVariableTextArea=Ct,y.default=ce,y.defaultFieldNames=ke,y.getCollectionFieldOptions=Se,y.isValidFilter=qe,y.linkNodes=kt,y.nodesOptions=Lt,y.scopeOptions=zt,y.systemOptions=Jt,y.traverseSchema=St,y.triggerOptions=Wt,y.useAvailableUpstreams=Mt,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"}})});