@nocobase/plugin-workflow 0.19.0-alpha.7 → 0.19.0-alpha.9

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.
@@ -1,4 +1,4 @@
1
- (function(g,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):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,T,a,b,y,Q,ge,P,we,ue,ie,Vo,Ee,jo){"use strict";var lr=Object.defineProperty,ir=Object.defineProperties;var ar=Object.getOwnPropertyDescriptors;var ut=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Po=Object.prototype.propertyIsEnumerable;var Et=(g,r,T)=>r in g?lr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[r]=T,w=(g,r)=>{for(var T in r||(r={}))Mo.call(r,T)&&Et(g,T,r[T]);if(ut)for(var T of ut(r))Po.call(r,T)&&Et(g,T,r[T]);return g},A=(g,r)=>ir(g,ar(r));var Bo=g=>typeof g=="symbol"?g:g+"",q=(g,r)=>{var T={};for(var a in g)Mo.call(g,a)&&r.indexOf(a)<0&&(T[a]=g[a]);if(g!=null&&ut)for(var a of ut(g))r.indexOf(a)<0&&Po.call(g,a)&&(T[a]=g[a]);return T};var x=(g,r,T)=>(Et(g,typeof r!="symbol"?r+"":r,T),T);var K=(g,r,T)=>new Promise((a,b)=>{var y=P=>{try{ge(T.next(P))}catch(we){b(we)}},Q=P=>{try{ge(T.throw(P))}catch(we){b(we)}},ge=P=>P.done?a(P.value):Promise.resolve(P.value).then(y,Q);ge((T=T.apply(g,r)).next())});const Je=b.createContext({});function Z(){return b.useContext(Je)}const p="workflow";function D(e,t={}){return a.i18n.t(e,A(w({},t),{ns:p}))}function dt(){return Q.useTranslation(p)}const te=a.createStyles(({css:e,token:t})=>({workflowPageClass:e`
1
+ (function(g,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):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,T,a,b,y,Q,ge,P,we,ue,ie,Vo,De,jo){"use strict";var lr=Object.defineProperty,ir=Object.defineProperties;var ar=Object.getOwnPropertyDescriptors;var ut=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Po=Object.prototype.propertyIsEnumerable;var Dt=(g,r,T)=>r in g?lr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[r]=T,w=(g,r)=>{for(var T in r||(r={}))Mo.call(r,T)&&Dt(g,T,r[T]);if(ut)for(var T of ut(r))Po.call(r,T)&&Dt(g,T,r[T]);return g},A=(g,r)=>ir(g,ar(r));var Bo=g=>typeof g=="symbol"?g:g+"",q=(g,r)=>{var T={};for(var a in g)Mo.call(g,a)&&r.indexOf(a)<0&&(T[a]=g[a]);if(g!=null&&ut)for(var a of ut(g))r.indexOf(a)<0&&Po.call(g,a)&&(T[a]=g[a]);return T};var x=(g,r,T)=>(Dt(g,typeof r!="symbol"?r+"":r,T),T);var K=(g,r,T)=>new Promise((a,b)=>{var y=P=>{try{ge(T.next(P))}catch(we){b(we)}},Q=P=>{try{ge(T.throw(P))}catch(we){b(we)}},ge=P=>P.done?a(P.value):Promise.resolve(P.value).then(y,Q);ge((T=T.apply(g,r)).next())});const Je=b.createContext({});function Z(){return b.useContext(Je)}const p="workflow";function E(e,t={}){return a.i18n.t(e,A(w({},t),{ns:p}))}function dt(){return Q.useTranslation(p)}const te=a.createStyles(({css:e,token:t})=>({workflowPageClass:e`
2
2
  flex-grow: 1;
3
3
  overflow: hidden;
4
4
  display: flex;
@@ -350,7 +350,7 @@
350
350
  border-radius: 50%;
351
351
  background-color: ${t.colorText};
352
352
  color: ${t.colorBgContainer};
353
- `}));function Dt(e){var h;const{upstream:t,branchIndex:o=null}=e,n=a.usePlugin(ce),s=a.useCompile(),l=a.useAPIClient(),{workflow:i,refresh:c}=(h=Z())!=null?h:{},u=Array.from(n.instructions.getValues()),{styles:d}=te(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(m=>{const C=u.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({engine:n,workflow:i,upstream:t,branchIndex:o}):!0));return A(w({},m),{type:"group",children:C.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(M=>({role:"button","aria-label":M.key,key:M.key,label:M.label})):null}))})}).filter(m=>m.children.length),[o,n,u,t,i]),v=b.useCallback(C=>K(this,[C],function*({keyPath:m}){var z,H,$;const F=m.pop(),M={},[O]=m,B=n.instructions.get(F);if(O){const{value:N}=(H=(z=B.options)==null?void 0:z.find(S=>S.key===O))!=null?H:{};Object.assign(M,typeof N=="function"?N():N)}i&&(yield l.resource("workflows.nodes",i.id).create({values:{type:F,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:s(B.title),config:M}}),c())}),[l,o,n.instructions,c,t==null?void 0:t.id,i]),k=b.useMemo(()=>({onClick:v,items:s(f)}),[f,v]);return i?r.jsx("div",{className:d.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:k,disabled:i.executed,overlayClassName:a.css`
353
+ `}));function Et(e){var h;const{upstream:t,branchIndex:o=null}=e,n=a.usePlugin(ce),s=a.useCompile(),l=a.useAPIClient(),{workflow:i,refresh:c}=(h=Z())!=null?h:{},u=Array.from(n.instructions.getValues()),{styles:d}=te(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(m=>{const C=u.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({engine:n,workflow:i,upstream:t,branchIndex:o}):!0));return A(w({},m),{type:"group",children:C.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(M=>({role:"button","aria-label":M.key,key:M.key,label:M.label})):null}))})}).filter(m=>m.children.length),[o,n,u,t,i]),v=b.useCallback(C=>K(this,[C],function*({keyPath:m}){var z,H,$;const F=m.pop(),M={},[O]=m,B=n.instructions.get(F);if(O){const{value:N}=(H=(z=B.options)==null?void 0:z.find(S=>S.key===O))!=null?H:{};Object.assign(M,typeof N=="function"?N():N)}i&&(yield l.resource("workflows.nodes",i.id).create({values:{type:F,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:s(B.title),config:M}}),c())}),[l,o,n.instructions,c,t==null?void 0:t.id,i]),k=b.useMemo(()=>({onClick:v,items:s(f)}),[f,v]);return i?r.jsx("div",{className:d.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:k,disabled:i.executed,overlayClassName:a.css`
354
354
  .ant-dropdown-menu-root {
355
355
  max-height: 30em;
356
356
  overflow-y: auto;
@@ -396,7 +396,7 @@
396
396
  }
397
397
  `,noStatusButtonClass:e`
398
398
  border-width: 2px;
399
- `}));function De(e){var n;const{styles:t}=Ho();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:l}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:l,children:s})}return r.jsx(y.Button,A(w({},e),{shape:"circle",size:"small",className:Jo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ae={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:ae.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(T.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ae.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ae.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ae.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ue=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),re={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:re.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.ClockCircleOutlined,{})},{value:re.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{})},{value:re.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{})},{value:re.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{})},{value:re.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90})},{value:re.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45})},{value:re.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{})},{value:re.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{})}],Ye=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class fe{constructor(){x(this,"title");x(this,"type");x(this,"group");x(this,"description");x(this,"options");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"end")}}function Uo(){const e=P.useForm(),t=a.useAPIClient(),o=a.useActionContext(),{refresh:n}=a.useResourceActionContext(),s=Ce(),{workflow:l}=Z();return{run(){return K(this,null,function*(){var c,u;if(l.executed){y.message.error(D("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=b.createContext({});function Ce(){return b.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}=te(),{getAriaLabel:o}=pt(e),n=a.usePlugin(ce),{Component:s=ht,end:l}=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}),!l||typeof l=="function"&&!l(e)?r.jsx(Dt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=a.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Z())!=null?d:{},l=Ce(),{modal:i}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function f(){return K(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:l.id}),s()})}const v=n.filter(m=>m===l?!1:ue.parse(m.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${l.key}.`)||M===`$jobsMapByNodeKey.${l.key}`).length);if(v.length){i.error({title:D("Can not delete"),content:D("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:v.map(m=>`#${m.id}`).join(", ")})});return}const h=!n.find(m=>m.upstream===l&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):D("This node contains branches, deleting will also be preformed to them, are you sure?");i.confirm({title:e("Delete"),content:h,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(T.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var l;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(l=Ce())!=null?l:{},{styles:n}=te();if(!e)return null;if(!o.length)return r.jsx(De,{className:n.nodeJobButtonClass,disabled:!0});function s({key:i}){const c=o.find(u=>u.id==i);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(i=>({key:i.id,label:r.jsxs(r.Fragment,{children:[r.jsx(De,{statusMap:Ye,status:i.status}),r.jsx("time",{children:ue.str2moment(i.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(De,{statusMap:Ye,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(De,{statusMap:Ye,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Yo(){return{form:P.useForm()}}function ht(e){var $,N;const{data:t,children:o}=e,n=a.useCompile(),s=a.useAPIClient(),{workflow:l,refresh:i}=($=Z())!=null?$:{},{styles:c}=te(),d=a.usePlugin(ce).instructions.get(t.type),f=l.executed?'{{t("View")}}':'{{t("Configure")}}',v=n(d.title),[k,h]=b.useState((N=t.title)!=null?N:v),[m,C]=b.useState(!1),[F,M]=b.useState(!1),O=b.useMemo(()=>{const S=we.cloneDeep(t.config);return ge.createForm({initialValues:S,disabled:l.executed})},[t,l]),B=b.useCallback(S=>{C(S),S||O.reset()},[O]),z=b.useCallback(function(S){return K(this,null,function*(){var W,J;const I=S||v;h(I),I!==t.title&&(yield(J=(W=s.resource("flow_nodes")).update)==null?void 0:J.call(W,{filterByTk:t.id,values:{title:I}}),i())})},[t]),H=b.useCallback(function(S){if(S.target===S.currentTarget){C(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let W=S.target;W&&W!==S.currentTarget&&W!==document.documentElement;W=W.parentNode)if(Array.from(W.classList).some(J=>I.has(J))){C(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${v}-${k}`,className:a.cx(c.nodeCardClass,{configuring:m}),onClick:H,children:[r.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:v}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:l.executed,value:k,onChange:S=>h(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:m,setVisible:B,formValueChanged:F,setFormValueChanged:M},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},d.scope),{useFormProviderProps:Yo}),components:d.components,schema:{type:"void",properties:A(w({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:a.css`
399
+ `}));function Ee(e){var n;const{styles:t}=Ho();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:l}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:l,children:s})}return r.jsx(y.Button,A(w({},e),{shape:"circle",size:"small",className:Jo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ae={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:ae.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(T.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ae.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ae.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ae.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ue=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),re={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:re.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.ClockCircleOutlined,{})},{value:re.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{})},{value:re.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{})},{value:re.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{})},{value:re.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90})},{value:re.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45})},{value:re.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{})},{value:re.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{})}],Ye=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class fe{constructor(){x(this,"title");x(this,"type");x(this,"group");x(this,"description");x(this,"options");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"end")}}function Uo(){const e=P.useForm(),t=a.useAPIClient(),o=a.useActionContext(),{refresh:n}=a.useResourceActionContext(),s=Ce(),{workflow:l}=Z();return{run(){return K(this,null,function*(){var c,u;if(l.executed){y.message.error(E("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=b.createContext({});function Ce(){return b.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}=te(),{getAriaLabel:o}=pt(e),n=a.usePlugin(ce),{Component:s=ht,end:l}=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}),!l||typeof l=="function"&&!l(e)?r.jsx(Et,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=a.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Z())!=null?d:{},l=Ce(),{modal:i}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function f(){return K(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:l.id}),s()})}const v=n.filter(m=>m===l?!1:ue.parse(m.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${l.key}.`)||M===`$jobsMapByNodeKey.${l.key}`).length);if(v.length){i.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:v.map(m=>`#${m.id}`).join(", ")})});return}const h=!n.find(m=>m.upstream===l&&m.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?");i.confirm({title:e("Delete"),content:h,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(T.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var l;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(l=Ce())!=null?l:{},{styles:n}=te();if(!e)return null;if(!o.length)return r.jsx(Ee,{className:n.nodeJobButtonClass,disabled:!0});function s({key:i}){const c=o.find(u=>u.id==i);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(i=>({key:i.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ee,{statusMap:Ye,status:i.status}),r.jsx("time",{children:ue.str2moment(i.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ee,{statusMap:Ye,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ee,{statusMap:Ye,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Yo(){return{form:P.useForm()}}function ht(e){var $,N;const{data:t,children:o}=e,n=a.useCompile(),s=a.useAPIClient(),{workflow:l,refresh:i}=($=Z())!=null?$:{},{styles:c}=te(),d=a.usePlugin(ce).instructions.get(t.type),f=l.executed?'{{t("View")}}':'{{t("Configure")}}',v=n(d.title),[k,h]=b.useState((N=t.title)!=null?N:v),[m,C]=b.useState(!1),[F,M]=b.useState(!1),O=b.useMemo(()=>{const S=we.cloneDeep(t.config);return ge.createForm({initialValues:S,disabled:l.executed})},[t,l]),B=b.useCallback(S=>{C(S),S||O.reset()},[O]),z=b.useCallback(function(S){return K(this,null,function*(){var W,J;const I=S||v;h(I),I!==t.title&&(yield(J=(W=s.resource("flow_nodes")).update)==null?void 0:J.call(W,{filterByTk:t.id,values:{title:I}}),i())})},[t]),H=b.useCallback(function(S){if(S.target===S.currentTarget){C(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let W=S.target;W&&W!==S.currentTarget&&W!==document.documentElement;W=W.parentNode)if(Array.from(W.classList).some(J=>I.has(J))){C(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${v}-${k}`,className:a.cx(c.nodeCardClass,{configuring:m}),onClick:H,children:[r.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:v}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:l.executed,value:k,onChange:S=>h(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:m,setVisible:B,formValueChanged:F,setFormValueChanged:M},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},d.scope),{useFormProviderProps:Yo}),components:d.components,schema:{type:"void",properties:A(w({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:a.css`
400
400
  display: flex;
401
401
  justify-content: space-between;
402
402
 
@@ -411,7 +411,7 @@
411
411
  code {
412
412
  font-weight: normal;
413
413
  }
414
- `,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:D("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:A(w({},d.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:D("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
414
+ `,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:E("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:A(w({},d.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
415
415
  .ant-input,
416
416
  .ant-select,
417
417
  .ant-cascader-picker,
@@ -423,15 +423,15 @@
423
423
  min-width: 6em;
424
424
  }
425
425
  }
