@tachybase/module-workflow 1.3.22 → 1.3.23

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(S,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@ant-design/icons"),require("@tachybase/schema"),require("lodash"),require("@dnd-kit/core")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@ant-design/icons","@tachybase/schema","lodash","@dnd-kit/core"],s):(S=typeof globalThis!="undefined"?globalThis:S||self,s(S["@tachybase/module-workflow"]={},S["@tachybase/client"],S["@tego/client"],S.jsxRuntime,S.antd,S["react-router-dom"],S["react-i18next"],S.react,S["@ant-design/icons"],S["@tachybase/schema"],S.lodash,S["@dnd-kit/core"]))})(this,function(S,s,E,r,b,ne,Q,y,j,k,ie,Me){"use strict";var oc=Object.defineProperty,nc=Object.defineProperties;var rc=Object.getOwnPropertyDescriptors;var Bt=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable;var Kn=(S,s,E)=>s in S?oc(S,s,{enumerable:!0,configurable:!0,writable:!0,value:E}):S[s]=E,w=(S,s)=>{for(var E in s||(s={}))_n.call(s,E)&&Kn(S,E,s[E]);if(Bt)for(var E of Bt(s))Gn.call(s,E)&&Kn(S,E,s[E]);return S},A=(S,s)=>nc(S,rc(s));var Hn=S=>typeof S=="symbol"?S:S+"",K=(S,s)=>{var E={};for(var r in S)_n.call(S,r)&&s.indexOf(r)<0&&(E[r]=S[r]);if(S!=null&&Bt)for(var r of Bt(S))s.indexOf(r)<0&&Gn.call(S,r)&&(E[r]=S[r]);return E};var D=(S,s,E)=>new Promise((r,b)=>{var ne=j=>{try{y(E.next(j))}catch(k){b(k)}},Q=j=>{try{y(E.throw(j))}catch(k){b(k)}},y=j=>j.done?r(j.value):Promise.resolve(j.value).then(ne,Q);y((E=E.apply(S,s)).next())});const m="workflow";function F(e,t={}){return s.i18n.t(e,A(w({},t),{ns:[m,"core"]}))}function he(){return Q.useTranslation([m,"core"])}const N=(e,t={})=>s.tval(e,w({ns:[m,"core"]},t)),Jn=()=>{const{t:e}=he(),t=ne.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},dt=(e,t)=>({getAriaLabel:y.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),ao=y.createContext({}),Yn=ao.Provider;function Qn(){return y.useContext(ao)}const Ee=y.createContext({}),Zn=Ee.Provider;function q(){return y.useContext(Ee)}var Ue=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(Ue||{});class H{}function Xn(e){var x;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(X),i=s.useCompile(),a=s.useAPIClient(),{workflow:l,refresh:c}=(x=q())!=null?x:{},d=Array.from(n.instructions.getValues()),p=y.useMemo(()=>tr(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:i}),[o,n,d,t,l]),[u,f]=y.useState(!1),h=y.useCallback(I=>D(null,[I],function*({keyPath:v}){var $,P,B;const T=v.pop(),C={},[O]=v,V=n.instructions.get(T);if(O){const{value:_}=(P=($=V.options)==null?void 0:$.find(z=>z.key===O))!=null?P:{};Object.assign(C,typeof _=="function"?_():_)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:T,upstreamId:(B=t==null?void 0:t.id)!=null?B:null,branchIndex:o,title:i(V.title),config:C}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),g=y.useMemo(()=>({onClick:v=>{const{keyPath:I}=v||{};(I==null?void 0:I[0])==="load"?f(!0):h(v)},items:p}),[p,h]);return{workflow:l,menu:g,isShowUploadModal:u,setIsShowUploadModal:f}}const lo=[{key:Ue.CONTROL,label:F("Control")},{key:Ue.COLLECTION,label:F("Collection operations")},{key:Ue.MANUAL,label:F("Manual")},{key:Ue.EXTENDED,label:F("Extended types")}],Rn={key:"hot",label:F("Hot tools")},er={key:"load",label:F("Load")};function tr(e,{engine:t,workflow:o,upstream:n,branchIndex:i,compile:a}){const l=[],c=[];for(const d of lo){const p=e.filter(h=>{var g,x;return h.group===d.key&&((x=(g=h.isAvailable)==null?void 0:g.call(h,{engine:t,workflow:o,upstream:n,branchIndex:i}))!=null?x:!0)});let u=[];for(const h of p){const{type:g,title:x,icon:v,color:I,options:T,isHot:C}=h,O=co(v,I),V={role:"button","aria-label":g,key:g,label:a(x),type:T?"subMenu":null,icon:O,children:T?T.map($=>({role:"button","aria-label":$.key,key:$.key,label:a($.label)})):null};u.push(V),C&&c.push(V)}const f=A(w({},d),{type:"group",children:u});l.push(f)}return l.unshift(A(w({},er),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:F("Upload node"),icon:co("ToTopOutlined","#ff92ca")}]})),l.unshift(A(w({},Rn),{type:"group",children:c})),l.filter(d=>d.children.length)}function co(e,t){return r.jsx("div",{className:s.css`
1
+ (function(k,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@ant-design/icons"),require("@tachybase/schema"),require("lodash"),require("@dnd-kit/core"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@ant-design/icons","@tachybase/schema","lodash","@dnd-kit/core","dayjs"],s):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tego/client"],k.jsxRuntime,k.antd,k["react-router-dom"],k["react-i18next"],k.react,k["@ant-design/icons"],k["@tachybase/schema"],k.lodash,k["@dnd-kit/core"],k.dayjs))})(this,function(k,s,E,r,b,re,Q,y,j,S,R,Me,ao){"use strict";var nc=Object.defineProperty,rc=Object.defineProperties;var sc=Object.getOwnPropertyDescriptors;var Bt=Object.getOwnPropertySymbols;var Gn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable;var _n=(k,s,E)=>s in k?nc(k,s,{enumerable:!0,configurable:!0,writable:!0,value:E}):k[s]=E,w=(k,s)=>{for(var E in s||(s={}))Gn.call(s,E)&&_n(k,E,s[E]);if(Bt)for(var E of Bt(s))Hn.call(s,E)&&_n(k,E,s[E]);return k},A=(k,s)=>rc(k,sc(s));var Jn=k=>typeof k=="symbol"?k:k+"",K=(k,s)=>{var E={};for(var r in k)Gn.call(k,r)&&s.indexOf(r)<0&&(E[r]=k[r]);if(k!=null&&Bt)for(var r of Bt(k))s.indexOf(r)<0&&Hn.call(k,r)&&(E[r]=k[r]);return E};var D=(k,s,E)=>new Promise((r,b)=>{var re=j=>{try{y(E.next(j))}catch(S){b(S)}},Q=j=>{try{y(E.throw(j))}catch(S){b(S)}},y=j=>j.done?r(j.value):Promise.resolve(j.value).then(re,Q);y((E=E.apply(k,s)).next())});const m="workflow";function F(e,t={}){return s.i18n.t(e,A(w({},t),{ns:[m,"core"]}))}function he(){return Q.useTranslation([m,"core"])}const N=(e,t={})=>s.tval(e,w({ns:[m,"core"]},t)),Yn=()=>{const{t:e}=he(),t=re.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},dt=(e,t)=>({getAriaLabel:y.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),lo=y.createContext({}),Qn=lo.Provider;function Zn(){return y.useContext(lo)}const Ee=y.createContext({}),Xn=Ee.Provider;function q(){return y.useContext(Ee)}var Ue=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(Ue||{});class H{}function Rn(e){var x;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(X),i=s.useCompile(),a=s.useAPIClient(),{workflow:l,refresh:c}=(x=q())!=null?x:{},d=Array.from(n.instructions.getValues()),p=y.useMemo(()=>or(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:i}),[o,n,d,t,l]),[u,f]=y.useState(!1),h=y.useCallback(I=>D(null,[I],function*({keyPath:v}){var $,P,B;const T=v.pop(),C={},[O]=v,V=n.instructions.get(T);if(O){const{value:_}=(P=($=V.options)==null?void 0:$.find(z=>z.key===O))!=null?P:{};Object.assign(C,typeof _=="function"?_():_)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:T,upstreamId:(B=t==null?void 0:t.id)!=null?B:null,branchIndex:o,title:i(V.title),config:C}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),g=y.useMemo(()=>({onClick:v=>{const{keyPath:I}=v||{};(I==null?void 0:I[0])==="load"?f(!0):h(v)},items:p}),[p,h]);return{workflow:l,menu:g,isShowUploadModal:u,setIsShowUploadModal:f}}const co=[{key:Ue.CONTROL,label:F("Control")},{key:Ue.COLLECTION,label:F("Collection operations")},{key:Ue.MANUAL,label:F("Manual")},{key:Ue.EXTENDED,label:F("Extended types")}],er={key:"hot",label:F("Hot tools")},tr={key:"load",label:F("Load")};function or(e,{engine:t,workflow:o,upstream:n,branchIndex:i,compile:a}){const l=[],c=[];for(const d of co){const p=e.filter(h=>{var g,x;return h.group===d.key&&((x=(g=h.isAvailable)==null?void 0:g.call(h,{engine:t,workflow:o,upstream:n,branchIndex:i}))!=null?x:!0)});let u=[];for(const h of p){const{type:g,title:x,icon:v,color:I,options:T,isHot:C}=h,O=po(v,I),V={role:"button","aria-label":g,key:g,label:a(x),type:T?"subMenu":null,icon:O,children:T?T.map($=>({role:"button","aria-label":$.key,key:$.key,label:a($.label)})):null};u.push(V),C&&c.push(V)}const f=A(w({},d),{type:"group",children:u});l.push(f)}return l.unshift(A(w({},tr),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:F("Upload node"),icon:po("ToTopOutlined","#ff92ca")}]})),l.unshift(A(w({},er),{type:"group",children:c})),l.filter(d=>d.children.length)}function po(e,t){return r.jsx("div",{className:s.css`
2
2
  display: flex;
3
3
  justify-content: center;
4
4
  align-items: center;
@@ -13,7 +13,7 @@
13
13
  width: 100%;
14
14
  height: 100%;
15
15
  }
16
- `,children:r.jsx(s.Icon,{type:e})})}const or=s.createStyles(({css:e,token:t})=>({addButtonClass:e`
16
+ `,children:r.jsx(s.Icon,{type:e})})}const nr=s.createStyles(({css:e,token:t})=>({addButtonClass:e`
17
17
  flex-shrink: 0;
18
18
  padding: 2em 0;
19
19
 
@@ -32,14 +32,14 @@
32
32
  border-radius: 8px;
33
33
  overflow-y: auto;
34
34
  }
35
- `,iconContainerClass:e``}));function nr(){const e=s.useActionContext(),t=k.useForm();return{onClick(){return D(this,null,function*(){var n;(n=e==null?void 0:e.setVisible)==null||n.call(e,!1),t.reset()})}}}function rr(){var d;const{t:e}=he(),t=s.useAPIClient(),o=s.useActionContext(),{workflow:n,refresh:i}=(d=q())!=null?d:{},a=k.useForm(),{upstream:l,branchIndex:c}=Qn();return{onClick(){return D(this,null,function*(){var u;try{const h=yield(yield fetch(a.values.file.url)).json();n&&(yield t.resource("workflows.nodes",n.id).create({values:{type:h.type,upstreamId:(u=l==null?void 0:l.id)!=null?u:null,branchIndex:c,title:h.title,config:h.config}}),o.setVisible(!1),b.message.success(e("Operation succeeded")),i(),a.reset())}catch(f){o.setVisible(!1),console.error("JSON解析失败:",f),i()}})}}}const sr={type:"void","x-decorator":"FormV2",properties:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1,style:{marginTop:"20px"}}},footer:{type:"void","x-component":"ActionBar","x-component-props":{style:{justifyContent:"right"}},properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}},ir=()=>r.jsx(s.SchemaComponent,{schema:sr,scope:{useCancelActionProps:nr,useCreateActionProps:rr}}),Vt=e=>{const{t}=he(),{styles:o}=or(),{upstream:n,branchIndex:i=null}=e,{workflow:a,menu:l,isShowUploadModal:c,setIsShowUploadModal:d}=Xn(e);return a?r.jsxs("div",{className:o.addButtonClass,children:[r.jsx(b.Dropdown,{trigger:["click"],disabled:a.executed,overlayClassName:o.dropDownClass,menu:l,children:r.jsx(b.Button,{className:"add-btn",icon:r.jsx(j.PlusOutlined,{}),type:"primary","aria-label":e["aria-label"]||"add-button"})}),r.jsx(b.Modal,{footer:null,closable:!1,title:t("Upload node"),open:c,children:r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:d},children:r.jsx(Yn,{value:{upstream:n,branchIndex:i},children:r.jsx(ir,{})})})})]}):null};function $e(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}const po=y.createContext({}),uo=po.Provider;function ye(){return y.useContext(po)}const ar=s.createStyles(({css:e,token:t})=>({nodeBlockClass:e`
35
+ `,iconContainerClass:e``}));function rr(){const e=s.useActionContext(),t=S.useForm();return{onClick(){return D(this,null,function*(){var n;(n=e==null?void 0:e.setVisible)==null||n.call(e,!1),t.reset()})}}}function sr(){var d;const{t:e}=he(),t=s.useAPIClient(),o=s.useActionContext(),{workflow:n,refresh:i}=(d=q())!=null?d:{},a=S.useForm(),{upstream:l,branchIndex:c}=Zn();return{onClick(){return D(this,null,function*(){var u;try{const h=yield(yield fetch(a.values.file.url)).json();n&&(yield t.resource("workflows.nodes",n.id).create({values:{type:h.type,upstreamId:(u=l==null?void 0:l.id)!=null?u:null,branchIndex:c,title:h.title,config:h.config}}),o.setVisible(!1),b.message.success(e("Operation succeeded")),i(),a.reset())}catch(f){o.setVisible(!1),console.error("JSON解析失败:",f),i()}})}}}const ir={type:"void","x-decorator":"FormV2",properties:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1,style:{marginTop:"20px"}}},footer:{type:"void","x-component":"ActionBar","x-component-props":{style:{justifyContent:"right"}},properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}},ar=()=>r.jsx(s.SchemaComponent,{schema:ir,scope:{useCancelActionProps:rr,useCreateActionProps:sr}}),Vt=e=>{const{t}=he(),{styles:o}=nr(),{upstream:n,branchIndex:i=null}=e,{workflow:a,menu:l,isShowUploadModal:c,setIsShowUploadModal:d}=Rn(e);return a?r.jsxs("div",{className:o.addButtonClass,children:[r.jsx(b.Dropdown,{trigger:["click"],disabled:a.executed,overlayClassName:o.dropDownClass,menu:l,children:r.jsx(b.Button,{className:"add-btn",icon:r.jsx(j.PlusOutlined,{}),type:"primary","aria-label":e["aria-label"]||"add-button"})}),r.jsx(b.Modal,{footer:null,closable:!1,title:t("Upload node"),open:c,children:r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:d},children:r.jsx(Qn,{value:{upstream:n,branchIndex:i},children:r.jsx(ar,{})})})})]}):null};function $e(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}const uo=y.createContext({}),mo=uo.Provider;function ye(){return y.useContext(uo)}const lr=s.createStyles(({css:e,token:t})=>({nodeBlockClass:e`
36
36
  flex-grow: 1;
37
37
  flex-shrink: 0;
38
38
  display: flex;
39
39
  flex-direction: column;
40
40
  align-items: center;
41
41
  position: relative;
42
- `})),mo=({data:e})=>{const{styles:t}=ar(),{getAriaLabel:o}=dt(e),n=s.usePlugin(X),{Component:i=nt,end:a,group:l}=n.instructions.get(e.type);return r.jsx(uo,{value:A(w({},e),{group:l}),children:r.jsxs("div",{className:s.cx(t.nodeBlockClass),children:[r.jsx(i,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Vt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})})]})})},xe=s.createStyles(({css:e,token:t})=>({workflowPageClass:e`
42
+ `})),fo=({data:e})=>{const{styles:t}=lr(),{getAriaLabel:o}=dt(e),n=s.usePlugin(X),{Component:i=nt,end:a,group:l}=n.instructions.get(e.type);return r.jsx(mo,{value:A(w({},e),{group:l}),children:r.jsxs("div",{className:s.cx(t.nodeBlockClass),children:[r.jsx(i,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Vt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})})]})})},xe=s.createStyles(({css:e,token:t})=>({workflowPageClass:e`
43
43
  flex-grow: 1;
44
44
  overflow: hidden;
45
45
  display: flex;
@@ -329,7 +329,7 @@
329
329
  .workflow-node-config-button {
330
330
  display: none;
331
331
  }
332
- `}));function Be({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:i,end:a}){const{styles:l}=xe(),{getAriaLabel:c}=dt(e,o),d=[];for(let p=t;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,i),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Vt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(mo,{data:p},p.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})}):null]})}const lr=s.createStyles(({css:e,token:t})=>({container:e`
332
+ `}));function Be({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:i,end:a}){const{styles:l}=xe(),{getAriaLabel:c}=dt(e,o),d=[];for(let p=t;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,i),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Vt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(fo,{data:p},p.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})}):null]})}const cr=s.createStyles(({css:e,token:t})=>({container:e`
333
333
  margin-bottom: 1.5em;
334
334
  padding: 1em;
335
335
  background-color: ${t.colorFillAlter};
@@ -354,7 +354,7 @@
354
354
  p {
355
355
  color: ${t.colorTextDescription};
356
356
  }
357
- `}));function fo(e){const{label:t,title:o,description:n,workflowKey:i,createdAt:a,createdBy:l}=e,{styles:c}=lr(),{t:d}=he();return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:s.cx(c.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]}),i||a||l?r.jsxs("div",{className:s.cx(c.container,e.className),children:[i?r.jsx("p",{children:`${d("Key")}: ${i}`}):null,a?r.jsx("p",{children:`${d("Created at")}: ${E.convertUTCToLocal(a)}`}):null,l?r.jsx("p",{children:`${d("Created by")}: ${l}`}):null]}):null]})}const go="json-parse",ho="js-parse",yo="data-mapping",Ke="deprecated",cr=e=>{var d;const{className:t}=e,{t:o}=he(),{styles:n}=dr(),i=s.useCompile(),{instructions:a}=s.usePlugin(X),{nodes:l}=(d=q())!=null?d:{},c=y.useMemo(()=>l==null?void 0:l.reduce((p,u)=>{const f=a.get(u.type),{group:h,title:g}=f,x=lo.find(T=>T.key===h),v={key:h,title:g,groupLabel:x!=null&&x.label?x==null?void 0:x.label:o("Unkown group"),count:1,isDeprecated:h===Ke},I=p.findIndex(T=>T.key===h);return I>0?p[I].count++:p.push(v),p},[]),[l]);return r.jsxs("div",{className:s.cx(n.container,t),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o("Node list")}),r.jsx("dd",{children:o("group-title-count")})]}),c.map(({key:p,title:u,groupLabel:f,count:h,isDeprecated:g},x)=>r.jsx("p",{className:g?n.deprecated:"",children:`${x+1}: ${f}:${i(u)}-${h} ${g?o("Deprecated, please do not use it"):""}`},p))]})},dr=s.createStyles(({css:e,token:t})=>({container:e`
357
+ `}));function go(e){const{label:t,title:o,description:n,workflowKey:i,createdAt:a,createdBy:l}=e,{styles:c}=cr(),{t:d}=he();return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:s.cx(c.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]}),i||a||l?r.jsxs("div",{className:s.cx(c.container,e.className),children:[i?r.jsx("p",{children:`${d("Key")}: ${i}`}):null,a?r.jsx("p",{children:`${d("Created at")}: ${E.convertUTCToLocal(a)}`}):null,l?r.jsx("p",{children:`${d("Created by")}: ${l}`}):null]}):null]})}const ho="json-parse",yo="js-parse",xo="data-mapping",Ke="deprecated",dr=e=>{var d;const{className:t}=e,{t:o}=he(),{styles:n}=pr(),i=s.useCompile(),{instructions:a}=s.usePlugin(X),{nodes:l}=(d=q())!=null?d:{},c=y.useMemo(()=>l==null?void 0:l.reduce((p,u)=>{const f=a.get(u.type),{group:h,title:g}=f,x=co.find(T=>T.key===h),v={key:h,title:g,groupLabel:x!=null&&x.label?x==null?void 0:x.label:o("Unkown group"),count:1,isDeprecated:h===Ke},I=p.findIndex(T=>T.key===h);return I>0?p[I].count++:p.push(v),p},[]),[l]);return r.jsxs("div",{className:s.cx(n.container,t),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o("Node list")}),r.jsx("dd",{children:o("group-title-count")})]}),c.map(({key:p,title:u,groupLabel:f,count:h,isDeprecated:g},x)=>r.jsx("p",{className:g?n.deprecated:"",children:`${x+1}: ${f}:${i(u)}-${h} ${g?o("Deprecated, please do not use it"):""}`},p))]})},pr=s.createStyles(({css:e,token:t})=>({container:e`
358
358
  margin-bottom: 1.5em;
359
359
  padding: 1em;
360
360
  background-color: ${t.colorFillAlter};
@@ -381,23 +381,23 @@
381
381
  }
382
382
  `,deprecated:e`
383
383
  background-color: yellow;
384
- `}));function pr(){var a;const e=k.useForm(),t=s.useAPIClient(),{workflow:o}=(a=q())!=null?a:{},n=s.useActionContext(),{refresh:i}=s.useResourceActionContext();return{run(){return D(this,null,function*(){if(o.executed){b.message.error(F("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),b.message.success("success"),i()})}}}class Ye{}const ur=()=>{const e=s.useCompile(),{workflow:t,execution:o}=q(),{styles:n}=xe(),i=Qe();return o?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(s.Icon,{type:"InfoOutlined"}),shape:"circle",size:"small",className:s.cx(n.nodeJobButtonClass,s.css`
384
+ `}));function ur(){var a;const e=S.useForm(),t=s.useAPIClient(),{workflow:o}=(a=q())!=null?a:{},n=s.useActionContext(),{refresh:i}=s.useResourceActionContext();return{run(){return D(this,null,function*(){if(o.executed){b.message.error(F("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),b.message.success("success"),i()})}}}class Ye{}const mr=()=>{const e=s.useCompile(),{workflow:t,execution:o}=q(),{styles:n}=xe(),i=Qe();return o?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(s.Icon,{type:"InfoOutlined"}),shape:"circle",size:"small",className:s.cx(n.nodeJobButtonClass,s.css`
385
385
  position: absolute;
386
386
  top: 50%;
387
387
  right: -50px;
388
388
  transform: translateY(-50%);
389
- `),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:A(w({},o),{context:JSON.stringify(o.context||{},null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(i.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"string",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:a}=s.useTranslation();return{run(){return D(this,null,function*(){try{const c=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(c),b.message.success(a("Copied"))}catch(c){b.message.error(a("Copy failed"))}})}}}}}}}}}}}}):null};function mr(){return{form:k.useForm()}}const fr=()=>{var $;const e=s.useAPIClient(),{workflow:t,refresh:o}=q(),[n,i]=y.useState(""),[a,l]=y.useState(!1),[c,d]=y.useState(!1),{styles:p}=xe(),u=s.useCompile(),f=Qe(),h=u(f.title),{fieldset:g,scope:x,components:v}=f,I=t.executed?'{{t("View")}}':'{{t("Configure")}}',T=F("Trigger");y.useEffect(()=>{var P,B;t&&i((B=(P=t.triggerTitle)!=null?P:t.title)!=null?B:h)},[t]);const C=y.useMemo(()=>{const P=ie.cloneDeep(t.config);return k.createForm({initialValues:P,disabled:t.executed})},[t]),O=y.useCallback(P=>{l(P),P||C.reset()},[C]);y.useCallback(function(P){return D(this,null,function*(){const B=P||h;i(B),B!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:B}}),o())})},[t]);const V=y.useCallback(function(P){var _;if(P.target===P.currentTarget){l(!0);return}const B=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let z=P.target;z&&z!==P.currentTarget;z=z.parentNode)if(Array.from((_=z.classList)!=null?_:[]).some(J=>B.has(J))){l(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{role:"button","aria-label":`${T}-${n}`,className:s.cx(p.terminalClass),onClick:V,children:[F("Start"),r.jsx(s.ActionContextProvider,{value:{visible:a,setVisible:O,formValueChanged:c,setFormValueChanged:d},children:r.jsx(s.FormProvider,{form:C,children:r.jsx(s.SchemaComponent,{scope:A(w({},x),{useFormProviderProps:mr}),components:v,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":I,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:T,"x-component":"Action.Area","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:A(w({},f.description?{description:{type:"void","x-component":fo,"x-component-props":{label:F("Trigger type"),title:f.title,description:f.description,workflowKey:t.key,createdAt:t.createdAt,createdBy:($=t.createdBy)==null?void 0:$.nickname}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
389
+ `),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:A(w({},o),{context:JSON.stringify(o.context||{},null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(i.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"string",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:a}=s.useTranslation();return{run(){return D(this,null,function*(){try{const c=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(c),b.message.success(a("Copied"))}catch(c){b.message.error(a("Copy failed"))}})}}}}}}}}}}}}):null};function fr(){return{form:S.useForm()}}const gr=()=>{var $;const e=s.useAPIClient(),{workflow:t,refresh:o}=q(),[n,i]=y.useState(""),[a,l]=y.useState(!1),[c,d]=y.useState(!1),{styles:p}=xe(),u=s.useCompile(),f=Qe(),h=u(f.title),{fieldset:g,scope:x,components:v}=f,I=t.executed?'{{t("View")}}':'{{t("Configure")}}',T=F("Trigger");y.useEffect(()=>{var P,B;t&&i((B=(P=t.triggerTitle)!=null?P:t.title)!=null?B:h)},[t]);const C=y.useMemo(()=>{const P=R.cloneDeep(t.config);return S.createForm({initialValues:P,disabled:t.executed})},[t]),O=y.useCallback(P=>{l(P),P||C.reset()},[C]);y.useCallback(function(P){return D(this,null,function*(){const B=P||h;i(B),B!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:B}}),o())})},[t]);const V=y.useCallback(function(P){var _;if(P.target===P.currentTarget){l(!0);return}const B=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let z=P.target;z&&z!==P.currentTarget;z=z.parentNode)if(Array.from((_=z.classList)!=null?_:[]).some(J=>B.has(J))){l(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{role:"button","aria-label":`${T}-${n}`,className:s.cx(p.terminalClass),onClick:V,children:[F("Start"),r.jsx(s.ActionContextProvider,{value:{visible:a,setVisible:O,formValueChanged:c,setFormValueChanged:d},children:r.jsx(s.FormProvider,{form:C,children:r.jsx(s.SchemaComponent,{scope:A(w({},x),{useFormProviderProps:fr}),components:v,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":I,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:T,"x-component":"Action.Area","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:A(w({},f.description?{description:{type:"void","x-component":go,"x-component-props":{label:F("Trigger type"),title:f.title,description:f.description,workflowKey:t.key,createdAt:t.createdAt,createdBy:($=t.createdBy)==null?void 0:$.nickname}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
390
390
  .ant-select.auto-width {
391
391
  width: auto;
392
392
  min-width: 6em;
393
393
  }
394
- `},properties:g},actions:t.executed?{}:{type:"void","x-component":"ActionArea.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:pr}}}},showNodes:{type:"void","x-component":cr}})}}}})})})]}),r.jsx(ur,{})]})};function Qe(){const e=s.usePlugin(X),{workflow:t}=q();return e.triggers.get(t.type)}const xo="workflow-zoom";function gr({entry:e}){const{styles:t}=xe(),{workflow:o}=q(),[n,i]=y.useState(100),a=ie.debounce(l=>{localStorage.setItem(xo,l)});return y.useEffect(()=>{const l=localStorage.getItem(xo);l&&Number(l)>0&&i(Number(l))},[]),r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
394
+ `},properties:g},actions:t.executed?{}:{type:"void","x-component":"ActionArea.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:ur}}}},showNodes:{type:"void","x-component":dr}})}}}})})})]}),r.jsx(mr,{})]})};function Qe(){const e=s.usePlugin(X),{workflow:t}=q();return e.triggers.get(t.type)}const bo="workflow-zoom";function hr({entry:e}){const{styles:t}=xe(),{workflow:o}=q(),[n,i]=y.useState(100),a=R.debounce(l=>{localStorage.setItem(bo,l)});return y.useEffect(()=>{const l=localStorage.getItem(bo);l&&Number(l)>0&&i(Number(l))},[]),r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
395
395
  margin-top: 0 !important;
396
396
  `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:F("Executed workflow cannot be modified"),showIcon:!0,className:s.css`
397
397
  margin-bottom: 1em;
398
- `}):null,r.jsx(fr,{}),r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
398
+ `}):null,r.jsx(gr,{}),r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
399
399
  margin-top: 0 !important;
400
- `),children:r.jsx(Be,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:F("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{i(l),a(l)}})})]})}const bo="workflow-splitter",wo=({entry:e})=>{const t=q(),[o,n]=y.useState(600),i=ie.debounce(a=>{localStorage.setItem(bo,a)});return y.useEffect(()=>{const a=localStorage.getItem(bo);a&&Number(a)>0&&n(Number(a))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(b.Splitter,{onResize:a=>{n(a[1]),i(String(a[1]))},children:[r.jsx(b.Splitter.Panel,{collapsible:!0,children:r.jsx(gr,{entry:e})}),r.jsx(b.Splitter.Panel,{size:o,min:"240",collapsible:!0,className:"workflow-operator-area",children:r.jsx(s.ActionAreaStub,{})})]})})};function hr(e){if(e>=86313600)return"999 D";const n=Math.floor(e/(24*60*60)),i=Math.floor(e%(24*60*60)/3600),a=Math.floor(e%3600/60),l=e%60;let c="";return n>0&&(c+=`${n} D `),(i>0||n>0)&&(c+=`${i} h `),(a>0||i>0||n>0)&&(c+=`${a} m `),e>=60?c+=`${Math.floor(l)} s`:c+=`${l.toFixed(3)} s`,c.trim()}function yr(e){if(!e)return;const a=e/1e3,l=999*86400;if(a>=l)return"999 D";if(e<6e5){const h=Math.floor(a/60),g=Math.floor(a%60),x=e%1e3;let v=`${x} ms`;return h>0?v=`${h} m ${g} s ${x} ms`:g>0&&(v=`${g} s ${x} ms`),v}const c=Math.floor(a/86400),d=Math.floor(a%86400/3600),p=Math.floor(a%3600/60),u=a%60;let f="";return c>0&&(f+=`${c} D `),(d>0||c>0)&&(f+=`${d} h `),(p>0||d>0||c>0)&&(f+=`${p} m `),a>=60?f+=`${Math.floor(u)} s`:f+=`${u} s`,f.trim()}function xr(e,t){const o=()=>{const a=Date.now(),l=new Date(t.createdAt).getTime();return a-l},[n,i]=y.useState(e||o());return y.useEffect(()=>{let a;return t.status===0?a=setInterval(()=>{i(o())},1e3):i(e),()=>{a&&clearInterval(a)}},[e,t.status]),yr(n)}const vo=e=>{const t=ne.useNavigate();return r.jsx(b.Button,w({type:"text",icon:r.jsx(s.Icon,{type:"ArrowLeftOutlined"}),onClick:()=>{t(-1)}},e))},br=s.createStyles(({css:e})=>({statusButtonClass:e`
400
+ `),children:r.jsx(Be,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:F("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{i(l),a(l)}})})]})}const wo="workflow-splitter",vo=({entry:e})=>{const t=q(),[o,n]=y.useState(600),i=R.debounce(a=>{localStorage.setItem(wo,a)});return y.useEffect(()=>{const a=localStorage.getItem(wo);a&&Number(a)>0&&n(Number(a))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(b.Splitter,{onResize:a=>{n(a[1]),i(String(a[1]))},children:[r.jsx(b.Splitter.Panel,{collapsible:!0,children:r.jsx(hr,{entry:e})}),r.jsx(b.Splitter.Panel,{size:o,min:"240",collapsible:!0,className:"workflow-operator-area",children:r.jsx(s.ActionAreaStub,{})})]})})};function yr(e){if(e>=86313600)return"999 D";const n=Math.floor(e/(24*60*60)),i=Math.floor(e%(24*60*60)/3600),a=Math.floor(e%3600/60),l=e%60;let c="";return n>0&&(c+=`${n} D `),(i>0||n>0)&&(c+=`${i} h `),(a>0||i>0||n>0)&&(c+=`${a} m `),e>=60?c+=`${Math.floor(l)} s`:c+=`${l.toFixed(3)} s`,c.trim()}function xr(e){if(!e)return;const a=e/1e3,l=999*86400;if(a>=l)return"999 D";if(e<6e5){const h=Math.floor(a/60),g=Math.floor(a%60),x=e%1e3;let v=`${x} ms`;return h>0?v=`${h} m ${g} s ${x} ms`:g>0&&(v=`${g} s ${x} ms`),v}const c=Math.floor(a/86400),d=Math.floor(a%86400/3600),p=Math.floor(a%3600/60),u=a%60;let f="";return c>0&&(f+=`${c} D `),(d>0||c>0)&&(f+=`${d} h `),(p>0||d>0||c>0)&&(f+=`${p} m `),a>=60?f+=`${Math.floor(u)} s`:f+=`${u} s`,f.trim()}function br(e,t){const o=()=>{const a=Date.now(),l=new Date(t.createdAt).getTime();return a-l},[n,i]=y.useState(e||o());return y.useEffect(()=>{let a;return t.status===0?a=setInterval(()=>{i(o())},1e3):i(e),()=>{a&&clearInterval(a)}},[e,t.status]),xr(n)}const Co=e=>{const t=re.useNavigate();return r.jsx(b.Button,w({type:"text",icon:r.jsx(s.Icon,{type:"ArrowLeftOutlined"}),onClick:()=>{t(-1)}},e))},wr=s.createStyles(({css:e})=>({statusButtonClass:e`
401
401
  border: none;
402
402
  .ant-tag {
403
403
  display: inline-grid;
@@ -411,22 +411,22 @@
411
411
  }
412
412
  `,noStatusButtonClass:e`
413
413
  border-width: 2px;
414
- `}));function Ze(e){var n;const{styles:t}=br();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:i,color:a}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:a,children:i})}return r.jsx(b.Button,A(w({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},pt=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(j.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(j.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ut=pt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var be=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(be||{});const mt=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],Xe=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function ft(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 Re(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Re(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[i]=Object.keys(o[n]);return!(!i||typeof o[n][i]=="undefined")}):!1}function gt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{gt(e.properties[o],t)})}function Ve(e){return`/_admin/business-components/workflow/${e}/workflow`}function ht(e){return`/_admin/business-components/workflow/${e}/executions`}function wr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const i=o.get(n.nodeId);i.jobs.push(n),n.node={id:i.id,key:i.key,title:i.title,type:i.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((i,a)=>i.id-a.id)})}function vr(){const{instructions:e}=s.usePlugin(X),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=hr(o.cost/1e3);const{styles:i}=xe(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.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:A(w({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:c}=Q.useTranslation();return{run(){return D(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),b.message.success(c("Copied"))}catch(p){b.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function Cr(e){const{execution:t}=q(),o=s.useAPIClient(),n=ne.useNavigate(),{styles:i}=xe(),[a,l]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{d(u.data.reverse())}).catch(()=>{})},[t]);const p=y.useCallback(({key:u})=>{u!==t.id&&n(ht(u))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(i.dropdownClass,i.executionsDropdownRowClass),items:[...c,t,...a].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:E.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ze,{statusMap:ut,status:u.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function kr(){var C;const{t:e}=Q.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=y.useState(null),d=s.useApp(),p=s.useAPIClient();y.useEffect(()=>{var B;const{workflow:P}=(B=o==null?void 0:o.data)!=null?B:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${F("Execution history")}`)},[o==null?void 0:o.data]);const u=y.useCallback(()=>{b.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),i()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const O=(C=o==null?void 0:o.data)!=null?C:{},{jobs:f=[],workflow:V={}}=O,$=V,{nodes:h=[],revisions:g=[]}=$,x=K($,["nodes","revisions"]),v=K(O,["jobs","workflow"]);ft(h),wr(h,f);const I=h.find(P=>!P.upstream),T=ut[v.status];return r.jsxs(Ee.Provider,{value:{workflow:x.type?x:null,nodes:h,execution:v,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(vo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ne.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx(ne.Link,{to:Ve(x.id),children:x.title})},{title:r.jsx(Cr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:T.color,children:t(T.label)}),v.status?null:r.jsx(b.Tooltip,{title:F("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:E.str2moment(v.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(wo,{entry:I}),r.jsx(vr,{})]})}const Co=()=>{const e=ne.useParams(),{styles:t}=xe();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:kr}})})};function Sr(e){return["hasMany","belongsToMany"].includes(e.type)}function Ar(){const e=s.useCompile();return[yt,xt].map(t=>{var n;const o=(n=t.useOptions({types:[Sr],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function Ir(n){var i=n,{value:e,onChange:t}=i,o=K(i,["value","onChange"]);const{setValuesIn:a}=k.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=Ar(),[d,p]=y.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let h=[];const g=u.match(/^{{(.*)}}$/);g&&(h=[...g[1].trim().split(".").slice(0,-1),f]);const x=I=>D(null,null,function*(){var C;const T=I[I.length-1];!((C=T.children)!=null&&C.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(O=>[...O]))});y.useEffect(()=>{D(null,null,function*(){var C;if(!h||d.length<=1)return;let T=null;for(let O=0;O<h.length;O++){const V=h[O];try{O===0?T=d.find($=>$.value===V):(T.loadChildren&&!((C=T.children)!=null&&C.length)&&(yield T.loadChildren(T)),T=T.children.find($=>$.value===V))}catch($){console.error($)}}p([...d])})},[e,d.length]);const v=y.useCallback((I,T)=>{if(!(I!=null&&I.length)){a("collection",null),t({});return}const{field:C}=T.pop();if(!C||!["hasMany","belongsToMany"].includes(C.type))return;const{collectionName:O,target:V,name:$,dataSourceKey:P}=C,_=l(O,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${V}`),t({name:$,associatedKey:`{{${I.slice(0,-1).join(".")}.${_.name}}}`,associatedCollection:s.joinCollectionName(P,O)})},[t]);return r.jsx(b.Cascader,A(w({},o),{value:h,options:d,changeOnSelect:!0,onChange:v,loadData:x}))}class Fr extends H{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",this.description=`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`,this.fieldset={aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:t}=k.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
414
+ `}));function Ze(e){var n;const{styles:t}=wr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:i,color:a}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:a,children:i})}return r.jsx(b.Button,A(w({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},pt=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(j.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(j.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ut=pt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var be=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(be||{});const mt=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],Xe=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function ft(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 Re(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Re(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[i]=Object.keys(o[n]);return!(!i||typeof o[n][i]=="undefined")}):!1}function gt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{gt(e.properties[o],t)})}function Ve(e){return`/_admin/business-components/workflow/${e}/workflow`}function ht(e){return`/_admin/business-components/workflow/${e}/executions`}function vr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const i=o.get(n.nodeId);i.jobs.push(n),n.node={id:i.id,key:i.key,title:i.title,type:i.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((i,a)=>i.id-a.id)})}function Cr(){const{instructions:e}=s.usePlugin(X),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=yr(o.cost/1e3);const{styles:i}=xe(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.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:A(w({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:c}=Q.useTranslation();return{run(){return D(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),b.message.success(c("Copied"))}catch(p){b.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function kr(e){const{execution:t}=q(),o=s.useAPIClient(),n=re.useNavigate(),{styles:i}=xe(),[a,l]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{d(u.data.reverse())}).catch(()=>{})},[t]);const p=y.useCallback(({key:u})=>{u!==t.id&&n(ht(u))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(i.dropdownClass,i.executionsDropdownRowClass),items:[...c,t,...a].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:E.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ze,{statusMap:ut,status:u.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function Sr(){var C;const{t:e}=Q.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=y.useState(null),d=s.useApp(),p=s.useAPIClient();y.useEffect(()=>{var B;const{workflow:P}=(B=o==null?void 0:o.data)!=null?B:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${F("Execution history")}`)},[o==null?void 0:o.data]);const u=y.useCallback(()=>{b.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),i()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const O=(C=o==null?void 0:o.data)!=null?C:{},{jobs:f=[],workflow:V={}}=O,$=V,{nodes:h=[],revisions:g=[]}=$,x=K($,["nodes","revisions"]),v=K(O,["jobs","workflow"]);ft(h),vr(h,f);const I=h.find(P=>!P.upstream),T=ut[v.status];return r.jsxs(Ee.Provider,{value:{workflow:x.type?x:null,nodes:h,execution:v,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(Co,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx(re.Link,{to:Ve(x.id),children:x.title})},{title:r.jsx(kr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:T.color,children:t(T.label)}),v.status?null:r.jsx(b.Tooltip,{title:F("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:E.str2moment(v.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(vo,{entry:I}),r.jsx(Cr,{})]})}const ko=()=>{const e=re.useParams(),{styles:t}=xe();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:Sr}})})};function Ar(e){return["hasMany","belongsToMany"].includes(e.type)}function Ir(){const e=s.useCompile();return[yt,xt].map(t=>{var n;const o=(n=t.useOptions({types:[Ar],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function Fr(n){var i=n,{value:e,onChange:t}=i,o=K(i,["value","onChange"]);const{setValuesIn:a}=S.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=Ir(),[d,p]=y.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let h=[];const g=u.match(/^{{(.*)}}$/);g&&(h=[...g[1].trim().split(".").slice(0,-1),f]);const x=I=>D(null,null,function*(){var C;const T=I[I.length-1];!((C=T.children)!=null&&C.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(O=>[...O]))});y.useEffect(()=>{D(null,null,function*(){var C;if(!h||d.length<=1)return;let T=null;for(let O=0;O<h.length;O++){const V=h[O];try{O===0?T=d.find($=>$.value===V):(T.loadChildren&&!((C=T.children)!=null&&C.length)&&(yield T.loadChildren(T)),T=T.children.find($=>$.value===V))}catch($){console.error($)}}p([...d])})},[e,d.length]);const v=y.useCallback((I,T)=>{if(!(I!=null&&I.length)){a("collection",null),t({});return}const{field:C}=T.pop();if(!C||!["hasMany","belongsToMany"].includes(C.type))return;const{collectionName:O,target:V,name:$,dataSourceKey:P}=C,_=l(O,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${V}`),t({name:$,associatedKey:`{{${I.slice(0,-1).join(".")}.${_.name}}}`,associatedCollection:s.joinCollectionName(P,O)})},[t]);return r.jsx(b.Cascader,A(w({},o),{value:h,options:d,changeOnSelect:!0,onChange:v,loadData:x}))}class Tr extends H{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",this.description=`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`,this.fieldset={aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:t}=S.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
415
415
  position: relative;
416
416
  width: 100%;
417
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Ae,FieldsSelect:et,ValueBlock:ke,AssociatedConfig:Ir}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:o}:null}}class Tr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Fr)})}}const ko=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function Nr(e){return ko.slice().reverse().find(t=>!(e%t.value))}function Dr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Nr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:ko.map(a=>({value:a.value,label:o(a.label)}))})]})}class Or extends H{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:be.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:be.FAILED}],required:!0,default:be.RESOLVED}},this.components={Duration:Dr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class Pr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Or)})}}function Mr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function Er({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=ce({types:[Mr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class $r extends H{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:Er,WorkflowVariableInput:Ce,ValueBlock:ke}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:F("Calculation result")}}}const Br=k.observer(e=>{const{onChange:t}=e,o=k.useField(),n=k.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();k.useFormEffects(()=>{k.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),k.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=me({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,A(w({},e),{scope:u}))},{displayName:"InternalExpression"});function Vr(e){const{t}=Q.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=y.useMemo(()=>me({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,A(w({},e),{scope:a})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const Wr=k.connect(Br,k.mapReadPretty(Vr)),{defaultProps:jr}=s.interfacesProperties;class zr extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=w({},jr)}}class Lr extends s.Plugin{load(){return D(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([zr]),this.app.addComponents({DynamicExpression:Wr});const t=this.app.pm.get("workflow"),o=new $r;t.instructions.register(o.type,o)})}}function qr(n){var i=n,{collection:e,dataPath:t}=i,o=K(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,h]=s.parseCollectionName(e);p=c(h,f)}else p=e;function u(h){return D(this,arguments,function*({item:f}){const g=f.template?yield l(f):null,x={type:"void",name:k.uid(),title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};gt(x,v=>{v["x-uid"]&&delete v["x-uid"]}),a(x)})}return r.jsx(s.SchemaInitializerItem,A(w({},o),{onClick:u,items:d}))}function Ne(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(qr,w(w({},t),e))})}function Ur(e){const{execution:t,nodes:o}=q(),n=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=y.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return y.useMemo(()=>ie.get(i,e),[i,e])}function Wt({collection:e,dataPath:t,children:o}){const n=k.useField(),i=y.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Ur(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=y.useMemo(()=>k.createForm({values:d,readPretty:!0}),[d]),h={appends:l},g={loading:!1,data:{data:d}},v=s.useAPIClient().resource(u),I=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:v,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:{params:h,form:f,field:n,service:g,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Kr(){return!0}const et=k.observer(e=>{const p=e,{filter:t=Kr}=p,o=K(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=k.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(b.Select,A(w({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function _r(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}const ue={label:"label",value:"value",children:"children"},So={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=ye(),n=s.usePlugin(X).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},yt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(X),o=ye(),n=$e(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},xt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(X),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},jt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ue,current:o}=e,{instructions:n}=s.usePlugin(X),i=ye(),a=o!=null?o:i,l=_r(a),c=[];return l.forEach(d=>{var f,h;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(h=d.title)!=null?h:`#${d.id}`,[t.children]:u})}),c}},Ao={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ue}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},De={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 Io(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=De[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?zt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function zt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Lt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function qt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Io(l,d)):!0;if(zt(l)){if(o===null)return n?c||qt({fields:Ut(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=Lt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&qt({fields:Ut(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function tt(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function ce(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(jt,o),tt(yt,o),tt(xt,o),tt(Ao,o),s.useGlobalVariable("$env")].filter(Boolean)}function Fo(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(So,o)]}function Ut(e,{compile:t,getCollectionFields:o}){var d,p,u,f,h,g,x;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(v=>{v.isForeignKey?l.push(v):c.push(v)});for(let v=c.length-1;v>=0;v--){const I=c[v];if(I.type==="belongsTo"){const T=l.find(C=>C.name===I.foreignKey);T?c.splice(v,0,A(w(w({},I),T),{uiSchema:A(w({},I.uiSchema),{title:(d=I.uiSchema)!=null&&d.title?`${t((p=I.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(v,0,A(w({},I),{name:I.foreignKey,type:"bigInt",isForeignKey:!0,interface:I.interface,uiSchema:A(w({},I.uiSchema),{title:(u=I.uiSchema)!=null&&u.title?`${t((f=I.uiSchema)==null?void 0:f.title)} ID`:I.name})}))}else if(I.type==="context"&&I.collectionName==="users"){const T=(h=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===I.name))!=null?h:{};c.splice(v,0,A(w({},I),{type:I.dataType,interface:T.interface,uiSchema:A(w({},T.uiSchema),{title:(g=T.uiSchema)!=null&&g.title?`${t((x=T.uiSchema)==null?void 0:x.title)} ID`:I.name})}))}}return c.filter(v=>v.interface&&!v.hidden)}function Gr(e){const t=Lt(e.field,e.appends),o=me(w({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${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(i=>Io(e.field,i))||(e.disabled=!0))}function me(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=ue}=e,p=t!=null?t:Ut(o,{compile:l,getCollectionFields:c}),u=Gr.bind({compile:l,getCollectionFields:c,fieldNames:d});return qt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(h=>{var I;const g=l(((I=h.uiSchema)==null?void 0:I.title)||h.name),x=Lt(h,i),v=!zt(h)||x&&!x.length&&!i.includes(h.name)||!1;return{[d.label]:g,key:h.name,[d.value]:h.name,isLeaf:v,loadChildren:v?null:u,field:h,depth:a,appends:i,types:n}})}function Ce(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.Input,w({scope:i},t))}function ot(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.TextArea,w({scope:i},t))}function To(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.RawTextArea,w({scope:i},t))}function No(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.JSON,w({scope:i},t))}function Hr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=Fo(e),l=ce(e);return r.jsx(s.Variable.CodeMirror,w({scope:[...a,...l,...i]},t))}function Ae({value:e,onChange:t,renderSchemaComponent:o}){const n=ce();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const d=e,{options:t=[],getOptions:o=()=>[],direction:n}=d,i=K(d,["options","getOptions","direction"]),a=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,A(w({},i),{children:r.jsx(b.Space,{direction:n,children:c.map(p=>r.jsxs(b.Radio,{value:p.value,children:[r.jsx("span",{className:s.css`
417
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Ae,FieldsSelect:et,ValueBlock:ke,AssociatedConfig:Fr}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:o}:null}}class Nr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Tr)})}}const So=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function Dr(e){return So.slice().reverse().find(t=>!(e%t.value))}function Or({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Dr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:So.map(a=>({value:a.value,label:o(a.label)}))})]})}class Pr extends H{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:be.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:be.FAILED}],required:!0,default:be.RESOLVED}},this.components={Duration:Or}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class Mr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Pr)})}}function Er(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function $r({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=ce({types:[Er.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class Br extends H{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:$r,WorkflowVariableInput:Ce,ValueBlock:ke}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:F("Calculation result")}}}const Vr=S.observer(e=>{const{onChange:t}=e,o=S.useField(),n=S.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();S.useFormEffects(()=>{S.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),S.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=me({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,A(w({},e),{scope:u}))},{displayName:"InternalExpression"});function Wr(e){const{t}=Q.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=y.useMemo(()=>me({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,A(w({},e),{scope:a})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const jr=S.connect(Vr,S.mapReadPretty(Wr)),{defaultProps:zr}=s.interfacesProperties;class Lr extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.icon="FunctionOutlined",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=w({},zr)}}class qr extends s.Plugin{load(){return D(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Lr]),this.app.addComponents({DynamicExpression:jr});const t=this.app.pm.get("workflow"),o=new Br;t.instructions.register(o.type,o)})}}function Ur(n){var i=n,{collection:e,dataPath:t}=i,o=K(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,h]=s.parseCollectionName(e);p=c(h,f)}else p=e;function u(h){return D(this,arguments,function*({item:f}){const g=f.template?yield l(f):null,x={type:"void",name:S.uid(),title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};gt(x,v=>{v["x-uid"]&&delete v["x-uid"]}),a(x)})}return r.jsx(s.SchemaInitializerItem,A(w({},o),{onClick:u,items:d}))}function Ne(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(Ur,w(w({},t),e))})}function Kr(e){const{execution:t,nodes:o}=q(),n=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=y.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return y.useMemo(()=>R.get(i,e),[i,e])}function Wt({collection:e,dataPath:t,children:o}){const n=S.useField(),i=y.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Kr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=y.useMemo(()=>S.createForm({values:d,readPretty:!0}),[d]),h={appends:l},g={loading:!1,data:{data:d}},v=s.useAPIClient().resource(u),I=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:v,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:{params:h,form:f,field:n,service:g,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function _r(){return!0}const et=S.observer(e=>{const p=e,{filter:t=_r}=p,o=K(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=S.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(b.Select,A(w({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Gr(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}const ue={label:"label",value:"value",children:"children"},Ao={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=ye(),n=s.usePlugin(X).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},yt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(X),o=ye(),n=$e(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},xt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(X),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},jt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ue,current:o}=e,{instructions:n}=s.usePlugin(X),i=ye(),a=o!=null?o:i,l=Gr(a),c=[];return l.forEach(d=>{var f,h;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(h=d.title)!=null?h:`#${d.id}`,[t.children]:u})}),c}},Io={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ue}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},De={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 Fo(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=De[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?zt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function zt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Lt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function qt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Fo(l,d)):!0;if(zt(l)){if(o===null)return n?c||qt({fields:Ut(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=Lt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&qt({fields:Ut(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function tt(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function ce(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(jt,o),tt(yt,o),tt(xt,o),tt(Io,o),s.useGlobalVariable("$env")].filter(Boolean)}function To(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(Ao,o)]}function Ut(e,{compile:t,getCollectionFields:o}){var d,p,u,f,h,g,x;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(v=>{v.isForeignKey?l.push(v):c.push(v)});for(let v=c.length-1;v>=0;v--){const I=c[v];if(I.type==="belongsTo"){const T=l.find(C=>C.name===I.foreignKey);T?c.splice(v,0,A(w(w({},I),T),{uiSchema:A(w({},I.uiSchema),{title:(d=I.uiSchema)!=null&&d.title?`${t((p=I.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(v,0,A(w({},I),{name:I.foreignKey,type:"bigInt",isForeignKey:!0,interface:I.interface,uiSchema:A(w({},I.uiSchema),{title:(u=I.uiSchema)!=null&&u.title?`${t((f=I.uiSchema)==null?void 0:f.title)} ID`:I.name})}))}else if(I.type==="context"&&I.collectionName==="users"){const T=(h=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===I.name))!=null?h:{};c.splice(v,0,A(w({},I),{type:I.dataType,interface:T.interface,uiSchema:A(w({},T.uiSchema),{title:(g=T.uiSchema)!=null&&g.title?`${t((x=T.uiSchema)==null?void 0:x.title)} ID`:I.name})}))}}return c.filter(v=>v.interface&&!v.hidden)}function Hr(e){const t=Lt(e.field,e.appends),o=me(w({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${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(i=>Fo(e.field,i))||(e.disabled=!0))}function me(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=ue}=e,p=t!=null?t:Ut(o,{compile:l,getCollectionFields:c}),u=Hr.bind({compile:l,getCollectionFields:c,fieldNames:d});return qt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(h=>{var I;const g=l(((I=h.uiSchema)==null?void 0:I.title)||h.name),x=Lt(h,i),v=!zt(h)||x&&!x.length&&!i.includes(h.name)||!1;return{[d.label]:g,key:h.name,[d.value]:h.name,isLeaf:v,loadChildren:v?null:u,field:h,depth:a,appends:i,types:n}})}function Ce(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.Input,w({scope:i},t))}function ot(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.TextArea,w({scope:i},t))}function No(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.RawTextArea,w({scope:i},t))}function Do(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.JSON,w({scope:i},t))}function Jr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=To(e),l=ce(e);return r.jsx(s.Variable.CodeMirror,w({scope:[...a,...l,...i]},t))}function Ae({value:e,onChange:t,renderSchemaComponent:o}){const n=ce();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const d=e,{options:t=[],getOptions:o=()=>[],direction:n}=d,i=K(d,["options","getOptions","direction"]),a=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,A(w({},i),{children:r.jsx(b.Space,{direction:n,children:c.map(p=>r.jsxs(b.Radio,{value:p.value,children:[r.jsx("span",{className:s.css`
418
418
  & + .anticon {
419
419
  margin-left: 0.25em;
420
420
  }
421
- `,children:a(p.label)}),p.tooltip&&r.jsx(b.Tooltip,{title:a(p.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},p.value))})}))}function Do(e){const a=e,{options:t=[],direction:o}=a,n=K(a,["options","direction"]),i=s.useCompile();return r.jsx(b.Checkbox.Group,A(w({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Checkbox,{value:l.value,children:[r.jsx("span",{className:s.css`
421
+ `,children:a(p.label)}),p.tooltip&&r.jsx(b.Tooltip,{title:a(p.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},p.value))})}))}function Oo(e){const a=e,{options:t=[],direction:o}=a,n=K(a,["options","direction"]),i=s.useCompile();return r.jsx(b.Checkbox.Group,A(w({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Checkbox,{value:l.value,children:[r.jsx("span",{className:s.css`
422
422
  & + .anticon {
423
423
  margin-left: 0.25em;
424
424
  }
425
- `,children:i(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Kt(){const e=k.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ke=()=>null;function Jr(){const a=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=K(a,["node","resultTitle"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{var l;i({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function Yr({dataSource:e}){var i;const t=k.useFieldSchema(),{execution:o}=q();if(!o)return t.title;const n=E.parse(e)({$jobsMapByNodeKey:((i=o.jobs)!=null?i:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
425
+ `,children:i(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Kt(){const e=S.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ke=()=>null;function Yr(){const a=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=K(a,["node","resultTitle"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{var l;i({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function Qr({dataSource:e}){var i;const t=S.useFieldSchema(),{execution:o}=q();if(!o)return t.title;const n=E.parse(e)({$jobsMapByNodeKey:((i=o.jobs)!=null?i:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
426
426
  margin: 0;
427
- `,children:JSON.stringify(n,null,2)})}ke.Initializer=Jr,ke.Result=Yr,ke.Designer=Kt;function Oo(n){var i=n,{component:e="div",children:t}=i,o=K(i,["component","children"]);const[a,l]=y.useState(!1),c=k.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,A(w({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Po(e){var a;const o=s.useCompile()(e.label),n=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:i}=(a=ut[e.value])!=null?a:{};return r.jsx(b.Tag,{color:i,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function Qr(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Po,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Mo(t){var e=K(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Po,children:pt.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,A(w({},n),{children:r.jsx(Qr,w({},n))}),n.value))}))}function _t(e){const{t}=Q.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useCollectionRecordData(),a=y.useCallback(()=>{b.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:i.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[i]);return r.jsxs("div",{className:s.css`
427
+ `,children:JSON.stringify(n,null,2)})}ke.Initializer=Yr,ke.Result=Qr,ke.Designer=Kt;function Po(n){var i=n,{component:e="div",children:t}=i,o=K(i,["component","children"]);const[a,l]=y.useState(!1),c=S.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,A(w({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Mo(e){var a;const o=s.useCompile()(e.label),n=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:i}=(a=ut[e.value])!=null?a:{};return r.jsx(b.Tag,{color:i,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function Zr(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Mo,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Eo(t){var e=K(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Mo,children:pt.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,A(w({},n),{children:r.jsx(Zr,w({},n))}),n.value))}))}function _t(e){const{t}=Q.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useCollectionRecordData(),a=y.useCallback(()=>{b.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:i.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[i]);return r.jsxs("div",{className:s.css`
428
428
  display: flex;
429
- `,children:[e.children,i.status?null:r.jsx(b.Tooltip,{title:F("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})})]})}const Eo=t=>{var e=K(t,[]);const[o,n]=y.useState(30),i=y.useRef(null),a=l=>{var c;n(i.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return y.useEffect(()=>{n(i.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,A(w({},e),{onChange:a,style:{width:`${o}px`}})),r.jsx("span",{ref:i,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},Zr=e=>e.value&&typeof e.value=="object"?r.jsx(Rr,w({},e)):r.jsx(Xr,w({},e)),Xr=({value:e,onChange:t})=>{const o=ce({types:[es]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},Rr=()=>{const e=k.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function es(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Gt(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function $o(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const ts=()=>{const e=Gt(),t=E.ArrayItems.useArray()||{field:[]},{t:o}=he(),[n,i]=y.useState(!1),a=y.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=y.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:i,content:r.jsx(os,{onSlecet:a,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},os=({onSlecet:e,onQuery:t})=>{const{t:o}=he();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ns=e=>{const{t}=he(),[o,n]=y.useState(!1),i=y.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Ht=()=>{const{t:e}=Q.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(ne.Link,{to:ht(t),onClick:()=>o(!1),children:e("View")})},Jt=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest();return{onClick(){return D(this,null,function*(){yield t.retry({filterByTk:e.id}),o==null||o.refresh()})}}};function rs(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:F("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:F("Values submitted"),value:"values",children:me(A(w({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class ss extends Ye{constructor(){super(...arguments),this.sync=!0,this.title=F("Interceptor"),this.description=F('Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.'),this.fieldset={collection:{type:"string",title:N("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:N("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:N("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:N("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Create record action"),value:"create"},{label:N("Update record action"),value:"update"},{label:N("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FieldsSelect:et,RadioWithTooltip:Ie,CheckboxGroupWithTooltip:Do},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=me(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User acted")}}],compile:n,getCollectionFields:i})),l=[{label:F("Parameters"),value:"params",children:rs(t,o)}];return[...a,{label:F("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Ne,collection:t.collection,dataPath:"$context.params.values"}:null}}class is extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerTrigger("request-interception",ss)})}}class as extends H{constructor(){super(...arguments),this.title=N("JS Parse"),this.type=ho,this.group=Ke,this.description=N("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:N("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
429
+ `,children:[e.children,i.status?null:r.jsx(b.Tooltip,{title:F("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})})]})}const $o=t=>{var e=K(t,[]);const[o,n]=y.useState(30),i=y.useRef(null),a=l=>{var c;n(i.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return y.useEffect(()=>{n(i.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,A(w({},e),{onChange:a,style:{width:`${o}px`}})),r.jsx("span",{ref:i,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},Xr=e=>e.value&&typeof e.value=="object"?r.jsx(es,w({},e)):r.jsx(Rr,w({},e)),Rr=({value:e,onChange:t})=>{const o=ce({types:[ts]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},es=()=>{const e=S.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function ts(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Gt(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function Bo(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const os=()=>{const e=Gt(),t=E.ArrayItems.useArray()||{field:[]},{t:o}=he(),[n,i]=y.useState(!1),a=y.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=y.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:i,content:r.jsx(ns,{onSlecet:a,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},ns=({onSlecet:e,onQuery:t})=>{const{t:o}=he();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},rs=e=>{const{t}=he(),[o,n]=y.useState(!1),i=y.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Ht=()=>{const{t:e}=Q.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(re.Link,{to:ht(t),onClick:()=>o(!1),children:e("View")})},Jt=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest();return{onClick(){return D(this,null,function*(){yield t.retry({filterByTk:e.id}),o==null||o.refresh()})}}};function ss(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:F("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:F("Values submitted"),value:"values",children:me(A(w({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class is extends Ye{constructor(){super(...arguments),this.sync=!0,this.title=F("Interceptor"),this.description=F('Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.'),this.fieldset={collection:{type:"string",title:N("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:N("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:N("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:N("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Create record action"),value:"create"},{label:N("Update record action"),value:"update"},{label:N("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FieldsSelect:et,RadioWithTooltip:Ie,CheckboxGroupWithTooltip:Oo},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=me(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User acted")}}],compile:n,getCollectionFields:i})),l=[{label:F("Parameters"),value:"params",children:ss(t,o)}];return[...a,{label:F("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Ne,collection:t.collection,dataPath:"$context.params.values"}:null}}class as extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerTrigger("request-interception",is)})}}class ls extends H{constructor(){super(...arguments),this.title=N("JS Parse"),this.type=yo,this.group=Ke,this.description=N("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:N("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
430
430
  ctx.body
431
431
  __ctx
432
432
  lib.JSON
@@ -440,14 +440,14 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
440
440
  button {
441
441
  padding: 0;
442
442
  }
443
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class ls extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(ho,as)})}}class cs extends H{constructor(){super(...arguments),this.title=N("JSON Parse"),this.type=go,this.group=Ke,this.description=N("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:N("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:N("Properties mapping"),description:N("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
443
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class cs extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(yo,ls)})}}class ds extends H{constructor(){super(...arguments),this.title=N("JSON Parse"),this.type=ho,this.group=Ke,this.description=N("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:N("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:N("Properties mapping"),description:N("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
444
444
  > *:not(:last-child) {
445
445
  margin-right: 0.5em;
446
446
  }
447
447
  button {
448
448
  padding: 0;
449
449
  }
450
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class ds extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(go,cs)})}}function ps(e,t){let o=e,n=null;for(let i=0;i<t.length;i++){const a=t[i],l=o.find(c=>c.value===a);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class us extends H{constructor(){super(...arguments),this.title=`{{t("Loop", { ns: "${m}" })}}`,this.type="loop",this.group="control",this.icon="RetweetOutlined",this.color="#0ed6ec",this.description=`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${m}" })}}`,this.fieldset={target:{type:"string",title:`{{t("Loop target", { ns: "${m}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:s.css`
450
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class ps extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(ho,ds)})}}function us(e,t){let o=e,n=null;for(let i=0;i<t.length;i++){const a=t[i],l=o.find(c=>c.value===a);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class ms extends H{constructor(){super(...arguments),this.title=`{{t("Loop", { ns: "${m}" })}}`,this.type="loop",this.group="control",this.icon="RetweetOutlined",this.color="#0ed6ec",this.description=`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${m}" })}}`,this.fieldset={target:{type:"string",title:`{{t("Loop target", { ns: "${m}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:s.css`
451
451
  width: 100%;
452
452
 
453
453
  .variable {
@@ -459,23 +459,23 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
459
459
  }
460
460
  `},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableInput:Ce}}Component({data:t}){var a;const{nodes:o}=q(),{styles:n}=xe(),i=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(nt,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
461
461
  padding-left: 20em;
462
- `),children:[r.jsx(Be,{from:t,entry:i,branchIndex:(a=i==null?void 0:i.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(j.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),i=F("Loop target"),a=F("Loop index"),l=F("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=ue}=o;let p={key:"item",[d.value]:"item",[d.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const u=c.slice(2,-2).split(".").map(g=>g.trim()),f=[jt,yt,xt].map(g=>{const x=g.useOptions(A(w({},o),{current:t})).filter(Boolean);return{[d.label]:n(g.label),[d.value]:g.value,key:g.value,[d.children]:x,disabled:x&&!x.length}}),h=ps(f,u);p=Object.assign({},h,p)}return[p,{key:"index",[d.value]:"index",[d.label]:a},{key:"length",[d.value]:"length",[d.label]:l}]}}class ms extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",us)})}}function fs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function gs({multiple:e=!1,value:t=[],onChange:o}){const n=ce({types:[fs]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:i=>{o([i])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:i=>{o(i!=null?[i]:[])}})})}function hs({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(E.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:F("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:F("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:F("All pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:F("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:F("Any pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
462
+ `),children:[r.jsx(Be,{from:t,entry:i,branchIndex:(a=i==null?void 0:i.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(j.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),i=F("Loop target"),a=F("Loop index"),l=F("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=ue}=o;let p={key:"item",[d.value]:"item",[d.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const u=c.slice(2,-2).split(".").map(g=>g.trim()),f=[jt,yt,xt].map(g=>{const x=g.useOptions(A(w({},o),{current:t})).filter(Boolean);return{[d.label]:n(g.label),[d.value]:g.value,key:g.value,[d.children]:x,disabled:x&&!x.length}}),h=us(f,u);p=Object.assign({},h,p)}return[p,{key:"index",[d.value]:"index",[d.label]:a},{key:"length",[d.value]:"length",[d.label]:l}]}}class fs extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",ms)})}}function gs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function hs({multiple:e=!1,value:t=[],onChange:o}){const n=ce({types:[gs]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:i=>{o([i])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:i=>{o(i!=null?[i]:[])}})})}function ys({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(E.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:F("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:F("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:F("All pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:F("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:F("Any pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
463
463
  .ant-radio-group {
464
464
  .anticon {
465
465
  margin-left: 0.5em;
466
466
  }
467
467
  }
468
- `,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:F("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:F("Separately")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:F("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:F("Collaboratively")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Bo(e){var $,P,B;const t=s.useRecord(),o=k.useFieldSchema(),n=k.useField(),i=y.useRef(null),a=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(a),{appends:c,updateAssociationValues:d}=l(),[p]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[p],{findComponent:f}=s.useDesignable(),h=f((B=n.component)==null?void 0:B[0])||y.Fragment,g=y.useMemo(()=>k.createForm({initialValues:u}),[u]),x=y.useMemo(()=>w({appends:c},e.params),[c,e.params]),v=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),I=s.useAPIClient(),T=s.useDataSourceHeaders(a),C=I.resource(e.collection,void 0,T),O=s.useBlockRequestContext(),V=y.useMemo(()=>({params:x,form:g,field:n,service:v,updateAssociationValues:d,formBlockRef:i}),[n,g,x,v,d]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:a,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:u,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:v,resource:C,__parent:O},children:r.jsx(s.FormBlockContext.Provider,{value:V,children:r.jsxs(h,A(w({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:g}),r.jsx("div",{ref:i,children:r.jsx(k.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function ys(e){return s.createFormBlockSchema(e)}function xs(o){var n=o,{schema:e}=n,t=K(n,["schema"]);const{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),{insert:a}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(p){return D(this,arguments,function*({item:d}){var x;const u=d.template?yield i(d):null,f=ys(A(w({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:be.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:u}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[h]=Object.keys(f.properties),g=((x=Object.entries(f.properties[h].properties).find(([v,I])=>I["x-component"]==="ActionBar"))==null?void 0:x[0])||"actions";f.properties[h].properties[g]["x-decorator"]="ActionBarProvider",f.properties[h].properties[g]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},gt(f,v=>{v["x-uid"]&&delete v["x-uid"]}),a(f)})}return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:c,items:l}))}function Vo(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(xs,w({},e))})}function Oe(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(i=>{n.push(...Oe(e.properties[i],t))}),n):n}function bs(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ws={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:ie.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Vo}))})),[e]),[o,n]=y.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{CreateFormDesigner:bs},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Oe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Wo(e){var p,u,f,h;const[t,o]=y.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),i=k.useField(),a=k.useFieldSchema(),[l]=Object.keys((f=a.toJSON().properties)!=null?f:{}),c=(h=n==null?void 0:n.result)==null?void 0:h[l],d=y.useMemo(()=>k.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:A(w({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:i,setCollectionFields:o},children:e.children})})}):null}function vs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:E.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[E.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:be.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const jo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function Cs(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:i="others"}=n;t[i]=t[i]||{},ie.set(t,[i,o],n)}),Object.keys(jo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:jo[o],children:Object.keys(t[o]||{}).map(n=>{const i=t[o][n];return w({value:n,title:i.title,name:n},t[o][n])}).sort((n,i)=>n.order-i.order)}))}function ks(){const{interfaces:e}=s.useCollectionManager_deprecated();return Cs(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:Is,fieldInterface:n.name}))}))}const zo=y.createContext({}),Ss=e=>{const[t,o]=y.useState(null),[n,i]=y.useState(),a=ks(),l=s.useCollection_deprecated(),{setCollectionFields:c}=y.useContext(s.FormBlockContext),d=y.useMemo(()=>k.createForm(),[t]);return r.jsxs(zo.Provider,{value:{onAddField(p){const u=ie.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,C=T,{unique:f,type:h,layout:g,autoIncrement:x}=C,v=K(C,["unique","type","layout","autoIncrement"]);u.properties=v;const I=ie.cloneDeep(u);delete I.properties.name["x-disabled"],o(I)},setCallback:i},children:[r.jsx(s.SchemaInitializerItems,A(w({},e),{items:a})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(p){p||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:d},"x-component":"Action.Drawer",properties:A(w({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const p=k.useForm();return{run(){return D(this,null,function*(){i(null),o(null),p.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:p,query:u,reset:f}=k.useForm(),h=[F("Field name existed in form")];return{run(){return D(this,null,function*(){var C,O,V,$;const{default:x}=t,v=E.uid();if(x.name=(C=p.name)!=null?C:v,x.uiSchema.title=(V=(O=p.uiSchema)==null?void 0:O.title)!=null?V:v,x.interface=t.name,($=l.fields)==null?void 0:$.find(P=>P.name===x.name)){u("name").take().setFeedback({type:"error",messages:h});return}const T=E.merge(x,p);c([...l.fields,T]),n({name:x.name,type:x.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${x.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),i(null),o(null)})}}}}}}}})},components:{ArrayTable:E.ArrayTable}}):null})]})},As=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:Ss});function Is(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:i}=y.useContext(zo),{getInterface:a}=s.useCollectionManager_deprecated(),l=a(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,w({onClick:()=>{i(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const Lo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:vs}},initializers:{},components:{CustomFormBlockProvider:Wo},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=Oe(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var f,h;return(h=(f=u["x-component-props"])==null?void 0:f.field)!=null?h:u["x-interface-options"]});const c=((d=Object.entries(a.properties).find(([u,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[i]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Oe(a.properties[c],u=>u["x-component"]==="Action").map(u=>{var f,h;return{status:u["x-decorator-props"].value,values:(h=(f=u["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:h.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Wo}}};function Fs(){const{name:e,title:t}=s.useCollection_deprecated(),o=k.useFieldSchema(),{t:n}=Q.useTranslation(),{dn:i}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ts={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:ie.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Vo}))})),[e]),[o,n]=y.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:Ae,UpdateFormDesigner:Fs},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]=A(w({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Oe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Pe=new E.Registry;Pe.register("customForm",Lo),Pe.register("createForm",ws),Pe.register("updateForm",Ts);function Ns(){const{workflow:e}=q(),t=Qe();return t.useInitializers?t.useInitializers(e.config):null}Lo.title;const Ds=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(X),t=ye(),o=$e(t),n=[Ns()].filter(Boolean),i=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Pe.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function Os(){var I,T,C;const e=y.useContext(s.SchemaComponentContext),{t}=Q.useTranslation(),o=k.useFieldSchema(),n=ce(),[i,a]=y.useState(!1),[l,c]=y.useState((C=(T=(I=o==null?void 0:o["x-action-settings"])==null?void 0:I.assignedValues)==null?void 0:T.schema)!=null?C:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,p]=y.useState(null),{components:u}=s.useSchemaOptionsContext();y.useEffect(()=>{p(new k.Schema({properties:{grid:l}}))},[l]);const f=y.useMemo(()=>{var V,$;const O=($=(V=o==null?void 0:o["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:$.values;return k.createForm({initialValues:E.lodash.cloneDeep(O),values:E.lodash.cloneDeep(O)})},[o]),h=s.useFormActiveFields(),g=t("Assign field values");function x(){a(!1)}function v(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=f.values,a(!1),setTimeout(()=>{var O;(O=e.refresh)==null||O.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:g,onClick:()=>a(!0),children:g}),r.jsx(b.Modal,{width:"50%",title:g,open:i,onCancel:x,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:x,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:v,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:h==null?void 0:h.getActiveFieldsName,children:r.jsx(k.FormProvider,{form:f,children:r.jsxs(E.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:F("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),i&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{refresh(){c(E.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:u})})]})})})})})})]})}function Ps(e){return r.jsxs(s.GeneralSchemaDesigner,A(w({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Os,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Ms(){const a=s.useSchemaInitializerItem(),{action:t,actionProps:o}=a,n=K(a,["action","actionProps"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{i({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function qo(){const e=s.useSchemaInitializerItem(),i=e,{action:t,actionProps:o}=i,n=K(i,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,A(w({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const Es=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Ms,action:be.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:qo,action:be.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:qo,action:be.PENDING}]});function $s(){return{run(){}}}function Bs({value:e,onChange:t}){const o=s.usePlugin(X),n=y.useContext(s.SchemaComponentContext),i=ye(),a=$e(i),l=k.useForm(),{workflow:c}=q(),d={};a.forEach(f=>{const h=o.instructions.get(f.type);Object.assign(d,h.components)});const p=y.useMemo(()=>new k.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
468
+ `,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:F("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:F("Separately")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:F("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:F("Collaboratively")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Vo(e){var $,P,B;const t=s.useRecord(),o=S.useFieldSchema(),n=S.useField(),i=y.useRef(null),a=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(a),{appends:c,updateAssociationValues:d}=l(),[p]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[p],{findComponent:f}=s.useDesignable(),h=f((B=n.component)==null?void 0:B[0])||y.Fragment,g=y.useMemo(()=>S.createForm({initialValues:u}),[u]),x=y.useMemo(()=>w({appends:c},e.params),[c,e.params]),v=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),I=s.useAPIClient(),T=s.useDataSourceHeaders(a),C=I.resource(e.collection,void 0,T),O=s.useBlockRequestContext(),V=y.useMemo(()=>({params:x,form:g,field:n,service:v,updateAssociationValues:d,formBlockRef:i}),[n,g,x,v,d]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:a,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:u,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:v,resource:C,__parent:O},children:r.jsx(s.FormBlockContext.Provider,{value:V,children:r.jsxs(h,A(w({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:g}),r.jsx("div",{ref:i,children:r.jsx(S.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function xs(e){return s.createFormBlockSchema(e)}function bs(o){var n=o,{schema:e}=n,t=K(n,["schema"]);const{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),{insert:a}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(p){return D(this,arguments,function*({item:d}){var x;const u=d.template?yield i(d):null,f=xs(A(w({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:be.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:u}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[h]=Object.keys(f.properties),g=((x=Object.entries(f.properties[h].properties).find(([v,I])=>I["x-component"]==="ActionBar"))==null?void 0:x[0])||"actions";f.properties[h].properties[g]["x-decorator"]="ActionBarProvider",f.properties[h].properties[g]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},gt(f,v=>{v["x-uid"]&&delete v["x-uid"]}),a(f)})}return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:c,items:l}))}function Wo(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(bs,w({},e))})}function Oe(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(i=>{n.push(...Oe(e.properties[i],t))}),n):n}function ws(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const vs={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:R.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Wo}))})),[e]),[o,n]=y.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{CreateFormDesigner:ws},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Oe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function jo(e){var p,u,f,h;const[t,o]=y.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),i=S.useField(),a=S.useFieldSchema(),[l]=Object.keys((f=a.toJSON().properties)!=null?f:{}),c=(h=n==null?void 0:n.result)==null?void 0:h[l],d=y.useMemo(()=>S.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:A(w({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:i,setCollectionFields:o},children:e.children})})}):null}function Cs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:E.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[E.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:be.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const zo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function ks(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:i="others"}=n;t[i]=t[i]||{},R.set(t,[i,o],n)}),Object.keys(zo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:zo[o],children:Object.keys(t[o]||{}).map(n=>{const i=t[o][n];return w({value:n,title:i.title,name:n},t[o][n])}).sort((n,i)=>n.order-i.order)}))}function Ss(){const{interfaces:e}=s.useCollectionManager_deprecated();return ks(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:Fs,fieldInterface:n.name}))}))}const Lo=y.createContext({}),As=e=>{const[t,o]=y.useState(null),[n,i]=y.useState(),a=Ss(),l=s.useCollection_deprecated(),{setCollectionFields:c}=y.useContext(s.FormBlockContext),d=y.useMemo(()=>S.createForm(),[t]);return r.jsxs(Lo.Provider,{value:{onAddField(p){const u=R.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,C=T,{unique:f,type:h,layout:g,autoIncrement:x}=C,v=K(C,["unique","type","layout","autoIncrement"]);u.properties=v;const I=R.cloneDeep(u);delete I.properties.name["x-disabled"],o(I)},setCallback:i},children:[r.jsx(s.SchemaInitializerItems,A(w({},e),{items:a})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(p){p||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:d},"x-component":"Action.Drawer",properties:A(w({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const p=S.useForm();return{run(){return D(this,null,function*(){i(null),o(null),p.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:p,query:u,reset:f}=S.useForm(),h=[F("Field name existed in form")];return{run(){return D(this,null,function*(){var C,O,V,$;const{default:x}=t,v=E.uid();if(x.name=(C=p.name)!=null?C:v,x.uiSchema.title=(V=(O=p.uiSchema)==null?void 0:O.title)!=null?V:v,x.interface=t.name,($=l.fields)==null?void 0:$.find(P=>P.name===x.name)){u("name").take().setFeedback({type:"error",messages:h});return}const T=E.merge(x,p);c([...l.fields,T]),n({name:x.name,type:x.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${x.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),i(null),o(null)})}}}}}}}})},components:{ArrayTable:E.ArrayTable}}):null})]})},Is=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:As});function Fs(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:i}=y.useContext(Lo),{getInterface:a}=s.useCollectionManager_deprecated(),l=a(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,w({onClick:()=>{i(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const qo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:Cs}},initializers:{},components:{CustomFormBlockProvider:jo},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=Oe(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var f,h;return(h=(f=u["x-component-props"])==null?void 0:f.field)!=null?h:u["x-interface-options"]});const c=((d=Object.entries(a.properties).find(([u,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[i]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Oe(a.properties[c],u=>u["x-component"]==="Action").map(u=>{var f,h;return{status:u["x-decorator-props"].value,values:(h=(f=u["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:h.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:jo}}};function Ts(){const{name:e,title:t}=s.useCollection_deprecated(),o=S.useFieldSchema(),{t:n}=Q.useTranslation(),{dn:i}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ns={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:R.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Wo}))})),[e]),[o,n]=y.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:Ae,UpdateFormDesigner:Ts},parseFormOptions(e){const t={};return Oe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]=A(w({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Oe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Pe=new E.Registry;Pe.register("customForm",qo),Pe.register("createForm",vs),Pe.register("updateForm",Ns);function Ds(){const{workflow:e}=q(),t=Qe();return t.useInitializers?t.useInitializers(e.config):null}qo.title;const Os=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(X),t=ye(),o=$e(t),n=[Ds()].filter(Boolean),i=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Pe.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function Ps(){var I,T,C;const e=y.useContext(s.SchemaComponentContext),{t}=Q.useTranslation(),o=S.useFieldSchema(),n=ce(),[i,a]=y.useState(!1),[l,c]=y.useState((C=(T=(I=o==null?void 0:o["x-action-settings"])==null?void 0:I.assignedValues)==null?void 0:T.schema)!=null?C:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,p]=y.useState(null),{components:u}=s.useSchemaOptionsContext();y.useEffect(()=>{p(new S.Schema({properties:{grid:l}}))},[l]);const f=y.useMemo(()=>{var V,$;const O=($=(V=o==null?void 0:o["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:$.values;return S.createForm({initialValues:R.cloneDeep(O),values:R.cloneDeep(O)})},[o]),h=s.useFormActiveFields(),g=t("Assign field values");function x(){a(!1)}function v(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=f.values,a(!1),setTimeout(()=>{var O;(O=e.refresh)==null||O.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:g,onClick:()=>a(!0),children:g}),r.jsx(b.Modal,{width:"50%",title:g,open:i,onCancel:x,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:x,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:v,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:h==null?void 0:h.getActiveFieldsName,children:r.jsx(S.FormProvider,{form:f,children:r.jsxs(E.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:F("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),i&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{refresh(){c(R.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:u})})]})})})})})})]})}function Ms(e){return r.jsxs(s.GeneralSchemaDesigner,A(w({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Ps,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Es(){const a=s.useSchemaInitializerItem(),{action:t,actionProps:o}=a,n=K(a,["action","actionProps"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{i({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Uo(){const e=s.useSchemaInitializerItem(),i=e,{action:t,actionProps:o}=i,n=K(i,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,A(w({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const $s=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Es,action:be.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Uo,action:be.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Uo,action:be.PENDING}]});function Bs(){return{run(){}}}function Vs({value:e,onChange:t}){const o=s.usePlugin(X),n=y.useContext(s.SchemaComponentContext),i=ye(),a=$e(i),l=S.useForm(),{workflow:c}=q(),d={};a.forEach(f=>{const h=o.instructions.get(f.type);Object.assign(d,h.components)});const p=y.useMemo(()=>new S.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
469
469
  .ant-drawer-body {
470
470
  background: var(--tb-box-bg);
471
471
  }
472
- `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),u=y.useCallback(function(){const{tabs:h}=E.lodash.get(p.toJSON(),"properties.drawer.properties"),g=Array.from(Pe.getValues()).reduce((x,v)=>Object.assign(x,v.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},n),{designable:!c.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:A(w(w({},d),Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.config.components),{})),{FormBlockProvider:Bo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Kt,ManualActionDesigner:Ps}),scope:{useSubmit:$s,useDetailsBlockProps:s.useFormBlockContext}})})}function Vs(e){const{workflow:t}=q(),[o,n]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:F(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class Ws extends H{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",this.description=`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`,this.fieldset={assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},this.components={SchemaConfigButton:Vs,SchemaConfig:Bs,ModeConfig:hs,AssigneesSelect:gs}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=ue}){var u;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((u=n.forms)!=null?u:{});if(!d.length)return null;const p=d.map(f=>{var v;const h=n.forms[f],g=me({fields:(v=h.collection)==null?void 0:v.fields,collection:h.collection,types:i,compile:l,getCollectionFields:c}),x=l(h.title)||f;return g.length?{key:f,value:f,label:x,title:x,children:g}:null}).filter(Boolean);return p.length?{[a.value]:t,[a.label]:o,[a.children]:p}:null}useInitializers(t){var a;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((a=t.config.forms)!=null?a:{});if(!n.length||t.config.mode)return null;const i=n.map(l=>{var p,u;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(p=c.title)!=null?p:l,type:"item",title:(u=c.title)!=null?u:l,Component:Ne,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return i.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:i}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}const js={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},zs={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Ls={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:mt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},qs=k.observer(()=>{var t,o,n;const e=k.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Us=k.observer(()=>{var t,o,n;const e=k.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Ks=k.observer(()=>{var t,o,n;const e=k.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function _s(e){const t=s.useRecord(),o=F("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Yt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:qs,WorkflowColumn:Us,UserColumn:Ks,UserJobStatusColumn:_s},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Gs(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=q(),{status:n,result:i,userId:a}=o,l=k.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?i[c]||(d=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(d=null),d}const Uo=y.createContext(null);Uo.displayName="ManualActionStatusContext";function Hs({value:e,children:t}){const{userJob:o,execution:n}=q(),i=k.useField(),a=k.useFieldSchema();return y.useEffect(()=>{(n.status||o.status)&&(i.disabled=!0,i.visible=o.status===e&&o.result._===a.name)},[n,o,e,i,a.name]),r.jsx(Uo.Provider,{value:e,children:t})}function Js(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=k.useForm(),i=k.useFieldSchema(),{service:a}=s.useTableBlockContext(),{userJob:l,execution:c}=q(),{name:d}=i,{name:p}=i.parent.parent;return{run(){return D(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:d}}}),t(!1),a.refresh())})}}}function Ys(e){var u;const t=s.usePlugin(X),o=s.useAPIClient(),{id:n}=s.useRecord(),[i,a]=y.useState(null),[l,c]=y.useState(null);y.useEffect(()=>{var f,h;n&&((h=(f=o.resource("users_jobs")).get)==null||h.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var O;const V=(O=g==null?void 0:g.data)!=null?O:{},{node:x,workflow:$={}}=V,P=$,{nodes:v=[]}=P,I=K(P,["nodes"]),B=V,{execution:T}=B,C=K(B,["node","workflow","execution"]);ft(v),c(x),a({userJob:C,workflow:I,nodes:v,execution:T})}))},[o,n]);const p=$e(i==null?void 0:i.nodes.find(f=>f.id===l.id)).reduce((f,{type:h})=>{var g;return Object.assign(f,(g=t.instructions.get(h))==null?void 0:g.components)},{});return l&&i?r.jsx(Ee.Provider,{value:i,children:r.jsx(s.SchemaComponent,{components:w(w({FormBlockProvider:Bo,DetailsBlockProvider:Wt,ActionBarProvider:Gs,ManualActionStatusProvider:Hs},Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.block.components),{})),p),scope:w({useSubmit:Js,useFormBlockProps:Qs,useDetailsBlockProps:Zs},Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(b.Spin,{})}function Qs(){var l;const{userJob:e,execution:t}=q(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:i}=s.useFormBlockContext(),a=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Zs(){const{form:e}=s.useFormBlockContext();return{form:e}}function Xs(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=Xe[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
472
+ `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),u=y.useCallback(function(){const{tabs:h}=R.get(p.toJSON(),"properties.drawer.properties"),g=Array.from(Pe.getValues()).reduce((x,v)=>Object.assign(x,v.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},n),{designable:!c.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:A(w(w({},d),Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.config.components),{})),{FormBlockProvider:Vo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Kt,ManualActionDesigner:Ms}),scope:{useSubmit:Bs,useDetailsBlockProps:s.useFormBlockContext}})})}function Ws(e){const{workflow:t}=q(),[o,n]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:F(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class js extends H{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",this.description=`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`,this.fieldset={assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},this.components={SchemaConfigButton:Ws,SchemaConfig:Vs,ModeConfig:ys,AssigneesSelect:hs}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=ue}){var u;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((u=n.forms)!=null?u:{});if(!d.length)return null;const p=d.map(f=>{var v;const h=n.forms[f],g=me({fields:(v=h.collection)==null?void 0:v.fields,collection:h.collection,types:i,compile:l,getCollectionFields:c}),x=l(h.title)||f;return g.length?{key:f,value:f,label:x,title:x,children:g}:null}).filter(Boolean);return p.length?{[a.value]:t,[a.label]:o,[a.children]:p}:null}useInitializers(t){var a;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((a=t.config.forms)!=null?a:{});if(!n.length||t.config.mode)return null;const i=n.map(l=>{var p,u;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(p=c.title)!=null?p:l,type:"item",title:(u=c.title)!=null?u:l,Component:Ne,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return i.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:i}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}const zs={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Ls={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},qs={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:mt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Us=S.observer(()=>{var t,o,n;const e=S.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Ks=S.observer(()=>{var t,o,n;const e=S.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),_s=S.observer(()=>{var t,o,n;const e=S.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function Gs(e){const t=s.useRecord(),o=F("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Yt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:Us,WorkflowColumn:Ks,UserColumn:_s,UserJobStatusColumn:Gs},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Hs(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=q(),{status:n,result:i,userId:a}=o,l=S.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?i[c]||(d=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(d=null),d}const Ko=y.createContext(null);Ko.displayName="ManualActionStatusContext";function Js({value:e,children:t}){const{userJob:o,execution:n}=q(),i=S.useField(),a=S.useFieldSchema();return y.useEffect(()=>{(n.status||o.status)&&(i.disabled=!0,i.visible=o.status===e&&o.result._===a.name)},[n,o,e,i,a.name]),r.jsx(Ko.Provider,{value:e,children:t})}function Ys(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=S.useForm(),i=S.useFieldSchema(),{service:a}=s.useTableBlockContext(),{userJob:l,execution:c}=q(),{name:d}=i,{name:p}=i.parent.parent;return{run(){return D(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:d}}}),t(!1),a.refresh())})}}}function Qs(e){var u;const t=s.usePlugin(X),o=s.useAPIClient(),{id:n}=s.useRecord(),[i,a]=y.useState(null),[l,c]=y.useState(null);y.useEffect(()=>{var f,h;n&&((h=(f=o.resource("users_jobs")).get)==null||h.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var O;const V=(O=g==null?void 0:g.data)!=null?O:{},{node:x,workflow:$={}}=V,P=$,{nodes:v=[]}=P,I=K(P,["nodes"]),B=V,{execution:T}=B,C=K(B,["node","workflow","execution"]);ft(v),c(x),a({userJob:C,workflow:I,nodes:v,execution:T})}))},[o,n]);const p=$e(i==null?void 0:i.nodes.find(f=>f.id===l.id)).reduce((f,{type:h})=>{var g;return Object.assign(f,(g=t.instructions.get(h))==null?void 0:g.components)},{});return l&&i?r.jsx(Ee.Provider,{value:i,children:r.jsx(s.SchemaComponent,{components:w(w({FormBlockProvider:Vo,DetailsBlockProvider:Wt,ActionBarProvider:Hs,ManualActionStatusProvider:Js},Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.block.components),{})),p),scope:w({useSubmit:Ys,useFormBlockProps:Zs,useDetailsBlockProps:Xs},Array.from(Pe.getValues()).reduce((f,h)=>Object.assign(f,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(b.Spin,{})}function Zs(){var l;const{userJob:e,execution:t}=q(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:i}=s.useFormBlockContext(),a=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Xs(){const{form:e}=s.useFormBlockContext();return{form:e}}function Rs(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=Xe[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
473
473
  margin-right: 0.5em;
474
- `,children:E.dayjs(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Rs(){var a;const e=y.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:i}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:Xs,FlowContextProvider:Ys},schema:{type:"void",name:`drawer-${t}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(a=o.title)!=null?a:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function ei({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:A(w({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[js,zs,Ls],children:r.jsx(s.TableBlockProvider,A(w({name:"workflow-todo"},o),{children:t}))})}Yt.Drawer=Rs,Yt.Decorator=ei;const ti=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({icon:r.jsx(j.TableOutlined,{})},e),{onClick:()=>{t({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class oi extends s.Plugin{load(){return D(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Ws),this.app.schemaInitializerManager.add(Ds),this.app.schemaInitializerManager.add(Es),this.app.schemaInitializerManager.add(As),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(j.PartitionOutlined,{}),children:[{name:"common",title:`{{t("Common", { ns: "${m}" })}}`,type:"itemGroup",children:[{name:"todos",title:`{{t("Workflow todos", { ns: "${m}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"}]}]})})}addComponents(){this.app.addComponents({WorkflowTodo:Yt,WorkflowTodoBlockInitializer:ti})}}const Ko="notice",Qt="workflowNotice",Fe="workflow";function _e(){return{t:(t,o={})=>s.i18n.t(t,w({ns:Fe},o))}}const ae=e=>s.tval(e,{ns:Fe});function ni(){const e=s.useAPIClient(),t=k.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=ne.useNavigate(),l=k.useFieldSchema(),c=k.useField(),d=s.useCompile(),{modal:p}=b.App.useApp(),u=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return D(this,null,function*(){var T,C,O;const{onSuccess:g,skipValidator:x,triggerWorkflows:v}=(T=l==null?void 0:l["x-action-settings"])!=null?T:{};x||(yield t.submit());const I=yield u();c.data=o.data||{},c.data.loading=!0;try{const V=yield e.resource("workflows").trigger({values:I,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(c.data.loading=!1,c.data.data=V,(O=(C=n==null?void 0:n.service)==null?void 0:C.refresh)==null||O.call(C),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?p.success({title:d(g==null?void 0:g.successMessage),onOk:()=>D(null,null,function*(){yield t.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(E.isURL(g.redirectTo)?window.location.href=g.redirectTo:a(g.redirectTo))})}):b.message.success(d(g==null?void 0:g.successMessage))}catch(V){c.data.loading=!1}})}}}function ri(){var h;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=k.useField(),i=k.useFieldSchema(),{field:a,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=b.App.useApp(),p=ne.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(h=i==null?void 0:i["x-action-settings"])!=null?h:{};return{onClick(){return D(this,null,function*(){var x,v;n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(v=(x=l==null?void 0:l.service)==null?void 0:x.refresh)==null||v.call(x),c==null||c(!1),!(u!=null&&u.successMessage))return;if(u!=null&&u.manualClose){let I;d.success({title:e(u==null?void 0:u.successMessage),onOk(){return D(this,null,function*(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(E.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))})}})}else b.message.success(e(u==null?void 0:u.successMessage))}catch(I){console.error(I)}finally{n.data.loading=!1}})}}}const si=()=>{const e=Gt(),t=E.ArrayItems.useArray()||{field:[]},{t:o}=_e(),[n,i]=y.useState(!1),a=y.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=y.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:i,content:r.jsx(ii,{onSlecet:a,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},ii=({onSlecet:e,onQuery:t})=>{const{t:o}=_e();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ai=e=>{const{t}=_e(),[o,n]=y.useState(!1),i=y.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},li=e=>e.value&&typeof e.value=="object"?r.jsx(di,w({},e)):r.jsx(ci,w({},e)),ci=({value:e,onChange:t})=>{const o=ce({types:[pi]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},di=()=>{const e=k.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function pi(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const ui=()=>{var d;const{workflow:e}=q(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=u=>D(null,[u],function*({item:p}){const f=p.template?yield a(p):null,h=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});ie.unset(h,["x-acl-action","x-acl-action-props"]);const[g]=Object.keys(h.properties);ie.set(h.properties[g],"x-component-props.useProps","usePropsNoticeDetail"),i(h)});return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:c,items:l}))},mi=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ae("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:ui}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(X),{workflow:t}=q(),o=Qe(),n=ye(),i=$e(n),a=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=i.map(d=>{var u;const p=e.instructions.get(d.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,d)}).filter(Boolean);return[...a,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class fi extends s.Plugin{load(){return D(this,null,function*(){this.app.schemaInitializerManager.add(mi)})}}function gi(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const hi=e=>{const{schemaData:t,loading:o,handleChange:n}=yi(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function yi(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:i,setValuesIn:a}=k.useForm(),{data:l,loading:c}=s.useRequest(()=>D(null,null,function*(){if(t){const f=yield xi(n,t);if(f["x-uid"]===t)return f}const p=t!=null?t:E.uid(),u=gi(p);return yield bi(n,u),o(p),u}));return{schemaData:l,loading:c,handleChange:p=>{}}}function xi(e,t){return D(this,null,function*(){var i;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(i=o.data)!=null?i:{}})}function bi(e,t){return D(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const wi={ActionStyle:s.css`
474
+ `,children:ao(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function ei(){var a;const e=y.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:i}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:Rs,FlowContextProvider:Qs},schema:{type:"void",name:`drawer-${t}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(a=o.title)!=null?a:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function ti({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:A(w({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[zs,Ls,qs],children:r.jsx(s.TableBlockProvider,A(w({name:"workflow-todo"},o),{children:t}))})}Yt.Drawer=ei,Yt.Decorator=ti;const oi=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({icon:r.jsx(j.TableOutlined,{})},e),{onClick:()=>{t({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class ni extends s.Plugin{load(){return D(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",js),this.app.schemaInitializerManager.add(Os),this.app.schemaInitializerManager.add($s),this.app.schemaInitializerManager.add(Is),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(j.PartitionOutlined,{}),children:[{name:"common",title:`{{t("Common", { ns: "${m}" })}}`,type:"itemGroup",children:[{name:"todos",title:`{{t("Workflow todos", { ns: "${m}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"}]}]})})}addComponents(){this.app.addComponents({WorkflowTodo:Yt,WorkflowTodoBlockInitializer:oi})}}const _o="notice",Qt="workflowNotice",Fe="workflow";function _e(){return{t:(t,o={})=>s.i18n.t(t,w({ns:Fe},o))}}const ae=e=>s.tval(e,{ns:Fe});function ri(){const e=s.useAPIClient(),t=S.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=re.useNavigate(),l=S.useFieldSchema(),c=S.useField(),d=s.useCompile(),{modal:p}=b.App.useApp(),u=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return D(this,null,function*(){var T,C,O;const{onSuccess:g,skipValidator:x,triggerWorkflows:v}=(T=l==null?void 0:l["x-action-settings"])!=null?T:{};x||(yield t.submit());const I=yield u();c.data=o.data||{},c.data.loading=!0;try{const V=yield e.resource("workflows").trigger({values:I,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(c.data.loading=!1,c.data.data=V,(O=(C=n==null?void 0:n.service)==null?void 0:C.refresh)==null||O.call(C),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?p.success({title:d(g==null?void 0:g.successMessage),onOk:()=>D(null,null,function*(){yield t.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(E.isURL(g.redirectTo)?window.location.href=g.redirectTo:a(g.redirectTo))})}):b.message.success(d(g==null?void 0:g.successMessage))}catch(V){c.data.loading=!1}})}}}function si(){var h;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=S.useField(),i=S.useFieldSchema(),{field:a,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=b.App.useApp(),p=re.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(h=i==null?void 0:i["x-action-settings"])!=null?h:{};return{onClick(){return D(this,null,function*(){var x,v;n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(v=(x=l==null?void 0:l.service)==null?void 0:x.refresh)==null||v.call(x),c==null||c(!1),!(u!=null&&u.successMessage))return;if(u!=null&&u.manualClose){let I;d.success({title:e(u==null?void 0:u.successMessage),onOk(){return D(this,null,function*(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(E.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))})}})}else b.message.success(e(u==null?void 0:u.successMessage))}catch(I){console.error(I)}finally{n.data.loading=!1}})}}}const ii=()=>{const e=Gt(),t=E.ArrayItems.useArray()||{field:[]},{t:o}=_e(),[n,i]=y.useState(!1),a=y.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=y.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:i,content:r.jsx(ai,{onSlecet:a,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},ai=({onSlecet:e,onQuery:t})=>{const{t:o}=_e();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},li=e=>{const{t}=_e(),[o,n]=y.useState(!1),i=y.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},ci=e=>e.value&&typeof e.value=="object"?r.jsx(pi,w({},e)):r.jsx(di,w({},e)),di=({value:e,onChange:t})=>{const o=ce({types:[ui]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},pi=()=>{const e=S.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function ui(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const mi=()=>{var d;const{workflow:e}=q(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=u=>D(null,[u],function*({item:p}){const f=p.template?yield a(p):null,h=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});R.unset(h,["x-acl-action","x-acl-action-props"]);const[g]=Object.keys(h.properties);R.set(h.properties[g],"x-component-props.useProps","usePropsNoticeDetail"),i(h)});return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:c,items:l}))},fi=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ae("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:mi}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(X),{workflow:t}=q(),o=Qe(),n=ye(),i=$e(n),a=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=i.map(d=>{var u;const p=e.instructions.get(d.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,d)}).filter(Boolean);return[...a,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class gi extends s.Plugin{load(){return D(this,null,function*(){this.app.schemaInitializerManager.add(fi)})}}function hi(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const yi=e=>{const{schemaData:t,loading:o,handleChange:n}=xi(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function xi(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:i,setValuesIn:a}=S.useForm(),{data:l,loading:c}=s.useRequest(()=>D(null,null,function*(){if(t){const f=yield bi(n,t);if(f["x-uid"]===t)return f}const p=t!=null?t:E.uid(),u=hi(p);return yield wi(n,u),o(p),u}));return{schemaData:l,loading:c,handleChange:p=>{}}}function bi(e,t){return D(this,null,function*(){var i;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(i=o.data)!=null?i:{}})}function wi(e,t){return D(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const vi={ActionStyle:s.css`
475
475
  .ant-drawer-body {
476
476
  background: var(--tb-box-bg);
477
477
  }
478
- `},vi=()=>{const e=y.useContext(s.SchemaComponentContext),[,t]=y.useState(E.uid()),{workflow:o}=q(),n=y.useMemo(()=>A(w({},e),{refresh:()=>t(E.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:hi},schema:Ci})})},Ci={name:"drawer",type:"void",title:ae("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:wi.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const _o={ArrayItemsStyle:s.css`
478
+ `},Ci=()=>{const e=y.useContext(s.SchemaComponentContext),[,t]=y.useState(E.uid()),{workflow:o}=q(),n=y.useMemo(()=>A(w({},e),{refresh:()=>t(E.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:yi},schema:ki})})},ki={name:"drawer",type:"void",title:ae("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:vi.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const Go={ArrayItemsStyle:s.css`
479
479
  &[disabled] {
480
480
  > .ant-formily-array-base-addition {
481
481
  display: none;
@@ -492,19 +492,19 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
492
492
  > .ant-space-item:nth-child(2) {
493
493
  flex-grow: 1;
494
494
  }
495
- `};class ki extends H{constructor(){super(...arguments),this.title=ae("Notice"),this.type=Ko,this.group=Ke,this.icon="MessageOutlined",this.color="#82e29c",this.description=ae("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:E.ArrayItems,SelectNotifiedPerson:li,AdditionNotifiedPerson:si,ConfigButtonNotice:ai,ShowNoticeDetail:vi},this.fieldset={notifiedPerson:{type:"array",title:ae("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:_o.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:_o.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:ae("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ae("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class Si extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(fi)})}load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(Ko,ki),this.app.addComponents({ArrayItems:E.ArrayItems})})}}const Ai={title:ae("Node"),name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Ii=k.observer(()=>{const{value:e}=k.useField(),t=s.useRecord();return r.jsx(Fi,{value:e,record:t})},{displayName:"ColumnStatus"}),Fi=e=>{const{value:t,record:o}=e,n=ie.omit(e,["value","record"]),i=s.useCompile(),{t:a}=_e(),{option:l=Ti[t]}=n,{workflow:c,execution:d,job:p}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||p!=null&&p.status)&&[].includes(t)?r.jsx(b.Tag,{children:a("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:i(l==null?void 0:l.label)})},Go=[{value:pe.QUEUEING,label:`{{t("Assigned", { ns: "${Fe}" })}}`,color:"blue"},{value:pe.STARTED,label:`{{t("Pending", { ns: "${Fe}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${Fe}" })}}`,color:"green"},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${Fe}" })}}`,color:"red"}],Ti=Go.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Ni={title:ae("Notice Center"),name:Qt,fields:[{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:ae("The Notified Person"),"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task node", { ns: "${Fe}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:Go}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${Fe}" })}}`}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{type:"string",name:"summary",interface:"input",uiSchema:{type:"string",title:ae("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},Di={title:ae("Workflow"),name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"select",uiSchema:{type:"boolean",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:[{label:'{{t("On", { ns: "workflow" })}}',value:!0},{label:'{{t("Off", { ns: "workflow" })}}',value:!1}]}}]},Oi=o=>{var n=o,{children:e}=n,t=K(n,["children"]);const{collection:i,params:a={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:i,resource:i,action:l,params:A(w({pageSize:20,sort:["-createdAt"]},a),{filter:c!=null&&c.id?w({dataKey:`${c.id}`},a.filter):w({},a.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[Di,Ai,Ni],children:r.jsx(s.TableBlockProvider,A(w({name:i},d),{children:e}))})},Ho=y.createContext({}),Pi=Ho.Provider;function Mi(){return y.useContext(Ho)}const Jo=y.createContext({}),Ei=Jo.Provider;function $i(){return y.useContext(Jo)}function Bi(){const{snapshot:e}=$i(),{form:t}=s.useFormBlockContext();return y.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function Yo({children:e,workflow:t,execution:o,nodes:n}){const i=s.usePlugin(X),a=i.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var p;return Object.assign(c,(p=i.instructions.get(d))==null?void 0:p.components)},{});return r.jsx(Ee.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:w(w({},a),l),children:e})})}const Qo=o=>{var n=o,{children:e}=n,t=K(n,["children"]);const i=s.useSchemaComponentContext(),{t:a}=_e(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=Vi(l);if(c)return r.jsx(b.Spin,{});if(!(d!=null&&d.data))return r.jsx(b.Result,{status:"error",title:a("Submission may be withdrawn, please try refresh the list.")});const p=d.data,{node:u,workflow:f,execution:h}=p,g=u==null?void 0:u.config.showNoticeDetail,{designable:x}=t;return r.jsx(Yo,{workflow:f,nodes:f.nodes,execution:h,children:r.jsx(Ei,{value:p,children:r.jsx(Pi,{value:{id:l,schemaId:g},children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:x}),children:e})})})})};function Vi(e){const{loading:t,data:o}=s.useRequest({resource:Qt,action:"get",params:{filterByTk:e,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs","user"],except:["workflow.config","workflow.options","nodes.config"],sort:["-createdAt"]}},{refreshDeps:[e]});return{loading:t,data:o}}const Wi=()=>r.jsx(Qo,{children:r.jsx(ji,{})}),ji=e=>{const{id:t,schemaId:o}=Mi();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:Qo,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:Wt},scope:{usePropsNoticeDetail:Bi,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ae("Content Detail"),"x-component":"Tabs.TabPane",properties:{detail:{type:"void","x-decorator":"NoticeDetailProvider","x-decorator-props":{designable:!1},"x-component":"RemoteSchemaComponent","x-component-props":{uid:o,noForm:!0}}}}}}})},zi=({record:e})=>{const{id:t}=e;return{name:`notice-view-${t}`,type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{content:{type:"void","x-component":"NoticeDetailContent"}}}}}},Li=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:Wi},schema:zi({record:e})})},qi=k.observer(()=>{const e=k.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),Ui=k.observer(()=>{const e=k.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),Ki=k.observer(()=>{const{t:e}=_e(),{value:t}=k.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
495
+ `};class Si extends H{constructor(){super(...arguments),this.title=ae("Notice"),this.type=_o,this.group=Ke,this.icon="MessageOutlined",this.color="#82e29c",this.description=ae("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:E.ArrayItems,SelectNotifiedPerson:ci,AdditionNotifiedPerson:ii,ConfigButtonNotice:li,ShowNoticeDetail:Ci},this.fieldset={notifiedPerson:{type:"array",title:ae("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:Go.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:Go.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:ae("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ae("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class Ai extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(gi)})}load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(_o,Si),this.app.addComponents({ArrayItems:E.ArrayItems})})}}const Ii={title:ae("Node"),name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Fi=S.observer(()=>{const{value:e}=S.useField(),t=s.useRecord();return r.jsx(Ti,{value:e,record:t})},{displayName:"ColumnStatus"}),Ti=e=>{const{value:t,record:o}=e,n=R.omit(e,["value","record"]),i=s.useCompile(),{t:a}=_e(),{option:l=Ni[t]}=n,{workflow:c,execution:d,job:p}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||p!=null&&p.status)&&[].includes(t)?r.jsx(b.Tag,{children:a("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:i(l==null?void 0:l.label)})},Ho=[{value:pe.QUEUEING,label:`{{t("Assigned", { ns: "${Fe}" })}}`,color:"blue"},{value:pe.STARTED,label:`{{t("Pending", { ns: "${Fe}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${Fe}" })}}`,color:"green"},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${Fe}" })}}`,color:"red"}],Ni=Ho.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Di={title:ae("Notice Center"),name:Qt,fields:[{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:ae("The Notified Person"),"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task node", { ns: "${Fe}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:Ho}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${Fe}" })}}`}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{type:"string",name:"summary",interface:"input",uiSchema:{type:"string",title:ae("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},Oi={title:ae("Workflow"),name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"select",uiSchema:{type:"boolean",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:[{label:'{{t("On", { ns: "workflow" })}}',value:!0},{label:'{{t("Off", { ns: "workflow" })}}',value:!1}]}}]},Pi=o=>{var n=o,{children:e}=n,t=K(n,["children"]);const{collection:i,params:a={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:i,resource:i,action:l,params:A(w({pageSize:20,sort:["-createdAt"]},a),{filter:c!=null&&c.id?w({dataKey:`${c.id}`},a.filter):w({},a.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[Oi,Ii,Di],children:r.jsx(s.TableBlockProvider,A(w({name:i},d),{children:e}))})},Jo=y.createContext({}),Mi=Jo.Provider;function Ei(){return y.useContext(Jo)}const Yo=y.createContext({}),$i=Yo.Provider;function Bi(){return y.useContext(Yo)}function Vi(){const{snapshot:e}=Bi(),{form:t}=s.useFormBlockContext();return y.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function Qo({children:e,workflow:t,execution:o,nodes:n}){const i=s.usePlugin(X),a=i.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var p;return Object.assign(c,(p=i.instructions.get(d))==null?void 0:p.components)},{});return r.jsx(Ee.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:w(w({},a),l),children:e})})}const Zo=o=>{var n=o,{children:e}=n,t=K(n,["children"]);const i=s.useSchemaComponentContext(),{t:a}=_e(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=Wi(l);if(c)return r.jsx(b.Spin,{});if(!(d!=null&&d.data))return r.jsx(b.Result,{status:"error",title:a("Submission may be withdrawn, please try refresh the list.")});const p=d.data,{node:u,workflow:f,execution:h}=p,g=u==null?void 0:u.config.showNoticeDetail,{designable:x}=t;return r.jsx(Qo,{workflow:f,nodes:f.nodes,execution:h,children:r.jsx($i,{value:p,children:r.jsx(Mi,{value:{id:l,schemaId:g},children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:x}),children:e})})})})};function Wi(e){const{loading:t,data:o}=s.useRequest({resource:Qt,action:"get",params:{filterByTk:e,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs","user"],except:["workflow.config","workflow.options","nodes.config"],sort:["-createdAt"]}},{refreshDeps:[e]});return{loading:t,data:o}}const ji=()=>r.jsx(Zo,{children:r.jsx(zi,{})}),zi=e=>{const{id:t,schemaId:o}=Ei();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:Zo,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:Wt},scope:{usePropsNoticeDetail:Vi,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ae("Content Detail"),"x-component":"Tabs.TabPane",properties:{detail:{type:"void","x-decorator":"NoticeDetailProvider","x-decorator-props":{designable:!1},"x-component":"RemoteSchemaComponent","x-component-props":{uid:o,noForm:!0}}}}}}})},Li=({record:e})=>{const{id:t}=e;return{name:`notice-view-${t}`,type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{content:{type:"void","x-component":"NoticeDetailContent"}}}}}},qi=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:ji},schema:Li({record:e})})},Ui=S.observer(()=>{const e=S.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),Ki=S.observer(()=>{const e=S.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),_i=S.observer(()=>{const{t:e}=_e(),{value:t}=S.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
496
496
  text-decoration: line-through;
497
- `,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),_i={ActionbarStyle:s.css`
497
+ `,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),Gi={ActionbarStyle:s.css`
498
498
  margin-bottom: 16px;
499
499
  `,TableV2Style:s.css`
500
500
  .ant-table-cell {
501
501
  text-align: center;
502
502
  }
503
- `},Gi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:qi,ColumnWorkflow:Ki,ColumnUser:Ui,ColumnStatus:Ii,ColumnAction:Li},schema:Hi}),Hi={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:_i.ActionbarStyle},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",tableLayout:"fixed",className:s.css`
503
+ `},Hi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:Ui,ColumnWorkflow:_i,ColumnUser:Ki,ColumnStatus:Fi,ColumnAction:qi},schema:Ji}),Ji={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:Gi.ActionbarStyle},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",tableLayout:"fixed",className:s.css`
504
504
  .ant-table-cell {
505
505
  text-align: center;
506
506
  }
507
- `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ae("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ae("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ae("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Fe}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Ji extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockProvider:Oi,NoticeCenter:Gi})})}}function Zo(){const e=E.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Qt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Yi=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=y.useCallback(()=>{const n=Zo();e(n)},[e,Zo]);return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:o}))};class Qi extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Ji)})}load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Yi}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ae("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Zi extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Si),yield this.app.pm.add(Qi)})}}class Xi extends Ye{constructor(){super(...arguments),this.title=N("General event"),this.description=N("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=k.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=me(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...me({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const Ri=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,A(w({},e),{schema:ea,item:e}))},ea={type:"void",title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},ta=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=k.useFieldSchema();return k.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],oa=new s.SchemaSettings({name:"actionSettings:APIRegular",items:ta}),na=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=k.useFieldSchema(),a=y.useContext(k.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=Q.useTranslation();ne.useNavigate(),s.useCompile();const p=k.useField(),{modal:u,notification:f}=b.App.useApp(),h=s.useVariables(),{name:g,getField:x}=s.useCollection_deprecated(),v=s.useLocalVariables(),{run:I}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const O=C.current+1,V=Math.floor(O/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(b.Progress,{percent:Math.floor(O/C.total*100)}),duration:V})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return D(this,null,function*(){var Y,se,W,M,L,ee,G;const C=(M=(W=(se=(Y=l.field)==null?void 0:Y.data)==null?void 0:se.selectedRowKeys)!=null?W:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:O}=(ee=(L=n.params)==null?void 0:L[0])!=null?ee:{},{bindWorkflow:V=!1,triggerWorkflows:$=!1,assignedValues:P={},updateMode:B}=(G=i==null?void 0:i["x-action-settings"])!=null?G:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!$&&!V)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(R=>D(null,null,function*(){const re=P[R],qe=x(R);if(s.isVariable(re)){const we=yield h==null?void 0:h.parseVariable(re,v);we&&s.transformVariableValue(we,{targetCollectionField:qe})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return D(this,null,function*(){if(V){const R={filterByTk:V,updateData:encodeURIComponent(JSON.stringify(z))};I(R)}else $&&(_?yield t.trigger({filterByTk:C,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}):yield t.trigger({filter:O,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}));p.data.loading=!1})},onCancel(){return D(this,null,function*(){p.data.loading=!1})}})})}}};class ra extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({APIRegularInitializer:Ri}),this.app.addScopes({usePropsAPIRegular:na}),this.app.schemaSettingsManager.add(oa),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function sa(){const e=k.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=ne.useNavigate(),c=k.useFieldSchema(),d=k.useField(),p=s.useCompile(),{modal:u}=b.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return D(this,null,function*(){var T,C;const{onSuccess:g,skipValidator:x,triggerWorkflows:v}=(c==null?void 0:c["x-action-settings"])||{};x||(yield e.submit());const I=yield f();d.data=t.data||{},d.data.loading=!0;try{const O=yield n.trigger({values:I,filterByTk:a,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(d.data.data=O,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:p(g==null?void 0:g.successMessage),onOk:()=>D(null,null,function*(){return yield e.reset(),(g==null?void 0:g.redirecting)&&(g==null?void 0:g.redirectTo)&&(E.isURL(g.redirectTo)?window.location.href=g.redirectTo:l(g.redirectTo))})}):b.message.success(p(g==null?void 0:g.successMessage))}catch(O){console.error(O)}finally{d.data.loading=!1}})}}}function ia(){const e=s.useCompile(),t=s.useFilterByTk(),o=k.useField(),n=k.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=b.App.useApp(),p=ne.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(g,x){return D(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),x==null||x(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(E.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):b.message.success(e(u==null?void 0:u.successMessage))}catch(v){console.error(v)}finally{o.data.loading=!1}})}}}const Zt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},bt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Xt=A(w({},bt),{schema:A(w({},bt.schema),{"x-component":"Action.Link"})});class aa extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(ra)})}load(){return D(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Xi),this.app.addScopes({useFormWorkflowCustomActionProps:sa,useRecordWorkflowCustomTriggerActionProps:ia}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",bt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",bt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Xt)})}}class la extends H{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Ie}}Component({data:t}){const{styles:o}=xe(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((x,v)=>v.upstreamId===n&&v.branchIndex!=null?x.concat(v):x,[]).sort((x,v)=>x.branchIndex-v.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:u}=dt(t),f=F("Add branch"),h=Array(Math.max(0,d-c.length)).fill(null),g=c[c.length-1];return r.jsx(nt,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(x=>r.jsx(Be,{from:t,entry:x,branchIndex:x.branchIndex},x.id)),h.map((x,v)=>r.jsx(Be,{from:t,branchIndex:(g?g.branchIndex:0)+v+1,controller:c.length+v>1?r.jsx("div",{className:s.css`
507
+ `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ae("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ae("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ae("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Fe}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Yi extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockProvider:Pi,NoticeCenter:Hi})})}}function Xo(){const e=E.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Qt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Qi=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=y.useCallback(()=>{const n=Xo();e(n)},[e,Xo]);return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:o}))};class Zi extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Yi)})}load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Qi}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ae("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Xi extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Ai),yield this.app.pm.add(Zi)})}}class Ri extends Ye{constructor(){super(...arguments),this.title=N("General event"),this.description=N("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=me(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...me({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const ea=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,A(w({},e),{schema:ta,item:e}))},ta={type:"void",title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},oa=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],na=new s.SchemaSettings({name:"actionSettings:APIRegular",items:oa}),ra=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=S.useFieldSchema(),a=y.useContext(S.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=Q.useTranslation();re.useNavigate(),s.useCompile();const p=S.useField(),{modal:u,notification:f}=b.App.useApp(),h=s.useVariables(),{name:g,getField:x}=s.useCollection_deprecated(),v=s.useLocalVariables(),{run:I}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const O=C.current+1,V=Math.floor(O/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(b.Progress,{percent:Math.floor(O/C.total*100)}),duration:V})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return D(this,null,function*(){var Y,ie,W,M,L,te,G;const C=(M=(W=(ie=(Y=l.field)==null?void 0:Y.data)==null?void 0:ie.selectedRowKeys)!=null?W:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:O}=(te=(L=n.params)==null?void 0:L[0])!=null?te:{},{bindWorkflow:V=!1,triggerWorkflows:$=!1,assignedValues:P={},updateMode:B}=(G=i==null?void 0:i["x-action-settings"])!=null?G:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!$&&!V)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(ee=>D(null,null,function*(){const se=P[ee],qe=x(ee);if(s.isVariable(se)){const we=yield h==null?void 0:h.parseVariable(se,v);we&&s.transformVariableValue(we,{targetCollectionField:qe})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return D(this,null,function*(){if(V){const ee={filterByTk:V,updateData:encodeURIComponent(JSON.stringify(z))};I(ee)}else $&&(_?yield t.trigger({filterByTk:C,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}):yield t.trigger({filter:O,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}));p.data.loading=!1})},onCancel(){return D(this,null,function*(){p.data.loading=!1})}})})}}};class sa extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({APIRegularInitializer:ea}),this.app.addScopes({usePropsAPIRegular:ra}),this.app.schemaSettingsManager.add(na),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function ia(){const e=S.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=re.useNavigate(),c=S.useFieldSchema(),d=S.useField(),p=s.useCompile(),{modal:u}=b.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return D(this,null,function*(){var T,C;const{onSuccess:g,skipValidator:x,triggerWorkflows:v}=(c==null?void 0:c["x-action-settings"])||{};x||(yield e.submit());const I=yield f();d.data=t.data||{},d.data.loading=!0;try{const O=yield n.trigger({values:I,filterByTk:a,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(d.data.data=O,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:p(g==null?void 0:g.successMessage),onOk:()=>D(null,null,function*(){return yield e.reset(),(g==null?void 0:g.redirecting)&&(g==null?void 0:g.redirectTo)&&(E.isURL(g.redirectTo)?window.location.href=g.redirectTo:l(g.redirectTo))})}):b.message.success(p(g==null?void 0:g.successMessage))}catch(O){console.error(O)}finally{d.data.loading=!1}})}}}function aa(){const e=s.useCompile(),t=s.useFilterByTk(),o=S.useField(),n=S.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=b.App.useApp(),p=re.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(g,x){return D(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),x==null||x(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(E.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):b.message.success(e(u==null?void 0:u.successMessage))}catch(v){console.error(v)}finally{o.data.loading=!1}})}}}const Zt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},bt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Xt=A(w({},bt),{schema:A(w({},bt.schema),{"x-component":"Action.Link"})});class la extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(sa)})}load(){return D(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Ri),this.app.addScopes({useFormWorkflowCustomActionProps:ia,useRecordWorkflowCustomTriggerActionProps:aa}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",bt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",bt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Xt)})}}class ca extends H{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Ie}}Component({data:t}){const{styles:o}=xe(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((x,v)=>v.upstreamId===n&&v.branchIndex!=null?x.concat(v):x,[]).sort((x,v)=>x.branchIndex-v.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:u}=dt(t),f=F("Add branch"),h=Array(Math.max(0,d-c.length)).fill(null),g=c[c.length-1];return r.jsx(nt,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(x=>r.jsx(Be,{from:t,entry:x,branchIndex:x.branchIndex},x.id)),h.map((x,v)=>r.jsx(Be,{from:t,branchIndex:(g?g.branchIndex:0)+v+1,controller:c.length+v>1?r.jsx("div",{className:s.css`
508
508
  padding-top: 2em;
509
509
 
510
510
  > button {
@@ -524,7 +524,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
524
524
  transform-origin: center;
525
525
  transform: rotate(-45deg);
526
526
  }
527
- `,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class ca extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction("parallel",la)})}}class da extends H{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:E.ArrayItems,WorkflowVariableInput:Ce,WorkflowVariableTextArea:ot,WorkflowVariableJSON:No}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return{[i.value]:t,[i.label]:o}}}class pa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",da)})}}class ua extends H{constructor(){super(...arguments),this.title=N("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=N("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:N("Message content"),description:N("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Ie,WorkflowVariableTextArea:ot,WorkflowVariableInput:Ce}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class ma extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",ua)})}}class fa extends H{constructor(){super(...arguments),this.title=N("Data Mapping"),this.type=yo,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=N("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:N("Data source map"),description:N("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
527
+ `,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class da extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction("parallel",ca)})}}class pa extends H{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:E.ArrayItems,WorkflowVariableInput:Ce,WorkflowVariableTextArea:ot,WorkflowVariableJSON:Do}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return{[i.value]:t,[i.label]:o}}}class ua extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",pa)})}}class ma extends H{constructor(){super(...arguments),this.title=N("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=N("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:N("Message content"),description:N("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Ie,WorkflowVariableTextArea:ot,WorkflowVariableInput:Ce}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class fa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",ma)})}}class ga extends H{constructor(){super(...arguments),this.title=N("Data Mapping"),this.type=xo,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=N("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:N("Data source map"),description:N("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
528
528
  > *:not(:last-child) {
529
529
  margin-right: 0.5em;
530
530
  }
@@ -532,8 +532,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
532
532
  padding: 0;
533
533
  }
534
534
  `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}},type:{type:"string",title:N("type"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Cloud Component"),value:"ts"},{label:N("JSONata"),value:"jsonata"}],default:"ts"},code:{type:"string",title:N("expression"),"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"typescript",height:"50vh",defaultValue:`
535
- import { Context } from '@tachybase/actions';
536
- import { MagicAttributeModel, Transactionable } from '@tachybase/database';
535
+ import { Context, MagicAttributeModel, Transactionable } from '@tego/server';
537
536
 
538
537
  export default async function (
539
538
  _data,
@@ -553,23 +552,23 @@ export default async function (
553
552
  button {
554
553
  padding: 0;
555
554
  }
556
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}}class ga extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(yo,fa)})}}class ha extends H{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,this.fieldset={dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(t){return t.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
555
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:E.ArrayTable,WorkflowVariableInput:Ce}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}}class ha extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(X).registerInstruction(xo,ga)})}}class ya extends H{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,this.fieldset={dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(t){return t.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
557
556
  font-size: 80%;
558
557
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
559
- `}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:To}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return{[i.value]:t,[i.label]:o}}}class ya extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",ha)})}}const xa=()=>{const{workflow:e}=q();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class ba extends H{constructor(){super(...arguments),this.title=N("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={workflowKey:{type:"string",title:N("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":xa,required:!0},bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=k.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}}class wa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",ba)})}}const va=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
558
+ `}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:No}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return{[i.value]:t,[i.label]:o}}}class xa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",ya)})}}const ba=()=>{const{workflow:e}=q();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class wa extends H{constructor(){super(...arguments),this.title=N("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={workflowKey:{type:"string",title:N("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":ba,required:!0},bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}}class va extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",wa)})}}const Ca=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
560
559
  color: ${t.colorTextDescription};
561
560
 
562
561
  &:before {
563
562
  content: '#';
564
563
  }
565
- `}));function Ca({value:e,onChange:t}){const o=e==null,n=ye(),i=$e(n,d=>d.type==="variable"&&!d.config.target),{styles:a}=va(),l=y.useCallback(({target:d})=>{if(d.value)return t(null);i.length&&t(i[0].key)},[t,i]),c=y.useCallback((d,p)=>p.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${p.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:F("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!i.length,children:F("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:i.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:a.nodeIdClass,children:p.data.id})]})})]})]})})})}class ka extends H{constructor(){super(...arguments),this.title=N("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=N("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:N("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:N("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:Ce,VariableTargetSelect:Ca}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=ue}){return n.target?null:{[a.value]:t,[a.label]:o}}}class Sa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",ka)})}}const Xo=e=>{const t=E.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
564
+ `}));function ka({value:e,onChange:t}){const o=e==null,n=ye(),i=$e(n,d=>d.type==="variable"&&!d.config.target),{styles:a}=Ca(),l=y.useCallback(({target:d})=>{if(d.value)return t(null);i.length&&t(i[0].key)},[t,i]),c=y.useCallback((d,p)=>p.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${p.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:F("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!i.length,children:F("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:i.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:a.nodeIdClass,children:p.data.id})]})})]})]})})})}class Sa extends H{constructor(){super(...arguments),this.title=N("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=N("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:N("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:N("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:Ce,VariableTargetSelect:ka}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=ue}){return n.target?null:{[a.value]:t,[a.label]:o}}}class Aa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",Sa)})}}const Ro=e=>{const t=E.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
566
565
  &:after {
567
566
  content: ':';
568
567
  }
569
568
  & + a {
570
569
  margin-left: 0.25em;
571
570
  }
572
- `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Aa extends H{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{getOptions:E.getOptions},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=E.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:Xo},this.components={WorkflowVariableTextArea:ot,RadioWithTooltip:Ie,ValueBlock:ke}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:F("Calculation result")}}}const Ia=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:i,children:a}=e,[l,c]=y.useState(!1),d=y.useMemo(()=>{const u=ie.cloneDeep(n.config);return k.createForm({initialValues:u,disabled:i.executed})},[n,i]),p=y.useCallback(u=>{o(u),u||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:a})})};function Fa(){return{form:k.useForm()}}var wt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ta(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vt={exports:{}},Na=vt.exports,Ro;function Da(){return Ro||(Ro=1,function(e,t){(function(o,n){n()})(Na,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,u,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof wt=="object"&&wt.global===wt?wt:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var h=l.URL||l.webkitURL,g=document.createElement("a");u=u||p.name||"download",g.download=u,g.rel="noopener",typeof p=="string"?(g.href=p,g.origin===location.origin?a(g):i(g.href)?n(p,u,f):a(g,g.target="_blank")):(g.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(g.href)},4e4),setTimeout(function(){a(g)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){a(h)})}}:function(p,u,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var g=p.type==="application/octet-stream",x=/constructor/i.test(l.HTMLElement)||l.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||g&&x||c)&&typeof FileReader!="undefined"){var I=new FileReader;I.onloadend=function(){var O=I.result;O=v?O:O.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=O:location=O,h=null},I.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);h?h.location=C:location.href=C,h=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})}(vt)),vt.exports}var en=Da();const Oa=Ta(en);function Pa(){const e=k.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),i=ye(),{workflow:a}=q();return{run(){return D(this,null,function*(){var c,d;if(a.executed){b.message.error(F("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:i.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const Ma=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ke;return r.jsxs("div",{className:s.css`
571
+ `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Ia extends H{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{getOptions:E.getOptions},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=E.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:Ro},this.components={WorkflowVariableTextArea:ot,RadioWithTooltip:Ie,ValueBlock:ke}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){return n&&!n.some(a=>a in De||Object.values(De).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:ke.Initializer,node:t,resultTitle:F("Calculation result")}}}const Fa=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:i,children:a}=e,[l,c]=y.useState(!1),d=y.useMemo(()=>{const u=R.cloneDeep(n.config);return S.createForm({initialValues:u,disabled:i.executed})},[n,i]),p=y.useCallback(u=>{o(u),u||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:a})})};function Ta(){return{form:S.useForm()}}var wt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Na(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vt={exports:{}},Da=vt.exports,en;function Oa(){return en||(en=1,function(e,t){(function(o,n){n()})(Da,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,u,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof wt=="object"&&wt.global===wt?wt:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var h=l.URL||l.webkitURL,g=document.createElement("a");u=u||p.name||"download",g.download=u,g.rel="noopener",typeof p=="string"?(g.href=p,g.origin===location.origin?a(g):i(g.href)?n(p,u,f):a(g,g.target="_blank")):(g.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(g.href)},4e4),setTimeout(function(){a(g)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){a(h)})}}:function(p,u,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var g=p.type==="application/octet-stream",x=/constructor/i.test(l.HTMLElement)||l.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||g&&x||c)&&typeof FileReader!="undefined"){var I=new FileReader;I.onloadend=function(){var O=I.result;O=v?O:O.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=O:location=O,h=null},I.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);h?h.location=C:location.href=C,h=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})}(vt)),vt.exports}var tn=Oa();const Pa=Na(tn);function Ma(){const e=S.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),i=ye(),{workflow:a}=q();return{run(){return D(this,null,function*(){var c,d;if(a.executed){b.message.error(F("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:i.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const Ea=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ke;return r.jsxs("div",{className:s.css`
573
572
  display: flex;
574
573
  justify-content: space-between;
575
574
 
@@ -584,7 +583,7 @@ export default async function (
584
583
  code {
585
584
  font-weight: normal;
586
585
  }
587
- `,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",F("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:F("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function Ea(e,t){return r.jsx(Ma,{data:e,instruction:t})}const $a=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e;return{type:"void",properties:A(w({},t.view?{view:t.view}:{}),{button:{type:"void","x-content":n,"x-component":"Button","x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:Ea(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area",properties:A(w({},t.description?{description:{type:"void","x-component":fo,"x-component-props":{label:F("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
586
+ `,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",F("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:F("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function $a(e,t){return r.jsx(Ea,{data:e,instruction:t})}const Ba=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e;return{type:"void",properties:A(w({},t.view?{view:t.view}:{}),{button:{type:"void","x-content":n,"x-component":"Button","x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:$a(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area",properties:A(w({},t.description?{description:{type:"void","x-component":go,"x-component-props":{label:F("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
588
587
  .ant-input,
589
588
  .ant-select,
590
589
  .ant-cascader-picker,
@@ -596,7 +595,7 @@ export default async function (
596
595
  min-width: 6em;
597
596
  }
598
597
  }
599
- `},properties:t.fieldset},actions:i.executed?null:{type:"void","x-component":"ActionArea.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action","x-component-props":{useAction(){const{t:a}=s.useTranslation();return{run(){return D(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,p)=>{if(!(d==="upstream"||d==="downstream"))return p},2)],{type:"application/json"});Oa(c,o.title+"-"+o.key+".json"),b.message.success(a("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Pa}}}}})}})}},Ba=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e,a=$a({instruction:t,data:o,detailText:n,workflow:i});return r.jsx(s.SchemaComponent,{schema:a,components:t.components,scope:A(w({},t.scope),{useFormProviderProps:Fa})})},Va=e=>{const{instruction:t,data:o,detailText:n,workflow:i,editingConfig:a,setEditingConfig:l}=e;return r.jsx(Ia,{editingConfig:a,setEditingConfig:l,data:o,workflow:i,children:r.jsx(Ba,{instruction:t,data:o,detailText:n,workflow:i})})},Wa=s.createStyles(({css:e,token:t})=>({nodeClass:e`
598
+ `},properties:t.fieldset},actions:i.executed?null:{type:"void","x-component":"ActionArea.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action","x-component-props":{useAction(){const{t:a}=s.useTranslation();return{run(){return D(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,p)=>{if(!(d==="upstream"||d==="downstream"))return p},2)],{type:"application/json"});Pa(c,o.title+"-"+o.key+".json"),b.message.success(a("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Ma}}}}})}})}},Va=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e,a=Ba({instruction:t,data:o,detailText:n,workflow:i});return r.jsx(s.SchemaComponent,{schema:a,components:t.components,scope:A(w({},t.scope),{useFormProviderProps:Ta})})},Wa=e=>{const{instruction:t,data:o,detailText:n,workflow:i,editingConfig:a,setEditingConfig:l}=e;return r.jsx(Fa,{editingConfig:a,setEditingConfig:l,data:o,workflow:i,children:r.jsx(Va,{instruction:t,data:o,detailText:n,workflow:i})})},ja=s.createStyles(({css:e,token:t})=>({nodeClass:e`
600
599
  flex-shrink: 0;
601
600
  display: flex;
602
601
  flex-direction: column;
@@ -629,7 +628,7 @@ export default async function (
629
628
  padding: 0;
630
629
  display: none;
631
630
  }
632
- `})),ja=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=q())!=null?c:{},i=ye();if(!t)return null;const a=e.resource("flow_nodes");function l(){return D(this,null,function*(){var d;yield(d=a.moveUp)==null?void 0:d.call(a,{filterByTk:i.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(j.HolderOutlined,{}),onClick:l})},za=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
631
+ `})),za=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=q())!=null?c:{},i=ye();if(!t)return null;const a=e.resource("flow_nodes");function l(){return D(this,null,function*(){var d;yield(d=a.moveUp)==null?void 0:d.call(a,{filterByTk:i.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(j.HolderOutlined,{}),onClick:l})},La=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
633
632
  background-color: red;
634
633
  max-height: 50vh;
635
634
  overflow-y: auto;
@@ -651,7 +650,7 @@ export default async function (
651
650
  display: inline-flex;
652
651
  justify-content: center;
653
652
  align-items: center;
654
- `})),La=()=>{var a;const{execution:e,setViewJob:t}=q(),{jobs:o}=(a=ye())!=null?a:{},{styles:n}=za();if(!e)return null;if(!o.length)return r.jsx(Ze,{className:n.nodeJobButtonClass,disabled:!0});const i=l=>{const{key:c}=l,d=o.find(p=>p.id===+c);t(d)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ze,{statusMap:Xe,status:l.status}),r.jsx("time",{children:E.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:i},children:r.jsx(Ze,{statusMap:Xe,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ze,{statusMap:Xe,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},qa=()=>{var p;const{t:e}=Q.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:i}=(p=q())!=null?p:{},a=ye(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return D(this,null,function*(){function u(){return D(this,null,function*(){var x;yield(x=c.destroy)==null?void 0:x.call(c,{filterByTk:a.id}),i()})}const f=n.filter(x=>x===a?!1:E.parse(x.config).parameters.filter(({key:T})=>T.startsWith(`$jobsMapByNodeKey.${a.key}.`)||T===`$jobsMapByNodeKey.${a.key}`).length);if(f.length){l.error({title:F("Can not delete"),content:F("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(x=>`#${x.id}`).join(", ")})});return}const g=!n.find(x=>x.upstream===a&&x.branchIndex!=null)?e("Are you sure you want to delete it?"):F("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:g,onOk:u})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(j.DeleteOutlined,{}),onClick:d})},Ua=s.createStyles(({css:e,token:t})=>({nodePoint:e`
653
+ `})),qa=()=>{var a;const{execution:e,setViewJob:t}=q(),{jobs:o}=(a=ye())!=null?a:{},{styles:n}=La();if(!e)return null;if(!o.length)return r.jsx(Ze,{className:n.nodeJobButtonClass,disabled:!0});const i=l=>{const{key:c}=l,d=o.find(p=>p.id===+c);t(d)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ze,{statusMap:Xe,status:l.status}),r.jsx("time",{children:E.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:i},children:r.jsx(Ze,{statusMap:Xe,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ze,{statusMap:Xe,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},Ua=()=>{var p;const{t:e}=Q.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:i}=(p=q())!=null?p:{},a=ye(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return D(this,null,function*(){function u(){return D(this,null,function*(){var x;yield(x=c.destroy)==null?void 0:x.call(c,{filterByTk:a.id}),i()})}const f=n.filter(x=>x===a?!1:E.parse(x.config).parameters.filter(({key:T})=>T.startsWith(`$jobsMapByNodeKey.${a.key}.`)||T===`$jobsMapByNodeKey.${a.key}`).length);if(f.length){l.error({title:F("Can not delete"),content:F("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(x=>`#${x.id}`).join(", ")})});return}const g=!n.find(x=>x.upstream===a&&x.branchIndex!=null)?e("Are you sure you want to delete it?"):F("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:g,onOk:u})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(j.DeleteOutlined,{}),onClick:d})},Ka=s.createStyles(({css:e,token:t})=>({nodePoint:e`
655
654
  position: relative;
656
655
  display: flex;
657
656
  flex-direction: row;
@@ -775,16 +774,16 @@ export default async function (
775
774
  }
776
775
  }
777
776
  }
778
- `})),Ka=e=>{const{color:t,icon:o,workflow:n,editingTitle:i,configuring:a,setEditingTitle:l,onChangeTitle:c}=e,d=ye(),{styles:p}=Ua(),[u,f]=y.useState(!1),h=n.executed||!u,g=(d==null?void 0:d.group)===Ke,x=()=>{a&&f(!0)},v=I=>{c(I.target.value),f(!1)};return r.jsxs("div",{className:s.cx(p.nodePoint,{deprecated:g,configuring:a}),children:[r.jsx(_a,{color:t,icon:o}),r.jsx(Eo,{className:`workflow-node-edit ${h?"node-executed":""}`,readOnly:h,value:i,onChange:I=>l(I.target.value),onBlur:v,onClick:x}),r.jsx(Ga,{isExecuted:n.executed})]})},_a=e=>{const{color:t,icon:o}=e;return r.jsx("div",{className:"workflow-node-prefix",style:{backgroundColor:t},children:r.jsx(s.Icon,{type:o!=null?o:"dispatcher"})})},Ga=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(La,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(qa,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(ja,{})})]})})},nt=e=>{var V,$;const{data:t,children:o}=e,n=s.useCompile(),i=s.useAPIClient(),{workflow:a,refresh:l}=(V=q())!=null?V:{},{styles:c}=Wa(),p=s.usePlugin(X).instructions.get(t.type),u=a.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(p.title),{color:h,icon:g}=p,[x,v]=y.useState(($=t.title)!=null?$:f),[I,T]=y.useState(!1),C=y.useCallback(function(P){return D(this,null,function*(){var _,z;const B=P||f;v(B),B!==t.title&&(yield(z=(_=i.resource("flow_nodes")).update)==null?void 0:z.call(_,{filterByTk:t.id,values:{title:B}}),l())})},[t]),O=y.useCallback(function(P){var _,z;if(P.target===P.currentTarget){T(!0);return}(z=(_=P.target)==null?void 0:_.classList)!=null&&z.contains("workflow-node-edit")&&T(!0);const B=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let J=P.target;J&&J!==P.currentTarget&&J!==document.documentElement;J=J.parentNode)if(Array.from(J.classList).some(Y=>B.has(Y))){T(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(c.nodeCardClass),role:"button","aria-label":`${f}-${x}`,onClick:O,children:[r.jsx(Ka,{color:h,icon:g,workflow:a,editingTitle:x,configuring:I,setEditingTitle:v,onChangeTitle:C}),r.jsx(Va,{instruction:p,data:t,detailText:u,workflow:a,editingConfig:I,setEditingConfig:T})]}),o]})},Z=new E.Registry;Z.register("equal",{name:"=",type:"boolean",group:"boolean"}),Z.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Z.register("gt",{name:">",type:"boolean",group:"boolean"}),Z.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Z.register("lt",{name:"<",type:"boolean",group:"boolean"}),Z.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Z.register("add",{name:"+",type:"number",group:"number"}),Z.register("minus",{name:"-",type:"number",group:"number"}),Z.register("multiple",{name:"*",type:"number",group:"number"}),Z.register("divide",{name:"/",type:"number",group:"number"}),Z.register("mod",{name:"%",type:"number",group:"number"}),Z.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Z.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Z.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Z.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Z.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Z.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Z.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),Z.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const Ha=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`},{value:"existence",title:`{{t("Existence check", { ns: "${m}" })}}`}];function tn(e){return Array.from(Z.getEntities()).filter(([t,o])=>o.group===e)}function Ja({calculator:e,operands:t=[],onChange:o}){const[n,i]=y.useState(e),a=s.useCompile(),l=ce(),c=p=>{const u=Z.get(p);return(u==null?void 0:u.group)==="existence"},d=p=>{i(p),o({operands:t,calculator:p})};return r.jsxs("fieldset",{className:s.css`
777
+ `})),_a=e=>{const{color:t,icon:o,workflow:n,editingTitle:i,configuring:a,setEditingTitle:l,onChangeTitle:c}=e,d=ye(),{styles:p}=Ka(),[u,f]=y.useState(!1),h=n.executed||!u,g=(d==null?void 0:d.group)===Ke,x=()=>{a&&f(!0)},v=I=>{c(I.target.value),f(!1)};return r.jsxs("div",{className:s.cx(p.nodePoint,{deprecated:g,configuring:a}),children:[r.jsx(Ga,{color:t,icon:o}),r.jsx($o,{className:`workflow-node-edit ${h?"node-executed":""}`,readOnly:h,value:i,onChange:I=>l(I.target.value),onBlur:v,onClick:x}),r.jsx(Ha,{isExecuted:n.executed})]})},Ga=e=>{const{color:t,icon:o}=e;return r.jsx("div",{className:"workflow-node-prefix",style:{backgroundColor:t},children:r.jsx(s.Icon,{type:o!=null?o:"dispatcher"})})},Ha=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(qa,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(Ua,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(za,{})})]})})},nt=e=>{var V,$;const{data:t,children:o}=e,n=s.useCompile(),i=s.useAPIClient(),{workflow:a,refresh:l}=(V=q())!=null?V:{},{styles:c}=ja(),p=s.usePlugin(X).instructions.get(t.type),u=a.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(p.title),{color:h,icon:g}=p,[x,v]=y.useState(($=t.title)!=null?$:f),[I,T]=y.useState(!1),C=y.useCallback(function(P){return D(this,null,function*(){var _,z;const B=P||f;v(B),B!==t.title&&(yield(z=(_=i.resource("flow_nodes")).update)==null?void 0:z.call(_,{filterByTk:t.id,values:{title:B}}),l())})},[t]),O=y.useCallback(function(P){var _,z;if(P.target===P.currentTarget){T(!0);return}(z=(_=P.target)==null?void 0:_.classList)!=null&&z.contains("workflow-node-edit")&&T(!0);const B=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let J=P.target;J&&J!==P.currentTarget&&J!==document.documentElement;J=J.parentNode)if(Array.from(J.classList).some(Y=>B.has(Y))){T(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(c.nodeCardClass),role:"button","aria-label":`${f}-${x}`,onClick:O,children:[r.jsx(_a,{color:h,icon:g,workflow:a,editingTitle:x,configuring:I,setEditingTitle:v,onChangeTitle:C}),r.jsx(Wa,{instruction:p,data:t,detailText:u,workflow:a,editingConfig:I,setEditingConfig:T})]}),o]})},Z=new E.Registry;Z.register("equal",{name:"=",type:"boolean",group:"boolean"}),Z.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Z.register("gt",{name:">",type:"boolean",group:"boolean"}),Z.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Z.register("lt",{name:"<",type:"boolean",group:"boolean"}),Z.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Z.register("add",{name:"+",type:"number",group:"number"}),Z.register("minus",{name:"-",type:"number",group:"number"}),Z.register("multiple",{name:"*",type:"number",group:"number"}),Z.register("divide",{name:"/",type:"number",group:"number"}),Z.register("mod",{name:"%",type:"number",group:"number"}),Z.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Z.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Z.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Z.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Z.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Z.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Z.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),Z.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Z.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const Ja=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`},{value:"existence",title:`{{t("Existence check", { ns: "${m}" })}}`}];function on(e){return Array.from(Z.getEntities()).filter(([t,o])=>o.group===e)}function Ya({calculator:e,operands:t=[],onChange:o}){const[n,i]=y.useState(e),a=s.useCompile(),l=ce(),c=p=>{const u=Z.get(p);return(u==null?void 0:u.group)==="existence"},d=p=>{i(p),o({operands:t,calculator:p})};return r.jsxs("fieldset",{className:s.css`
779
778
  display: flex;