426
- `},properties:d.fieldset},actions:l.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:Uo}}}}})}})}})})})]}),o]})}function Ge({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:l}){const{styles:i}=te(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:a.cx("workflow-branch",i.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Dt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(Bt,{data:d},d.id))}),l?r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})}):null]})}function Go(){var l;const e=P.useForm(),t=a.useAPIClient(),{workflow:o}=(l=Z())!=null?l:{},n=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return K(this,null,function*(){if(o.executed){y.message.error(D("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class yt{constructor(){x(this,"sync");x(this,"title");x(this,"description");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"initializers");x(this,"isActionTriggerable")}}function qo(){const e=a.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=te(),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(y.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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:a.css`
426
+ `},properties:d.fieldset},actions:l.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:Uo}}}}})}})}})})})]}),o]})}function Ge({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:l}){const{styles:i}=te(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:a.cx("workflow-branch",i.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Et,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(Bt,{data:d},d.id))}),l?r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})}):null]})}function Go(){var l;const e=P.useForm(),t=a.useAPIClient(),{workflow:o}=(l=Z())!=null?l:{},n=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return K(this,null,function*(){if(o.executed){y.message.error(E("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class yt{constructor(){x(this,"sync");x(this,"title");x(this,"description");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"initializers");x(this,"isActionTriggerable")}}function qo(){const e=a.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=te(),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(y.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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:a.css`
427
427
  padding: 1em;
428
428
  background-color: #eee;
429
- `},"x-read-pretty":!0}}}}}}):null}function _o(){return{form:P.useForm()}}const Ko=()=>{const e=a.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=b.useState(""),[l,i]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=te(),f=a.useCompile(),v=gt(),k=f(v.title),{fieldset:h,scope:m,components:C}=v,F=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=D("Trigger");b.useEffect(()=>{var $,N;t&&s((N=($=t.triggerTitle)!=null?$:t.title)!=null?N:k)},[t]);const O=b.useMemo(()=>{const $=we.cloneDeep(t.config);return ge.createForm({initialValues:$,disabled:t.executed})},[t]),B=b.useCallback($=>{i($),$||O.reset()},[O]),z=b.useCallback(function($){return K(this,null,function*(){const N=$||k;s(N),N!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:N}}),o())})},[t]),H=b.useCallback(function($){var S;if($.target===$.currentTarget){i(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=$.target;I&&I!==$.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(W=>N.has(W))){i(!0),$.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:a.cx(d.nodeCardClass),onClick:H,children:[r.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:$=>s($.target.value),onBlur:$=>z($.target.value),autoSize:!0})}),r.jsx(qo,{}),r.jsx(a.ActionContextProvider,{value:{visible:l,setVisible:B,formValueChanged:c,setFormValueChanged:u},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},m),{useFormProviderProps:_o}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":y.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(w({},v.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:D("Trigger type"),title:v.title,description:v.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
429
+ `},"x-read-pretty":!0}}}}}}):null}function _o(){return{form:P.useForm()}}const Ko=()=>{const e=a.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=b.useState(""),[l,i]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=te(),f=a.useCompile(),v=gt(),k=f(v.title),{fieldset:h,scope:m,components:C}=v,F=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=E("Trigger");b.useEffect(()=>{var $,N;t&&s((N=($=t.triggerTitle)!=null?$:t.title)!=null?N:k)},[t]);const O=b.useMemo(()=>{const $=we.cloneDeep(t.config);return ge.createForm({initialValues:$,disabled:t.executed})},[t]),B=b.useCallback($=>{i($),$||O.reset()},[O]),z=b.useCallback(function($){return K(this,null,function*(){const N=$||k;s(N),N!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:N}}),o())})},[t]),H=b.useCallback(function($){var S;if($.target===$.currentTarget){i(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=$.target;I&&I!==$.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(W=>N.has(W))){i(!0),$.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:a.cx(d.nodeCardClass),onClick:H,children:[r.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:$=>s($.target.value),onBlur:$=>z($.target.value),autoSize:!0})}),r.jsx(qo,{}),r.jsx(a.ActionContextProvider,{value:{visible:l,setVisible:B,formValueChanged:c,setFormValueChanged:u},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},m),{useFormProviderProps:_o}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":y.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(w({},v.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Trigger type"),title:v.title,description:v.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
430
430
  .ant-select.auto-width {
431
431
  width: auto;
432
432
  min-width: 6em;
433
433
  }
434
- `},properties:h},actions:w({},t.executed?{}:{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:Go}}}})})}}}})})})]})};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: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=a.usePlugin(ce),o=Ce(),n=Mt(o),s=[];return n.forEach(l=>{var u;const i=t.get(l.type),c=(u=i.useVariables)==null?void 0:u.call(i,l,e);c&&s.push(c)}),s}},Wt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,l;const{triggers:t}=a.usePlugin(ce),{workflow:o}=Z(),n=t.get(o.type);return(l=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?l:null}},zt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=a.usePlugin(ce),s=Ce(),l=o!=null?o:s,i=Pt(l),c=[];return i.forEach(u=>{var v,k;const d=n.get(u.type),f=(v=d.useScopeVariables)==null?void 0:v.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(k=u.title)!=null?k:`#${u.id}`,[t.children]:f})}),c}},Jt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:D("System time"),[t.value]:"now"}]:[]]}},qe={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,l,i,c;return typeof t=="string"?(o=qe[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)||((l=t.options)==null?void 0:l.collection)==="*"):e.isForeignKey?e.collectionName===((i=t.options)==null?void 0:i.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:l}){return e.filter(i=>{const c=t!=null&&t.length?t.some(u=>Ht(i,u)):!0;if(bt(i)){if(o===null)return n?c||vt({fields:wt(i.target,{compile:s,getCollectionFields:l}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:l}):!1;const u=xt(i,o),d=o.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&vt({fields:wt(i.target,{compile:s,getCollectionFields:l}),types:t,appends:u,compile:s,getCollectionFields:l}).length}else return c})}function _e(e,t){var l,i;const o=a.useCompile(),n=(i=(l=e.useOptions)==null?void 0:l.call(e,t))==null?void 0:i.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 he(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 i,c,u,d,f,v,k;const n=o(e),s=[],l=[];n.forEach(h=>{h.isForeignKey?s.push(h):l.push(h)});for(let h=l.length-1;h>=0;h--){const m=l[h];if(m.type==="belongsTo"){const C=s.find(F=>F.name===m.foreignKey);C?l.splice(h,0,A(w(w({},m),C),{uiSchema:A(w({},m.uiSchema),{title:(i=m.uiSchema)!=null&&i.title?`${t((c=m.uiSchema)==null?void 0:c.title)} ID`:C.name})})):l.splice(h,0,A(w({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:A(w({},m.uiSchema),{title:(u=m.uiSchema)!=null&&u.title?`${t((d=m.uiSchema)==null?void 0:d.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const C=(f=l.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};l.splice(h,0,A(w({},m),{type:m.dataType,interface:C.interface,uiSchema:A(w({},C.uiSchema),{title:(v=C.uiSchema)!=null&&v.title?`${t((k=C.uiSchema)==null?void 0:k.title)} ID`:m.name})}))}}return l.filter(h=>h.interface&&!h.hidden)}function Zo(e){const t=xt(e.field,e.appends),o=Se(w({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:l=1,compile:i,getCollectionFields:c,fieldNames:u=ke}=e,d=wt(o,{compile:i,getCollectionFields:c}),f=t!=null?t:d,v=Zo.bind({compile:i,getCollectionFields:c,fieldNames:u});return vt({fields:f,types:n,depth:l,appends:s,compile:i,getCollectionFields:c}).map(h=>{var M;const m=i(((M=h.uiSchema)==null?void 0:M.title)||h.name),C=xt(h,s),F=!bt(h)||C&&!C.length&&!s.includes(h.name)||!1;return{[u.label]:m,key:h.name,[u.value]:h.name,isLeaf:F,loadChildren:F?null:v,field:h,depth:l,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.Input,w({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.TextArea,w({scope:s},t))}function Qo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.RawTextArea,w({scope:s},t))}function Xo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.JSON,w({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 Ke(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Ke(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 Ro(n){var s=n,{collection:e,dataSource:t}=s,o=q(s,["collection","dataSource"]);const{insert:l}=a.useSchemaInitializer(),{getTemplateSchemaByMode:i}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager(),u=a.useRecordCollectionDataSourceItems("FormItem"),d=c(e);function f(k){return K(this,arguments,function*({item:v}){const h=v.template?yield i(v):null,m={type:"void",name:d.name,title:d.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(m,C=>{C["x-uid"]&&delete C["x-uid"]}),l(m)})}return r.jsx(a.SchemaInitializerItem,A(w({},o),{onClick:f,items:u}))}function Ne(){const e=a.useSchemaInitializerItem();return r.jsx(a.CollectionProvider,{collection:e.collection,children:r.jsx(Ro,w({},e))})}function en(){return!0}const Ot=P.observer(e=>{const c=e,{filter:t=en}=c,o=q(c,["filter"]),n=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager(),{values:l}=P.useForm(),i=s(l==null?void 0:l.collection);return r.jsx(y.Select,A(w({popupMatchSelectWidth:!1},o),{options:i.filter(t).map(u=>{var d;return{label:n((d=u.uiSchema)==null?void 0:d.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Ze({value:e,onChange:t,renderSchemaComponent:o}){const n=he();return r.jsx(a.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const l=e,{options:t=[],direction:o}=l,n=q(l,["options","direction"]),s=a.useCompile();return r.jsx(y.Radio.Group,A(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(i=>r.jsxs(y.Radio,{value:i.value,children:[r.jsx("span",{className:a.css`
434
+ `},properties:h},actions:w({},t.executed?{}:{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:Go}}}})})}}}})})})]})};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: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=a.usePlugin(ce),o=Ce(),n=Mt(o),s=[];return n.forEach(l=>{var u;const i=t.get(l.type),c=(u=i.useVariables)==null?void 0:u.call(i,l,e);c&&s.push(c)}),s}},Wt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,l;const{triggers:t}=a.usePlugin(ce),{workflow:o}=Z(),n=t.get(o.type);return(l=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?l:null}},zt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=a.usePlugin(ce),s=Ce(),l=o!=null?o:s,i=Pt(l),c=[];return i.forEach(u=>{var v,k;const d=n.get(u.type),f=(v=d.useScopeVariables)==null?void 0:v.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(k=u.title)!=null?k:`#${u.id}`,[t.children]:f})}),c}},Jt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:E("System time"),[t.value]:"now"}]:[]]}},qe={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,l,i,c;return typeof t=="string"?(o=qe[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)||((l=t.options)==null?void 0:l.collection)==="*"):e.isForeignKey?e.collectionName===((i=t.options)==null?void 0:i.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:l}){return e.filter(i=>{const c=t!=null&&t.length?t.some(u=>Ht(i,u)):!0;if(bt(i)){if(o===null)return n?c||vt({fields:wt(i.target,{compile:s,getCollectionFields:l}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:l}):!1;const u=xt(i,o),d=o.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&vt({fields:wt(i.target,{compile:s,getCollectionFields:l}),types:t,appends:u,compile:s,getCollectionFields:l}).length}else return c})}function _e(e,t){var l,i;const o=a.useCompile(),n=(i=(l=e.useOptions)==null?void 0:l.call(e,t))==null?void 0:i.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 he(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 i,c,u,d,f,v,k;const n=o(e),s=[],l=[];n.forEach(h=>{h.isForeignKey?s.push(h):l.push(h)});for(let h=l.length-1;h>=0;h--){const m=l[h];if(m.type==="belongsTo"){const C=s.find(F=>F.name===m.foreignKey);C?l.splice(h,0,A(w(w({},m),C),{uiSchema:A(w({},m.uiSchema),{title:(i=m.uiSchema)!=null&&i.title?`${t((c=m.uiSchema)==null?void 0:c.title)} ID`:C.name})})):l.splice(h,0,A(w({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:A(w({},m.uiSchema),{title:(u=m.uiSchema)!=null&&u.title?`${t((d=m.uiSchema)==null?void 0:d.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const C=(f=l.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};l.splice(h,0,A(w({},m),{type:m.dataType,interface:C.interface,uiSchema:A(w({},C.uiSchema),{title:(v=C.uiSchema)!=null&&v.title?`${t((k=C.uiSchema)==null?void 0:k.title)} ID`:m.name})}))}}return l.filter(h=>h.interface&&!h.hidden)}function Zo(e){const t=xt(e.field,e.appends),o=Se(w({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:l=1,compile:i,getCollectionFields:c,fieldNames:u=ke}=e,d=wt(o,{compile:i,getCollectionFields:c}),f=t!=null?t:d,v=Zo.bind({compile:i,getCollectionFields:c,fieldNames:u});return vt({fields:f,types:n,depth:l,appends:s,compile:i,getCollectionFields:c}).map(h=>{var M;const m=i(((M=h.uiSchema)==null?void 0:M.title)||h.name),C=xt(h,s),F=!bt(h)||C&&!C.length&&!s.includes(h.name)||!1;return{[u.label]:m,key:h.name,[u.value]:h.name,isLeaf:F,loadChildren:F?null:v,field:h,depth:l,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.Input,w({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.TextArea,w({scope:s},t))}function Qo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.RawTextArea,w({scope:s},t))}function Xo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.JSON,w({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 Ke(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Ke(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 Ro(n){var s=n,{collection:e,dataSource:t}=s,o=q(s,["collection","dataSource"]);const{insert:l}=a.useSchemaInitializer(),{getTemplateSchemaByMode:i}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager(),u=a.useRecordCollectionDataSourceItems("FormItem"),d=c(e);function f(k){return K(this,arguments,function*({item:v}){const h=v.template?yield i(v):null,m={type:"void",name:d.name,title:d.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(m,C=>{C["x-uid"]&&delete C["x-uid"]}),l(m)})}return r.jsx(a.SchemaInitializerItem,A(w({},o),{onClick:f,items:u}))}function Ne(){const e=a.useSchemaInitializerItem();return r.jsx(a.CollectionProvider,{collection:e.collection,children:r.jsx(Ro,w({},e))})}function en(){return!0}const Ot=P.observer(e=>{const c=e,{filter:t=en}=c,o=q(c,["filter"]),n=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager(),{values:l}=P.useForm(),i=s(l==null?void 0:l.collection);return r.jsx(y.Select,A(w({popupMatchSelectWidth:!1},o),{options:i.filter(t).map(u=>{var d;return{label:n((d=u.uiSchema)==null?void 0:d.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Ze({value:e,onChange:t,renderSchemaComponent:o}){const n=he();return r.jsx(a.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const l=e,{options:t=[],direction:o}=l,n=q(l,["options","direction"]),s=a.useCompile();return r.jsx(y.Radio.Group,A(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(i=>r.jsxs(y.Radio,{value:i.value,children:[r.jsx("span",{className:a.css`
435
435
  & + .anticon {
436
436
  margin-left: 0.25em;
437
437
  }