780
779
  gap: 0.5em;
781
780
  align-items: center;
782
781
  flex-wrap: wrap;
783
- `,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:p=>o({calculator:n,operands:[p,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:F("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Ha.filter(p=>!!tn(p.value).length).map(p=>r.jsx(b.Select.OptGroup,{label:a(p.title),children:tn(p.value).map(([u,{name:f}])=>r.jsx(b.Select.Option,{value:u,children:a(f)},u))},p.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:p=>o({calculator:n,operands:[t[0],p]}),scope:l,useTypedConstant:!0})]})}function Ya({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:i=[]}=e;return r.jsxs("div",{className:s.css`
782
+ `,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:p=>o({calculator:n,operands:[p,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:F("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Ja.filter(p=>!!on(p.value).length).map(p=>r.jsx(b.Select.OptGroup,{label:a(p.title),children:on(p.value).map(([u,{name:f}])=>r.jsx(b.Select.Option,{value:u,children:a(f)},u))},p.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:p=>o({calculator:n,operands:[t[0],p]}),scope:l,useTypedConstant:!0})]})}function Qa({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:i=[]}=e;return r.jsxs("div",{className:s.css`
784
783
  display: flex;
785
784
  position: relative;
786
785
  margin: 0.5em 0;
787
- `,children:[e.group?r.jsx(on,{value:e.group,onChange:a=>t(A(w({},e),{group:a}))}):r.jsx(Ja,{operands:i,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(j.CloseCircleOutlined,{})})]})}function on({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:i=[]}=e;function a(){t(A(w({},e),{calculations:[...i,{not:!1,calculator:"equal"}]}))}function l(){t(A(w({},e),{calculations:[...i,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){i.splice(p,1),t(A(w({},e),{calculations:[...i]}))}function d(p,u){i.splice(p,1,u),t(A(w({},e),{calculations:[...i]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
786
+ `,children:[e.group?r.jsx(nn,{value:e.group,onChange:a=>t(A(w({},e),{group:a}))}):r.jsx(Ya,{operands:i,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(j.CloseCircleOutlined,{})})]})}function nn({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:i=[]}=e;function a(){t(A(w({},e),{calculations:[...i,{not:!1,calculator:"equal"}]}))}function l(){t(A(w({},e),{calculations:[...i,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){i.splice(p,1),t(A(w({},e),{calculations:[...i]}))}function d(p,u){i.splice(p,1,u),t(A(w({},e),{calculations:[...i]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
788
787
  position: relative;
789
788
  width: 100%;
790
789
  .node-type-condition-group {
@@ -803,14 +802,14 @@ export default async function (
803
802
  width: auto;
804
803
  min-width: 6em;
805
804
  }
806
- `,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(A(w({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:i.map((p,u)=>r.jsx(Ya,{value:p,onChange:d.bind(this,u),onRemove:()=>c(u)},`${p.calculator}_${u}`))}),r.jsxs("div",{className:s.css`
805
+ `,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(A(w({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:i.map((p,u)=>r.jsx(Qa,{value:p,onChange:d.bind(this,u),onRemove:()=>c(u)},`${p.calculator}_${u}`))}),r.jsxs("div",{className:s.css`
807
806
  button {
808
807
  padding: 0;
809
808
  &:not(:last-child) {
810
809
  margin-right: 1em;
811
810
  }
812
811
  }
813
- `,children:[r.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Qa({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(on,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class Za extends H{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",this.description=`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(E.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(w({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=E.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:Xo,useWorkflowVariableOptions:ce},this.components={CalculationConfig:Qa,WorkflowVariableTextArea:ot,RadioWithTooltip:Ie}}Component({data:t}){const{t:o}=Q.useTranslation(),{nodes:n}=q(),{styles:i}=xe(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),d=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(nt,{data:t,children:l?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Be,{from:t,entry:c,branchIndex:1}),r.jsx(Be,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function Xa(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=k.useField(),n=o.segments[o.segments.length-1],{values:i}=k.useForm(),[a,l]=s.parseCollectionName(i==null?void 0:i.collection),c=t(l,a),{type:d}=c.find(f=>f.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(f){const h=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?h:h.split(/[,\s]+/))}return r.jsx(b.Input,A(w({},e),{value:p,onChange:u}))}const Rt=k.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:i}=s.useToken(),{t:a}=Q.useTranslation(),l=s.useCompile(),c=k.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),p=ce(),{values:u}=c,[f,h]=s.parseCollectionName(u==null?void 0:u.collection),g=d(h,f).filter(C=>C.uiSchema),x=n?g.filter(n.bind(u)):g,v=y.useMemo(()=>x.filter(C=>!e||!(C.name in e)),[x,e]),I=t||c.disabled,T=y.useMemo(()=>({onClick:({key:C})=>{o(A(w({},e),{[C]:null}))},style:{maxHeight:300,overflowY:"auto"},items:v.map(C=>{var O,V;return{key:C.name,label:l((V=(O=C.uiSchema)==null?void 0:O.title)!=null?V:C.name)}})}),[o,v,e]);return r.jsx("fieldset",{className:s.css`
812
+ `,children:[r.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Za({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(nn,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class Xa extends H{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",this.description=`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(E.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(w({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=E.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:Ro,useWorkflowVariableOptions:ce},this.components={CalculationConfig:Za,WorkflowVariableTextArea:ot,RadioWithTooltip:Ie}}Component({data:t}){const{t:o}=Q.useTranslation(),{nodes:n}=q(),{styles:i}=xe(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),d=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(nt,{data:t,children:l?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Be,{from:t,entry:c,branchIndex:1}),r.jsx(Be,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function Ra(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=S.useField(),n=o.segments[o.segments.length-1],{values:i}=S.useForm(),[a,l]=s.parseCollectionName(i==null?void 0:i.collection),c=t(l,a),{type:d}=c.find(f=>f.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(f){const h=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?h:h.split(/[,\s]+/))}return r.jsx(b.Input,A(w({},e),{value:p,onChange:u}))}const Rt=S.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:i}=s.useToken(),{t:a}=Q.useTranslation(),l=s.useCompile(),c=S.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),p=ce(),{values:u}=c,[f,h]=s.parseCollectionName(u==null?void 0:u.collection),g=d(h,f).filter(C=>C.uiSchema),x=n?g.filter(n.bind(u)):g,v=y.useMemo(()=>x.filter(C=>!e||!(C.name in e)),[x,e]),I=t||c.disabled,T=y.useMemo(()=>({onClick:({key:C})=>{o(A(w({},e),{[C]:null}))},style:{maxHeight:300,overflowY:"auto"},items:v.map(C=>{var O,V;return{key:C.name,label:l((V=(O=C.uiSchema)==null?void 0:O.title)!=null?V:C.name)}})}),[o,v,e]);return r.jsx("fieldset",{className:s.css`
814
813
  margin-top: 0.5em;
815
814
 
816
815
  > .ant-formily-item {
@@ -820,22 +819,22 @@ export default async function (
820
819
  line-height: 32px;
821
820
  }
822
821
  }
823
- `,children:x.length?r.jsxs(s.CollectionProvider_deprecated,{name:h,dataSource:f,children:[x.filter(C=>e&&C.name in e).map(C=>{var V,$;const O=["belongsTo","hasOne","hasMany","belongsToMany"].includes(C.type)?Xa:s.CollectionField;return r.jsxs(b.Form.Item,{label:l(($=(V=C.uiSchema)==null?void 0:V.title)!=null?$:C.name),labelAlign:"left",className:s.css`
822
+ `,children:x.length?r.jsxs(s.CollectionProvider_deprecated,{name:h,dataSource:f,children:[x.filter(C=>e&&C.name in e).map(C=>{var V,$;const O=["belongsTo","hasOne","hasMany","belongsToMany"].includes(C.type)?Ra:s.CollectionField;return r.jsxs(b.Form.Item,{label:l(($=(V=C.uiSchema)==null?void 0:V.title)!=null?$:C.name),labelAlign:"left",className:s.css`
824
823
  .ant-form-item-control-input-content {
825
824
  display: flex;
826
825
  }
827
- `,children:[r.jsx(s.Variable.Input,{scope:p,value:e[C.name],changeOnSelect:!0,onChange:P=>{o(A(w({},e),{[C.name]:P}))},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[C.name]:{"x-component":O,"x-validator"(){return""}}}}})}),I?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(j.CloseCircleOutlined,{}),onClick:()=>{var _;const z=e,{[_=C.name]:P}=z,B=K(z,[Hn(_)]);o(B)}})]},C.name)}),v.length?r.jsx(b.Dropdown,{menu:T,children:r.jsx(b.Button,{icon:r.jsx(j.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:i.colorText},children:F("Please select collection first")})})},{displayName:"CollectionFieldSet"}),fe={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},eo={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:s.css`
826
+ `,children:[r.jsx(s.Variable.Input,{scope:p,value:e[C.name],changeOnSelect:!0,onChange:P=>{o(A(w({},e),{[C.name]:P}))},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[C.name]:{"x-component":O,"x-validator"(){return""}}}}})}),I?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(j.CloseCircleOutlined,{}),onClick:()=>{var _;const z=e,{[_=C.name]:P}=z,B=K(z,[Jn(_)]);o(B)}})]},C.name)}),v.length?r.jsx(b.Dropdown,{menu:T,children:r.jsx(b.Button,{icon:r.jsx(j.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:i.colorText},children:F("Please select collection first")})})},{displayName:"CollectionFieldSet"}),fe={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},eo={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:s.css`
828
827
  flex-direction: column;
829
- `},"x-component":"CollectionFieldset"},rt={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=k.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
828
+ `},"x-component":"CollectionFieldset"},rt={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=S.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
830
829
  position: relative;
831
830
  width: 100%;
832
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Ra={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"}}},el={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],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}}}}}}}}},st={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=k.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class tl extends H{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:eo,appends:st}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Rt}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ne,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class ol extends H{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",this.description=`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(w({},rt),{"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae}}}class nl extends H{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:be.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:be.FAILED}],required:!0,default:be.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class rl extends H{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:rt,sort:Ra,pagination:el,appends:st},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=k.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:E.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:Ce}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ne,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function sl(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=k.useForm(),{collection:l}=a.values,c=i(l),d=k.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(g[x.name]=f.value[x.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Ie,A(w({},t),{onChange:p}))}class il extends H{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:A(w({},rt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}}),values:A(w({},eo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:Rt,IndividualHooksRadioWithTooltip:sl}}}function al(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=k.useForm(),{collection:l}=a.values,c=i(l),d=k.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(g[x.name]=f.value[x.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Ie,A(w({},t),{onChange:p}))}class ll extends H{constructor(){super(...arguments),this.title=`{{t("Update or create record", { ns: "${m}" })}}`,this.type="updateorcreate",this.group="collection",this.icon="FileSyncOutlined",this.color="#f6f66a",this.description=`{{t("Update or create record, if no matching record is found, a new record will be created, with the ability to assign values to fields using variables from upstream nodes.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:A(w({},rt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}}),values:A(w({},eo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:Rt,IndividualHooksRadioWithTooltip:al}}}const cl=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=k.useFieldSchema();return k.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),We={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},dl=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:We.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:We.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:We.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:We.DELETED}];class pl extends Ye{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...fe["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:dl,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${We.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${We.UPDATED})}}`}}}]},condition:A(w({},rt),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},st),{"x-reactions":[...st["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${We.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:$o},this.components={FieldsSelect:et}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return me(A(w({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const je={STATIC:0,DATE_FIELD:1};function ul(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function nn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[i,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
831
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},el={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"}}},tl={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],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}}}}}}}}},st={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=S.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class ol extends H{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:eo,appends:st}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Rt}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ne,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class nl extends H{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",this.description=`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(w({},rt),{"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae}}}class rl extends H{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:be.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:be.FAILED}],required:!0,default:be.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class sl extends H{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:rt,sort:el,pagination:tl,appends:st},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=S.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:E.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:Ce}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ne,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function il(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(g[x.name]=f.value[x.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Ie,A(w({},t),{onChange:p}))}class al extends H{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:A(w({},rt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}}),values:A(w({},eo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:Rt,IndividualHooksRadioWithTooltip:il}}}function ll(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(g[x.name]=f.value[x.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Ie,A(w({},t),{onChange:p}))}class cl extends H{constructor(){super(...arguments),this.title=`{{t("Update or create record", { ns: "${m}" })}}`,this.type="updateorcreate",this.group="collection",this.icon="FileSyncOutlined",this.color="#f6f66a",this.description=`{{t("Update or create record, if no matching record is found, a new record will be created, with the ability to assign values to fields using variables from upstream nodes.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:A(w({},rt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return Re(t)?"":F("Please add at least one condition")}}),values:A(w({},eo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:Rt,IndividualHooksRadioWithTooltip:ll}}}const dl=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),We={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},pl=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:We.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:We.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:We.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:We.DELETED}];class ul extends Ye{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},fe),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...fe["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:pl,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${We.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${We.UPDATED})}}`}}}]},condition:A(w({},rt),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},st),{"x-reactions":[...st["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${We.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Bo},this.components={FieldsSelect:et}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return me(A(w({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const je={STATIC:0,DATE_FIELD:1};function ml(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function rn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[i,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
833
832
  display: flex;
834
833
  gap: 0.5em;
835
- `,children:[r.jsx(et,{value:o.field,onChange:l=>t(A(w({},o),{field:l})),filter:ul,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:i,onChange:l=>{a(l),t(A(w({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:F("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,i?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(A(w({},o),{offset:(l!=null?l:0)*i}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(A(w({},o),{unit:l})),options:[{value:864e5,label:F("Days")},{value:36e5,label:F("Hours")},{value:6e4,label:F("Minutes")},{value:1e3,label:F("Seconds")}],className:"auto-width"})]}):null]})}function ml({value:e,onChange:t}){const{t:o}=he(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
834
+ `,children:[r.jsx(et,{value:o.field,onChange:l=>t(A(w({},o),{field:l})),filter:ml,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:i,onChange:l=>{a(l),t(A(w({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:F("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,i?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(A(w({},o),{offset:(l!=null?l:0)*i}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(A(w({},o),{unit:l})),options:[{value:864e5,label:F("Days")},{value:36e5,label:F("Hours")},{value:6e4,label:F("Minutes")},{value:1e3,label:F("Seconds")}],className:"auto-width"})]}):null]})}function fl({value:e,onChange:t}){const{t:o}=he(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
836
835
  display: flex;
837
836
  gap: 0.5em;
838
- `,children:[r.jsxs(b.Select,{value:n,onChange:i=>{t(i?i==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(nn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:E.dayjs(e),onChange:i=>{t(i?i.toDate():null)}}):null]})}var de=function(){return de=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de.apply(this,arguments)};function rn(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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function Ct(e,t,o){if(o||arguments.length===2)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var fl=[{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 * * * *"}],ze=[{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"]}],U={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 sn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function kt(e){return e.sort(function(t,o){return t-o}),e}function an(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ve(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 ln(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function St(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function cn(e,t,o,n,i,a,l,c,d,p,u,f,h,g){o&&o(void 0),t(!1);var x=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;x=!0}if(!x){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var v=fl.find(function(C){return C.name===e});v&&(e=v.value)}try{var I=function(C){if(typeof C!="string")throw new Error("Invalid cron string");var O=C.replace(/\s+/g," ").trim().split(" ");if(O.length===5)return O.map(function(V,$){return function(P,B){if(P==="*"||P==="*/1")return[];var _=kt(an(mn(function(J,Y,se){if(se){J=J.toUpperCase();for(var W=0;W<se.length;W++)J=J.replace(se[W],"".concat(W+Y))}return J}(P,B.min,B.alt).split(",").map(function(J){var Y,se=J.split("/");if(se.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat(B.type,'"'));var W=se[0],M=se[1];Y=W==="*"?sn(B.min,B.max):function(G,te,R){var re=G.split("-");if(re.length===1){var qe=St(re[0]);if(isNaN(qe))throw new Error('Invalid value "'.concat(te,'" for ').concat(R.type));return[qe]}if(re.length===2){var we=St(re[0]),He=St(re[1]);if(isNaN(we)||isNaN(He))throw new Error('Invalid value "'.concat(te,'" for ').concat(R.type));if(He<we)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return sn(we,He)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}(W,P,B);var L=function(G,te){if(G!==void 0){var R=St(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(te.type));return R}}(M,B),ee=function(G,te){if(te){var R=G[0];G=G.filter(function(re){return re%te==R%te||re===R})}return G}(Y,L);return ee}).flat(),B))),z=fn(_,B);if(z!==void 0)throw new Error('Value "'.concat(z,'" out of range for ').concat(B.type));return _.length===B.total?[]:_}(V,ze[$])});throw new Error("Invalid cron string format")}(e),T=function(C){return C[3].length>0?"year":C[2].length>0?"month":C[4].length>0?"week":C[1].length>0?"day":C[0].length>0?"hour":"minute"}(I);g(T),d(I[0]),p(I[1]),u(I[2]),f(I[3]),h(I[4])}catch(C){x=!0}}x&&(i.current=e,t(!0),ln(o,l))}function dn(e,t,o,n,i,a,l){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(u,f){var h=ze[f];return pn(un(u,h),h,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&i?i:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function pn(e,t,o,n,i){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var p=1;p<c.length;p++){var u=c[p-1];if(c[p]-u!==d)return!1}return!0}(e,l)?function(c,d,p){var u=gn(c),f=hn(c),h=c.length===(f-u)/p+1;return!!(u===d.min&&f+p>d.max&&h)}(e,t,l)?"*/".concat(l):"".concat(Ge(gn(e),t,o,n,i),"-").concat(Ge(hn(e),t,o,n,i),"/").concat(l):function(c){var d=[],p=null;return c.forEach(function(u,f,h){u!==h[f+1]-1?p!==null?(d.push([p,u]),p=null):d.push(u):p===null&&(p=u)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ge(c[0],t,o,n,i),"-").concat(Ge(c[1],t,o,n,i)):Ge(c,t,o,n,i)}).join(",")}return a}function Ge(e,t,o,n,i){var a=e.toString(),l=t.type,c=t.alt,d=t.min,p=n&&(n===!0||n.includes(l)),u=i==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(p||u)&&(a=a.padStart(2,"0")),l==="hours"&&i==="12-hour-clock"){var f=e>=12?"PM":"AM",h=e%12||12;h<10&&p&&(h=h.toString().padStart(2,"0")),a="".concat(h).concat(f)}return a}function un(e,t){var o=kt(an(mn(e,t)));if(o.length===0)return o;var n=fn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function mn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function fn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function gn(e){return e[0]}function hn(e){return e[e.length-1]}function it(e){var t=e.value,o=e.grid,n=o===void 0||o,i=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,u=e.readOnly,f=e.leadingZero,h=e.clockFormat,g=e.period,x=e.unit,v=e.periodicityOnDoubleClick,I=e.mode,T=rn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),C=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(W){return W.toString()})},[t]),O=y.useMemo(function(){return i?i.map(function(W,M){return{value:(x.min===0?M:M+1).toString(),label:W}}):Ct([],Array(x.total),!0).map(function(W,M){var L=x.min===0?M:M+1;return{value:L.toString(),label:Ge(L,x,d,f,h)}})},[i,f,d,h]),V=JSON.stringify(l),$=y.useCallback(function(W){var M=W.value;if(!t||t[0]!==Number(M))return r.jsx(r.Fragment,{});var L=pn(un(t,x),x,d,f,h),ee=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ee[1]?"".concat(l.everyText||U.everyText," ").concat(ee[1]):L})},[t,V,d,f,h]),P=y.useCallback(function(W){var M=Array.isArray(W)?kt(W):[W],L=M;t&&(L=I==="single"?[]:Ct([],t,!0),M.forEach(function(ee){var G=Number(ee);L=t.some(function(te){return te===G})?L.filter(function(te){return te!==G}):kt(Ct(Ct([],L,!0),[G],!1))})),L.length===x.total?a([]):a(L)},[a,t]),B=y.useCallback(function(W){if(W!==0&&W!==1){for(var M=x.total+x.min,L=[],ee=x.min;ee<M;ee++)ee%W==0&&L.push(ee);var G=t&&L&&t.length===L.length&&t.every(function(R,re){return R===L[re]}),te=L.length===O.length;a(te||G?[]:L)}else a([])},[t,O,a]),_=y.useRef([]),z=y.useCallback(function(W){if(!u){var M=_.current;M.push({time:new Date().getTime(),value:Number(W)});var L=window.setTimeout(function(){v&&M.length>1&&M[M.length-1].time-M[M.length-2].time<300?M[M.length-1].value===M[M.length-2].value?B(Number(W)):P([M[M.length-2].value,M[M.length-1].value]):P(Number(W)),_.current=[]},300);return function(){window.clearTimeout(L)}}},[_,P,B,u,v]),J=y.useCallback(function(){u||a([])},[a,u]),Y=y.useMemo(function(){var W;return ve(((W={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,W))},[c]),se=y.useMemo(function(){var W;return ve(((W={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown"]=!0,W["react-js-cron-custom-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown-minutes-large"]=x.type==="minutes"&&g!=="hour"&&g!=="day",W["react-js-cron-custom-select-dropdown-minutes-medium"]=x.type==="minutes"&&(g==="day"||g==="hour"),W["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=x.type==="hours"&&h==="12-hour-clock",W["react-js-cron-custom-select-dropdown-grid"]=!!n,W["".concat(c,"-select-dropdown")]=!!c,W["".concat(c,"-select-dropdown-").concat(x.type)]=!!c,W))},[c,n,h,g]);return r.jsx(b.Select,de({mode:I!=="single"||v?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:C,onClear:J,tagRender:$,className:Y,popupClassName:se,options:O,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:z,onDeselect:z,disabled:p,dropdownAlign:x.type!=="minutes"&&x.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(x.type)},T))}function gl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-hours")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(it,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:ze[1],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f})]}))}function hl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-minutes")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||U.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||U.prefixMinutes}),r.jsx(it,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:ze[0],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function yl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=!a||a.length===0,g=y.useMemo(function(){var I;return ve(((I={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!h})["".concat(i,"-field")]=!!i,I["".concat(i,"-month-days")]=!!i,I))},[i,h]),x=JSON.stringify(n),v=y.useMemo(function(){return h?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[h,x]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",de({className:g},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(it,{placeholder:v,value:t,setValue:o,unit:ze[2],locale:n,className:i,disabled:l,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function xl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,u=e.mode,f=n.months||U.months,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-months")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(it,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:f,grid:!1,value:t,unit:de(de({},ze[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:u})]}))}function bl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),d.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),d.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),d.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),d.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),d.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=y.useCallback(function(x){l||o(x)},[o,l]),f=y.useMemo(function(){var x;return ve(((x={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(i,"-field")]=!!i,x["".concat(i,"-period")]=!!i,x))},[i]),h=y.useMemo(function(){var x;return ve(((x={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(i,"-select")]=!!i,x))},[i,n.prefixPeriod]),g=y.useMemo(function(){var x;return ve(((x={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(i,"-select-dropdown")]=!!i,x["".concat(i,"-select-dropdown-period")]=!!i,x))},[i]);return r.jsxs("div",de({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:u,options:p,className:h,popupClassName:g,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function wl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.weekDays||U.weekDays,g=p==="week"||!l||l.length===0,x=y.useMemo(function(){var O;return ve(((O={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(i,"-field")]=!!i,O["".concat(i,"-week-days")]=!!i,O))},[i,g]),v=JSON.stringify(n),I=y.useMemo(function(){return g?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[g,v]),T=p==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),C=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",de({className:x},{children:[n.prefixWeekDays!==""&&(p==="week"||!C)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&C&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(it,{placeholder:I,optionsList:h,grid:!1,value:t,unit:de(de({},ze[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function vl(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,i=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?U:c,p=e.value,u=p===void 0?"":p,f=e.setValue,h=e.displayError,g=h===void 0||h,x=e.onError,v=e.className,I=e.defaultPeriod,T=I===void 0?"day":I,C=e.allowEmpty,O=C===void 0?"for-default-value":C,V=e.humanizeLabels,$=V===void 0||V,P=e.humanizeValue,B=P!==void 0&&P,_=e.disabled,z=_!==void 0&&_,J=e.readOnly,Y=J!==void 0&&J,se=e.leadingZero,W=se!==void 0&&se,M=e.shortcuts,L=M===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:M,ee=e.clockFormat,G=e.periodicityOnDoubleClick,te=G===void 0||G,R=e.mode,re=R===void 0?"multiple":R,qe=e.allowedDropdowns,we=qe===void 0?["period","months","month-days","week-days","hours","minutes"]:qe,He=e.allowedPeriods,Xl=He===void 0?["year","month","week","day","hour","minute","reboot"]:He,Je=y.useRef(u),ro=y.useRef(T),Dn=y.useState(),Te=Dn[0],It=Dn[1],On=y.useState(),at=On[0],Ft=On[1],Pn=y.useState(),Tt=Pn[0],Nt=Pn[1],Mn=y.useState(),lt=Mn[0],Dt=Mn[1],En=y.useState(),Ot=En[0],Pt=En[1],$n=y.useState(),Mt=$n[0],Et=$n[1],Bn=y.useState(!1),so=Bn[0],ct=Bn[1],Vn=y.useState(!1),$t=Vn[0],Wn=Vn[1],Rl=function(oe){var Se=y.useRef(oe);return y.useEffect(function(){Se.current=oe},[oe]),Se.current}($t),jn=JSON.stringify(d);y.useEffect(function(){cn(u,ct,x,O,Je,!0,d,L,Et,Pt,Ft,Nt,Dt,It)},[]),y.useEffect(function(){u!==Je.current&&cn(u,ct,x,O,Je,!1,d,L,Et,Pt,Ft,Nt,Dt,It)},[u,Je,jn,O,L]),y.useEffect(function(){if(!(Te||Mt||Tt||at||lt||Ot)||$t||Rl)$t&&Wn(!1);else{var oe=Te||ro.current,Se=dn(oe,Tt,at,lt,Ot,Mt,B);f(Se,{selectedPeriod:oe}),Je.current=Se,x&&x(void 0),ct(!1)}},[Te,at,Tt,lt,Ot,Mt,B,$t]);var zn=y.useCallback(function(){Ft(void 0),Nt(void 0),Dt(void 0),Pt(void 0),Et(void 0);var oe="",Se=Te!=="reboot"&&Te?Te:ro.current;Se!==Te&&It(Se),l==="fill-with-every"&&(oe=dn(Se,void 0,void 0,void 0,void 0,void 0)),f(oe,{selectedPeriod:Se}),Je.current=oe,Wn(!0),O==="never"&&l==="empty"?(ct(!0),ln(x,d)):(x&&x(void 0),ct(!1))},[Te,f,x,l]),ec=y.useMemo(function(){var oe;return ve(((oe={"react-js-cron":!0,"react-js-cron-error":so&&g,"react-js-cron-disabled":z,"react-js-cron-read-only":Y})["".concat(v)]=!!v,oe["".concat(v,"-error")]=so&&g&&!!v,oe["".concat(v,"-disabled")]=z&&!!v,oe["".concat(v,"-read-only")]=Y&&!!v,oe))},[v,so,g,z,Y]),io=i.className,Ln=rn(i,["className"]),qn=y.useMemo(function(){var oe;return ve(((oe={"react-js-cron-clear-button":!0})["".concat(v,"-clear-button")]=!!v,oe["".concat(io)]=!!io,oe))},[v,io]),tc=JSON.stringify(Ln),Un=y.useMemo(function(){return o&&!Y?r.jsx(b.Button,de({className:qn,danger:!0,type:"primary",disabled:z},Ln,{onClick:zn},{children:d.clearButtonText||U.clearButtonText})):null},[o,Y,jn,qn,z,tc,zn]),le=Te||ro.current;return r.jsxs("div",de({className:ec},{children:[we.includes("period")&&r.jsx(bl,{value:le,setValue:It,locale:d,className:v,disabled:z,readOnly:Y,shortcuts:L,allowedPeriods:Xl}),le==="reboot"?Un:r.jsxs(r.Fragment,{children:[le==="year"&&we.includes("months")&&r.jsx(xl,{value:Tt,setValue:Nt,locale:d,className:v,humanizeLabels:$,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:te,mode:re}),(le==="year"||le==="month")&&we.includes("month-days")&&r.jsx(yl,{value:at,setValue:Ft,locale:d,className:v,weekDays:lt,disabled:z,readOnly:Y,leadingZero:W,period:le,periodicityOnDoubleClick:te,mode:re}),(le==="year"||le==="month"||le==="week")&&we.includes("week-days")&&r.jsx(wl,{value:lt,setValue:Dt,locale:d,className:v,humanizeLabels:$,monthDays:at,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:te,mode:re}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&we.includes("hours")&&r.jsx(gl,{value:Ot,setValue:Pt,locale:d,className:v,disabled:z,readOnly:Y,leadingZero:W,clockFormat:ee,period:le,periodicityOnDoubleClick:te,mode:re}),le!=="minute"&&we.includes("minutes")&&r.jsx(hl,{value:Mt,setValue:Et,locale:d,period:le,className:v,disabled:z,readOnly:Y,leadingZero:W,clockFormat:ee,periodicityOnDoubleClick:te,mode:re}),Un]})]})]}))}const Cl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},yn=[{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 xn(e){return yn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function kl(e){let t;switch(typeof e){case"number":return t=xn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Sl({value:e,onChange:t}){const{t:o}=he(),n=xn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:i=>t(i*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Al({value:e=null,onChange:t}){const{t:o}=he(),n=kl(e);function i(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Cl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
837
+ `,children:[r.jsxs(b.Select,{value:n,onChange:i=>{t(i?i==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(rn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:ao(e),onChange:i=>{t(i?i.toDate():null)}}):null]})}var de=function(){return de=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de.apply(this,arguments)};function sn(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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function Ct(e,t,o){if(o||arguments.length===2)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var gl=[{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 * * * *"}],ze=[{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"]}],U={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 an(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function kt(e){return e.sort(function(t,o){return t-o}),e}function ln(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ve(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 cn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function St(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function dn(e,t,o,n,i,a,l,c,d,p,u,f,h,g){o&&o(void 0),t(!1);var x=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;x=!0}if(!x){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var v=gl.find(function(C){return C.name===e});v&&(e=v.value)}try{var I=function(C){if(typeof C!="string")throw new Error("Invalid cron string");var O=C.replace(/\s+/g," ").trim().split(" ");if(O.length===5)return O.map(function(V,$){return function(P,B){if(P==="*"||P==="*/1")return[];var _=kt(ln(fn(function(J,Y,ie){if(ie){J=J.toUpperCase();for(var W=0;W<ie.length;W++)J=J.replace(ie[W],"".concat(W+Y))}return J}(P,B.min,B.alt).split(",").map(function(J){var Y,ie=J.split("/");if(ie.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat(B.type,'"'));var W=ie[0],M=ie[1];Y=W==="*"?an(B.min,B.max):function(G,oe,ee){var se=G.split("-");if(se.length===1){var qe=St(se[0]);if(isNaN(qe))throw new Error('Invalid value "'.concat(oe,'" for ').concat(ee.type));return[qe]}if(se.length===2){var we=St(se[0]),He=St(se[1]);if(isNaN(we)||isNaN(He))throw new Error('Invalid value "'.concat(oe,'" for ').concat(ee.type));if(He<we)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(ee.type));return an(we,He)}throw new Error('Invalid value "'.concat(G,'" for ').concat(ee.type))}(W,P,B);var L=function(G,oe){if(G!==void 0){var ee=St(G);if(isNaN(ee)||ee<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(oe.type));return ee}}(M,B),te=function(G,oe){if(oe){var ee=G[0];G=G.filter(function(se){return se%oe==ee%oe||se===ee})}return G}(Y,L);return te}).flat(),B))),z=gn(_,B);if(z!==void 0)throw new Error('Value "'.concat(z,'" out of range for ').concat(B.type));return _.length===B.total?[]:_}(V,ze[$])});throw new Error("Invalid cron string format")}(e),T=function(C){return C[3].length>0?"year":C[2].length>0?"month":C[4].length>0?"week":C[1].length>0?"day":C[0].length>0?"hour":"minute"}(I);g(T),d(I[0]),p(I[1]),u(I[2]),f(I[3]),h(I[4])}catch(C){x=!0}}x&&(i.current=e,t(!0),cn(o,l))}function pn(e,t,o,n,i,a,l){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(u,f){var h=ze[f];return un(mn(u,h),h,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&i?i:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function un(e,t,o,n,i){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var p=1;p<c.length;p++){var u=c[p-1];if(c[p]-u!==d)return!1}return!0}(e,l)?function(c,d,p){var u=hn(c),f=yn(c),h=c.length===(f-u)/p+1;return!!(u===d.min&&f+p>d.max&&h)}(e,t,l)?"*/".concat(l):"".concat(Ge(hn(e),t,o,n,i),"-").concat(Ge(yn(e),t,o,n,i),"/").concat(l):function(c){var d=[],p=null;return c.forEach(function(u,f,h){u!==h[f+1]-1?p!==null?(d.push([p,u]),p=null):d.push(u):p===null&&(p=u)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ge(c[0],t,o,n,i),"-").concat(Ge(c[1],t,o,n,i)):Ge(c,t,o,n,i)}).join(",")}return a}function Ge(e,t,o,n,i){var a=e.toString(),l=t.type,c=t.alt,d=t.min,p=n&&(n===!0||n.includes(l)),u=i==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(p||u)&&(a=a.padStart(2,"0")),l==="hours"&&i==="12-hour-clock"){var f=e>=12?"PM":"AM",h=e%12||12;h<10&&p&&(h=h.toString().padStart(2,"0")),a="".concat(h).concat(f)}return a}function mn(e,t){var o=kt(ln(fn(e,t)));if(o.length===0)return o;var n=gn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function fn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function gn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function hn(e){return e[0]}function yn(e){return e[e.length-1]}function it(e){var t=e.value,o=e.grid,n=o===void 0||o,i=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,u=e.readOnly,f=e.leadingZero,h=e.clockFormat,g=e.period,x=e.unit,v=e.periodicityOnDoubleClick,I=e.mode,T=sn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),C=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(W){return W.toString()})},[t]),O=y.useMemo(function(){return i?i.map(function(W,M){return{value:(x.min===0?M:M+1).toString(),label:W}}):Ct([],Array(x.total),!0).map(function(W,M){var L=x.min===0?M:M+1;return{value:L.toString(),label:Ge(L,x,d,f,h)}})},[i,f,d,h]),V=JSON.stringify(l),$=y.useCallback(function(W){var M=W.value;if(!t||t[0]!==Number(M))return r.jsx(r.Fragment,{});var L=un(mn(t,x),x,d,f,h),te=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:te[1]?"".concat(l.everyText||U.everyText," ").concat(te[1]):L})},[t,V,d,f,h]),P=y.useCallback(function(W){var M=Array.isArray(W)?kt(W):[W],L=M;t&&(L=I==="single"?[]:Ct([],t,!0),M.forEach(function(te){var G=Number(te);L=t.some(function(oe){return oe===G})?L.filter(function(oe){return oe!==G}):kt(Ct(Ct([],L,!0),[G],!1))})),L.length===x.total?a([]):a(L)},[a,t]),B=y.useCallback(function(W){if(W!==0&&W!==1){for(var M=x.total+x.min,L=[],te=x.min;te<M;te++)te%W==0&&L.push(te);var G=t&&L&&t.length===L.length&&t.every(function(ee,se){return ee===L[se]}),oe=L.length===O.length;a(oe||G?[]:L)}else a([])},[t,O,a]),_=y.useRef([]),z=y.useCallback(function(W){if(!u){var M=_.current;M.push({time:new Date().getTime(),value:Number(W)});var L=window.setTimeout(function(){v&&M.length>1&&M[M.length-1].time-M[M.length-2].time<300?M[M.length-1].value===M[M.length-2].value?B(Number(W)):P([M[M.length-2].value,M[M.length-1].value]):P(Number(W)),_.current=[]},300);return function(){window.clearTimeout(L)}}},[_,P,B,u,v]),J=y.useCallback(function(){u||a([])},[a,u]),Y=y.useMemo(function(){var W;return ve(((W={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,W))},[c]),ie=y.useMemo(function(){var W;return ve(((W={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown"]=!0,W["react-js-cron-custom-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown-minutes-large"]=x.type==="minutes"&&g!=="hour"&&g!=="day",W["react-js-cron-custom-select-dropdown-minutes-medium"]=x.type==="minutes"&&(g==="day"||g==="hour"),W["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=x.type==="hours"&&h==="12-hour-clock",W["react-js-cron-custom-select-dropdown-grid"]=!!n,W["".concat(c,"-select-dropdown")]=!!c,W["".concat(c,"-select-dropdown-").concat(x.type)]=!!c,W))},[c,n,h,g]);return r.jsx(b.Select,de({mode:I!=="single"||v?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:C,onClear:J,tagRender:$,className:Y,popupClassName:ie,options:O,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:z,onDeselect:z,disabled:p,dropdownAlign:x.type!=="minutes"&&x.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(x.type)},T))}function hl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-hours")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(it,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:ze[1],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f})]}))}function yl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-minutes")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||U.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||U.prefixMinutes}),r.jsx(it,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:ze[0],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function xl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=!a||a.length===0,g=y.useMemo(function(){var I;return ve(((I={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!h})["".concat(i,"-field")]=!!i,I["".concat(i,"-month-days")]=!!i,I))},[i,h]),x=JSON.stringify(n),v=y.useMemo(function(){return h?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[h,x]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",de({className:g},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(it,{placeholder:v,value:t,setValue:o,unit:ze[2],locale:n,className:i,disabled:l,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function bl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,u=e.mode,f=n.months||U.months,h=y.useMemo(function(){var g;return ve(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-months")]=!!i,g))},[i]);return r.jsxs("div",de({className:h},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(it,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:f,grid:!1,value:t,unit:de(de({},ze[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:u})]}))}function wl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),d.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),d.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),d.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),d.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),d.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=y.useCallback(function(x){l||o(x)},[o,l]),f=y.useMemo(function(){var x;return ve(((x={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(i,"-field")]=!!i,x["".concat(i,"-period")]=!!i,x))},[i]),h=y.useMemo(function(){var x;return ve(((x={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(i,"-select")]=!!i,x))},[i,n.prefixPeriod]),g=y.useMemo(function(){var x;return ve(((x={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(i,"-select-dropdown")]=!!i,x["".concat(i,"-select-dropdown-period")]=!!i,x))},[i]);return r.jsxs("div",de({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:u,options:p,className:h,popupClassName:g,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function vl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.weekDays||U.weekDays,g=p==="week"||!l||l.length===0,x=y.useMemo(function(){var O;return ve(((O={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(i,"-field")]=!!i,O["".concat(i,"-week-days")]=!!i,O))},[i,g]),v=JSON.stringify(n),I=y.useMemo(function(){return g?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[g,v]),T=p==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),C=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",de({className:x},{children:[n.prefixWeekDays!==""&&(p==="week"||!C)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&C&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(it,{placeholder:I,optionsList:h,grid:!1,value:t,unit:de(de({},ze[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function Cl(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,i=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?U:c,p=e.value,u=p===void 0?"":p,f=e.setValue,h=e.displayError,g=h===void 0||h,x=e.onError,v=e.className,I=e.defaultPeriod,T=I===void 0?"day":I,C=e.allowEmpty,O=C===void 0?"for-default-value":C,V=e.humanizeLabels,$=V===void 0||V,P=e.humanizeValue,B=P!==void 0&&P,_=e.disabled,z=_!==void 0&&_,J=e.readOnly,Y=J!==void 0&&J,ie=e.leadingZero,W=ie!==void 0&&ie,M=e.shortcuts,L=M===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:M,te=e.clockFormat,G=e.periodicityOnDoubleClick,oe=G===void 0||G,ee=e.mode,se=ee===void 0?"multiple":ee,qe=e.allowedDropdowns,we=qe===void 0?["period","months","month-days","week-days","hours","minutes"]:qe,He=e.allowedPeriods,Rl=He===void 0?["year","month","week","day","hour","minute","reboot"]:He,Je=y.useRef(u),ro=y.useRef(T),On=y.useState(),Te=On[0],It=On[1],Pn=y.useState(),at=Pn[0],Ft=Pn[1],Mn=y.useState(),Tt=Mn[0],Nt=Mn[1],En=y.useState(),lt=En[0],Dt=En[1],$n=y.useState(),Ot=$n[0],Pt=$n[1],Bn=y.useState(),Mt=Bn[0],Et=Bn[1],Vn=y.useState(!1),so=Vn[0],ct=Vn[1],Wn=y.useState(!1),$t=Wn[0],jn=Wn[1],ec=function(ne){var Se=y.useRef(ne);return y.useEffect(function(){Se.current=ne},[ne]),Se.current}($t),zn=JSON.stringify(d);y.useEffect(function(){dn(u,ct,x,O,Je,!0,d,L,Et,Pt,Ft,Nt,Dt,It)},[]),y.useEffect(function(){u!==Je.current&&dn(u,ct,x,O,Je,!1,d,L,Et,Pt,Ft,Nt,Dt,It)},[u,Je,zn,O,L]),y.useEffect(function(){if(!(Te||Mt||Tt||at||lt||Ot)||$t||ec)$t&&jn(!1);else{var ne=Te||ro.current,Se=pn(ne,Tt,at,lt,Ot,Mt,B);f(Se,{selectedPeriod:ne}),Je.current=Se,x&&x(void 0),ct(!1)}},[Te,at,Tt,lt,Ot,Mt,B,$t]);var Ln=y.useCallback(function(){Ft(void 0),Nt(void 0),Dt(void 0),Pt(void 0),Et(void 0);var ne="",Se=Te!=="reboot"&&Te?Te:ro.current;Se!==Te&&It(Se),l==="fill-with-every"&&(ne=pn(Se,void 0,void 0,void 0,void 0,void 0)),f(ne,{selectedPeriod:Se}),Je.current=ne,jn(!0),O==="never"&&l==="empty"?(ct(!0),cn(x,d)):(x&&x(void 0),ct(!1))},[Te,f,x,l]),tc=y.useMemo(function(){var ne;return ve(((ne={"react-js-cron":!0,"react-js-cron-error":so&&g,"react-js-cron-disabled":z,"react-js-cron-read-only":Y})["".concat(v)]=!!v,ne["".concat(v,"-error")]=so&&g&&!!v,ne["".concat(v,"-disabled")]=z&&!!v,ne["".concat(v,"-read-only")]=Y&&!!v,ne))},[v,so,g,z,Y]),io=i.className,qn=sn(i,["className"]),Un=y.useMemo(function(){var ne;return ve(((ne={"react-js-cron-clear-button":!0})["".concat(v,"-clear-button")]=!!v,ne["".concat(io)]=!!io,ne))},[v,io]),oc=JSON.stringify(qn),Kn=y.useMemo(function(){return o&&!Y?r.jsx(b.Button,de({className:Un,danger:!0,type:"primary",disabled:z},qn,{onClick:Ln},{children:d.clearButtonText||U.clearButtonText})):null},[o,Y,zn,Un,z,oc,Ln]),le=Te||ro.current;return r.jsxs("div",de({className:tc},{children:[we.includes("period")&&r.jsx(wl,{value:le,setValue:It,locale:d,className:v,disabled:z,readOnly:Y,shortcuts:L,allowedPeriods:Rl}),le==="reboot"?Kn:r.jsxs(r.Fragment,{children:[le==="year"&&we.includes("months")&&r.jsx(bl,{value:Tt,setValue:Nt,locale:d,className:v,humanizeLabels:$,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:oe,mode:se}),(le==="year"||le==="month")&&we.includes("month-days")&&r.jsx(xl,{value:at,setValue:Ft,locale:d,className:v,weekDays:lt,disabled:z,readOnly:Y,leadingZero:W,period:le,periodicityOnDoubleClick:oe,mode:se}),(le==="year"||le==="month"||le==="week")&&we.includes("week-days")&&r.jsx(vl,{value:lt,setValue:Dt,locale:d,className:v,humanizeLabels:$,monthDays:at,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:oe,mode:se}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&we.includes("hours")&&r.jsx(hl,{value:Ot,setValue:Pt,locale:d,className:v,disabled:z,readOnly:Y,leadingZero:W,clockFormat:te,period:le,periodicityOnDoubleClick:oe,mode:se}),le!=="minute"&&we.includes("minutes")&&r.jsx(yl,{value:Mt,setValue:Et,locale:d,period:le,className:v,disabled:z,readOnly:Y,leadingZero:W,clockFormat:te,periodicityOnDoubleClick:oe,mode:se}),Kn]})]})]}))}const kl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},xn=[{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 bn(e){return xn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Sl(e){let t;switch(typeof e){case"number":return t=bn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Al({value:e,onChange:t}){const{t:o}=he(),n=bn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:i=>t(i*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Il({value:e=null,onChange:t}){const{t:o}=he(),n=Sl(e);function i(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=kl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
839
838
  display: flex;
840
839
  flex-direction: ${n==="cron"?"column":"row"};
841
840
  align-items: flex-start;
@@ -864,7 +863,7 @@ export default async function (
864
863
  }
865
864
  }
866
865
  }
867
- `,children:[r.jsx(b.Select,{value:n,onChange:i,className:"auto-width",children:yn.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Sl,{value:e,onChange:t}):null,n==="cron"?r.jsx(vl,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const Il={[je.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[je.DATE_FIELD]:{collection:A(w({},fe),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...fe["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:A(w({},st),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${je.DATE_FIELD} && $deps[1]}}`}}}]})}},Fl=[{value:je.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:je.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Tl=()=>{const{values:e={},clearFormGraph:t}=k.useForm(),[o,n]=y.useState(e.mode);return k.useFormEffects(()=>{k.onFieldValueChange("mode",i=>{n(i.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Fl},required:!0,default:je.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
866
+ `,children:[r.jsx(b.Select,{value:n,onChange:i,className:"auto-width",children:xn.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Al,{value:e,onChange:t}):null,n==="cron"?r.jsx(Cl,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const Fl={[je.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[je.DATE_FIELD]:{collection:A(w({},fe),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...fe["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:A(w({},st),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${je.DATE_FIELD} && $deps[1]}}`}}}]})}},Tl=[{value:je.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:je.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Nl=()=>{const{values:e={},clearFormGraph:t}=S.useForm(),[o,n]=y.useState(e.mode);return S.useFormEffects(()=>{S.onFieldValueChange("mode",i=>{n(i.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Tl},required:!0,default:je.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
868
867
  .ant-input-number {
869
868
  width: auto;
870
869
  min-width: 6em;
@@ -873,4 +872,4 @@ export default async function (
873
872
  .ant-picker {
874
873
  width: auto;
875
874
  }
876
- `},properties:Il[o]}}},components:{OnField:nn,RepeatField:Al,EndsByField:ml}})]})};class Nl extends Ye{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:Tl}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===je.DATE_FIELD){const[c]=me(A(w({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const to={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: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=xr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(ne.Link,{to:Ve(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:pt}}]},bn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:to,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=he(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return D(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},oo=bn();function Dl(n){var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const{workflow:a}=q(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))}function Ol(){var se;const e=ne.useNavigate(),{t}=Q.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=y.useState(!1),[u,f]=y.useState(!1),[h,g]=y.useState(null),{styles:x}=xe(),{modal:v}=b.App.useApp();if(y.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const W=(se=n==null?void 0:n.data)!=null?se:{},{nodes:I=[],revisions:T=[]}=W,C=K(W,["nodes","revisions"]);ft(I);const O=I.find(M=>!M.upstream);function V({key:M}){M!==C.id&&e(Ve(M))}function $(M){return D(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return D(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(ht(M.executionId))})}function B(){return D(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key},values:{color:C.color}});b.message.success(t("Operation succeeded")),e(Ve(M.id))})}function _(){return D(this,null,function*(){const M=C.current?F("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:M,onOk(){return D(this,null,function*(){var ee;yield l.destroy({filterByTk:C.id}),b.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Ve((ee=T.find(G=>G.current))==null?void 0:ee.id))})}})})}const z=()=>D(null,null,function*(){h?(yield l.moveWorkflow({id:C.id,targetKey:h}),b.message.success(F("Move success")),f(!1),C.key=h,i()):b.message.error(F("Select target workflow"))});function J(L){return D(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return B();case"delete":return _();case"move":g(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(Ee.Provider,{value:{workflow:C,nodes:I,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(vo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ne.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:V,defaultSelectedKeys:[`${C.id}`],className:s.cx(x.dropdownClass,x.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:E.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:C.enabled,onChange:$,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:oo,components:{ExecutionResourceProvider:Dl,ExecutionLink:Ht,ExecutionStatusColumn:_t},scope:{ExecutionRetryAction:Jt}})})]})]}),r.jsx(wo,{entry:O}),r.jsxs(b.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:h,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>g(M)})]})]})}const wn=()=>{const e=ne.useParams(),{styles:t}=xe();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Ol}})})},vn=y.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),no=()=>y.useContext(vn),Pl=k.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),Ml=()=>{const e=k.useForm(),t=s.useActionContext(),{refresh:o}=no(),n=s.useAPIClient();return{run(){return D(this,null,function*(){yield e.submit();const a=ie.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:w({},a)}),t.setVisible(!1),yield e.reset(),o()})}}},El=e=>r.jsx(Cn,w({},e)),Cn=e=>{const{scope:t,getContainer:o,children:n}=e,[i,a]=y.useState(!1),{t:l}=he();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:a},children:[r.jsx("div",{onClick:()=>a(!0),title:l("Add category"),children:n||r.jsx(j.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:$l,components:{CollectionCategory:Pl},scope:w({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:Ml},t)})]})},$l={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}},Bl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},Vl=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},Wl=()=>{const e=k.useForm(),t=s.useActionContext(),{refresh:o}=no(),n=s.useAPIClient(),{id:i}=s.useRecord();return{run(){return D(this,null,function*(){yield e.submit();const l=ie.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:i},values:w({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},jl=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:ie.cloneDeep(t)}),A(w({},e),{manual:!0})),n=s.useActionContext();return y.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},zl=e=>r.jsx(kn,w({},e)),kn=e=>{const{scope:t,getContainer:o,item:n,children:i}=e,[a,l]=y.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l},children:[r.jsx(r.Fragment,{children:i||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:Ll,scope:w({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:Wl,useValuesFromRecord:jl},t)})]})})},Ll={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},ql=n=>{var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const a=s.useCollectionRecordData(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))},At=k.observable({value:""}),Le={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("workflow Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:N("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},Sn={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},ge={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},An={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Le.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:ge.title,category:ge.category,type:ge.type,sync:ge.sync,description:ge.description,options:ge.options}}}}}}}},In={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Le.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Le,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:ge.title,category:ge.category,type:ge.type,enabled:ge.enabled,sync:ge.sync,description:ge.description,options:ge.options}}}}}}}},Ul={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=k.useForm();return{run(){return D(this,null,function*(){yield o.revision({filterByTk:i,values:a}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},Kl={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:'{ "data":{} }',"x-component":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},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}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=k.useForm();return{run(){return D(this,null,function*(){try{const c=JSON.parse(a.params);yield o.test({filterByTk:i,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function _l(e){const{isOver:t,setNodeRef:o}=Me.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function Gl(e){const{attributes:t,listeners:o,setNodeRef:n}=Me.useDraggable({id:e.id,data:e.data});return r.jsx("div",A(w(w({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const Hl=k.observer(({item:e})=>r.jsx(_l,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(Gl,{id:e.id.toString(),data:e,children:r.jsx(Fn,{item:e})})})}),{displayName:"TabTitle"}),Fn=({item:e})=>{const{t}=Q.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},Jl=k.observer(e=>{const[t,o]=y.useState(null),{refresh:n}=no(),i=s.useAPIClient(),a=p=>D(null,null,function*(){const{active:u,over:f}=p;setTimeout(()=>{o(null)}),f&&f.id!==u.id&&(yield i.resource("workflowCategories").move({sourceId:u.id,targetId:f.id}),n())});function l(p){var u;o((u=p.active)==null?void 0:u.data.current)}const c=Me.useSensor(Me.MouseSensor,{activationConstraint:{distance:10}}),d=Me.useSensors(c);return r.jsxs(Me.DndContext,{sensors:d,onDragEnd:a,onDragStart:l,children:[e.children,r.jsx(Me.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(Fn,{item:t})}):null})]})},{displayName:"DndProvider"}),Yl=({children:e})=>{const t=s.useAPIClient(),[o,n]=y.useState([]),[i,a]=y.useState(!0),[l,c]=y.useState({tab:""}),d=s.useCompile(),{modal:p}=b.App.useApp(),u=y.useCallback(()=>D(null,null,function*(){a(!0);const{data:g}=yield t.request({url:"workflowCategories:list",params:{paginate:!1,sort:["sort"]}});n(g.data),a(!1)}),[]);y.useEffect(()=>{u()},[u]);const f=g=>{p.confirm({title:d("{{t('Delete category')}}"),content:d("{{t('Are you sure you want to delete it?')}}"),onOk:()=>D(null,null,function*(){yield t.resource("workflowCategories").destroy({filter:{id:g}}),c({tab:""}),At.value="",u()})})},h=ie.memoize(g=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[k.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:g}}}}})},{key:"delete",label:d("{{t('Delete category')}}"),onClick:()=>f(g.id)}]}));return r.jsx(vn.Provider,{value:{refresh:u,activeKey:l.tab,setActiveKey:g=>c({tab:g})},children:r.jsx(Jl,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary"}}}}}),type:"editable-card",activeKey:l.tab,onChange:g=>{c({tab:g}),At.value=g,g===""&&u()},defaultActiveKey:l.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:F("All"),closable:!1}].concat(o).filter(g=>g&&g.name!=null&&g.id!=null).map(g=>({label:g.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(Hl,{item:g})}):d(g.name),key:g.id,closable:g.closable,closeIcon:r.jsx(b.Dropdown,{menu:h(g),children:r.jsx(j.MenuOutlined,{role:"button","aria-label":d(g.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:e})}))})})})},Tn={type:"void",properties:{provider:{type:"void","x-decorator":k.observer(e=>{const t={collection:Le,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return At.value&&(t.params.filter["category.id"]=[At.value]),r.jsx(s.TableBlockProvider,w(w({},e),t))}),"x-component":Yl,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-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},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(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=k.useForm();return{run(){return D(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:A(w({},l),{workflow:d})}),b.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:An}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"workflows.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return y.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:oo}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:In,revision:Ul,test:Kl,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return D(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});en.saveAs(a,i.data.title+"-"+i.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},Ql=()=>{const{t:e}=Q.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(ne.Link,{"aria-label":n(),to:Ve(t),onClick:()=>o(!1),children:e("Configure")})};function Zl(e){const t=k.useField(),o=s.usePlugin(X);return k.useFormEffects(()=>{k.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Ie,w({},e))}function Nn(e){const{schema:t=Tn,components:o,scopes:n}=e,i=y.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(X);return r.jsx(s.ExtendCollectionsProvider,{collections:[Le,to,Sn],children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:w({WorkflowLink:Ql,ExecutionResourceProvider:ql,ExecutionLink:Ht,OpenDrawer:Oo,ExecutionStatusSelect:Mo,SyncOptionSelect:Zl,ExecutionStatusColumn:_t,ColumnShowTitle:Vl,ColumnShowCollection:Bl,AddWorkflowCategory:El,AddWorkflowCategoryAction:Cn,EditWorkflowCategory:zl,EditWorkflowCategoryAction:kn},o),scope:w({getTriggersOptions:a,ExecutionRetryAction:Jt},n)})})})}class X extends s.Plugin{constructor(){super(...arguments),this.triggers=new E.Registry,this.instructions=new E.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=K(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof H)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return D(this,null,function*(){yield this.pm.add(ya),yield this.pm.add(pa),yield this.pm.add(ca),yield this.pm.add(oi),yield this.pm.add(ms),yield this.pm.add(Lr),yield this.pm.add(Pr),yield this.pm.add(Tr),yield this.pm.add(ga),yield this.pm.add(is),yield this.pm.add(Sa),yield this.pm.add(ma),yield this.pm.add(aa),yield this.pm.add(wa),yield this.pm.add(Zi),yield this.pm.add(ds),yield this.pm.add(ls)})}load(){return D(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Nn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:wn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Co,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(cl),this.registerTrigger("collection",pl),this.registerTrigger("schedule",Nl),this.registerInstruction("calculation",Aa),this.registerInstruction("condition",Za),this.registerInstruction("end",nl),this.registerInstruction("updateorcreate",ll),this.registerInstruction("query",rl),this.registerInstruction("create",tl),this.registerInstruction("update",il),this.registerInstruction("destroy",ol)})}addComponents(){this.app.addComponents({WorkflowLink:Jn,WorkflowPage:wn,ExecutionPage:Co})}}S.AddButton=Vt,S.AdditionNotifiedPerson=ts,S.AutoResizeInput=Eo,S.BaseTypeSets=De,S.Branch=Be,S.BuiltinGroupType=Ue,S.CheckboxGroupWithTooltip=Do,S.CollectionBlockInitializer=Ne,S.ConfigButtonMessage=ns,S.DetailsBlockProvider=Wt,S.EXECUTION_STATUS=pe,S.ExecutionContextProvider=Yo,S.ExecutionLink=Ht,S.ExecutionRetryAction=Jt,S.ExecutionStatusColumn=_t,S.ExecutionStatusOptions=pt,S.ExecutionStatusOptionsMap=ut,S.ExecutionStatusSelect=Mo,S.FieldsSelect=et,S.FilterDynamicComponent=Ae,S.FlowContext=Ee,S.Instruction=H,S.JOB_STATUS=be,S.JobStatusOptions=mt,S.JobStatusOptionsMap=Xe,S.Node=mo,S.NodeDefaultView=nt,S.OpenDrawer=Oo,S.ProviderContextNode=uo,S.ProviderContextWorkflow=Zn,S.RadioWithTooltip=Ie,S.SelectNotifiedPerson=Zr,S.SimpleDesigner=Kt,S.Trigger=Ye,S.ValueBlock=ke,S.WorkflowPane=Nn,S.WorkflowVariableCodeMirror=Hr,S.WorkflowVariableInput=Ce,S.WorkflowVariableJSON=No,S.WorkflowVariableRawTextArea=To,S.WorkflowVariableTextArea=ot,S.collectionWorkflowCategories=Sn,S.collectionWorkflows=Le,S.createWorkflow=An,S.currentFormOptions=So,S.default=X,S.defaultFieldNames=ue,S.executionCollection=to,S.executionSchema=oo,S.getCollectionFieldOptions=me,S.getExecutionSchema=bn,S.getWorkflowDetailPath=Ve,S.getWorkflowExecutionsPath=ht,S.isValidFilter=Re,S.linkNodes=ft,S.nodesOptions=yt,S.scopeOptions=jt,S.systemOptions=Ao,S.traverseSchema=gt,S.triggerOptions=xt,S.updateWorkflow=In,S.useAvailableUpstreams=$e,S.useContextNode=ye,S.useFlowContext=q,S.useGetAriaLabelOfAddButton=dt,S.useRecordTriggerWorkflowsActionProps=ri,S.useStyles=xe,S.useTrigger=Qe,S.useTriggerWorkflowsActionProps=ni,S.useWorkflowAnyExecuted=$o,S.useWorkflowExecuted=Gt,S.useWorkflowVariableFormOptions=Fo,S.useWorkflowVariableOptions=ce,S.workflowFieldset=ge,S.workflowSchema=Tn,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
875
+ `},properties:Fl[o]}}},components:{OnField:rn,RepeatField:Il,EndsByField:fl}})]})};class Dl extends Ye{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:Nl}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===je.DATE_FIELD){const[c]=me(A(w({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:t.collection,dataPath:"$context.data"}:null}}const to={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: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=br(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(re.Link,{to:Ve(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:pt}}]},wn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:to,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=he(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return D(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},oo=wn();function Ol(n){var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const{workflow:a}=q(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))}function Pl(){var ie;const e=re.useNavigate(),{t}=Q.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=y.useState(!1),[u,f]=y.useState(!1),[h,g]=y.useState(null),{styles:x}=xe(),{modal:v}=b.App.useApp();if(y.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const W=(ie=n==null?void 0:n.data)!=null?ie:{},{nodes:I=[],revisions:T=[]}=W,C=K(W,["nodes","revisions"]);ft(I);const O=I.find(M=>!M.upstream);function V({key:M}){M!==C.id&&e(Ve(M))}function $(M){return D(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return D(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(ht(M.executionId))})}function B(){return D(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key},values:{color:C.color}});b.message.success(t("Operation succeeded")),e(Ve(M.id))})}function _(){return D(this,null,function*(){const M=C.current?F("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:M,onOk(){return D(this,null,function*(){var te;yield l.destroy({filterByTk:C.id}),b.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Ve((te=T.find(G=>G.current))==null?void 0:te.id))})}})})}const z=()=>D(null,null,function*(){h?(yield l.moveWorkflow({id:C.id,targetKey:h}),b.message.success(F("Move success")),f(!1),C.key=h,i()):b.message.error(F("Select target workflow"))});function J(L){return D(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return B();case"delete":return _();case"move":g(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(Ee.Provider,{value:{workflow:C,nodes:I,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(Co,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:V,defaultSelectedKeys:[`${C.id}`],className:s.cx(x.dropdownClass,x.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:E.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:C.enabled,onChange:$,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:oo,components:{ExecutionResourceProvider:Ol,ExecutionLink:Ht,ExecutionStatusColumn:_t},scope:{ExecutionRetryAction:Jt}})})]})]}),r.jsx(vo,{entry:O}),r.jsxs(b.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:h,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>g(M)})]})]})}const vn=()=>{const e=re.useParams(),{styles:t}=xe();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Pl}})})},Cn=y.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),no=()=>y.useContext(Cn),Ml=S.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),El=()=>{const e=S.useForm(),t=s.useActionContext(),{refresh:o}=no(),n=s.useAPIClient();return{run(){return D(this,null,function*(){yield e.submit();const a=R.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:w({},a)}),t.setVisible(!1),yield e.reset(),o()})}}},$l=e=>r.jsx(kn,w({},e)),kn=e=>{const{scope:t,getContainer:o,children:n}=e,[i,a]=y.useState(!1),{t:l}=he();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:a},children:[r.jsx("div",{onClick:()=>a(!0),title:l("Add category"),children:n||r.jsx(j.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:Bl,components:{CollectionCategory:Ml},scope:w({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:El},t)})]})},Bl={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}},Vl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},Wl=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},jl=()=>{const e=S.useForm(),t=s.useActionContext(),{refresh:o}=no(),n=s.useAPIClient(),{id:i}=s.useRecord();return{run(){return D(this,null,function*(){yield e.submit();const l=R.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:i},values:w({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},zl=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:R.cloneDeep(t)}),A(w({},e),{manual:!0})),n=s.useActionContext();return y.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},Ll=e=>r.jsx(Sn,w({},e)),Sn=e=>{const{scope:t,getContainer:o,item:n,children:i}=e,[a,l]=y.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l},children:[r.jsx(r.Fragment,{children:i||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:ql,scope:w({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:jl,useValuesFromRecord:zl},t)})]})})},ql={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},Ul=n=>{var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const a=s.useCollectionRecordData(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))},At=S.observable({value:""}),Le={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("workflow Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:N("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},An={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},ge={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},In={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Le.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:ge.title,category:ge.category,type:ge.type,sync:ge.sync,description:ge.description,options:ge.options}}}}}}}},Fn={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Le.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Le,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:ge.title,category:ge.category,type:ge.type,enabled:ge.enabled,sync:ge.sync,description:ge.description,options:ge.options}}}}}}}},Kl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return D(this,null,function*(){yield o.revision({filterByTk:i,values:a}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},_l={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:'{ "data":{} }',"x-component":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},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}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return D(this,null,function*(){try{const c=JSON.parse(a.params);yield o.test({filterByTk:i,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function Gl(e){const{isOver:t,setNodeRef:o}=Me.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function Hl(e){const{attributes:t,listeners:o,setNodeRef:n}=Me.useDraggable({id:e.id,data:e.data});return r.jsx("div",A(w(w({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const Jl=S.observer(({item:e})=>r.jsx(Gl,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(Hl,{id:e.id.toString(),data:e,children:r.jsx(Tn,{item:e})})})}),{displayName:"TabTitle"}),Tn=({item:e})=>{const{t}=Q.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},Yl=S.observer(e=>{const[t,o]=y.useState(null),{refresh:n}=no(),i=s.useAPIClient(),a=p=>D(null,null,function*(){const{active:u,over:f}=p;setTimeout(()=>{o(null)}),f&&f.id!==u.id&&(yield i.resource("workflowCategories").move({sourceId:u.id,targetId:f.id}),n())});function l(p){var u;o((u=p.active)==null?void 0:u.data.current)}const c=Me.useSensor(Me.MouseSensor,{activationConstraint:{distance:10}}),d=Me.useSensors(c);return r.jsxs(Me.DndContext,{sensors:d,onDragEnd:a,onDragStart:l,children:[e.children,r.jsx(Me.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(Tn,{item:t})}):null})]})},{displayName:"DndProvider"}),Ql=({children:e})=>{const t=s.useAPIClient(),[o,n]=y.useState([]),[i,a]=y.useState(!0),[l,c]=y.useState({tab:""}),d=s.useCompile(),{modal:p}=b.App.useApp(),u=y.useCallback(()=>D(null,null,function*(){a(!0);const{data:g}=yield t.request({url:"workflowCategories:list",params:{paginate:!1,sort:["sort"]}});n(g.data),a(!1)}),[]);y.useEffect(()=>{u()},[u]);const f=g=>{p.confirm({title:d("{{t('Delete category')}}"),content:d("{{t('Are you sure you want to delete it?')}}"),onOk:()=>D(null,null,function*(){yield t.resource("workflowCategories").destroy({filter:{id:g}}),c({tab:""}),At.value="",u()})})},h=R.memoize(g=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[S.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:g}}}}})},{key:"delete",label:d("{{t('Delete category')}}"),onClick:()=>f(g.id)}]}));return r.jsx(Cn.Provider,{value:{refresh:u,activeKey:l.tab,setActiveKey:g=>c({tab:g})},children:r.jsx(Yl,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary"}}}}}),type:"editable-card",activeKey:l.tab,onChange:g=>{c({tab:g}),At.value=g,g===""&&u()},defaultActiveKey:l.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:F("All"),closable:!1}].concat(o).filter(g=>g&&g.name!=null&&g.id!=null).map(g=>({label:g.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(Jl,{item:g})}):d(g.name),key:g.id,closable:g.closable,closeIcon:r.jsx(b.Dropdown,{menu:h(g),children:r.jsx(j.MenuOutlined,{role:"button","aria-label":d(g.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:e})}))})})})},Nn={type:"void",properties:{provider:{type:"void","x-decorator":S.observer(e=>{const t={collection:Le,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return At.value&&(t.params.filter["category.id"]=[At.value]),r.jsx(s.TableBlockProvider,w(w({},e),t))}),"x-component":Ql,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-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},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(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=S.useForm();return{run(){return D(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:A(w({},l),{workflow:d})}),b.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:In}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"workflows.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return y.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:oo}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:Fn,revision:Kl,test:_l,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return D(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});tn.saveAs(a,i.data.title+"-"+i.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},Zl=()=>{const{t:e}=Q.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(re.Link,{"aria-label":n(),to:Ve(t),onClick:()=>o(!1),children:e("Configure")})};function Xl(e){const t=S.useField(),o=s.usePlugin(X);return S.useFormEffects(()=>{S.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Ie,w({},e))}function Dn(e){const{schema:t=Nn,components:o,scopes:n}=e,i=y.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(X);return r.jsx(s.ExtendCollectionsProvider,{collections:[Le,to,An],children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:w({WorkflowLink:Zl,ExecutionResourceProvider:Ul,ExecutionLink:Ht,OpenDrawer:Po,ExecutionStatusSelect:Eo,SyncOptionSelect:Xl,ExecutionStatusColumn:_t,ColumnShowTitle:Wl,ColumnShowCollection:Vl,AddWorkflowCategory:$l,AddWorkflowCategoryAction:kn,EditWorkflowCategory:Ll,EditWorkflowCategoryAction:Sn},o),scope:w({getTriggersOptions:a,ExecutionRetryAction:Jt},n)})})})}class X extends s.Plugin{constructor(){super(...arguments),this.triggers=new E.Registry,this.instructions=new E.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=K(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof H)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return D(this,null,function*(){yield this.pm.add(xa),yield this.pm.add(ua),yield this.pm.add(da),yield this.pm.add(ni),yield this.pm.add(fs),yield this.pm.add(qr),yield this.pm.add(Mr),yield this.pm.add(Nr),yield this.pm.add(ha),yield this.pm.add(as),yield this.pm.add(Aa),yield this.pm.add(fa),yield this.pm.add(la),yield this.pm.add(va),yield this.pm.add(Xi),yield this.pm.add(ps),yield this.pm.add(cs)})}load(){return D(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Dn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:vn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:ko,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(dl),this.registerTrigger("collection",ul),this.registerTrigger("schedule",Dl),this.registerInstruction("calculation",Ia),this.registerInstruction("condition",Xa),this.registerInstruction("end",rl),this.registerInstruction("updateorcreate",cl),this.registerInstruction("query",sl),this.registerInstruction("create",ol),this.registerInstruction("update",al),this.registerInstruction("destroy",nl)})}addComponents(){this.app.addComponents({WorkflowLink:Yn,WorkflowPage:vn,ExecutionPage:ko})}}k.AddButton=Vt,k.AdditionNotifiedPerson=os,k.AutoResizeInput=$o,k.BaseTypeSets=De,k.Branch=Be,k.BuiltinGroupType=Ue,k.CheckboxGroupWithTooltip=Oo,k.CollectionBlockInitializer=Ne,k.ConfigButtonMessage=rs,k.DetailsBlockProvider=Wt,k.EXECUTION_STATUS=pe,k.ExecutionContextProvider=Qo,k.ExecutionLink=Ht,k.ExecutionRetryAction=Jt,k.ExecutionStatusColumn=_t,k.ExecutionStatusOptions=pt,k.ExecutionStatusOptionsMap=ut,k.ExecutionStatusSelect=Eo,k.FieldsSelect=et,k.FilterDynamicComponent=Ae,k.FlowContext=Ee,k.Instruction=H,k.JOB_STATUS=be,k.JobStatusOptions=mt,k.JobStatusOptionsMap=Xe,k.Node=fo,k.NodeDefaultView=nt,k.OpenDrawer=Po,k.ProviderContextNode=mo,k.ProviderContextWorkflow=Xn,k.RadioWithTooltip=Ie,k.SelectNotifiedPerson=Xr,k.SimpleDesigner=Kt,k.Trigger=Ye,k.ValueBlock=ke,k.WorkflowPane=Dn,k.WorkflowVariableCodeMirror=Jr,k.WorkflowVariableInput=Ce,k.WorkflowVariableJSON=Do,k.WorkflowVariableRawTextArea=No,k.WorkflowVariableTextArea=ot,k.collectionWorkflowCategories=An,k.collectionWorkflows=Le,k.createWorkflow=In,k.currentFormOptions=Ao,k.default=X,k.defaultFieldNames=ue,k.executionCollection=to,k.executionSchema=oo,k.getCollectionFieldOptions=me,k.getExecutionSchema=wn,k.getWorkflowDetailPath=Ve,k.getWorkflowExecutionsPath=ht,k.isValidFilter=Re,k.linkNodes=ft,k.nodesOptions=yt,k.scopeOptions=jt,k.systemOptions=Io,k.traverseSchema=gt,k.triggerOptions=xt,k.updateWorkflow=Fn,k.useAvailableUpstreams=$e,k.useContextNode=ye,k.useFlowContext=q,k.useGetAriaLabelOfAddButton=dt,k.useRecordTriggerWorkflowsActionProps=si,k.useStyles=xe,k.useTrigger=Qe,k.useTriggerWorkflowsActionProps=ri,k.useWorkflowAnyExecuted=Bo,k.useWorkflowExecuted=Gt,k.useWorkflowVariableFormOptions=To,k.useWorkflowVariableOptions=ce,k.workflowFieldset=ge,k.workflowSchema=Nn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});