@@ -443,24 +443,24 @@
443
443
  margin: 0;
444
444
  `,children:JSON.stringify(n,null,2)})}Me.Initializer=on,Me.Result=nn;function Yt({entry:e}){const{styles:t}=te(),{workflow:o}=Z(),[n,s]=b.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`
445
445
  margin-top: 0 !important;
446
- `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:D("Executed workflow cannot be modified"),showIcon:!0,className:a.css`
446
+ `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:a.css`
447
447
  margin-bottom: 1em;
448
448
  `}):null,r.jsx(Ko,{}),r.jsx("div",{className:a.cx(t.branchBlockClass,a.css`
449
449
  margin-top: 0 !important;
450
- `),children:r.jsx(Ge,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:D("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.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 rn(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,l)=>s.id-l.id)})}function sn(){const{instructions:e}=a.usePlugin(ce),t=a.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=te(),{node:l={}}=o!=null?o:{},i=e.get(l.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(y.Tag,{children:t(i==null?void 0:i.title)}),r.jsx("strong",{children:l.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",l.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function ln(e){const{execution:t}=Z(),o=a.useAPIClient(),n=ie.useNavigate(),{styles:s}=te(),[l,i]=b.useState([]),[c,u]=b.useState([]);b.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})=>{i(f.data)}).catch(()=>{})},[t]),b.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})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const d=b.useCallback(({key:f})=>{f!=t.id&&n(At(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...l].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ue.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(De,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(T.DownOutlined,{})]})}):null}function an(){var O;const{t:e}=Q.useTranslation(),t=a.useCompile(),{data:o,loading:n,refresh:s}=a.useResourceActionContext(),{setTitle:l}=a.useDocumentTitle(),[i,c]=b.useState(null),u=a.useApp(),d=a.useAPIClient();b.useEffect(()=>{var N;const{workflow:$}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${$!=null&&$.title?`${$.title} - `:""}${D("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(T.ExclamationCircleFilled,{}),content:D("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch($=>{console.error($.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const B=(O=o==null?void 0:o.data)!=null?O:{},{jobs:v=[],workflow:z={}}=B,H=z,{nodes:k=[],revisions:h=[]}=H,m=q(H,["nodes","revisions"]),C=q(B,["jobs","workflow"]);kt(k),rn(k,v);const F=k.find($=>!$.upstream),M=Ue[C.status];return r.jsxs(Je.Provider,{value:{workflow:m.type?m:null,nodes:k,execution:C,viewJob:i,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(ie.Link,{to:Oe(m.id),children:m.title})},{title:r.jsx(ln,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:M.color,children:t(M.label)}),C.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})}),r.jsx("time",{children:ue.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Yt,{entry:F}),r.jsx(sn,{})]})}const Gt=()=>{const e=ie.useParams(),{styles:t}=te();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:an}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext();return r.jsx(ie.Link,{to:At(t),onClick:()=>o(!1),children:e("View")})},cn={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"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: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},_t={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:cn,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}=Q.useTranslation(),{refresh:t,defaultRequest:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return K(this,null,function*(){var i;yield n.destroy({filter:(i=o.params)==null?void 0:i.filter}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,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: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},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",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","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","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var l;const o=a.useCompile()(e.label),n=b.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(l=Ue[e.value])!=null?l:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function un(e){const t=a.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function dn(t){var e=q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(n=>!!n.value&&n.value!==ae.ABORTED).map(n=>r.jsx(y.Select.Option,A(w({},n),{children:r.jsx(un,w({},n))}),n.value))}))}function Zt(e){const{t}=Q.useTranslation(),{refresh:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),s=a.useRecord(),l=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(T.ExclamationCircleFilled,{}),content:D("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return r.jsxs("div",{className:a.css`
450
+ `),children:r.jsx(Ge,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:E("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.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 rn(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,l)=>s.id-l.id)})}function sn(){const{instructions:e}=a.usePlugin(ce),t=a.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=te(),{node:l={}}=o!=null?o:{},i=e.get(l.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(y.Tag,{children:t(i==null?void 0:i.title)}),r.jsx("strong",{children:l.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",l.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function ln(e){const{execution:t}=Z(),o=a.useAPIClient(),n=ie.useNavigate(),{styles:s}=te(),[l,i]=b.useState([]),[c,u]=b.useState([]);b.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})=>{i(f.data)}).catch(()=>{})},[t]),b.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})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const d=b.useCallback(({key:f})=>{f!=t.id&&n(At(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...l].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ue.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(T.DownOutlined,{})]})}):null}function an(){var O;const{t:e}=Q.useTranslation(),t=a.useCompile(),{data:o,loading:n,refresh:s}=a.useResourceActionContext(),{setTitle:l}=a.useDocumentTitle(),[i,c]=b.useState(null),u=a.useApp(),d=a.useAPIClient();b.useEffect(()=>{var N;const{workflow:$}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${$!=null&&$.title?`${$.title} - `:""}${E("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx(T.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch($=>{console.error($.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const B=(O=o==null?void 0:o.data)!=null?O:{},{jobs:v=[],workflow:z={}}=B,H=z,{nodes:k=[],revisions:h=[]}=H,m=q(H,["nodes","revisions"]),C=q(B,["jobs","workflow"]);kt(k),rn(k,v);const F=k.find($=>!$.upstream),M=Ue[C.status];return r.jsxs(Je.Provider,{value:{workflow:m.type?m:null,nodes:k,execution:C,viewJob:i,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(ie.Link,{to:Oe(m.id),children:m.title})},{title:r.jsx(ln,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:M.color,children:t(M.label)}),C.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})}),r.jsx("time",{children:ue.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Yt,{entry:F}),r.jsx(sn,{})]})}const Gt=()=>{const e=ie.useParams(),{styles:t}=te();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:an}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext();return r.jsx(ie.Link,{to:At(t),onClick:()=>o(!1),children:e("View")})},cn={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"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: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},_t={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:cn,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}=Q.useTranslation(),{refresh:t,defaultRequest:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return K(this,null,function*(){var i;yield n.destroy({filter:(i=o.params)==null?void 0:i.filter}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,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: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},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",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","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","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var l;const o=a.useCompile()(e.label),n=b.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(l=Ue[e.value])!=null?l:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function un(e){const t=a.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function dn(t){var e=q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(n=>!!n.value&&n.value!==ae.ABORTED).map(n=>r.jsx(y.Select.Option,A(w({},n),{children:r.jsx(un,w({},n))}),n.value))}))}function Zt(e){const{t}=Q.useTranslation(),{refresh:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),s=a.useRecord(),l=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx(T.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return r.jsxs("div",{className:a.css`
451
451
  display: flex;
452
- `,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:l,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})})]})}function pn(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:l}=Z(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))}function mn(){var $;const e=ie.useNavigate(),{t}=Q.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:l}=a.useResourceActionContext(),{resource:i}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=te(),{modal:v}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${D("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return l?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,m=q(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function F({key:S}){S!=m.id&&e(Oe(S))}function M(S){return K(this,null,function*(){yield i.update({filterByTk:m.id,values:{enabled:S}}),s()})}function O(){return K(this,null,function*(){const{data:{data:S}}=yield i.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return K(this,null,function*(){const S=m.current?D("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return K(this,null,function*(){var W;yield i.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((W=h.find(J=>J.current))==null?void 0:W.id))})}})})}function z(I){return K(this,arguments,function*({key:S}){switch(S){case"history":d(!0);return;case"revision":return O();case"delete":return B()}})}const H=m.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(m.createdAt));return r.jsxs(Je.Provider,{value:{workflow:m,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ue.str2moment(S.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:D("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(T.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:M,checkedChildren:D("On"),unCheckedChildren:D("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:D("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:D("Copy to new version"),disabled:!H},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(a.SchemaComponent,{schema:_t,components:{ExecutionResourceProvider:pn,ExecutionLink:qt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(Yt,{entry:C})]})}const Qt=()=>{const e=ie.useParams(),{styles:t}=te();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:mn}})})},fn=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const l=a.useRecord(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))},hn=()=>{const{t:e}=Q.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 yn(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[l,i]=b.useState(!1),c=P.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:l,setVisible:i,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){i(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={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: "${p}" })}}`,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: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},de={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},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: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},gn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Xt},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:de.title,type:de.type,sync:de.sync,description:de.description,options:de.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 b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:_t}}}},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:de.title,enabled:de.enabled,sync:de.sync,description:de.description,options:de.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: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"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}=Q.useTranslation(),{refresh:t}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:l}=a.useRecord(),{values:i}=P.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:l,values:i}),y.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 bn(e){const t=P.useField(),o=a.useRecord(),n=a.usePlugin(ce);return P.useFormEffects(s=>{ge.onFieldChange("type",l=>{let i=o.id||!l.value;if(l.value){const c=n.triggers.get(l.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Ie,w({},e))}function xn(){const e=b.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(w({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:gn,components:{WorkflowLink:hn,ExecutionResourceProvider:fn,ExecutionLink:qt,OpenDrawer:yn,ExecutionStatusSelect:dn,SyncOptionSelect:bn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
452
+ `,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:l,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})})]})}function pn(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:l}=Z(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))}function mn(){var $;const e=ie.useNavigate(),{t}=Q.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:l}=a.useResourceActionContext(),{resource:i}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=te(),{modal:v}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${E("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return l?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,m=q(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function F({key:S}){S!=m.id&&e(Oe(S))}function M(S){return K(this,null,function*(){yield i.update({filterByTk:m.id,values:{enabled:S}}),s()})}function O(){return K(this,null,function*(){const{data:{data:S}}=yield i.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return K(this,null,function*(){const S=m.current?E("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return K(this,null,function*(){var W;yield i.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((W=h.find(J=>J.current))==null?void 0:W.id))})}})})}function z(I){return K(this,arguments,function*({key:S}){switch(S){case"history":d(!0);return;case"revision":return O();case"delete":return B()}})}const H=m.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(m.createdAt));return r.jsxs(Je.Provider,{value:{workflow:m,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ue.str2moment(S.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:E("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(T.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:M,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!m.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(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(a.SchemaComponent,{schema:_t,components:{ExecutionResourceProvider:pn,ExecutionLink:qt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(Yt,{entry:C})]})}const Qt=()=>{const e=ie.useParams(),{styles:t}=te();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:mn}})})},fn=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const l=a.useRecord(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))},hn=()=>{const{t:e}=Q.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 yn(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[l,i]=b.useState(!1),c=P.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:l,setVisible:i,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){i(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={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: "${p}" })}}`,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: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},de={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},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: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},gn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Xt},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:de.title,type:de.type,sync:de.sync,description:de.description,options:de.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 b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:_t}}}},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:de.title,enabled:de.enabled,sync:de.sync,description:de.description,options:de.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: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"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}=Q.useTranslation(),{refresh:t}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:l}=a.useRecord(),{values:i}=P.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:l,values:i}),y.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 bn(e){const t=P.useField(),o=a.useRecord(),n=a.usePlugin(ce);return P.useFormEffects(s=>{ge.onFieldChange("type",l=>{let i=o.id||!l.value;if(l.value){const c=n.triggers.get(l.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Ie,w({},e))}function xn(){const e=b.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(w({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:gn,components:{WorkflowLink:hn,ExecutionResourceProvider:fn,ExecutionLink:qt,OpenDrawer:yn,ExecutionStatusSelect:dn,SyncOptionSelect:bn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
453
453
  flex-direction: column;
454
454
  `},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`},Pe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=P.useForm();return{options:a.useCollectionFilterOptions(e==null?void 0:e.collection),className:a.css`
455
455
  position: relative;
456
456
  width: 100%;
457
- `}},dynamicComponent:"FilterDynamicComponent"}},vn={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"}}},wn={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}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=P.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},Cn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class kn extends yt{constructor(){super(...arguments);x(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:A(w({},be),{"x-reactions":[...be["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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Cn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,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: "${p}" })}}`,"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(w({},Pe),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{useProps:Pe["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FieldsSelect:Ot})}useVariables(o,n){var u;const s=a.useCompile(),{getCollectionFields:l}=a.useCollectionManager(),i=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}];return Se(A(w({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:i,compile:s,getCollectionFields:l}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,COLLECTION_FIELD:1};function Sn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function eo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:a.css`
457
+ `}},dynamicComponent:"FilterDynamicComponent"}},vn={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"}}},wn={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}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=P.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},Cn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class kn extends yt{constructor(){super(...arguments);x(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:A(w({},be),{"x-reactions":[...be["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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Cn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,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: "${p}" })}}`,"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(w({},Pe),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{useProps:Pe["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FieldsSelect:Ot})}useVariables(o,n){var u;const s=a.useCompile(),{getCollectionFields:l}=a.useCollectionManager(),i=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}];return Se(A(w({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:i,compile:s,getCollectionFields:l}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,DATE_FIELD:1};function Sn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function eo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:a.css`
458
458
  display: flex;
459
459
  gap: 0.5em;
460
- `,children:[r.jsx(Ot,{value:e.field,onChange:l=>t(A(w({},e),{field:l})),filter:Sn,placeholder:o("Select field")}),e.field?r.jsx(y.Select,{value:n,onChange:l=>{s(l),t(A(w({},e),{offset:Math.abs(e.offset)*l}))},options:[{value:0,label:D("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(e.offset),onChange:l=>t(A(w({},e),{offset:(l!=null?l:0)*n}))}),r.jsx(y.Select,{value:e.unit||864e5,onChange:l=>t(A(w({},e),{unit:l})),options:[{value:864e5,label:D("Days")},{value:36e5,label:D("Hours")},{value:6e4,label:D("Minutes")},{value:1e3,label:D("Seconds")}]})]}):null]})}function On({value:e,onChange:t}){const{t:o}=dt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:a.css`
460
+ `,children:[r.jsx(Ot,{value:e.field,onChange:l=>t(A(w({},e),{field:l})),filter:Sn,placeholder:o("Select field"),className:"auto-width"}),e.field?r.jsx(y.Select,{value:n,onChange:l=>{s(l),t(A(w({},e),{offset:Math.abs(e.offset)*l}))},options:[{value:0,label:E("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}],className:"auto-width"}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(e.offset),onChange:l=>t(A(w({},e),{offset:(l!=null?l:0)*n}))}),r.jsx(y.Select,{value:e.unit||864e5,onChange:l=>t(A(w({},e),{unit:l})),options:[{value:864e5,label:E("Days")},{value:36e5,label:E("Hours")},{value:6e4,label:E("Minutes")},{value:1e3,label:E("Seconds")}],className:"auto-width"})]}):null]})}function On({value:e,onChange:t}){const{t:o}=dt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:a.css`
461
461
  display: flex;
462
462
  gap: 0.5em;
463
- `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=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},oe.apply(this,arguments)};function to(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,l=t.length;s<l;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 An=[{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"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(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 no(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 ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,l,i,c,u,d,f,v,k,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||l&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=An.find(function(O){return O.name===e});C&&(e=C.value)}try{var F=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var B=O.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(W,J,le){if(le){W=W.toUpperCase();for(var E=0;E<le.length;E++)W=W.replace(le[E],"".concat(E+J))}return W}($,N.min,N.alt).split(",").map(function(W){var J,le=W.split("/");if(le.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var E=le[0],j=le[1];J=E==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(E,$,N);var L=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,L);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),M=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(F);h(M),u(F[0]),d(F[1]),f(F[2]),v(F[3]),k(F[4])}catch(O){m=!0}}m&&(s.current=e,t(!0),ro(o,i))}function lo(e,t,o,n,s,l,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,v){var k=ve[v];return io(ao(f,k),k,d)})}([e!=="minute"&&l?l:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],i);return c.join(" ")}function io(e,t,o,n,s){var l="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)l="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);l=i&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,i)?function(c,u,d){var f=po(c),v=mo(c),k=c.length===(v-f)/d+1;return!!(f===u.min&&v+d>u.max&&k)}(e,t,i)?"*/".concat(i):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(f,v,k){f!==k[v+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(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 l}function Te(e,t,o,n,s){var l=e.toString(),i=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(i)),f=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?l=c[e-u]:e<10&&(d||f)&&(l=l.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var v=e>=12?"PM":"AM",k=e%12||12;k<10&&d&&(k=k.toString().padStart(2,"0")),l="".concat(k).concat(v)}return l}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,l=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,v=e.leadingZero,k=e.clockFormat,h=e.period,m=e.unit,C=e.periodicityOnDoubleClick,F=e.mode,M=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):Qe([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Te(L,m,u,v,k)}})},[s,v,u,k]),z=JSON.stringify(i),H=b.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var L=io(ao(t,m),m,u,v,k),ne=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(i.everyText||V.everyText," ").concat(ne[1]):L})},[t,z,u,v,k]),$=b.useCallback(function(E){var j=Array.isArray(E)?Xe(E):[E],L=j;t&&(L=F==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);L=t.some(function(Y){return Y===U})?L.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],L,!0),[U],!1))})),L.length===m.total?l([]):l(L)},[l,t]),N=b.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ne=m.min;ne<j;ne++)ne%E==0&&L.push(ne);var U=t&&L&&t.length===L.length&&t.every(function(X,R){return X===L[R]}),Y=L.length===B.length;l(Y||U?[]:L)}else l([])},[t,B,l]),S=b.useRef([]),I=b.useCallback(function(E){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(E)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(E)),S.current=[]},300);return function(){window.clearTimeout(L)}}},[S,$,N,f,C]),W=b.useCallback(function(){f||l([])},[l,f]),J=b.useMemo(function(){var E;return se(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),le=b.useMemo(function(){var E;return se(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&k==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:F!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:O,onClear:W,tagRender:H,className:J,popupClassName:le,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},M))}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.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",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.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",oe({className:k},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=!l||l.length===0,h=b.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,k]),m=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,v=n.months||V.months,k=b.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",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:v,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(m){i||o(m)},[o,i]),v=b.useMemo(function(){var m;return se(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),k=b.useMemo(function(){var m;return se(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),h=b.useMemo(function(){var m;return se(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",oe({className:v},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:k,popupClassName:h,disabled:l,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Nn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=n.weekDays||V.weekDays,h=d==="week"||!i||i.length===0,m=b.useMemo(function(){var B;return se(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),F=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),O=!u||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return M?r.jsxs("div",oe({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!O)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&O&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:F,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function In(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,l=e.clearButtonAction,i=l===void 0?"fill-with-every":l,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,v=e.setValue,k=e.displayError,h=k===void 0||k,m=e.onError,C=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,O=e.allowEmpty,B=O===void 0?"for-default-value":O,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,W=e.readOnly,J=W!==void 0&&W,le=e.leadingZero,E=le!==void 0&&le,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,or=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(M),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),Le=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),We=ko[0],rt=ko[1],So=b.useState(),st=So[0],lt=So[1],Oo=b.useState(),it=Oo[0],at=Oo[1],Ao=b.useState(!1),Ft=Ao[0],ze=Ao[1],To=b.useState(!1),ct=To[0],Fo=To[1],nr=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(u);b.useEffect(function(){so(f,ze,m,B,$e,!0,u,L,at,lt,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,m,B,$e,!1,u,L,at,lt,tt,nt,rt,et)},[f,$e,$o,B,L]),b.useEffect(function(){if(!(ye||it||ot||Le||We||st)||ct||nr)ct&&Fo(!1);else{var G=ye||Tt.current,me=lo(G,ot,Le,We,st,it,N);v(me,{selectedPeriod:G}),$e.current=me,m&&m(void 0),ze(!1)}},[ye,Le,ot,We,st,it,N,ct]);var Eo=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),lt(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),i==="fill-with-every"&&(G=lo(me,void 0,void 0,void 0,void 0,void 0)),v(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&i==="empty"?(ze(!0),ro(m,u)):(m&&m(void 0),ze(!1))},[ye,v,m,i]),rr=b.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Do=to(s,["className"]),No=b.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),sr=JSON.stringify(Do),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Do,{onClick:Eo},{children:u.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,sr,Eo]),ee=ye||Tt.current;return r.jsxs("div",oe({className:rr},{children:[pe.includes("period")&&r.jsx(Dn,{value:ee,setValue:et,locale:u,className:C,disabled:I,readOnly:J,shortcuts:L,allowedPeriods:or}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx(En,{value:ot,setValue:nt,locale:u,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx($n,{value:Le,setValue:tt,locale:u,className:C,weekDays:We,disabled:I,readOnly:J,leadingZero:E,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(Nn,{value:We,setValue:rt,locale:u,className:C,humanizeLabels:H,monthDays:Le,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(Tn,{value:st,setValue:lt,locale:u,className:C,disabled:I,readOnly:J,leadingZero:E,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(Fn,{value:it,setValue:at,locale:u,period:ee,className:C,disabled:I,readOnly:J,leadingZero:E,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const Mn={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{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 ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Pn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Bn({value:e,onChange:t}){const{t:o}=dt(),n=ho(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Vn({value:e=null,onChange:t}){const{t:o}=dt(),n=Pn(e);function s(i){if(i==="none"){t(null);return}if(i==="cron"){t("0 * * * * *");return}t(i)}const l=Mn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
463
+ `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=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},oe.apply(this,arguments)};function to(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,l=t.length;s<l;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 An=[{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"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(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 no(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 ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,l,i,c,u,d,f,v,k,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||l&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=An.find(function(O){return O.name===e});C&&(e=C.value)}try{var F=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var B=O.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(W,J,le){if(le){W=W.toUpperCase();for(var D=0;D<le.length;D++)W=W.replace(le[D],"".concat(D+J))}return W}($,N.min,N.alt).split(",").map(function(W){var J,le=W.split("/");if(le.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var D=le[0],j=le[1];J=D==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(D,$,N);var L=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,L);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),M=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(F);h(M),u(F[0]),d(F[1]),f(F[2]),v(F[3]),k(F[4])}catch(O){m=!0}}m&&(s.current=e,t(!0),ro(o,i))}function lo(e,t,o,n,s,l,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,v){var k=ve[v];return io(ao(f,k),k,d)})}([e!=="minute"&&l?l:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],i);return c.join(" ")}function io(e,t,o,n,s){var l="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)l="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);l=i&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,i)?function(c,u,d){var f=po(c),v=mo(c),k=c.length===(v-f)/d+1;return!!(f===u.min&&v+d>u.max&&k)}(e,t,i)?"*/".concat(i):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(f,v,k){f!==k[v+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(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 l}function Te(e,t,o,n,s){var l=e.toString(),i=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(i)),f=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?l=c[e-u]:e<10&&(d||f)&&(l=l.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var v=e>=12?"PM":"AM",k=e%12||12;k<10&&d&&(k=k.toString().padStart(2,"0")),l="".concat(k).concat(v)}return l}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,l=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,v=e.leadingZero,k=e.clockFormat,h=e.period,m=e.unit,C=e.periodicityOnDoubleClick,F=e.mode,M=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(D,j){return{value:(m.min===0?j:j+1).toString(),label:D}}):Qe([],Array(m.total),!0).map(function(D,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Te(L,m,u,v,k)}})},[s,v,u,k]),z=JSON.stringify(i),H=b.useCallback(function(D){var j=D.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var L=io(ao(t,m),m,u,v,k),ne=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(i.everyText||V.everyText," ").concat(ne[1]):L})},[t,z,u,v,k]),$=b.useCallback(function(D){var j=Array.isArray(D)?Xe(D):[D],L=j;t&&(L=F==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);L=t.some(function(Y){return Y===U})?L.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],L,!0),[U],!1))})),L.length===m.total?l([]):l(L)},[l,t]),N=b.useCallback(function(D){if(D!==0&&D!==1){for(var j=m.total+m.min,L=[],ne=m.min;ne<j;ne++)ne%D==0&&L.push(ne);var U=t&&L&&t.length===L.length&&t.every(function(X,R){return X===L[R]}),Y=L.length===B.length;l(Y||U?[]:L)}else l([])},[t,B,l]),S=b.useRef([]),I=b.useCallback(function(D){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(D)});var L=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(D)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(D)),S.current=[]},300);return function(){window.clearTimeout(L)}}},[S,$,N,f,C]),W=b.useCallback(function(){f||l([])},[l,f]),J=b.useMemo(function(){var D;return se(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),le=b.useMemo(function(){var D;return se(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&k==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,D))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:F!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:O,onClear:W,tagRender:H,className:J,popupClassName:le,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},M))}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.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",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.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",oe({className:k},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=!l||l.length===0,h=b.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,k]),m=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,v=n.months||V.months,k=b.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",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:v,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(m){i||o(m)},[o,i]),v=b.useMemo(function(){var m;return se(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),k=b.useMemo(function(){var m;return se(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),h=b.useMemo(function(){var m;return se(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",oe({className:v},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:k,popupClassName:h,disabled:l,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Nn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=n.weekDays||V.weekDays,h=d==="week"||!i||i.length===0,m=b.useMemo(function(){var B;return se(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),F=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),O=!u||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return M?r.jsxs("div",oe({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!O)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&O&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:F,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function In(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,l=e.clearButtonAction,i=l===void 0?"fill-with-every":l,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,v=e.setValue,k=e.displayError,h=k===void 0||k,m=e.onError,C=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,O=e.allowEmpty,B=O===void 0?"for-default-value":O,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,W=e.readOnly,J=W!==void 0&&W,le=e.leadingZero,D=le!==void 0&&le,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,or=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(M),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),Le=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),We=ko[0],rt=ko[1],So=b.useState(),st=So[0],lt=So[1],Oo=b.useState(),it=Oo[0],at=Oo[1],Ao=b.useState(!1),Ft=Ao[0],ze=Ao[1],To=b.useState(!1),ct=To[0],Fo=To[1],nr=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(u);b.useEffect(function(){so(f,ze,m,B,$e,!0,u,L,at,lt,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,m,B,$e,!1,u,L,at,lt,tt,nt,rt,et)},[f,$e,$o,B,L]),b.useEffect(function(){if(!(ye||it||ot||Le||We||st)||ct||nr)ct&&Fo(!1);else{var G=ye||Tt.current,me=lo(G,ot,Le,We,st,it,N);v(me,{selectedPeriod:G}),$e.current=me,m&&m(void 0),ze(!1)}},[ye,Le,ot,We,st,it,N,ct]);var Do=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),lt(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),i==="fill-with-every"&&(G=lo(me,void 0,void 0,void 0,void 0,void 0)),v(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&i==="empty"?(ze(!0),ro(m,u)):(m&&m(void 0),ze(!1))},[ye,v,m,i]),rr=b.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Eo=to(s,["className"]),No=b.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),sr=JSON.stringify(Eo),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Eo,{onClick:Do},{children:u.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,sr,Do]),ee=ye||Tt.current;return r.jsxs("div",oe({className:rr},{children:[pe.includes("period")&&r.jsx(En,{value:ee,setValue:et,locale:u,className:C,disabled:I,readOnly:J,shortcuts:L,allowedPeriods:or}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx(Dn,{value:ot,setValue:nt,locale:u,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx($n,{value:Le,setValue:tt,locale:u,className:C,weekDays:We,disabled:I,readOnly:J,leadingZero:D,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(Nn,{value:We,setValue:rt,locale:u,className:C,humanizeLabels:H,monthDays:Le,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(Tn,{value:st,setValue:lt,locale:u,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(Fn,{value:it,setValue:at,locale:u,period:ee,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const Mn={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{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 ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Pn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Bn({value:e,onChange:t}){const{t:o}=dt(),n=ho(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Vn({value:e=null,onChange:t}){const{t:o}=dt(),n=Pn(e);function s(i){if(i==="none"){t(null);return}if(i==="cron"){t("0 * * * * *");return}t(i)}const l=Mn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
464
464
  display: flex;
465
465
  flex-direction: ${n==="cron"?"column":"row"};
466
466
  align-items: flex-start;
@@ -489,7 +489,7 @@
489
489
  }
490
490
  }
491
491
  }
492
- `,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(i=>r.jsx(y.Select.Option,{value:i.value,children:o(i.text)},i.value))}),typeof n=="number"?r.jsx(Bn,{value:e,onChange:t}):null,n==="cron"?r.jsx(In,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:i=>t(`0 ${i}`),clearButton:!1,locale:l}):null]})}const jn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[xe.COLLECTION_FIELD]:{collection:A(w({},be),{"x-reactions":[...be["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"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: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(w({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Ln=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:xe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Wn=()=>{const{values:e={},clearFormGraph:t}=P.useForm(),[o,n]=b.useState(e.mode);return P.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: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Ln},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`
492
+ `,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(i=>r.jsx(y.Select.Option,{value:i.value,children:o(i.text)},i.value))}),typeof n=="number"?r.jsx(Bn,{value:e,onChange:t}):null,n==="cron"?r.jsx(In,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:i=>t(`0 ${i}`),clearButton:!1,locale:l}):null]})}const jn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[xe.DATE_FIELD]:{collection:A(w({},be),{"x-reactions":[...be["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"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: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(w({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.DATE_FIELD} && $deps[1]}}`}}}]})}},Ln=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:xe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Wn=()=>{const{values:e={},clearFormGraph:t}=P.useForm(),[o,n]=b.useState(e.mode);return P.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: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Ln},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`
493
493
  .ant-input-number {
494
494
  width: auto;
495
495
  min-width: 6em;
@@ -498,19 +498,19 @@
498
498
  .ant-picker {
499
499
  width: auto;
500
500
  }
501
- `},properties:jn[o]}}},components:{OnField:eo,RepeatField:Vn,EndsByField:On}})]})};class zn extends yt{constructor(){super(...arguments);x(this,"sync",!1);x(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{ScheduleConfig:Wn})}useVariables(o,n){var c;const s=a.useCompile(),{getCollectionFields:l}=a.useCollectionManager(),i=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&i.push({key:"date",value:"date",label:D("Trigger time")}),o.mode===xe.COLLECTION_FIELD){const[u]=Se(A(w({appends:["data",...((c=o.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}],compile:s,getCollectionFields:l}));u&&i.push(u)}return i}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const yo=e=>{const t=Ee.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
501
+ `},properties:jn[o]}}},components:{OnField:eo,RepeatField:Vn,EndsByField:On}})]})};class zn extends yt{constructor(){super(...arguments);x(this,"sync",!1);x(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{ScheduleConfig:Wn})}useVariables(o,n){var c;const s=a.useCompile(),{getCollectionFields:l}=a.useCollectionManager(),i=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&i.push({key:"date",value:"date",label:E("Trigger time")}),o.mode===xe.DATE_FIELD){const[u]=Se(A(w({appends:["data",...((c=o.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}],compile:s,getCollectionFields:l}));u&&i.push(u)}return i}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const yo=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
502
502
  &:after {
503
503
  content: ':';
504
504
  }
505
505
  & + a {
506
506
  margin-left: 0.25em;
507
507
  }
508
- `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Jn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);x(this,"type","calculation");x(this,"group","control");x(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: "${p}" })}}`);x(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ee.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:l}=s,{evaluate:i}=Ee.evaluators.get(l.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(c),""}catch(u){return D("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});x(this,"scope",{renderEngineReference:yo});x(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:l=ke}){return s&&!s.some(i=>i in qe||Object.values(qe).some(c=>c.has(i)))?null:{[l.value]:o,[l.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:D("Calculation result")}}}const _=new ue.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: "${p}" })}}`,type:"string",group:"string"});const Hn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function go(e){return Array.from(_.getEntities()).filter(([t,o])=>o.group===e)}function Un({calculator:e,operands:t=[],onChange:o}){const n=a.useCompile(),s=he();return r.jsxs("fieldset",{className:a.css`
508
+ `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Jn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);x(this,"type","calculation");x(this,"group","control");x(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: "${p}" })}}`);x(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:l}=s,{evaluate:i}=De.evaluators.get(l.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(c),""}catch(u){return E("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});x(this,"scope",{renderEngineReference:yo});x(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:l=ke}){return s&&!s.some(i=>i in qe||Object.values(qe).some(c=>c.has(i)))?null:{[l.value]:o,[l.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 ue.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: "${p}" })}}`,type:"string",group:"string"});const Hn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function go(e){return Array.from(_.getEntities()).filter(([t,o])=>o.group===e)}function Un({calculator:e,operands:t=[],onChange:o}){const n=a.useCompile(),s=he();return r.jsxs("fieldset",{className:a.css`
509
509
  display: flex;
510
510
  gap: 0.5em;
511
511
  align-items: center;
512
512
  flex-wrap: wrap;
513
- `,children:[r.jsx(a.Variable.Input,{value:t[0],onChange:l=>o({calculator:e,operands:[l,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:l=>o({operands:t,calculator:l}),placeholder:D("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Hn.filter(l=>!!go(l.value).length).map(l=>r.jsx(y.Select.OptGroup,{label:n(l.title),children:go(l.value).map(([i,{name:c}])=>r.jsx(y.Select.Option,{value:i,children:n(c)},i))},l.value))}),r.jsx(a.Variable.Input,{value:t[1],onChange:l=>o({calculator:e,operands:[t[0],l]}),scope:s,useTypedConstant:!0})]})}function Yn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:a.css`
513
+ `,children:[r.jsx(a.Variable.Input,{value:t[0],onChange:l=>o({calculator:e,operands:[l,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:l=>o({operands:t,calculator:l}),placeholder:E("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Hn.filter(l=>!!go(l.value).length).map(l=>r.jsx(y.Select.OptGroup,{label:n(l.title),children:go(l.value).map(([i,{name:c}])=>r.jsx(y.Select.Option,{value:i,children:n(c)},i))},l.value))}),r.jsx(a.Variable.Input,{value:t[1],onChange:l=>o({calculator:e,operands:[t[0],l]}),scope:s,useTypedConstant:!0})]})}function Yn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:a.css`
514
514
  display: flex;
515
515
  position: relative;
516
516
  margin: 0.5em 0;
@@ -540,7 +540,7 @@
540
540
  margin-right: 1em;
541
541
  }
542
542
  }
543
- `,children:[r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition group")})]})]})}function Gn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(bo,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class qn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Condition", { ns: "${p}" })}}`);x(this,"type","condition");x(this,"group","control");x(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: "${p}" })}}`);x(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from(Ee.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(w({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(o,n,{form:s}){const{values:l}=s,{evaluate:i}=Ee.evaluators.get(l.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(c),""}catch(u){return D("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});x(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);x(this,"scope",{renderEngineReference:yo,useWorkflowVariableOptions:he});x(this,"components",{CalculationConfig:Gn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Z(),{styles:l}=te(),{id:i,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===i&&f.branchIndex===1),d=s.find(f=>f.upstreamId===i&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:l.nodeSubtreeClass,children:[r.jsxs("div",{className:l.branchBlockClass,children:[r.jsx(Ge,{from:o,entry:d,branchIndex:0}),r.jsx(Ge,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:l.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class _n extends fe{constructor(){super(...arguments);x(this,"title",`{{t("End process", { ns: "${p}" })}}`);x(this,"type","end");x(this,"group","control");x(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);x(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:re.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:re.FAILED}],required:!0,default:re.RESOLVED}});x(this,"end",!0)}}class Kn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Query record", { ns: "${p}" })}}`);x(this,"type","query");x(this,"group","collection");x(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${p}" })}}`,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: "${p}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Pe,sort:vn,pagination:wn,appends:Be},"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: "${p}" })}}`}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const o=a.useCompile(),{getCollectionFields:n,getInterface:s}=a.useCollectionManager(),{values:l}=P.useForm();return n(l.collection).filter(c=>{if(!c.interface)return!1;const u=s(c.interface);return!!(u!=null&&u.sortable)}).map(c=>{var u,d;return{value:c.name,label:(u=c==null?void 0:c.uiSchema)!=null&&u.title?o((d=c==null?void 0:c.uiSchema)==null?void 0:d.title):c.name}})}});x(this,"components",{ArrayItems:jo.ArrayItems,FilterDynamicComponent:Ze,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},l){var d,f;const i=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},l),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:i,getCollectionFields:c}));return u}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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Zn(e){const{getCollectionFields:t}=a.useCollectionManager(),{path:o}=P.useField(),n=o.segments[o.segments.length-1],{values:s}=P.useForm(),l=t(s==null?void 0:s.collection),{type:i}=l.find(d=>d.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(d){const f=d.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(i)?f:f.split(/[,\s]+/))}return r.jsx(y.Input,A(w({},e),{value:c,onChange:u}))}const xo=P.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=a.useToken(),{t:l}=Q.useTranslation(),i=a.useCompile(),c=P.useForm(),{getCollection:u,getCollectionFields:d}=a.useCollectionManager(),f=he(),{values:v}=c,k=v==null?void 0:v.collection,h=d(k).filter(O=>O.uiSchema),m=n?h.filter(n.bind(v)):h,C=b.useMemo(()=>m.filter(O=>!e||!(O.name in e)),[m,e]),F=t||c.disabled,M=b.useMemo(()=>({onClick:({key:O})=>{o(A(w({},e),{[O]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(O=>{var B,z;return{key:O.name,label:i((z=(B=O.uiSchema)==null?void 0:B.title)!=null?z:O.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:a.css`
543
+ `,children:[r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition group")})]})]})}function Gn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(bo,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class qn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Condition", { ns: "${p}" })}}`);x(this,"type","condition");x(this,"group","control");x(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: "${p}" })}}`);x(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from(De.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(w({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(o,n,{form:s}){const{values:l}=s,{evaluate:i}=De.evaluators.get(l.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(c),""}catch(u){return E("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});x(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);x(this,"scope",{renderEngineReference:yo,useWorkflowVariableOptions:he});x(this,"components",{CalculationConfig:Gn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Z(),{styles:l}=te(),{id:i,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===i&&f.branchIndex===1),d=s.find(f=>f.upstreamId===i&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:l.nodeSubtreeClass,children:[r.jsxs("div",{className:l.branchBlockClass,children:[r.jsx(Ge,{from:o,entry:d,branchIndex:0}),r.jsx(Ge,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:l.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class _n extends fe{constructor(){super(...arguments);x(this,"title",`{{t("End process", { ns: "${p}" })}}`);x(this,"type","end");x(this,"group","control");x(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);x(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:re.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:re.FAILED}],required:!0,default:re.RESOLVED}});x(this,"end",!0)}}class Kn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Query record", { ns: "${p}" })}}`);x(this,"type","query");x(this,"group","collection");x(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${p}" })}}`,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: "${p}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Pe,sort:vn,pagination:wn,appends:Be},"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: "${p}" })}}`}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const o=a.useCompile(),{getCollectionFields:n,getInterface:s}=a.useCollectionManager(),{values:l}=P.useForm();return n(l.collection).filter(c=>{if(!c.interface)return!1;const u=s(c.interface);return!!(u!=null&&u.sortable)}).map(c=>{var u,d;return{value:c.name,label:(u=c==null?void 0:c.uiSchema)!=null&&u.title?o((d=c==null?void 0:c.uiSchema)==null?void 0:d.title):c.name}})}});x(this,"components",{ArrayItems:jo.ArrayItems,FilterDynamicComponent:Ze,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},l){var d,f;const i=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},l),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:i,getCollectionFields:c}));return u}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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Zn(e){const{getCollectionFields:t}=a.useCollectionManager(),{path:o}=P.useField(),n=o.segments[o.segments.length-1],{values:s}=P.useForm(),l=t(s==null?void 0:s.collection),{type:i}=l.find(d=>d.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(d){const f=d.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(i)?f:f.split(/[,\s]+/))}return r.jsx(y.Input,A(w({},e),{value:c,onChange:u}))}const xo=P.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=a.useToken(),{t:l}=Q.useTranslation(),i=a.useCompile(),c=P.useForm(),{getCollection:u,getCollectionFields:d}=a.useCollectionManager(),f=he(),{values:v}=c,k=v==null?void 0:v.collection,h=d(k).filter(O=>O.uiSchema),m=n?h.filter(n.bind(v)):h,C=b.useMemo(()=>m.filter(O=>!e||!(O.name in e)),[m,e]),F=t||c.disabled,M=b.useMemo(()=>({onClick:({key:O})=>{o(A(w({},e),{[O]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(O=>{var B,z;return{key:O.name,label:i((z=(B=O.uiSchema)==null?void 0:B.title)!=null?z:O.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:a.css`
544
544
  margin-top: 0.5em;
545
545
 
546
546
  > .ant-formily-item {
@@ -554,4 +554,4 @@
554
554
  .ant-form-item-control-input-content {
555
555
  display: flex;
556
556
  }
557
- `,children:[r.jsx(a.Variable.Input,{scope:f,value:e[O.name],changeOnSelect:!0,onChange:$=>{o(A(w({},e),{[O.name]:$}))},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[O.name]:{"x-component":B,"x-validator"(){return""}}}}})}),F?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=O.name]:$}=I,N=q(I,[Bo(S)]);o(N)}})]},O.name)}),C.length?r.jsx(y.Dropdown,{menu:M,children:r.jsx(y.Button,{icon:r.jsx(T.PlusOutlined,{}),children:l("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:D("Please select collection first")})})},{displayName:"CollectionFieldSet"});class Qn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Create record", { ns: "${p}" })}}`);x(this,"type","create");x(this,"group","collection");x(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{values:Rt,appends:Be}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{CollectionFieldset:xo})}useVariables({key:o,title:n,config:s},l){var d,f;const i=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},l),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:i,getCollectionFields:c}));return u}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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function Xn(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=a.useCollectionManager(),l=P.useForm(),{collection:i}=l.values,c=s(i),u=P.useField();function d({target:f}){const v=u.query(".values").take();if(!v)return;const k=c.reduce((h,m)=>(m.name in v.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=v.value[m.name]),h),{});l.setValuesIn("params.values",k),e(f.value)}return r.jsx(Ie,A(w({},t),{onChange:d}))}class Rn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Update record", { ns: "${p}" })}}`);x(this,"type","update");x(this,"group","collection");x(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,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: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,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: "${p}" })}}`}]},default:!1},filter:A(w({},Pe),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return Ke(o)?"":D("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze,CollectionFieldset:xo,IndividualHooksRadioWithTooltip:Xn})}}class er extends fe{constructor(){super(...arguments);x(this,"title",'{{t("Delete record")}}');x(this,"type","destroy");x(this,"group","collection");x(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: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{filter:A(w({},Pe),{"x-validator"(o){return Ke(o)?"":D("Please add at least one condition")}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze})}}function tr(){const e=a.useAPIClient(),t=P.useForm(),{field:o,__parent:n}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),l=ie.useNavigate(),i=P.useFieldSchema(),c=P.useField(),u=a.useCompile(),{modal:d}=y.App.useApp(),f=a.useCollectValuesToSubmit(),v=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var M,O,B;const{onSuccess:h,skipValidator:m,triggerWorkflows:C}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};m||(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:v,triggerWorkflows:C!=null&&C.length?C.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(B=(O=n==null?void 0:n.service)==null?void 0:O.refresh)==null||B.call(O),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?d.success({title:u(h==null?void 0:h.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ue.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):y.message.success(u(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}class ce extends a.Plugin{constructor(){super(...arguments);x(this,"triggers",new ue.Registry);x(this,"instructions",new ue.Registry);x(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(l=>{var[o,i]=l,c=i,{title:n}=c,s=q(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}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 fe)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(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:xn,aclSnippet:"pm.workflow.workflows"}),this.registerTrigger("collection",kn),this.registerTrigger("schedule",zn),this.registerInstruction("calculation",Jn),this.registerInstruction("condition",qn),this.registerInstruction("end",_n),this.registerInstruction("query",Kn),this.registerInstruction("create",Qn),this.registerInstruction("update",Rn),this.registerInstruction("destroy",er)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:tr})}addComponents(){this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Oe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:At(":id"),element:r.jsx(Gt,{})})}}g.BaseTypeSets=qe,g.Branch=Ge,g.CheckboxGroupWithTooltip=tn,g.CollectionBlockInitializer=Ne,g.EXECUTION_STATUS=ae,g.ExecutionStatusOptions=He,g.ExecutionStatusOptionsMap=Ue,g.FieldsSelect=Ot,g.FilterDynamicComponent=Ze,g.FlowContext=Je,g.Instruction=fe,g.JOB_STATUS=re,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Ye,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Ie,g.RemoveButton=Vt,g.Trigger=yt,g.ValueBlock=Me,g.WorkflowVariableInput=Ut,g.WorkflowVariableJSON=Xo,g.WorkflowVariableRawTextArea=Qo,g.WorkflowVariableTextArea=Ct,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.isValidFilter=Ke,g.linkNodes=kt,g.nodesOptions=Lt,g.scopeOptions=zt,g.systemOptions=Jt,g.traverseSchema=St,g.triggerOptions=Wt,g.useAvailableUpstreams=Mt,g.useFlowContext=Z,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useStyles=te,g.useTrigger=gt,g.useUpstreamScopes=Pt,g.useWorkflowVariableOptions=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
557
+ `,children:[r.jsx(a.Variable.Input,{scope:f,value:e[O.name],changeOnSelect:!0,onChange:$=>{o(A(w({},e),{[O.name]:$}))},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[O.name]:{"x-component":B,"x-validator"(){return""}}}}})}),F?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=O.name]:$}=I,N=q(I,[Bo(S)]);o(N)}})]},O.name)}),C.length?r.jsx(y.Dropdown,{menu:M,children:r.jsx(y.Button,{icon:r.jsx(T.PlusOutlined,{}),children:l("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:E("Please select collection first")})})},{displayName:"CollectionFieldSet"});class Qn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Create record", { ns: "${p}" })}}`);x(this,"type","create");x(this,"group","collection");x(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{values:Rt,appends:Be}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{CollectionFieldset:xo})}useVariables({key:o,title:n,config:s},l){var d,f;const i=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},l),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:i,getCollectionFields:c}));return u}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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function Xn(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=a.useCollectionManager(),l=P.useForm(),{collection:i}=l.values,c=s(i),u=P.useField();function d({target:f}){const v=u.query(".values").take();if(!v)return;const k=c.reduce((h,m)=>(m.name in v.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=v.value[m.name]),h),{});l.setValuesIn("params.values",k),e(f.value)}return r.jsx(Ie,A(w({},t),{onChange:d}))}class Rn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Update record", { ns: "${p}" })}}`);x(this,"type","update");x(this,"group","collection");x(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,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: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,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: "${p}" })}}`}]},default:!1},filter:A(w({},Pe),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze,CollectionFieldset:xo,IndividualHooksRadioWithTooltip:Xn})}}class er extends fe{constructor(){super(...arguments);x(this,"title",'{{t("Delete record")}}');x(this,"type","destroy");x(this,"group","collection");x(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: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{filter:A(w({},Pe),{"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze})}}function tr(){const e=a.useAPIClient(),t=P.useForm(),{field:o,__parent:n}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),l=ie.useNavigate(),i=P.useFieldSchema(),c=P.useField(),u=a.useCompile(),{modal:d}=y.App.useApp(),f=a.useCollectValuesToSubmit(),v=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var M,O,B;const{onSuccess:h,skipValidator:m,triggerWorkflows:C}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};m||(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:v,triggerWorkflows:C!=null&&C.length?C.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(B=(O=n==null?void 0:n.service)==null?void 0:O.refresh)==null||B.call(O),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?d.success({title:u(h==null?void 0:h.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ue.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):y.message.success(u(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}class ce extends a.Plugin{constructor(){super(...arguments);x(this,"triggers",new ue.Registry);x(this,"instructions",new ue.Registry);x(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(l=>{var[o,i]=l,c=i,{title:n}=c,s=q(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}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 fe)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(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:xn,aclSnippet:"pm.workflow.workflows"}),this.registerTrigger("collection",kn),this.registerTrigger("schedule",zn),this.registerInstruction("calculation",Jn),this.registerInstruction("condition",qn),this.registerInstruction("end",_n),this.registerInstruction("query",Kn),this.registerInstruction("create",Qn),this.registerInstruction("update",Rn),this.registerInstruction("destroy",er)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:tr})}addComponents(){this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Oe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:At(":id"),element:r.jsx(Gt,{})})}}g.BaseTypeSets=qe,g.Branch=Ge,g.CheckboxGroupWithTooltip=tn,g.CollectionBlockInitializer=Ne,g.EXECUTION_STATUS=ae,g.ExecutionStatusOptions=He,g.ExecutionStatusOptionsMap=Ue,g.FieldsSelect=Ot,g.FilterDynamicComponent=Ze,g.FlowContext=Je,g.Instruction=fe,g.JOB_STATUS=re,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Ye,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Ie,g.RemoveButton=Vt,g.Trigger=yt,g.ValueBlock=Me,g.WorkflowVariableInput=Ut,g.WorkflowVariableJSON=Xo,g.WorkflowVariableRawTextArea=Qo,g.WorkflowVariableTextArea=Ct,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.isValidFilter=Ke,g.linkNodes=kt,g.nodesOptions=Lt,g.scopeOptions=zt,g.systemOptions=Jt,g.traverseSchema=St,g.triggerOptions=Wt,g.useAvailableUpstreams=Mt,g.useFlowContext=Z,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useStyles=te,g.useTrigger=gt,g.useUpstreamScopes=Pt,g.useWorkflowVariableOptions=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});