@nocobase/plugin-workflow 0.14.0-alpha.4 → 0.14.0-alpha.6
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.
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("react"),require("react-i18next"),require("@formily/react"),require("@nocobase/utils/client"),require("@formily/core"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client"),require("lodash"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@ant-design/icons","antd","react","react-i18next","@formily/react","@nocobase/utils/client","@formily/core","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client","lodash","@emotion/css"],r):(O=typeof globalThis!="undefined"?globalThis:O||self,r(O["@nocobase/plugin-workflow"]={},O.jsxRuntime,O["@nocobase/client"],O["@ant-design/icons"],O.antd,O.react,O["react-i18next"],O["@formily/react"],O["@nocobase/utils"],O["@formily/core"],O["react-router-dom"],O.dayjs,O["@formily/antd-v5"],O["@nocobase/evaluators"],O.lodash,O["@emotion/css"]))})(this,function(O,r,i,P,x,b,te,I,L,me,he,bo,Se,Je,xo,
|
|
1
|
+
(function(O,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("react"),require("react-i18next"),require("@formily/react"),require("@nocobase/utils/client"),require("@formily/core"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client"),require("lodash"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@ant-design/icons","antd","react","react-i18next","@formily/react","@nocobase/utils/client","@formily/core","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client","lodash","@emotion/css"],r):(O=typeof globalThis!="undefined"?globalThis:O||self,r(O["@nocobase/plugin-workflow"]={},O.jsxRuntime,O["@nocobase/client"],O["@ant-design/icons"],O.antd,O.react,O["react-i18next"],O["@formily/react"],O["@nocobase/utils"],O["@formily/core"],O["react-router-dom"],O.dayjs,O["@formily/antd-v5"],O["@nocobase/evaluators"],O.lodash,O["@emotion/css"]))})(this,function(O,r,i,P,x,b,te,I,L,me,he,bo,Se,Je,xo,Jr){"use strict";var Xg=Object.defineProperty,Rg=Object.defineProperties;var ev=Object.getOwnPropertyDescriptors;var Et=Object.getOwnPropertySymbols;var Hr=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable;var Wr=(O,r,i)=>r in O?Xg(O,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):O[r]=i,v=(O,r)=>{for(var i in r||(r={}))Hr.call(r,i)&&Wr(O,i,r[i]);if(Et)for(var i of Et(r))qr.call(r,i)&&Wr(O,i,r[i]);return O},C=(O,r)=>Rg(O,ev(r));var Kr=O=>typeof O=="symbol"?O:O+"",q=(O,r)=>{var i={};for(var P in O)Hr.call(O,P)&&r.indexOf(P)<0&&(i[P]=O[P]);if(O!=null&&Et)for(var P of Et(O))r.indexOf(P)<0&&qr.call(O,P)&&(i[P]=O[P]);return i};var K=(O,r,i)=>new Promise((P,x)=>{var b=L=>{try{I(i.next(L))}catch(me){x(me)}},te=L=>{try{I(i.throw(L))}catch(me){x(me)}},I=L=>L.done?P(L.value):Promise.resolve(L.value).then(b,te);I((i=i.apply(O,r)).next())});const Ye=b.createContext({});function z(){return b.useContext(Ye)}const d="workflow";function T(e,t={}){return i.i18n.t(e,C(v({},t),{ns:d}))}function Mt(){return te.useTranslation(d)}const Yr=i.createStyles(({css:e,token:t})=>({container:e`
|
|
2
2
|
margin-bottom: 1.5em;
|
|
3
3
|
padding: 1em;
|
|
4
4
|
background-color: ${t.colorFillAlter};
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
p {
|
|
24
24
|
color: ${t.colorTextDescription};
|
|
25
25
|
}
|
|
26
|
-
`}));function Co(e){const{label:t,title:o,description:n}=e,{styles:s}=
|
|
26
|
+
`}));function Co(e){const{label:t,title:o,description:n}=e,{styles:s}=Yr();return r.jsxs("div",{className:i.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(x.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}const be={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5},_t=[{value:be.QUEUEING,label:`{{t("Queueing", { ns: "${d}" })}}`,color:"blue",icon:r.jsx(P.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${d}" })}}`},{value:be.STARTED,label:`{{t("On going", { ns: "${d}" })}}`,color:"gold",icon:r.jsx(P.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${d}" })}}`},{value:be.RESOLVED,label:`{{t("Resolved", { ns: "${d}" })}}`,color:"green",icon:r.jsx(P.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${d}" })}}`},{value:be.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${d}" })}}`},{value:be.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${d}" })}}`},{value:be.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${d}" })}}`},{value:be.CANCELED,label:`{{t("Canceled", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(P.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${d}" })}}`},{value:be.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(P.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${d}" })}}`}],jt=_t.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),oe={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5},Bt=[{value:oe.PENDING,label:`{{t("Pending", { ns: "${d}" })}}`,color:"gold",icon:r.jsx(P.ClockCircleOutlined,{})},{value:oe.RESOLVED,label:`{{t("Resolved", { ns: "${d}" })}}`,color:"green",icon:r.jsx(P.CheckOutlined,{})},{value:oe.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.ExclamationOutlined,{})},{value:oe.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.CloseOutlined,{})},{value:oe.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:r.jsx(P.MinusOutlined,{rotate:90})},{value:oe.CANCELED,label:`{{t("Canceled", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(P.MinusOutlined,{rotate:45})},{value:oe.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(P.MinusOutlined,{})}],ut=Bt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),se=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
27
27
|
flex-grow: 1;
|
|
28
28
|
overflow: hidden;
|
|
29
29
|
display: flex;
|
|
@@ -344,18 +344,18 @@
|
|
|
344
344
|
border-radius: 50%;
|
|
345
345
|
background-color: ${t.colorText};
|
|
346
346
|
color: ${t.colorBgContainer};
|
|
347
|
-
`}));function
|
|
347
|
+
`}));function Zr(){return!0}const Vt=I.observer(e=>{const c=e,{filter:t=Zr}=c,o=q(c,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),{values:a}=I.useForm(),l=s(a==null?void 0:a.collection);return r.jsx(x.Select,C(v({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(u=>{var p;return{label:n((p=u.uiSchema)==null?void 0:p.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Lt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{Lt(e.properties[o],t)})}function ke(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(s=>{n.push(...ke(e.properties[s],t))}),n):n}function Qr(s){var a=s,{insert:e,collection:t,dataSource:o}=a,n=q(a,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager(),u=i.useRecordCollectionDataSourceItems("FormItem"),p=c(t);function m(g){return K(this,arguments,function*({item:h}){const f=h.template?yield l(h):null,y={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:t,dataSource:o},"x-component":"CardItem","x-component-props":{title:n.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:f||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};Lt(y,w=>{w["x-uid"]&&delete w["x-uid"]}),e(y)})}return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:m,items:u}))}function Me(e){return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(Qr,v({},e))})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},wo={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
|
|
348
348
|
flex-direction: column;
|
|
349
349
|
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${d}" })}}`},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=I.useForm();return{options:i.useCollectionFilterOptions(e==null?void 0:e.collection),className:i.css`
|
|
350
350
|
position: relative;
|
|
351
351
|
width: 100%;
|
|
352
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},Qr={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"}}},Xr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",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}}}}}}},je={type:"array",title:`{{t("Preload associations", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){const{values:e}=I.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Be={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Rr=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Be.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Be.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Be.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Be.DELETED}],$o={title:`{{t("Collection event", { ns: "${d}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${d}" })}}`,className:"auto-width"},enum:Rr,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Be.UPDATED})}}`}}}]},condition:C(v({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:_e["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},je),{"x-reactions":[...je["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Be.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:Vt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}}];return xe(C(v({},t),{fields:s,appends:["data",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};var dt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function So(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function es(e,t){for(var o=-1,n=e==null?0:e.length,s=Array(n);++o<n;)s[o]=t(e[o],o,e);return s}var ko=es;function ts(){this.__data__=[],this.size=0}var os=ts;function ns(e,t){return e===t||e!==e&&t!==t}var Ao=ns,rs=Ao;function ss(e,t){for(var o=e.length;o--;)if(rs(e[o][0],t))return o;return-1}var pt=ss,as=pt,is=Array.prototype,ls=is.splice;function cs(e){var t=this.__data__,o=as(t,e);if(o<0)return!1;var n=t.length-1;return o==n?t.pop():ls.call(t,o,1),--this.size,!0}var us=cs,ds=pt;function ps(e){var t=this.__data__,o=ds(t,e);return o<0?void 0:t[o][1]}var ms=ps,fs=pt;function hs(e){return fs(this.__data__,e)>-1}var ys=hs,gs=pt;function vs(e,t){var o=this.__data__,n=gs(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var bs=vs,xs=os,Cs=us,ws=ms,$s=ys,Ss=bs;function Ve(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=xs,Ve.prototype.delete=Cs,Ve.prototype.get=ws,Ve.prototype.has=$s,Ve.prototype.set=Ss;var mt=Ve,ks=mt;function As(){this.__data__=new ks,this.size=0}var Ts=As;function Os(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Fs=Os;function Is(e){return this.__data__.get(e)}var Ds=Is;function Ns(e){return this.__data__.has(e)}var Ps=Ns,Es=typeof dt=="object"&&dt&&dt.Object===Object&&dt,To=Es,Ms=To,_s=typeof self=="object"&&self&&self.Object===Object&&self,js=Ms||_s||Function("return this")(),ye=js,Bs=ye,Vs=Bs.Symbol,Ze=Vs,Oo=Ze,Fo=Object.prototype,Ls=Fo.hasOwnProperty,zs=Fo.toString,Qe=Oo?Oo.toStringTag:void 0;function Us(e){var t=Ls.call(e,Qe),o=e[Qe];try{e[Qe]=void 0;var n=!0}catch(a){}var s=zs.call(e);return n&&(t?e[Qe]=o:delete e[Qe]),s}var Gs=Us,Ws=Object.prototype,Hs=Ws.toString;function qs(e){return Hs.call(e)}var Ks=qs,Io=Ze,Js=Gs,Ys=Ks,Zs="[object Null]",Qs="[object Undefined]",Do=Io?Io.toStringTag:void 0;function Xs(e){return e==null?e===void 0?Qs:Zs:Do&&Do in Object(e)?Js(e):Ys(e)}var Le=Xs;function Rs(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xe=Rs,ea=Le,ta=Xe,oa="[object AsyncFunction]",na="[object Function]",ra="[object GeneratorFunction]",sa="[object Proxy]";function aa(e){if(!ta(e))return!1;var t=ea(e);return t==na||t==ra||t==oa||t==sa}var No=aa,ia=ye,la=ia["__core-js_shared__"],ca=la,zt=ca,Po=function(){var e=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ua(e){return!!Po&&Po in e}var da=ua,pa=Function.prototype,ma=pa.toString;function fa(e){if(e!=null){try{return ma.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Eo=fa,ha=No,ya=da,ga=Xe,va=Eo,ba=/[\\^$.*+?()[\]{}|]/g,xa=/^\[object .+?Constructor\]$/,Ca=Function.prototype,wa=Object.prototype,$a=Ca.toString,Sa=wa.hasOwnProperty,ka=RegExp("^"+$a.call(Sa).replace(ba,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Aa(e){if(!ga(e)||ya(e))return!1;var t=ha(e)?ka:xa;return t.test(va(e))}var Ta=Aa;function Oa(e,t){return e==null?void 0:e[t]}var Fa=Oa,Ia=Ta,Da=Fa;function Na(e,t){var o=Da(e,t);return Ia(o)?o:void 0}var Te=Na,Pa=Te,Ea=ye,Ma=Pa(Ea,"Map"),Ut=Ma,_a=Te,ja=_a(Object,"create"),ft=ja,Mo=ft;function Ba(){this.__data__=Mo?Mo(null):{},this.size=0}var Va=Ba;function La(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var za=La,Ua=ft,Ga="__lodash_hash_undefined__",Wa=Object.prototype,Ha=Wa.hasOwnProperty;function qa(e){var t=this.__data__;if(Ua){var o=t[e];return o===Ga?void 0:o}return Ha.call(t,e)?t[e]:void 0}var Ka=qa,Ja=ft,Ya=Object.prototype,Za=Ya.hasOwnProperty;function Qa(e){var t=this.__data__;return Ja?t[e]!==void 0:Za.call(t,e)}var Xa=Qa,Ra=ft,ei="__lodash_hash_undefined__";function ti(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=Ra&&t===void 0?ei:t,this}var oi=ti,ni=Va,ri=za,si=Ka,ai=Xa,ii=oi;function ze(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=ni,ze.prototype.delete=ri,ze.prototype.get=si,ze.prototype.has=ai,ze.prototype.set=ii;var li=ze,_o=li,ci=mt,ui=Ut;function di(){this.size=0,this.__data__={hash:new _o,map:new(ui||ci),string:new _o}}var pi=di;function mi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var fi=mi,hi=fi;function yi(e,t){var o=e.__data__;return hi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var ht=yi,gi=ht;function vi(e){var t=gi(this,e).delete(e);return this.size-=t?1:0,t}var bi=vi,xi=ht;function Ci(e){return xi(this,e).get(e)}var wi=Ci,$i=ht;function Si(e){return $i(this,e).has(e)}var ki=Si,Ai=ht;function Ti(e,t){var o=Ai(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var Oi=Ti,Fi=pi,Ii=bi,Di=wi,Ni=ki,Pi=Oi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ue.prototype.clear=Fi,Ue.prototype.delete=Ii,Ue.prototype.get=Di,Ue.prototype.has=Ni,Ue.prototype.set=Pi;var jo=Ue,Ei=mt,Mi=Ut,_i=jo,ji=200;function Bi(e,t){var o=this.__data__;if(o instanceof Ei){var n=o.__data__;if(!Mi||n.length<ji-1)return n.push([e,t]),this.size=++o.size,this;o=this.__data__=new _i(n)}return o.set(e,t),this.size=o.size,this}var Vi=Bi,Li=mt,zi=Ts,Ui=Fs,Gi=Ds,Wi=Ps,Hi=Vi;function Ge(e){var t=this.__data__=new Li(e);this.size=t.size}Ge.prototype.clear=zi,Ge.prototype.delete=Ui,Ge.prototype.get=Gi,Ge.prototype.has=Wi,Ge.prototype.set=Hi;var qi=Ge;function Ki(e,t){for(var o=-1,n=e==null?0:e.length;++o<n&&t(e[o],o,e)!==!1;);return e}var Ji=Ki,Yi=Te,Zi=function(){try{var e=Yi(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Bo=Zi,Vo=Bo;function Qi(e,t,o){t=="__proto__"&&Vo?Vo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Lo=Qi,Xi=Lo,Ri=Ao,el=Object.prototype,tl=el.hasOwnProperty;function ol(e,t,o){var n=e[t];(!(tl.call(e,t)&&Ri(n,o))||o===void 0&&!(t in e))&&Xi(e,t,o)}var zo=ol,nl=zo,rl=Lo;function sl(e,t,o,n){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=n?n(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?rl(o,c,u):nl(o,c,u)}return o}var Re=sl;function al(e,t){for(var o=-1,n=Array(e);++o<e;)n[o]=t(o);return n}var il=al;function ll(e){return e!=null&&typeof e=="object"}var Oe=ll,cl=Le,ul=Oe,dl="[object Arguments]";function pl(e){return ul(e)&&cl(e)==dl}var ml=pl,Uo=ml,fl=Oe,Go=Object.prototype,hl=Go.hasOwnProperty,yl=Go.propertyIsEnumerable,gl=Uo(function(){return arguments}())?Uo:function(e){return fl(e)&&hl.call(e,"callee")&&!yl.call(e,"callee")},Wo=gl,vl=Array.isArray,Fe=vl,yt={exports:{}};function bl(){return!1}var xl=bl;yt.exports,function(e,t){var o=ye,n=xl,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?o.Buffer:void 0,u=c?c.isBuffer:void 0,p=u||n;e.exports=p}(yt,yt.exports);var Ho=yt.exports,Cl=9007199254740991,wl=/^(?:0|[1-9]\d*)$/;function $l(e,t){var o=typeof e;return t=t==null?Cl:t,!!t&&(o=="number"||o!="symbol"&&wl.test(e))&&e>-1&&e%1==0&&e<t}var Sl=$l,kl=9007199254740991;function Al(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=kl}var qo=Al,Tl=Le,Ol=qo,Fl=Oe,Il="[object Arguments]",Dl="[object Array]",Nl="[object Boolean]",Pl="[object Date]",El="[object Error]",Ml="[object Function]",_l="[object Map]",jl="[object Number]",Bl="[object Object]",Vl="[object RegExp]",Ll="[object Set]",zl="[object String]",Ul="[object WeakMap]",Gl="[object ArrayBuffer]",Wl="[object DataView]",Hl="[object Float32Array]",ql="[object Float64Array]",Kl="[object Int8Array]",Jl="[object Int16Array]",Yl="[object Int32Array]",Zl="[object Uint8Array]",Ql="[object Uint8ClampedArray]",Xl="[object Uint16Array]",Rl="[object Uint32Array]",W={};W[Hl]=W[ql]=W[Kl]=W[Jl]=W[Yl]=W[Zl]=W[Ql]=W[Xl]=W[Rl]=!0,W[Il]=W[Dl]=W[Gl]=W[Nl]=W[Wl]=W[Pl]=W[El]=W[Ml]=W[_l]=W[jl]=W[Bl]=W[Vl]=W[Ll]=W[zl]=W[Ul]=!1;function ec(e){return Fl(e)&&Ol(e.length)&&!!W[Tl(e)]}var tc=ec;function oc(e){return function(t){return e(t)}}var Gt=oc,gt={exports:{}};gt.exports,function(e,t){var o=To,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a&&o.process,c=function(){try{var u=s&&s.require&&s.require("util").types;return u||l&&l.binding&&l.binding("util")}catch(p){}}();e.exports=c}(gt,gt.exports);var Wt=gt.exports,nc=tc,rc=Gt,Ko=Wt,Jo=Ko&&Ko.isTypedArray,sc=Jo?rc(Jo):nc,ac=sc,ic=il,lc=Wo,cc=Fe,uc=Ho,dc=Sl,pc=ac,mc=Object.prototype,fc=mc.hasOwnProperty;function hc(e,t){var o=cc(e),n=!o&&lc(e),s=!o&&!n&&uc(e),a=!o&&!n&&!s&&pc(e),l=o||n||s||a,c=l?ic(e.length,String):[],u=c.length;for(var p in e)(t||fc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||dc(p,u)))&&c.push(p);return c}var Yo=hc,yc=Object.prototype;function gc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||yc;return e===o}var Ht=gc;function vc(e,t){return function(o){return e(t(o))}}var Zo=vc,bc=Zo,xc=bc(Object.keys,Object),Cc=xc,wc=Ht,$c=Cc,Sc=Object.prototype,kc=Sc.hasOwnProperty;function Ac(e){if(!wc(e))return $c(e);var t=[];for(var o in Object(e))kc.call(e,o)&&o!="constructor"&&t.push(o);return t}var Tc=Ac,Oc=No,Fc=qo;function Ic(e){return e!=null&&Fc(e.length)&&!Oc(e)}var Qo=Ic,Dc=Yo,Nc=Tc,Pc=Qo;function Ec(e){return Pc(e)?Dc(e):Nc(e)}var qt=Ec,Mc=Re,_c=qt;function jc(e,t){return e&&Mc(t,_c(t),e)}var Bc=jc;function Vc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var Lc=Vc,zc=Xe,Uc=Ht,Gc=Lc,Wc=Object.prototype,Hc=Wc.hasOwnProperty;function qc(e){if(!zc(e))return Gc(e);var t=Uc(e),o=[];for(var n in e)n=="constructor"&&(t||!Hc.call(e,n))||o.push(n);return o}var Kc=qc,Jc=Yo,Yc=Kc,Zc=Qo;function Qc(e){return Zc(e)?Jc(e,!0):Yc(e)}var Kt=Qc,Xc=Re,Rc=Kt;function eu(e,t){return e&&Xc(t,Rc(t),e)}var tu=eu,vt={exports:{}};vt.exports,function(e,t){var o=ye,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,m){if(m)return p.slice();var h=p.length,g=c?c(h):new p.constructor(h);return p.copy(g),g}e.exports=u}(vt,vt.exports);var ou=vt.exports;function nu(e,t){var o=-1,n=e.length;for(t||(t=Array(n));++o<n;)t[o]=e[o];return t}var ru=nu;function su(e,t){for(var o=-1,n=e==null?0:e.length,s=0,a=[];++o<n;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var au=su;function iu(){return[]}var Xo=iu,lu=au,cu=Xo,uu=Object.prototype,du=uu.propertyIsEnumerable,Ro=Object.getOwnPropertySymbols,pu=Ro?function(e){return e==null?[]:(e=Object(e),lu(Ro(e),function(t){return du.call(e,t)}))}:cu,Jt=pu,mu=Re,fu=Jt;function hu(e,t){return mu(e,fu(e),t)}var yu=hu;function gu(e,t){for(var o=-1,n=t.length,s=e.length;++o<n;)e[s+o]=t[o];return e}var Yt=gu,vu=Zo,bu=vu(Object.getPrototypeOf,Object),Zt=bu,xu=Yt,Cu=Zt,wu=Jt,$u=Xo,Su=Object.getOwnPropertySymbols,ku=Su?function(e){for(var t=[];e;)xu(t,wu(e)),e=Cu(e);return t}:$u,en=ku,Au=Re,Tu=en;function Ou(e,t){return Au(e,Tu(e),t)}var Fu=Ou,Iu=Yt,Du=Fe;function Nu(e,t,o){var n=t(e);return Du(e)?n:Iu(n,o(e))}var tn=Nu,Pu=tn,Eu=Jt,Mu=qt;function _u(e){return Pu(e,Mu,Eu)}var ju=_u,Bu=tn,Vu=en,Lu=Kt;function zu(e){return Bu(e,Lu,Vu)}var on=zu,Uu=Te,Gu=ye,Wu=Uu(Gu,"DataView"),Hu=Wu,qu=Te,Ku=ye,Ju=qu(Ku,"Promise"),Yu=Ju,Zu=Te,Qu=ye,Xu=Zu(Qu,"Set"),Ru=Xu,ed=Te,td=ye,od=ed(td,"WeakMap"),nd=od,Qt=Hu,Xt=Ut,Rt=Yu,eo=Ru,to=nd,nn=Le,We=Eo,rn="[object Map]",rd="[object Object]",sn="[object Promise]",an="[object Set]",ln="[object WeakMap]",cn="[object DataView]",sd=We(Qt),ad=We(Xt),id=We(Rt),ld=We(eo),cd=We(to),Ie=nn;(Qt&&Ie(new Qt(new ArrayBuffer(1)))!=cn||Xt&&Ie(new Xt)!=rn||Rt&&Ie(Rt.resolve())!=sn||eo&&Ie(new eo)!=an||to&&Ie(new to)!=ln)&&(Ie=function(e){var t=nn(e),o=t==rd?e.constructor:void 0,n=o?We(o):"";if(n)switch(n){case sd:return cn;case ad:return rn;case id:return sn;case ld:return an;case cd:return ln}return t});var oo=Ie,ud=Object.prototype,dd=ud.hasOwnProperty;function pd(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&dd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var md=pd,fd=ye,hd=fd.Uint8Array,yd=hd,un=yd;function gd(e){var t=new e.constructor(e.byteLength);return new un(t).set(new un(e)),t}var no=gd,vd=no;function bd(e,t){var o=t?vd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var xd=bd,Cd=/\w*$/;function wd(e){var t=new e.constructor(e.source,Cd.exec(e));return t.lastIndex=e.lastIndex,t}var $d=wd,dn=Ze,pn=dn?dn.prototype:void 0,mn=pn?pn.valueOf:void 0;function Sd(e){return mn?Object(mn.call(e)):{}}var kd=Sd,Ad=no;function Td(e,t){var o=t?Ad(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Od=Td,Fd=no,Id=xd,Dd=$d,Nd=kd,Pd=Od,Ed="[object Boolean]",Md="[object Date]",_d="[object Map]",jd="[object Number]",Bd="[object RegExp]",Vd="[object Set]",Ld="[object String]",zd="[object Symbol]",Ud="[object ArrayBuffer]",Gd="[object DataView]",Wd="[object Float32Array]",Hd="[object Float64Array]",qd="[object Int8Array]",Kd="[object Int16Array]",Jd="[object Int32Array]",Yd="[object Uint8Array]",Zd="[object Uint8ClampedArray]",Qd="[object Uint16Array]",Xd="[object Uint32Array]";function Rd(e,t,o){var n=e.constructor;switch(t){case Ud:return Fd(e);case Ed:case Md:return new n(+e);case Gd:return Id(e,o);case Wd:case Hd:case qd:case Kd:case Jd:case Yd:case Zd:case Qd:case Xd:return Pd(e,o);case _d:return new n;case jd:case Ld:return new n(e);case Bd:return Dd(e);case Vd:return new n;case zd:return Nd(e)}}var ep=Rd,tp=Xe,fn=Object.create,op=function(){function e(){}return function(t){if(!tp(t))return{};if(fn)return fn(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),np=op,rp=np,sp=Zt,ap=Ht;function ip(e){return typeof e.constructor=="function"&&!ap(e)?rp(sp(e)):{}}var lp=ip,cp=oo,up=Oe,dp="[object Map]";function pp(e){return up(e)&&cp(e)==dp}var mp=pp,fp=mp,hp=Gt,hn=Wt,yn=hn&&hn.isMap,yp=yn?hp(yn):fp,gp=yp,vp=oo,bp=Oe,xp="[object Set]";function Cp(e){return bp(e)&&vp(e)==xp}var wp=Cp,$p=wp,Sp=Gt,gn=Wt,vn=gn&&gn.isSet,kp=vn?Sp(vn):$p,Ap=kp,Tp=qi,Op=Ji,Fp=zo,Ip=Bc,Dp=tu,Np=ou,Pp=ru,Ep=yu,Mp=Fu,_p=ju,jp=on,Bp=oo,Vp=md,Lp=ep,zp=lp,Up=Fe,Gp=Ho,Wp=gp,Hp=Xe,qp=Ap,Kp=qt,Jp=Kt,Yp=1,Zp=2,Qp=4,bn="[object Arguments]",Xp="[object Array]",Rp="[object Boolean]",em="[object Date]",tm="[object Error]",xn="[object Function]",om="[object GeneratorFunction]",nm="[object Map]",rm="[object Number]",Cn="[object Object]",sm="[object RegExp]",am="[object Set]",im="[object String]",lm="[object Symbol]",cm="[object WeakMap]",um="[object ArrayBuffer]",dm="[object DataView]",pm="[object Float32Array]",mm="[object Float64Array]",fm="[object Int8Array]",hm="[object Int16Array]",ym="[object Int32Array]",gm="[object Uint8Array]",vm="[object Uint8ClampedArray]",bm="[object Uint16Array]",xm="[object Uint32Array]",G={};G[bn]=G[Xp]=G[um]=G[dm]=G[Rp]=G[em]=G[pm]=G[mm]=G[fm]=G[hm]=G[ym]=G[nm]=G[rm]=G[Cn]=G[sm]=G[am]=G[im]=G[lm]=G[gm]=G[vm]=G[bm]=G[xm]=!0,G[tm]=G[xn]=G[cm]=!1;function bt(e,t,o,n,s,a){var l,c=t&Yp,u=t&Zp,p=t&Qp;if(o&&(l=s?o(e,n,s,a):o(e)),l!==void 0)return l;if(!Hp(e))return e;var m=Up(e);if(m){if(l=Vp(e),!c)return Pp(e,l)}else{var h=Bp(e),g=h==xn||h==om;if(Gp(e))return Np(e,c);if(h==Cn||h==bn||g&&!s){if(l=u||g?{}:zp(e),!c)return u?Mp(e,Dp(l,e)):Ep(e,Ip(l,e))}else{if(!G[h])return s?e:{};l=Lp(e,h,c)}}a||(a=new Tp);var f=a.get(e);if(f)return f;a.set(e,l),qp(e)?e.forEach(function($){l.add(bt($,t,o,$,e,a))}):Wp(e)&&e.forEach(function($,k){l.set(k,bt($,t,o,k,e,a))});var y=p?u?jp:_p:u?Jp:Kp,w=m?void 0:y(e);return Op(w||e,function($,k){w&&(k=$,$=e[k]),Fp(l,k,bt($,t,o,k,e,a))}),l}var Cm=bt,wm=Le,$m=Oe,Sm="[object Symbol]";function km(e){return typeof e=="symbol"||$m(e)&&wm(e)==Sm}var ro=km,Am=Fe,Tm=ro,Om=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fm=/^\w*$/;function Im(e,t){if(Am(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||Tm(e)?!0:Fm.test(e)||!Om.test(e)||t!=null&&e in Object(t)}var Dm=Im,wn=jo,Nm="Expected a function";function so(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Nm);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,n);return o.cache=a.set(s,l)||a,l};return o.cache=new(so.Cache||wn),o}so.Cache=wn;var Pm=so,Em=Pm,Mm=500;function _m(e){var t=Em(e,function(n){return o.size===Mm&&o.clear(),n}),o=t.cache;return t}var jm=_m,Bm=jm,Vm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lm=/\\(\\)?/g,zm=Bm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Vm,function(o,n,s,a){t.push(s?a.replace(Lm,"$1"):n||o)}),t}),Um=zm,$n=Ze,Gm=ko,Wm=Fe,Hm=ro,qm=1/0,Sn=$n?$n.prototype:void 0,kn=Sn?Sn.toString:void 0;function An(e){if(typeof e=="string")return e;if(Wm(e))return Gm(e,An)+"";if(Hm(e))return kn?kn.call(e):"";var t=e+"";return t=="0"&&1/e==-qm?"-0":t}var Km=An,Jm=Km;function Ym(e){return e==null?"":Jm(e)}var Zm=Ym,Qm=Fe,Xm=Dm,Rm=Um,ef=Zm;function tf(e,t){return Qm(e)?e:Xm(e,t)?[e]:Rm(ef(e))}var ao=tf;function of(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var nf=of,rf=ro,sf=1/0;function af(e){if(typeof e=="string"||rf(e))return e;var t=e+"";return t=="0"&&1/e==-sf?"-0":t}var Tn=af,lf=ao,cf=Tn;function uf(e,t){t=lf(t,e);for(var o=0,n=t.length;e!=null&&o<n;)e=e[cf(t[o++])];return o&&o==n?e:void 0}var df=uf;function pf(e,t,o){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),o=o>s?s:o,o<0&&(o+=s),s=t>o?0:o-t>>>0,t>>>=0;for(var a=Array(s);++n<s;)a[n]=e[n+t];return a}var mf=pf,ff=df,hf=mf;function yf(e,t){return t.length<2?e:ff(e,hf(t,0,-1))}var gf=yf,vf=ao,bf=nf,xf=gf,Cf=Tn;function wf(e,t){return t=vf(t,e),e=xf(e,t),e==null||delete e[Cf(bf(t))]}var $f=wf,Sf=Le,kf=Zt,Af=Oe,Tf="[object Object]",Of=Function.prototype,Ff=Object.prototype,On=Of.toString,If=Ff.hasOwnProperty,Df=On.call(Object);function Nf(e){if(!Af(e)||Sf(e)!=Tf)return!1;var t=kf(e);if(t===null)return!0;var o=If.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&On.call(o)==Df}var Pf=Nf,Ef=Pf;function Mf(e){return Ef(e)?void 0:e}var _f=Mf,Fn=Ze,jf=Wo,Bf=Fe,In=Fn?Fn.isConcatSpreadable:void 0;function Vf(e){return Bf(e)||jf(e)||!!(In&&e&&e[In])}var Lf=Vf,zf=Yt,Uf=Lf;function Dn(e,t,o,n,s){var a=-1,l=e.length;for(o||(o=Uf),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Dn(c,t-1,o,n,s):zf(s,c):n||(s[s.length]=c)}return s}var Gf=Dn,Wf=Gf;function Hf(e){var t=e==null?0:e.length;return t?Wf(e,1):[]}var qf=Hf;function Kf(e,t,o){switch(o.length){case 0:return e.call(t);case 1:return e.call(t,o[0]);case 2:return e.call(t,o[0],o[1]);case 3:return e.call(t,o[0],o[1],o[2])}return e.apply(t,o)}var Jf=Kf,Yf=Jf,Nn=Math.max;function Zf(e,t,o){return t=Nn(t===void 0?e.length-1:t,0),function(){for(var n=arguments,s=-1,a=Nn(n.length-t,0),l=Array(a);++s<a;)l[s]=n[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=n[s];return c[t]=o(l),Yf(e,this,c)}}var Qf=Zf;function Xf(e){return function(){return e}}var Rf=Xf;function eh(e){return e}var th=eh,oh=Rf,Pn=Bo,nh=th,rh=Pn?function(e,t){return Pn(e,"toString",{configurable:!0,enumerable:!1,value:oh(t),writable:!0})}:nh,sh=rh,ah=800,ih=16,lh=Date.now;function ch(e){var t=0,o=0;return function(){var n=lh(),s=ih-(n-o);if(o=n,s>0){if(++t>=ah)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var uh=ch,dh=sh,ph=uh,mh=ph(dh),fh=mh,hh=qf,yh=Qf,gh=fh;function vh(e){return gh(yh(e,void 0,hh),e+"")}var bh=vh,xh=ko,Ch=Cm,wh=$f,$h=ao,Sh=Re,kh=_f,Ah=bh,Th=on,Oh=1,Fh=2,Ih=4,Dh=Ah(function(e,t){var o={};if(e==null)return o;var n=!1;t=xh(t,function(a){return a=$h(a,e),n||(n=a.length>1),a}),Sh(e,Th(e),o),n&&(o=Ch(o,Oh|Fh|Ih,kh));for(var s=t.length;s--;)wh(o,t[s]);return o}),Nh=Dh;const Ph=So(Nh),En={title:`{{t("Form event", { ns: "${d}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{title:`{{t("Form data model", { ns: "${d}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${d}" })}}`,"x-reactions":[...de["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(v({},je),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User submitted form")}}];return xe(C(v({},t),{fields:s,appends:["data","user",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Eh(e,t,o,n,s,a){var l;if(e){const c=(l=t==null?void 0:t.data)==null?void 0:l.activeFields;if(c){const u=Object.keys(o.values).filter(p=>{const m=s(p);return!c.has(p)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(m==null?void 0:m.type)});return Ph(v({},o.values),u)}}return o.values}function Mh(){var M;const e=i.useAPIClient(),t=I.useForm(),{field:o,resource:n,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=I.useFieldSchema(),p=I.useField(),{fields:m,getField:h,getTreeParentField:g}=i.useCollection(),f=i.useCompile(),y=i.useFilterByTk(),w=i.useRecord(),$=i.useCurrentUserContext(),{modal:k}=x.App.useApp(),S=(M=$==null?void 0:$.data)==null?void 0:M.data,A=p.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var V,ne,J,Z,Q,ee;const _=m.map(re=>re.name),{assignedValues:F={},onSuccess:N,overwriteValues:U,skipValidator:ie,triggerWorkflows:Y}=(V=u==null?void 0:u["x-action-settings"])!=null?V:{},ue=(ne=l==null?void 0:l["x-component-props"])==null?void 0:ne.addChild,E=L.parse(F)({currentTime:new Date,currentRecord:w,currentUser:S});ie||(yield t.submit());const j=Eh(y,o,t,_,h);if(ue){const re=g();j[(J=re==null?void 0:re.name)!=null?J:"parent"]=w,j[(Z=re==null?void 0:re.foreignKey)!=null?Z:"parentId"]=w.id}p.data=o.data||{},p.data.loading=!0;try{const re=yield e.resource("workflows").trigger({values:v(v(v({},j),U),E),filterKeys:A,triggerWorkflows:Y!=null&&Y.length?Y.map(pe=>[pe.workflowKey,pe.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=re,(ee=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||ee.call(Q),a==null||a(!1),!(N!=null&&N.successMessage))return;N!=null&&N.manualClose?k.success({title:f(N==null?void 0:N.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),N!=null&&N.redirecting&&(N!=null&&N.redirectTo)&&(L.isURL(N.redirectTo)?window.location.href=N.redirectTo:c(N.redirectTo))})}):x.message.success(f(N==null?void 0:N.successMessage))}catch(re){p.data.loading=!1}})}}}const De={STATIC:0,COLLECTION_FIELD:1};function _h(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Mn({value:e,onChange:t}){const{t:o}=te.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
352
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},Xr={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"}}},Rr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",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}}}}}}},je={type:"array",title:`{{t("Preload associations", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){const{values:e}=I.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Be={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},es=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Be.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Be.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Be.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Be.DELETED}],$o={title:`{{t("Collection event", { ns: "${d}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${d}" })}}`,className:"auto-width"},enum:es,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Be.UPDATED})}}`}}}]},condition:C(v({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:_e["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},je),{"x-reactions":[...je["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Be.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:Vt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}}];return xe(C(v({},t),{fields:s,appends:["data",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};var dt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function So(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ts(e,t){for(var o=-1,n=e==null?0:e.length,s=Array(n);++o<n;)s[o]=t(e[o],o,e);return s}var ko=ts;function os(){this.__data__=[],this.size=0}var ns=os;function rs(e,t){return e===t||e!==e&&t!==t}var Ao=rs,ss=Ao;function as(e,t){for(var o=e.length;o--;)if(ss(e[o][0],t))return o;return-1}var pt=as,is=pt,ls=Array.prototype,cs=ls.splice;function us(e){var t=this.__data__,o=is(t,e);if(o<0)return!1;var n=t.length-1;return o==n?t.pop():cs.call(t,o,1),--this.size,!0}var ds=us,ps=pt;function ms(e){var t=this.__data__,o=ps(t,e);return o<0?void 0:t[o][1]}var fs=ms,hs=pt;function ys(e){return hs(this.__data__,e)>-1}var gs=ys,vs=pt;function bs(e,t){var o=this.__data__,n=vs(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var xs=bs,Cs=ns,ws=ds,$s=fs,Ss=gs,ks=xs;function Ve(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=Cs,Ve.prototype.delete=ws,Ve.prototype.get=$s,Ve.prototype.has=Ss,Ve.prototype.set=ks;var mt=Ve,As=mt;function Ts(){this.__data__=new As,this.size=0}var Os=Ts;function Fs(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Is=Fs;function Ds(e){return this.__data__.get(e)}var Ns=Ds;function Ps(e){return this.__data__.has(e)}var Es=Ps,Ms=typeof dt=="object"&&dt&&dt.Object===Object&&dt,To=Ms,_s=To,js=typeof self=="object"&&self&&self.Object===Object&&self,Bs=_s||js||Function("return this")(),ye=Bs,Vs=ye,Ls=Vs.Symbol,Ze=Ls,Oo=Ze,Fo=Object.prototype,zs=Fo.hasOwnProperty,Us=Fo.toString,Qe=Oo?Oo.toStringTag:void 0;function Gs(e){var t=zs.call(e,Qe),o=e[Qe];try{e[Qe]=void 0;var n=!0}catch(a){}var s=Us.call(e);return n&&(t?e[Qe]=o:delete e[Qe]),s}var Ws=Gs,Hs=Object.prototype,qs=Hs.toString;function Ks(e){return qs.call(e)}var Js=Ks,Io=Ze,Ys=Ws,Zs=Js,Qs="[object Null]",Xs="[object Undefined]",Do=Io?Io.toStringTag:void 0;function Rs(e){return e==null?e===void 0?Xs:Qs:Do&&Do in Object(e)?Ys(e):Zs(e)}var Le=Rs;function ea(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xe=ea,ta=Le,oa=Xe,na="[object AsyncFunction]",ra="[object Function]",sa="[object GeneratorFunction]",aa="[object Proxy]";function ia(e){if(!oa(e))return!1;var t=ta(e);return t==ra||t==sa||t==na||t==aa}var No=ia,la=ye,ca=la["__core-js_shared__"],ua=ca,zt=ua,Po=function(){var e=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function da(e){return!!Po&&Po in e}var pa=da,ma=Function.prototype,fa=ma.toString;function ha(e){if(e!=null){try{return fa.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Eo=ha,ya=No,ga=pa,va=Xe,ba=Eo,xa=/[\\^$.*+?()[\]{}|]/g,Ca=/^\[object .+?Constructor\]$/,wa=Function.prototype,$a=Object.prototype,Sa=wa.toString,ka=$a.hasOwnProperty,Aa=RegExp("^"+Sa.call(ka).replace(xa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ta(e){if(!va(e)||ga(e))return!1;var t=ya(e)?Aa:Ca;return t.test(ba(e))}var Oa=Ta;function Fa(e,t){return e==null?void 0:e[t]}var Ia=Fa,Da=Oa,Na=Ia;function Pa(e,t){var o=Na(e,t);return Da(o)?o:void 0}var Te=Pa,Ea=Te,Ma=ye,_a=Ea(Ma,"Map"),Ut=_a,ja=Te,Ba=ja(Object,"create"),ft=Ba,Mo=ft;function Va(){this.__data__=Mo?Mo(null):{},this.size=0}var La=Va;function za(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ua=za,Ga=ft,Wa="__lodash_hash_undefined__",Ha=Object.prototype,qa=Ha.hasOwnProperty;function Ka(e){var t=this.__data__;if(Ga){var o=t[e];return o===Wa?void 0:o}return qa.call(t,e)?t[e]:void 0}var Ja=Ka,Ya=ft,Za=Object.prototype,Qa=Za.hasOwnProperty;function Xa(e){var t=this.__data__;return Ya?t[e]!==void 0:Qa.call(t,e)}var Ra=Xa,ei=ft,ti="__lodash_hash_undefined__";function oi(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=ei&&t===void 0?ti:t,this}var ni=oi,ri=La,si=Ua,ai=Ja,ii=Ra,li=ni;function ze(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=ri,ze.prototype.delete=si,ze.prototype.get=ai,ze.prototype.has=ii,ze.prototype.set=li;var ci=ze,_o=ci,ui=mt,di=Ut;function pi(){this.size=0,this.__data__={hash:new _o,map:new(di||ui),string:new _o}}var mi=pi;function fi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var hi=fi,yi=hi;function gi(e,t){var o=e.__data__;return yi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var ht=gi,vi=ht;function bi(e){var t=vi(this,e).delete(e);return this.size-=t?1:0,t}var xi=bi,Ci=ht;function wi(e){return Ci(this,e).get(e)}var $i=wi,Si=ht;function ki(e){return Si(this,e).has(e)}var Ai=ki,Ti=ht;function Oi(e,t){var o=Ti(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var Fi=Oi,Ii=mi,Di=xi,Ni=$i,Pi=Ai,Ei=Fi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ue.prototype.clear=Ii,Ue.prototype.delete=Di,Ue.prototype.get=Ni,Ue.prototype.has=Pi,Ue.prototype.set=Ei;var jo=Ue,Mi=mt,_i=Ut,ji=jo,Bi=200;function Vi(e,t){var o=this.__data__;if(o instanceof Mi){var n=o.__data__;if(!_i||n.length<Bi-1)return n.push([e,t]),this.size=++o.size,this;o=this.__data__=new ji(n)}return o.set(e,t),this.size=o.size,this}var Li=Vi,zi=mt,Ui=Os,Gi=Is,Wi=Ns,Hi=Es,qi=Li;function Ge(e){var t=this.__data__=new zi(e);this.size=t.size}Ge.prototype.clear=Ui,Ge.prototype.delete=Gi,Ge.prototype.get=Wi,Ge.prototype.has=Hi,Ge.prototype.set=qi;var Ki=Ge;function Ji(e,t){for(var o=-1,n=e==null?0:e.length;++o<n&&t(e[o],o,e)!==!1;);return e}var Yi=Ji,Zi=Te,Qi=function(){try{var e=Zi(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Bo=Qi,Vo=Bo;function Xi(e,t,o){t=="__proto__"&&Vo?Vo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Lo=Xi,Ri=Lo,el=Ao,tl=Object.prototype,ol=tl.hasOwnProperty;function nl(e,t,o){var n=e[t];(!(ol.call(e,t)&&el(n,o))||o===void 0&&!(t in e))&&Ri(e,t,o)}var zo=nl,rl=zo,sl=Lo;function al(e,t,o,n){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=n?n(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?sl(o,c,u):rl(o,c,u)}return o}var Re=al;function il(e,t){for(var o=-1,n=Array(e);++o<e;)n[o]=t(o);return n}var ll=il;function cl(e){return e!=null&&typeof e=="object"}var Oe=cl,ul=Le,dl=Oe,pl="[object Arguments]";function ml(e){return dl(e)&&ul(e)==pl}var fl=ml,Uo=fl,hl=Oe,Go=Object.prototype,yl=Go.hasOwnProperty,gl=Go.propertyIsEnumerable,vl=Uo(function(){return arguments}())?Uo:function(e){return hl(e)&&yl.call(e,"callee")&&!gl.call(e,"callee")},Wo=vl,bl=Array.isArray,Fe=bl,yt={exports:{}};function xl(){return!1}var Cl=xl;yt.exports,function(e,t){var o=ye,n=Cl,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?o.Buffer:void 0,u=c?c.isBuffer:void 0,p=u||n;e.exports=p}(yt,yt.exports);var Ho=yt.exports,wl=9007199254740991,$l=/^(?:0|[1-9]\d*)$/;function Sl(e,t){var o=typeof e;return t=t==null?wl:t,!!t&&(o=="number"||o!="symbol"&&$l.test(e))&&e>-1&&e%1==0&&e<t}var kl=Sl,Al=9007199254740991;function Tl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Al}var qo=Tl,Ol=Le,Fl=qo,Il=Oe,Dl="[object Arguments]",Nl="[object Array]",Pl="[object Boolean]",El="[object Date]",Ml="[object Error]",_l="[object Function]",jl="[object Map]",Bl="[object Number]",Vl="[object Object]",Ll="[object RegExp]",zl="[object Set]",Ul="[object String]",Gl="[object WeakMap]",Wl="[object ArrayBuffer]",Hl="[object DataView]",ql="[object Float32Array]",Kl="[object Float64Array]",Jl="[object Int8Array]",Yl="[object Int16Array]",Zl="[object Int32Array]",Ql="[object Uint8Array]",Xl="[object Uint8ClampedArray]",Rl="[object Uint16Array]",ec="[object Uint32Array]",W={};W[ql]=W[Kl]=W[Jl]=W[Yl]=W[Zl]=W[Ql]=W[Xl]=W[Rl]=W[ec]=!0,W[Dl]=W[Nl]=W[Wl]=W[Pl]=W[Hl]=W[El]=W[Ml]=W[_l]=W[jl]=W[Bl]=W[Vl]=W[Ll]=W[zl]=W[Ul]=W[Gl]=!1;function tc(e){return Il(e)&&Fl(e.length)&&!!W[Ol(e)]}var oc=tc;function nc(e){return function(t){return e(t)}}var Gt=nc,gt={exports:{}};gt.exports,function(e,t){var o=To,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a&&o.process,c=function(){try{var u=s&&s.require&&s.require("util").types;return u||l&&l.binding&&l.binding("util")}catch(p){}}();e.exports=c}(gt,gt.exports);var Wt=gt.exports,rc=oc,sc=Gt,Ko=Wt,Jo=Ko&&Ko.isTypedArray,ac=Jo?sc(Jo):rc,ic=ac,lc=ll,cc=Wo,uc=Fe,dc=Ho,pc=kl,mc=ic,fc=Object.prototype,hc=fc.hasOwnProperty;function yc(e,t){var o=uc(e),n=!o&&cc(e),s=!o&&!n&&dc(e),a=!o&&!n&&!s&&mc(e),l=o||n||s||a,c=l?lc(e.length,String):[],u=c.length;for(var p in e)(t||hc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||pc(p,u)))&&c.push(p);return c}var Yo=yc,gc=Object.prototype;function vc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||gc;return e===o}var Ht=vc;function bc(e,t){return function(o){return e(t(o))}}var Zo=bc,xc=Zo,Cc=xc(Object.keys,Object),wc=Cc,$c=Ht,Sc=wc,kc=Object.prototype,Ac=kc.hasOwnProperty;function Tc(e){if(!$c(e))return Sc(e);var t=[];for(var o in Object(e))Ac.call(e,o)&&o!="constructor"&&t.push(o);return t}var Oc=Tc,Fc=No,Ic=qo;function Dc(e){return e!=null&&Ic(e.length)&&!Fc(e)}var Qo=Dc,Nc=Yo,Pc=Oc,Ec=Qo;function Mc(e){return Ec(e)?Nc(e):Pc(e)}var qt=Mc,_c=Re,jc=qt;function Bc(e,t){return e&&_c(t,jc(t),e)}var Vc=Bc;function Lc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var zc=Lc,Uc=Xe,Gc=Ht,Wc=zc,Hc=Object.prototype,qc=Hc.hasOwnProperty;function Kc(e){if(!Uc(e))return Wc(e);var t=Gc(e),o=[];for(var n in e)n=="constructor"&&(t||!qc.call(e,n))||o.push(n);return o}var Jc=Kc,Yc=Yo,Zc=Jc,Qc=Qo;function Xc(e){return Qc(e)?Yc(e,!0):Zc(e)}var Kt=Xc,Rc=Re,eu=Kt;function tu(e,t){return e&&Rc(t,eu(t),e)}var ou=tu,vt={exports:{}};vt.exports,function(e,t){var o=ye,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,m){if(m)return p.slice();var h=p.length,g=c?c(h):new p.constructor(h);return p.copy(g),g}e.exports=u}(vt,vt.exports);var nu=vt.exports;function ru(e,t){var o=-1,n=e.length;for(t||(t=Array(n));++o<n;)t[o]=e[o];return t}var su=ru;function au(e,t){for(var o=-1,n=e==null?0:e.length,s=0,a=[];++o<n;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var iu=au;function lu(){return[]}var Xo=lu,cu=iu,uu=Xo,du=Object.prototype,pu=du.propertyIsEnumerable,Ro=Object.getOwnPropertySymbols,mu=Ro?function(e){return e==null?[]:(e=Object(e),cu(Ro(e),function(t){return pu.call(e,t)}))}:uu,Jt=mu,fu=Re,hu=Jt;function yu(e,t){return fu(e,hu(e),t)}var gu=yu;function vu(e,t){for(var o=-1,n=t.length,s=e.length;++o<n;)e[s+o]=t[o];return e}var Yt=vu,bu=Zo,xu=bu(Object.getPrototypeOf,Object),Zt=xu,Cu=Yt,wu=Zt,$u=Jt,Su=Xo,ku=Object.getOwnPropertySymbols,Au=ku?function(e){for(var t=[];e;)Cu(t,$u(e)),e=wu(e);return t}:Su,en=Au,Tu=Re,Ou=en;function Fu(e,t){return Tu(e,Ou(e),t)}var Iu=Fu,Du=Yt,Nu=Fe;function Pu(e,t,o){var n=t(e);return Nu(e)?n:Du(n,o(e))}var tn=Pu,Eu=tn,Mu=Jt,_u=qt;function ju(e){return Eu(e,_u,Mu)}var Bu=ju,Vu=tn,Lu=en,zu=Kt;function Uu(e){return Vu(e,zu,Lu)}var on=Uu,Gu=Te,Wu=ye,Hu=Gu(Wu,"DataView"),qu=Hu,Ku=Te,Ju=ye,Yu=Ku(Ju,"Promise"),Zu=Yu,Qu=Te,Xu=ye,Ru=Qu(Xu,"Set"),ed=Ru,td=Te,od=ye,nd=td(od,"WeakMap"),rd=nd,Qt=qu,Xt=Ut,Rt=Zu,eo=ed,to=rd,nn=Le,We=Eo,rn="[object Map]",sd="[object Object]",sn="[object Promise]",an="[object Set]",ln="[object WeakMap]",cn="[object DataView]",ad=We(Qt),id=We(Xt),ld=We(Rt),cd=We(eo),ud=We(to),Ie=nn;(Qt&&Ie(new Qt(new ArrayBuffer(1)))!=cn||Xt&&Ie(new Xt)!=rn||Rt&&Ie(Rt.resolve())!=sn||eo&&Ie(new eo)!=an||to&&Ie(new to)!=ln)&&(Ie=function(e){var t=nn(e),o=t==sd?e.constructor:void 0,n=o?We(o):"";if(n)switch(n){case ad:return cn;case id:return rn;case ld:return sn;case cd:return an;case ud:return ln}return t});var oo=Ie,dd=Object.prototype,pd=dd.hasOwnProperty;function md(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&pd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var fd=md,hd=ye,yd=hd.Uint8Array,gd=yd,un=gd;function vd(e){var t=new e.constructor(e.byteLength);return new un(t).set(new un(e)),t}var no=vd,bd=no;function xd(e,t){var o=t?bd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var Cd=xd,wd=/\w*$/;function $d(e){var t=new e.constructor(e.source,wd.exec(e));return t.lastIndex=e.lastIndex,t}var Sd=$d,dn=Ze,pn=dn?dn.prototype:void 0,mn=pn?pn.valueOf:void 0;function kd(e){return mn?Object(mn.call(e)):{}}var Ad=kd,Td=no;function Od(e,t){var o=t?Td(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Fd=Od,Id=no,Dd=Cd,Nd=Sd,Pd=Ad,Ed=Fd,Md="[object Boolean]",_d="[object Date]",jd="[object Map]",Bd="[object Number]",Vd="[object RegExp]",Ld="[object Set]",zd="[object String]",Ud="[object Symbol]",Gd="[object ArrayBuffer]",Wd="[object DataView]",Hd="[object Float32Array]",qd="[object Float64Array]",Kd="[object Int8Array]",Jd="[object Int16Array]",Yd="[object Int32Array]",Zd="[object Uint8Array]",Qd="[object Uint8ClampedArray]",Xd="[object Uint16Array]",Rd="[object Uint32Array]";function ep(e,t,o){var n=e.constructor;switch(t){case Gd:return Id(e);case Md:case _d:return new n(+e);case Wd:return Dd(e,o);case Hd:case qd:case Kd:case Jd:case Yd:case Zd:case Qd:case Xd:case Rd:return Ed(e,o);case jd:return new n;case Bd:case zd:return new n(e);case Vd:return Nd(e);case Ld:return new n;case Ud:return Pd(e)}}var tp=ep,op=Xe,fn=Object.create,np=function(){function e(){}return function(t){if(!op(t))return{};if(fn)return fn(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),rp=np,sp=rp,ap=Zt,ip=Ht;function lp(e){return typeof e.constructor=="function"&&!ip(e)?sp(ap(e)):{}}var cp=lp,up=oo,dp=Oe,pp="[object Map]";function mp(e){return dp(e)&&up(e)==pp}var fp=mp,hp=fp,yp=Gt,hn=Wt,yn=hn&&hn.isMap,gp=yn?yp(yn):hp,vp=gp,bp=oo,xp=Oe,Cp="[object Set]";function wp(e){return xp(e)&&bp(e)==Cp}var $p=wp,Sp=$p,kp=Gt,gn=Wt,vn=gn&&gn.isSet,Ap=vn?kp(vn):Sp,Tp=Ap,Op=Ki,Fp=Yi,Ip=zo,Dp=Vc,Np=ou,Pp=nu,Ep=su,Mp=gu,_p=Iu,jp=Bu,Bp=on,Vp=oo,Lp=fd,zp=tp,Up=cp,Gp=Fe,Wp=Ho,Hp=vp,qp=Xe,Kp=Tp,Jp=qt,Yp=Kt,Zp=1,Qp=2,Xp=4,bn="[object Arguments]",Rp="[object Array]",em="[object Boolean]",tm="[object Date]",om="[object Error]",xn="[object Function]",nm="[object GeneratorFunction]",rm="[object Map]",sm="[object Number]",Cn="[object Object]",am="[object RegExp]",im="[object Set]",lm="[object String]",cm="[object Symbol]",um="[object WeakMap]",dm="[object ArrayBuffer]",pm="[object DataView]",mm="[object Float32Array]",fm="[object Float64Array]",hm="[object Int8Array]",ym="[object Int16Array]",gm="[object Int32Array]",vm="[object Uint8Array]",bm="[object Uint8ClampedArray]",xm="[object Uint16Array]",Cm="[object Uint32Array]",G={};G[bn]=G[Rp]=G[dm]=G[pm]=G[em]=G[tm]=G[mm]=G[fm]=G[hm]=G[ym]=G[gm]=G[rm]=G[sm]=G[Cn]=G[am]=G[im]=G[lm]=G[cm]=G[vm]=G[bm]=G[xm]=G[Cm]=!0,G[om]=G[xn]=G[um]=!1;function bt(e,t,o,n,s,a){var l,c=t&Zp,u=t&Qp,p=t&Xp;if(o&&(l=s?o(e,n,s,a):o(e)),l!==void 0)return l;if(!qp(e))return e;var m=Gp(e);if(m){if(l=Lp(e),!c)return Ep(e,l)}else{var h=Vp(e),g=h==xn||h==nm;if(Wp(e))return Pp(e,c);if(h==Cn||h==bn||g&&!s){if(l=u||g?{}:Up(e),!c)return u?_p(e,Np(l,e)):Mp(e,Dp(l,e))}else{if(!G[h])return s?e:{};l=zp(e,h,c)}}a||(a=new Op);var f=a.get(e);if(f)return f;a.set(e,l),Kp(e)?e.forEach(function($){l.add(bt($,t,o,$,e,a))}):Hp(e)&&e.forEach(function($,k){l.set(k,bt($,t,o,k,e,a))});var y=p?u?Bp:jp:u?Yp:Jp,w=m?void 0:y(e);return Fp(w||e,function($,k){w&&(k=$,$=e[k]),Ip(l,k,bt($,t,o,k,e,a))}),l}var wm=bt,$m=Le,Sm=Oe,km="[object Symbol]";function Am(e){return typeof e=="symbol"||Sm(e)&&$m(e)==km}var ro=Am,Tm=Fe,Om=ro,Fm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Im=/^\w*$/;function Dm(e,t){if(Tm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||Om(e)?!0:Im.test(e)||!Fm.test(e)||t!=null&&e in Object(t)}var Nm=Dm,wn=jo,Pm="Expected a function";function so(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Pm);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,n);return o.cache=a.set(s,l)||a,l};return o.cache=new(so.Cache||wn),o}so.Cache=wn;var Em=so,Mm=Em,_m=500;function jm(e){var t=Mm(e,function(n){return o.size===_m&&o.clear(),n}),o=t.cache;return t}var Bm=jm,Vm=Bm,Lm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zm=/\\(\\)?/g,Um=Vm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Lm,function(o,n,s,a){t.push(s?a.replace(zm,"$1"):n||o)}),t}),Gm=Um,$n=Ze,Wm=ko,Hm=Fe,qm=ro,Km=1/0,Sn=$n?$n.prototype:void 0,kn=Sn?Sn.toString:void 0;function An(e){if(typeof e=="string")return e;if(Hm(e))return Wm(e,An)+"";if(qm(e))return kn?kn.call(e):"";var t=e+"";return t=="0"&&1/e==-Km?"-0":t}var Jm=An,Ym=Jm;function Zm(e){return e==null?"":Ym(e)}var Qm=Zm,Xm=Fe,Rm=Nm,ef=Gm,tf=Qm;function of(e,t){return Xm(e)?e:Rm(e,t)?[e]:ef(tf(e))}var ao=of;function nf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var rf=nf,sf=ro,af=1/0;function lf(e){if(typeof e=="string"||sf(e))return e;var t=e+"";return t=="0"&&1/e==-af?"-0":t}var Tn=lf,cf=ao,uf=Tn;function df(e,t){t=cf(t,e);for(var o=0,n=t.length;e!=null&&o<n;)e=e[uf(t[o++])];return o&&o==n?e:void 0}var pf=df;function mf(e,t,o){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),o=o>s?s:o,o<0&&(o+=s),s=t>o?0:o-t>>>0,t>>>=0;for(var a=Array(s);++n<s;)a[n]=e[n+t];return a}var ff=mf,hf=pf,yf=ff;function gf(e,t){return t.length<2?e:hf(e,yf(t,0,-1))}var vf=gf,bf=ao,xf=rf,Cf=vf,wf=Tn;function $f(e,t){return t=bf(t,e),e=Cf(e,t),e==null||delete e[wf(xf(t))]}var Sf=$f,kf=Le,Af=Zt,Tf=Oe,Of="[object Object]",Ff=Function.prototype,If=Object.prototype,On=Ff.toString,Df=If.hasOwnProperty,Nf=On.call(Object);function Pf(e){if(!Tf(e)||kf(e)!=Of)return!1;var t=Af(e);if(t===null)return!0;var o=Df.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&On.call(o)==Nf}var Ef=Pf,Mf=Ef;function _f(e){return Mf(e)?void 0:e}var jf=_f,Fn=Ze,Bf=Wo,Vf=Fe,In=Fn?Fn.isConcatSpreadable:void 0;function Lf(e){return Vf(e)||Bf(e)||!!(In&&e&&e[In])}var zf=Lf,Uf=Yt,Gf=zf;function Dn(e,t,o,n,s){var a=-1,l=e.length;for(o||(o=Gf),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Dn(c,t-1,o,n,s):Uf(s,c):n||(s[s.length]=c)}return s}var Wf=Dn,Hf=Wf;function qf(e){var t=e==null?0:e.length;return t?Hf(e,1):[]}var Kf=qf;function Jf(e,t,o){switch(o.length){case 0:return e.call(t);case 1:return e.call(t,o[0]);case 2:return e.call(t,o[0],o[1]);case 3:return e.call(t,o[0],o[1],o[2])}return e.apply(t,o)}var Yf=Jf,Zf=Yf,Nn=Math.max;function Qf(e,t,o){return t=Nn(t===void 0?e.length-1:t,0),function(){for(var n=arguments,s=-1,a=Nn(n.length-t,0),l=Array(a);++s<a;)l[s]=n[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=n[s];return c[t]=o(l),Zf(e,this,c)}}var Xf=Qf;function Rf(e){return function(){return e}}var eh=Rf;function th(e){return e}var oh=th,nh=eh,Pn=Bo,rh=oh,sh=Pn?function(e,t){return Pn(e,"toString",{configurable:!0,enumerable:!1,value:nh(t),writable:!0})}:rh,ah=sh,ih=800,lh=16,ch=Date.now;function uh(e){var t=0,o=0;return function(){var n=ch(),s=lh-(n-o);if(o=n,s>0){if(++t>=ih)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var dh=uh,ph=ah,mh=dh,fh=mh(ph),hh=fh,yh=Kf,gh=Xf,vh=hh;function bh(e){return vh(gh(e,void 0,yh),e+"")}var xh=bh,Ch=ko,wh=wm,$h=Sf,Sh=ao,kh=Re,Ah=jf,Th=xh,Oh=on,Fh=1,Ih=2,Dh=4,Nh=Th(function(e,t){var o={};if(e==null)return o;var n=!1;t=Ch(t,function(a){return a=Sh(a,e),n||(n=a.length>1),a}),kh(e,Oh(e),o),n&&(o=wh(o,Fh|Ih|Dh,Ah));for(var s=t.length;s--;)$h(o,t[s]);return o}),Ph=Nh;const Eh=So(Ph),En={title:`{{t("Form event", { ns: "${d}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{title:`{{t("Form data model", { ns: "${d}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${d}" })}}`,"x-reactions":[...de["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(v({},je),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User submitted form")}}];return xe(C(v({},t),{fields:s,appends:["data","user",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Mh(e,t,o,n,s,a){var l;if(e){const c=(l=t==null?void 0:t.data)==null?void 0:l.activeFields;if(c){const u=Object.keys(o.values).filter(p=>{const m=s(p);return!c.has(p)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(m==null?void 0:m.type)});return Eh(v({},o.values),u)}}return o.values}function _h(){var M;const e=i.useAPIClient(),t=I.useForm(),{field:o,resource:n,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=I.useFieldSchema(),p=I.useField(),{fields:m,getField:h,getTreeParentField:g}=i.useCollection(),f=i.useCompile(),y=i.useFilterByTk(),w=i.useRecord(),$=i.useCurrentUserContext(),{modal:k}=x.App.useApp(),S=(M=$==null?void 0:$.data)==null?void 0:M.data,A=p.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var V,ne,J,Z,Q,ee;const _=m.map(re=>re.name),{assignedValues:F={},onSuccess:N,overwriteValues:U,skipValidator:ie,triggerWorkflows:Y}=(V=u==null?void 0:u["x-action-settings"])!=null?V:{},ue=(ne=l==null?void 0:l["x-component-props"])==null?void 0:ne.addChild,E=L.parse(F)({currentTime:new Date,currentRecord:w,currentUser:S});ie||(yield t.submit());const j=Mh(y,o,t,_,h);if(ue){const re=g();j[(J=re==null?void 0:re.name)!=null?J:"parent"]=w,j[(Z=re==null?void 0:re.foreignKey)!=null?Z:"parentId"]=w.id}p.data=o.data||{},p.data.loading=!0;try{const re=yield e.resource("workflows").trigger({values:v(v(v({},j),U),E),filterKeys:A,triggerWorkflows:Y!=null&&Y.length?Y.map(pe=>[pe.workflowKey,pe.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=re,(ee=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||ee.call(Q),a==null||a(!1),!(N!=null&&N.successMessage))return;N!=null&&N.manualClose?k.success({title:f(N==null?void 0:N.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),N!=null&&N.redirecting&&(N!=null&&N.redirectTo)&&(L.isURL(N.redirectTo)?window.location.href=N.redirectTo:c(N.redirectTo))})}):x.message.success(f(N==null?void 0:N.successMessage))}catch(re){p.data.loading=!1}})}}}const De={STATIC:0,COLLECTION_FIELD:1};function jh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Mn({value:e,onChange:t}){const{t:o}=te.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
353
353
|
display: flex;
|
|
354
354
|
gap: 0.5em;
|
|
355
|
-
`,children:[r.jsx(Vt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:
|
|
355
|
+
`,children:[r.jsx(Vt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:jh,placeholder:o("Select field")}),e.field?r.jsx(x.Select,{value:n,onChange:a=>{s(a),t(C(v({},e),{offset:Math.abs(e.offset)*a}))},options:[{value:0,label:T("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(x.InputNumber,{value:Math.abs(e.offset),onChange:a=>t(C(v({},e),{offset:(a!=null?a:0)*n}))}),r.jsx(x.Select,{value:e.unit||864e5,onChange:a=>t(C(v({},e),{unit:a})),options:[{value:864e5,label:T("Days")},{value:36e5,label:T("Hours")},{value:6e4,label:T("Minutes")},{value:1e3,label:T("Seconds")}]})]}):null]})}function Bh({value:e,onChange:t}){const{t:o}=Mt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
|
|
356
356
|
display: flex;
|
|
357
357
|
gap: 0.5em;
|
|
358
|
-
`,children:[r.jsxs(x.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Mn,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:bo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ce.apply(this,arguments)};function _n(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function xt(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Bh=[{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 * * * *"}],Ne=[{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"]}],B={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 jn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ct(e){return e.sort(function(t,o){return t-o}),e}function Bn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function fe(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 Vn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function wt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Ln(e,t,o,n,s,a,l,c,u,p,m,h,g,f){o&&o(void 0),t(!1);var y=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;y=!0}if(!y){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void f("reboot");var w=Bh.find(function(S){return S.name===e});w&&(e=w.value)}try{var $=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var A=S.replace(/\s+/g," ").trim().split(" ");if(A.length===5)return A.map(function(M,D){return function(_,F){if(_==="*"||_==="*/1")return[];var N=Ct(Bn(Wn(function(ie,Y,ue){if(ue){ie=ie.toUpperCase();for(var E=0;E<ue.length;E++)ie=ie.replace(ue[E],"".concat(E+Y))}return ie}(_,F.min,F.alt).split(",").map(function(ie){var Y,ue=ie.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(_,' for "').concat(F.type,'"'));var E=ue[0],j=ue[1];Y=E==="*"?jn(F.min,F.max):function(J,Z,Q){var ee=J.split("-");if(ee.length===1){var re=wt(ee[0]);if(isNaN(re))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));return[re]}if(ee.length===2){var pe=wt(ee[0]),qe=wt(ee[1]);if(isNaN(pe)||isNaN(qe))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));if(qe<pe)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(Q.type));return jn(pe,qe)}throw new Error('Invalid value "'.concat(J,'" for ').concat(Q.type))}(E,_,F);var V=function(J,Z){if(J!==void 0){var Q=wt(J);if(isNaN(Q)||Q<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(Z.type));return Q}}(j,F),ne=function(J,Z){if(Z){var Q=J[0];J=J.filter(function(ee){return ee%Z==Q%Z||ee===Q})}return J}(Y,V);return ne}).flat(),F))),U=Hn(N,F);if(U!==void 0)throw new Error('Value "'.concat(U,'" out of range for ').concat(F.type));return N.length===F.total?[]:N}(M,Ne[D])});throw new Error("Invalid cron string format")}(e),k=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}($);f(k),u($[0]),p($[1]),m($[2]),h($[3]),g($[4])}catch(S){y=!0}}y&&(s.current=e,t(!0),Vn(o,l))}function zn(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(m,h){var g=Ne[h];return Un(Gn(m,g),g,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function Un(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var p=1;p<c.length;p++){var m=c[p-1];if(c[p]-m!==u)return!1}return!0}(e,l)?function(c,u,p){var m=qn(c),h=Kn(c),g=c.length===(h-m)/p+1;return!!(m===u.min&&h+p>u.max&&g)}(e,t,l)?"*/".concat(l):"".concat(He(qn(e),t,o,n,s),"-").concat(He(Kn(e),t,o,n,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(m,h,g){m!==g[h+1]-1?p!==null?(u.push([p,m]),p=null):u.push(m):p===null&&(p=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(He(c[0],t,o,n,s),"-").concat(He(c[1],t,o,n,s)):He(c,t,o,n,s)}).join(",")}return a}function He(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=n&&(n===!0||n.includes(l)),m=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||m)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",g=e%12||12;g<10&&p&&(g=g.toString().padStart(2,"0")),a="".concat(g).concat(h)}return a}function Gn(e,t){var o=Ct(Bn(Wn(e,t)));if(o.length===0)return o;var n=Hn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Wn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Hn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function qn(e){return e[0]}function Kn(e){return e[e.length-1]}function et(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,m=e.readOnly,h=e.leadingZero,g=e.clockFormat,f=e.period,y=e.unit,w=e.periodicityOnDoubleClick,$=e.mode,k=_n(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),A=b.useMemo(function(){return s?s.map(function(E,j){return{value:(y.min===0?j:j+1).toString(),label:E}}):xt([],Array(y.total),!0).map(function(E,j){var V=y.min===0?j:j+1;return{value:V.toString(),label:He(V,y,u,h,g)}})},[s,h,u,g]),M=JSON.stringify(l),D=b.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var V=Un(Gn(t,y),y,u,h,g),ne=V.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(l.everyText||B.everyText," ").concat(ne[1]):V})},[t,M,u,h,g]),_=b.useCallback(function(E){var j=Array.isArray(E)?Ct(E):[E],V=j;t&&(V=$==="single"?[]:xt([],t,!0),j.forEach(function(ne){var J=Number(ne);V=t.some(function(Z){return Z===J})?V.filter(function(Z){return Z!==J}):Ct(xt(xt([],V,!0),[J],!1))})),V.length===y.total?a([]):a(V)},[a,t]),F=b.useCallback(function(E){if(E!==0&&E!==1){for(var j=y.total+y.min,V=[],ne=y.min;ne<j;ne++)ne%E==0&&V.push(ne);var J=t&&V&&t.length===V.length&&t.every(function(Q,ee){return Q===V[ee]}),Z=V.length===A.length;a(Z||J?[]:V)}else a([])},[t,A,a]),N=b.useRef([]),U=b.useCallback(function(E){if(!m){var j=N.current;j.push({time:new Date().getTime(),value:Number(E)});var V=window.setTimeout(function(){w&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?F(Number(E)):_([j[j.length-2].value,j[j.length-1].value]):_(Number(E)),N.current=[]},300);return function(){window.clearTimeout(V)}}},[N,_,F,m,w]),ie=b.useCallback(function(){m||a([])},[a,m]),Y=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),ue=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=y.type==="minutes"&&f!=="hour"&&f!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=y.type==="minutes"&&(f==="day"||f==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=y.type==="hours"&&g==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(y.type)]=!!c,E))},[c,n,g,f]);return r.jsx(x.Select,ce({mode:$!=="single"||w?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:ie,tagRender:D,className:Y,popupClassName:ue,options:A,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:U,onDeselect:U,disabled:p,dropdownAlign:y.type!=="minutes"&&y.type!=="hours"||f==="day"||f==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(y.type)},k))}function Vh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-hours")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(et,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ne[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h})]}))}function Lh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-minutes")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(et,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ne[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function zh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=!a||a.length===0,f=b.useMemo(function(){var $;return fe((($={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!g})["".concat(s,"-field")]=!!s,$["".concat(s,"-month-days")]=!!s,$))},[s,g]),y=JSON.stringify(n),w=b.useMemo(function(){return g?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[g,y]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",ce({className:f},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(et,{placeholder:w,value:t,setValue:o,unit:Ne[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function Uh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,m=e.mode,h=n.months||B.months,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-months")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(et,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:ce(ce({},Ne[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:m})]}))}function Gh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,p=[];u.includes("year")&&p.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||B.rebootOption});var m=b.useCallback(function(y){l||o(y)},[o,l]),h=b.useMemo(function(){var y;return fe(((y={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-period")]=!!s,y))},[s]),g=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,y))},[s,n.prefixPeriod]),f=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,y["".concat(s,"-select-dropdown-period")]=!!s,y))},[s]);return r.jsxs("div",ce({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:m,options:p,className:g,popupClassName:f,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Wh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=n.weekDays||B.weekDays,f=p==="week"||!l||l.length===0,y=b.useMemo(function(){var A;return fe(((A={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!f})["".concat(s,"-field")]=!!s,A["".concat(s,"-week-days")]=!!s,A))},[s,f]),w=JSON.stringify(n),$=b.useMemo(function(){return f?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[f,w]),k=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return k?r.jsxs("div",ce({className:y},{children:[n.prefixWeekDays!==""&&(p==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(et,{placeholder:$,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ne[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function Hh(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,m=p===void 0?"":p,h=e.setValue,g=e.displayError,f=g===void 0||g,y=e.onError,w=e.className,$=e.defaultPeriod,k=$===void 0?"day":$,S=e.allowEmpty,A=S===void 0?"for-default-value":S,M=e.humanizeLabels,D=M===void 0||M,_=e.humanizeValue,F=_!==void 0&&_,N=e.disabled,U=N!==void 0&&N,ie=e.readOnly,Y=ie!==void 0&&ie,ue=e.leadingZero,E=ue!==void 0&&ue,j=e.shortcuts,V=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,J=e.periodicityOnDoubleClick,Z=J===void 0||J,Q=e.mode,ee=Q===void 0?"multiple":Q,re=e.allowedDropdowns,pe=re===void 0?["period","months","month-days","week-days","hours","minutes"]:re,qe=e.allowedPeriods,Jg=qe===void 0?["year","month","week","day","hour","minute","reboot"]:qe,Ke=b.useRef(m),yo=b.useRef(k),Fr=b.useState(),$e=Fr[0],St=Fr[1],Ir=b.useState(),it=Ir[0],kt=Ir[1],Dr=b.useState(),At=Dr[0],Tt=Dr[1],Nr=b.useState(),lt=Nr[0],Ot=Nr[1],Pr=b.useState(),Ft=Pr[0],It=Pr[1],Er=b.useState(),Dt=Er[0],Nt=Er[1],Mr=b.useState(!1),go=Mr[0],ct=Mr[1],_r=b.useState(!1),Pt=_r[0],jr=_r[1],Yg=function(X){var ve=b.useRef(X);return b.useEffect(function(){ve.current=X},[X]),ve.current}(Pt),Br=JSON.stringify(u);b.useEffect(function(){Ln(m,ct,y,A,Ke,!0,u,V,Nt,It,kt,Tt,Ot,St)},[]),b.useEffect(function(){m!==Ke.current&&Ln(m,ct,y,A,Ke,!1,u,V,Nt,It,kt,Tt,Ot,St)},[m,Ke,Br,A,V]),b.useEffect(function(){if(!($e||Dt||At||it||lt||Ft)||Pt||Yg)Pt&&jr(!1);else{var X=$e||yo.current,ve=zn(X,At,it,lt,Ft,Dt,F);h(ve,{selectedPeriod:X}),Ke.current=ve,y&&y(void 0),ct(!1)}},[$e,it,At,lt,Ft,Dt,F,Pt]);var Vr=b.useCallback(function(){kt(void 0),Tt(void 0),Ot(void 0),It(void 0),Nt(void 0);var X="",ve=$e!=="reboot"&&$e?$e:yo.current;ve!==$e&&St(ve),l==="fill-with-every"&&(X=zn(ve,void 0,void 0,void 0,void 0,void 0)),h(X,{selectedPeriod:ve}),Ke.current=X,jr(!0),A==="never"&&l==="empty"?(ct(!0),Vn(y,u)):(y&&y(void 0),ct(!1))},[$e,h,y,l]),Zg=b.useMemo(function(){var X;return fe(((X={"react-js-cron":!0,"react-js-cron-error":go&&f,"react-js-cron-disabled":U,"react-js-cron-read-only":Y})["".concat(w)]=!!w,X["".concat(w,"-error")]=go&&f&&!!w,X["".concat(w,"-disabled")]=U&&!!w,X["".concat(w,"-read-only")]=Y&&!!w,X))},[w,go,f,U,Y]),vo=s.className,Lr=_n(s,["className"]),zr=b.useMemo(function(){var X;return fe(((X={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,X["".concat(vo)]=!!vo,X))},[w,vo]),Qg=JSON.stringify(Lr),Ur=b.useMemo(function(){return o&&!Y?r.jsx(x.Button,ce({className:zr,danger:!0,type:"primary",disabled:U},Lr,{onClick:Vr},{children:u.clearButtonText||B.clearButtonText})):null},[o,Y,Br,zr,U,Qg,Vr]),le=$e||yo.current;return r.jsxs("div",ce({className:Zg},{children:[pe.includes("period")&&r.jsx(Gh,{value:le,setValue:St,locale:u,className:w,disabled:U,readOnly:Y,shortcuts:V,allowedPeriods:Jg}),le==="reboot"?Ur:r.jsxs(r.Fragment,{children:[le==="year"&&pe.includes("months")&&r.jsx(Uh,{value:At,setValue:Tt,locale:u,className:w,humanizeLabels:D,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month")&&pe.includes("month-days")&&r.jsx(zh,{value:it,setValue:kt,locale:u,className:w,weekDays:lt,disabled:U,readOnly:Y,leadingZero:E,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month"||le==="week")&&pe.includes("week-days")&&r.jsx(Wh,{value:lt,setValue:Ot,locale:u,className:w,humanizeLabels:D,monthDays:it,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&pe.includes("hours")&&r.jsx(Vh,{value:Ft,setValue:It,locale:u,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,period:le,periodicityOnDoubleClick:Z,mode:ee}),le!=="minute"&&pe.includes("minutes")&&r.jsx(Lh,{value:Dt,setValue:Nt,locale:u,period:le,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,periodicityOnDoubleClick:Z,mode:ee}),Ur]})]})]}))}const qh={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},Jn=[{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 Yn(e){return Jn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Kh(e){let t;switch(typeof e){case"number":return t=Yn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Jh({value:e,onChange:t}){const{t:o}=Mt(),n=Yn(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Yh({value:e=null,onChange:t}){const{t:o}=Mt(),n=Kh(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=qh[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
358
|
+
`,children:[r.jsxs(x.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Mn,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:bo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ce.apply(this,arguments)};function _n(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function xt(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Vh=[{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 * * * *"}],Ne=[{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"]}],B={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 jn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ct(e){return e.sort(function(t,o){return t-o}),e}function Bn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function fe(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 Vn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function wt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Ln(e,t,o,n,s,a,l,c,u,p,m,h,g,f){o&&o(void 0),t(!1);var y=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;y=!0}if(!y){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void f("reboot");var w=Vh.find(function(S){return S.name===e});w&&(e=w.value)}try{var $=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var A=S.replace(/\s+/g," ").trim().split(" ");if(A.length===5)return A.map(function(M,D){return function(_,F){if(_==="*"||_==="*/1")return[];var N=Ct(Bn(Wn(function(ie,Y,ue){if(ue){ie=ie.toUpperCase();for(var E=0;E<ue.length;E++)ie=ie.replace(ue[E],"".concat(E+Y))}return ie}(_,F.min,F.alt).split(",").map(function(ie){var Y,ue=ie.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(_,' for "').concat(F.type,'"'));var E=ue[0],j=ue[1];Y=E==="*"?jn(F.min,F.max):function(J,Z,Q){var ee=J.split("-");if(ee.length===1){var re=wt(ee[0]);if(isNaN(re))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));return[re]}if(ee.length===2){var pe=wt(ee[0]),qe=wt(ee[1]);if(isNaN(pe)||isNaN(qe))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));if(qe<pe)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(Q.type));return jn(pe,qe)}throw new Error('Invalid value "'.concat(J,'" for ').concat(Q.type))}(E,_,F);var V=function(J,Z){if(J!==void 0){var Q=wt(J);if(isNaN(Q)||Q<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(Z.type));return Q}}(j,F),ne=function(J,Z){if(Z){var Q=J[0];J=J.filter(function(ee){return ee%Z==Q%Z||ee===Q})}return J}(Y,V);return ne}).flat(),F))),U=Hn(N,F);if(U!==void 0)throw new Error('Value "'.concat(U,'" out of range for ').concat(F.type));return N.length===F.total?[]:N}(M,Ne[D])});throw new Error("Invalid cron string format")}(e),k=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}($);f(k),u($[0]),p($[1]),m($[2]),h($[3]),g($[4])}catch(S){y=!0}}y&&(s.current=e,t(!0),Vn(o,l))}function zn(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(m,h){var g=Ne[h];return Un(Gn(m,g),g,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function Un(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var p=1;p<c.length;p++){var m=c[p-1];if(c[p]-m!==u)return!1}return!0}(e,l)?function(c,u,p){var m=qn(c),h=Kn(c),g=c.length===(h-m)/p+1;return!!(m===u.min&&h+p>u.max&&g)}(e,t,l)?"*/".concat(l):"".concat(He(qn(e),t,o,n,s),"-").concat(He(Kn(e),t,o,n,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(m,h,g){m!==g[h+1]-1?p!==null?(u.push([p,m]),p=null):u.push(m):p===null&&(p=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(He(c[0],t,o,n,s),"-").concat(He(c[1],t,o,n,s)):He(c,t,o,n,s)}).join(",")}return a}function He(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=n&&(n===!0||n.includes(l)),m=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||m)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",g=e%12||12;g<10&&p&&(g=g.toString().padStart(2,"0")),a="".concat(g).concat(h)}return a}function Gn(e,t){var o=Ct(Bn(Wn(e,t)));if(o.length===0)return o;var n=Hn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Wn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Hn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function qn(e){return e[0]}function Kn(e){return e[e.length-1]}function et(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,m=e.readOnly,h=e.leadingZero,g=e.clockFormat,f=e.period,y=e.unit,w=e.periodicityOnDoubleClick,$=e.mode,k=_n(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),A=b.useMemo(function(){return s?s.map(function(E,j){return{value:(y.min===0?j:j+1).toString(),label:E}}):xt([],Array(y.total),!0).map(function(E,j){var V=y.min===0?j:j+1;return{value:V.toString(),label:He(V,y,u,h,g)}})},[s,h,u,g]),M=JSON.stringify(l),D=b.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var V=Un(Gn(t,y),y,u,h,g),ne=V.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(l.everyText||B.everyText," ").concat(ne[1]):V})},[t,M,u,h,g]),_=b.useCallback(function(E){var j=Array.isArray(E)?Ct(E):[E],V=j;t&&(V=$==="single"?[]:xt([],t,!0),j.forEach(function(ne){var J=Number(ne);V=t.some(function(Z){return Z===J})?V.filter(function(Z){return Z!==J}):Ct(xt(xt([],V,!0),[J],!1))})),V.length===y.total?a([]):a(V)},[a,t]),F=b.useCallback(function(E){if(E!==0&&E!==1){for(var j=y.total+y.min,V=[],ne=y.min;ne<j;ne++)ne%E==0&&V.push(ne);var J=t&&V&&t.length===V.length&&t.every(function(Q,ee){return Q===V[ee]}),Z=V.length===A.length;a(Z||J?[]:V)}else a([])},[t,A,a]),N=b.useRef([]),U=b.useCallback(function(E){if(!m){var j=N.current;j.push({time:new Date().getTime(),value:Number(E)});var V=window.setTimeout(function(){w&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?F(Number(E)):_([j[j.length-2].value,j[j.length-1].value]):_(Number(E)),N.current=[]},300);return function(){window.clearTimeout(V)}}},[N,_,F,m,w]),ie=b.useCallback(function(){m||a([])},[a,m]),Y=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),ue=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=y.type==="minutes"&&f!=="hour"&&f!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=y.type==="minutes"&&(f==="day"||f==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=y.type==="hours"&&g==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(y.type)]=!!c,E))},[c,n,g,f]);return r.jsx(x.Select,ce({mode:$!=="single"||w?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:ie,tagRender:D,className:Y,popupClassName:ue,options:A,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:U,onDeselect:U,disabled:p,dropdownAlign:y.type!=="minutes"&&y.type!=="hours"||f==="day"||f==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(y.type)},k))}function Lh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-hours")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(et,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ne[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h})]}))}function zh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-minutes")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(et,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ne[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Uh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=!a||a.length===0,f=b.useMemo(function(){var $;return fe((($={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!g})["".concat(s,"-field")]=!!s,$["".concat(s,"-month-days")]=!!s,$))},[s,g]),y=JSON.stringify(n),w=b.useMemo(function(){return g?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[g,y]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",ce({className:f},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(et,{placeholder:w,value:t,setValue:o,unit:Ne[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function Gh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,m=e.mode,h=n.months||B.months,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-months")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(et,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:ce(ce({},Ne[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:m})]}))}function Wh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,p=[];u.includes("year")&&p.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||B.rebootOption});var m=b.useCallback(function(y){l||o(y)},[o,l]),h=b.useMemo(function(){var y;return fe(((y={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-period")]=!!s,y))},[s]),g=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,y))},[s,n.prefixPeriod]),f=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,y["".concat(s,"-select-dropdown-period")]=!!s,y))},[s]);return r.jsxs("div",ce({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:m,options:p,className:g,popupClassName:f,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Hh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=n.weekDays||B.weekDays,f=p==="week"||!l||l.length===0,y=b.useMemo(function(){var A;return fe(((A={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!f})["".concat(s,"-field")]=!!s,A["".concat(s,"-week-days")]=!!s,A))},[s,f]),w=JSON.stringify(n),$=b.useMemo(function(){return f?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[f,w]),k=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return k?r.jsxs("div",ce({className:y},{children:[n.prefixWeekDays!==""&&(p==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(et,{placeholder:$,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ne[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function qh(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,m=p===void 0?"":p,h=e.setValue,g=e.displayError,f=g===void 0||g,y=e.onError,w=e.className,$=e.defaultPeriod,k=$===void 0?"day":$,S=e.allowEmpty,A=S===void 0?"for-default-value":S,M=e.humanizeLabels,D=M===void 0||M,_=e.humanizeValue,F=_!==void 0&&_,N=e.disabled,U=N!==void 0&&N,ie=e.readOnly,Y=ie!==void 0&&ie,ue=e.leadingZero,E=ue!==void 0&&ue,j=e.shortcuts,V=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,J=e.periodicityOnDoubleClick,Z=J===void 0||J,Q=e.mode,ee=Q===void 0?"multiple":Q,re=e.allowedDropdowns,pe=re===void 0?["period","months","month-days","week-days","hours","minutes"]:re,qe=e.allowedPeriods,Jg=qe===void 0?["year","month","week","day","hour","minute","reboot"]:qe,Ke=b.useRef(m),yo=b.useRef(k),Ir=b.useState(),$e=Ir[0],St=Ir[1],Dr=b.useState(),it=Dr[0],kt=Dr[1],Nr=b.useState(),At=Nr[0],Tt=Nr[1],Pr=b.useState(),lt=Pr[0],Ot=Pr[1],Er=b.useState(),Ft=Er[0],It=Er[1],Mr=b.useState(),Dt=Mr[0],Nt=Mr[1],_r=b.useState(!1),go=_r[0],ct=_r[1],jr=b.useState(!1),Pt=jr[0],Br=jr[1],Yg=function(X){var ve=b.useRef(X);return b.useEffect(function(){ve.current=X},[X]),ve.current}(Pt),Vr=JSON.stringify(u);b.useEffect(function(){Ln(m,ct,y,A,Ke,!0,u,V,Nt,It,kt,Tt,Ot,St)},[]),b.useEffect(function(){m!==Ke.current&&Ln(m,ct,y,A,Ke,!1,u,V,Nt,It,kt,Tt,Ot,St)},[m,Ke,Vr,A,V]),b.useEffect(function(){if(!($e||Dt||At||it||lt||Ft)||Pt||Yg)Pt&&Br(!1);else{var X=$e||yo.current,ve=zn(X,At,it,lt,Ft,Dt,F);h(ve,{selectedPeriod:X}),Ke.current=ve,y&&y(void 0),ct(!1)}},[$e,it,At,lt,Ft,Dt,F,Pt]);var Lr=b.useCallback(function(){kt(void 0),Tt(void 0),Ot(void 0),It(void 0),Nt(void 0);var X="",ve=$e!=="reboot"&&$e?$e:yo.current;ve!==$e&&St(ve),l==="fill-with-every"&&(X=zn(ve,void 0,void 0,void 0,void 0,void 0)),h(X,{selectedPeriod:ve}),Ke.current=X,Br(!0),A==="never"&&l==="empty"?(ct(!0),Vn(y,u)):(y&&y(void 0),ct(!1))},[$e,h,y,l]),Zg=b.useMemo(function(){var X;return fe(((X={"react-js-cron":!0,"react-js-cron-error":go&&f,"react-js-cron-disabled":U,"react-js-cron-read-only":Y})["".concat(w)]=!!w,X["".concat(w,"-error")]=go&&f&&!!w,X["".concat(w,"-disabled")]=U&&!!w,X["".concat(w,"-read-only")]=Y&&!!w,X))},[w,go,f,U,Y]),vo=s.className,zr=_n(s,["className"]),Ur=b.useMemo(function(){var X;return fe(((X={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,X["".concat(vo)]=!!vo,X))},[w,vo]),Qg=JSON.stringify(zr),Gr=b.useMemo(function(){return o&&!Y?r.jsx(x.Button,ce({className:Ur,danger:!0,type:"primary",disabled:U},zr,{onClick:Lr},{children:u.clearButtonText||B.clearButtonText})):null},[o,Y,Vr,Ur,U,Qg,Lr]),le=$e||yo.current;return r.jsxs("div",ce({className:Zg},{children:[pe.includes("period")&&r.jsx(Wh,{value:le,setValue:St,locale:u,className:w,disabled:U,readOnly:Y,shortcuts:V,allowedPeriods:Jg}),le==="reboot"?Gr:r.jsxs(r.Fragment,{children:[le==="year"&&pe.includes("months")&&r.jsx(Gh,{value:At,setValue:Tt,locale:u,className:w,humanizeLabels:D,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month")&&pe.includes("month-days")&&r.jsx(Uh,{value:it,setValue:kt,locale:u,className:w,weekDays:lt,disabled:U,readOnly:Y,leadingZero:E,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month"||le==="week")&&pe.includes("week-days")&&r.jsx(Hh,{value:lt,setValue:Ot,locale:u,className:w,humanizeLabels:D,monthDays:it,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&pe.includes("hours")&&r.jsx(Lh,{value:Ft,setValue:It,locale:u,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,period:le,periodicityOnDoubleClick:Z,mode:ee}),le!=="minute"&&pe.includes("minutes")&&r.jsx(zh,{value:Dt,setValue:Nt,locale:u,period:le,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,periodicityOnDoubleClick:Z,mode:ee}),Gr]})]})]}))}const Kh={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},Jn=[{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 Yn(e){return Jn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Jh(e){let t;switch(typeof e){case"number":return t=Yn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Yh({value:e,onChange:t}){const{t:o}=Mt(),n=Yn(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Zh({value:e=null,onChange:t}){const{t:o}=Mt(),n=Jh(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Kh[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
359
359
|
display: flex;
|
|
360
360
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
361
361
|
align-items: flex-start;
|
|
@@ -384,7 +384,7 @@
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
`,children:[r.jsx(x.Select,{value:n,onChange:s,className:"auto-width",children:Jn.map(l=>r.jsx(x.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(
|
|
387
|
+
`,children:[r.jsx(x.Select,{value:n,onChange:s,className:"auto-width",children:Jn.map(l=>r.jsx(x.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Yh,{value:e,onChange:t}):null,n==="cron"?r.jsx(qh,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const Qh={[De.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${d}" })}}`,min:0}}},[De.COLLECTION_FIELD]:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${d}" })}}`,min:0}},appends:C(v({},je),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${De.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Xh=[{value:De.STATIC,label:`{{t("Based on certain date", { ns: "${d}" })}}`},{value:De.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${d}" })}}`}],Rh=()=>{const{values:e={},clearFormGraph:t}=I.useForm(),[o,n]=b.useState(e.mode);return I.useFormEffects(()=>{me.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${d}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Xh},required:!0,default:De.STATIC}}),r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
388
388
|
.ant-input-number {
|
|
389
389
|
width: auto;
|
|
390
390
|
min-width: 6em;
|
|
@@ -393,10 +393,10 @@
|
|
|
393
393
|
.ant-picker {
|
|
394
394
|
width: auto;
|
|
395
395
|
}
|
|
396
|
-
`},properties:
|
|
396
|
+
`},properties:Qh[o]}}},components:{OnField:Mn,RepeatField:Zh,EndsByField:Bh}})]})},Zn={title:`{{t("Schedule event", { ns: "${d}" })}}`,type:"schedule",description:`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${d}" })}}`,fieldset:{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{ScheduleConfig:Rh},useVariables(e,t){var a;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&s.push({key:"date",value:"date",label:T("Trigger time")}),e.mode===De.COLLECTION_FIELD){const[l]=xe(C(v({},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}}],appends:["data",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}));l&&s.push(l)}return s},useInitializers(e){return e.collection?{type:"item",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function ey(){var a;const e=I.useForm(),t=i.useAPIClient(),{workflow:o}=(a=z())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return K(this,null,function*(){var c,u;if(o.executed){x.message.error(T("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("workflows")).update)==null?void 0:u.call(c,{filterByTk:o.id,values:{config:e.values}}),n.setVisible(!1),s()})}}}const ge=new L.Registry;ge.register(En.type,En),ge.register($o.type,$o),ge.register(Zn.type,Zn);function ty(){const e=i.useCompile(),{workflow:t,execution:o}=z(),{styles:n}=se();if(!o)return null;const s=ge.get(t.type);return r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(P.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(x.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
|
|
397
397
|
padding: 1em;
|
|
398
398
|
background-color: #eee;
|
|
399
|
-
`},"x-read-pretty":!0}}}}}})}const
|
|
399
|
+
`},"x-read-pretty":!0}}}}}})}const oy=()=>{const e=i.useAPIClient();i.useCompile();const{workflow:t,refresh:o}=z(),[n,s]=b.useState(""),[a,l]=b.useState(!1),{styles:c}=se();let u="";b.useEffect(()=>{var D;t&&s((D=t.title)!=null?D:u)},[t]);const p=b.useMemo(()=>me.createForm({initialValues:t==null?void 0:t.config,values:t==null?void 0:t.config,disabled:t==null?void 0:t.executed}),[t]);if(!t||!t.type)return null;const{title:m,type:h,executed:g}=t,f=ge.get(h),{fieldset:y,scope:w,components:$}=f;u=f.title;const k=g?'{{t("View")}}':'{{t("Configure")}}',S=T("Trigger");function A(D){return K(this,null,function*(){var F,N;const _=D||u;s(_),_!==m&&(yield(N=(F=e.resource("workflows")).update)==null?void 0:N.call(F,{filterByTk:t.id,values:{title:_}}),o())})}function M(D){var F;if(D.target===D.currentTarget){l(!0);return}const _=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let N=D.target;N&&N!==D.currentTarget;N=N.parentNode)if(Array.from((F=N.classList)!=null?F:[]).some(U=>_.has(U))){l(!0),D.stopPropagation();return}}return r.jsxs("div",{className:i.cx(c.nodeCardClass),onClick:M,children:[r.jsx("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:r.jsx(x.Tag,{color:"gold",children:S})}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{value:n,onChange:D=>s(D.target.value),onBlur:D=>A(D.target.value),autoSize:!0})}),r.jsx(ty,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:l},children:r.jsx(i.SchemaComponent,{schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":k,"x-component":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:S,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{form:p},properties:C(v({},g?{alert:{"x-component":x.Alert,"x-component-props":{type:"warning",showIcon:!0,message:`{{t("Trigger in executed workflow cannot be modified", { ns: "${d}" })}}`,className:i.css`
|
|
400
400
|
width: 100%;
|
|
401
401
|
font-size: 85%;
|
|
402
402
|
margin-bottom: 2em;
|
|
@@ -405,31 +405,31 @@
|
|
|
405
405
|
width: auto;
|
|
406
406
|
min-width: 6em;
|
|
407
407
|
}
|
|
408
|
-
`},properties:y},actions:v({},g?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:
|
|
408
|
+
`},properties:y},actions:v({},g?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:ey}}}})})}}},scope:w,components:$})})]})};function Qn(){const{workflow:e}=z();return ge.get(e.type)}function Xn(){return Array.from(ge.getEntities()).map(([e,{title:t}])=>({value:e,label:t,color:"gold"}))}const Pe={label:"label",value:"value",children:"children"},io={label:`{{t("Node result", { ns: "${d}" })}}`,value:"$jobsMapByNodeId",useOptions(e){const t=we(),o=st(t),n=[];return o.forEach(s=>{var c;const a=H.get(s.type),l=(c=a.useVariables)==null?void 0:c.call(a,s,e);l&&n.push(l)}),n}},lo={label:`{{t("Trigger variables", { ns: "${d}" })}}`,value:"$context",useOptions(e){var n,s;const{workflow:t}=z(),o=ge.get(t.type);return(s=(n=o==null?void 0:o.useVariables)==null?void 0:n.call(o,t.config,e))!=null?s:null}},ny={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Pe}=e,o=we(),n=gr(o),s=[];return n.forEach(a=>{var u,p;const l=H.get(a.type),c=(u=l.useScopeVariables)==null?void 0:u.call(l,a,e);c&&s.push({key:a.id.toString(),[t.value]:a.id.toString(),[t.label]:(p=a.title)!=null?p:`#${a.id}`,[t.children]:c})}),s}},ry={label:`{{t("System variables", { ns: "${d}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Pe}){return[...!e||e.includes("date")?[{key:"now",[t.label]:T("System time"),[t.value]:"now"}]:[]]}},tt={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 Rn(e,t,o){var s,a,l,c,u,p;const n=typeof t;return n==="string"?(s=tt[t])==null?void 0:s.has(e.interface):n==="object"&&t.type==="reference"?co(e)?((a=t.options)==null?void 0:a.entity)&&(e.collectionName===((l=t.options)==null?void 0:l.collection)||((c=t.options)==null?void 0:c.collection)==="*"):e.isForeignKey?e.collectionName===((u=t.options)==null?void 0:u.collection)&&e.name==="id"||e.target===((p=t.options)==null?void 0:p.collection):!1:n==="function"?t(e,o):!1}function co(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function uo(e,t){const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function er({fields:e,types:t,appends:o,compile:n,getCollectionFields:s}){return e.filter(a=>{if(t!=null&&t.length)return t.some(l=>Rn(a,l,o));if(co(a)){const l=uo(a,o),c=o.includes(a.name);return(l.length||c)&&er({fields:tr(a.target,{compile:n,getCollectionFields:s}),types:t,appends:l,compile:n,getCollectionFields:s}).length}return!0})}function ae(e={}){var a;const t=Object.assign({},Pe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t}),n=i.useCompile();return[ny,io,lo,ry].map(l=>{var u,p;const c=(p=(u=l.useOptions)==null?void 0:u.call(l,o))==null?void 0:p.filter(Boolean);return{[t.label]:n(l.label),[t.value]:l.value,key:l[t.value],[t.children]:c,disabled:!c||!c.length}})}function tr(e,{compile:t,getCollectionFields:o}){var l,c,u,p,m,h,g;const n=o(e),s=[],a=[];n.forEach(f=>{f.isForeignKey?s.push(f):a.push(f)});for(let f=a.length-1;f>=0;f--){const y=a[f];if(y.type==="belongsTo"){const w=s.find($=>$.name===y.foreignKey);w?a.splice(f,0,C(v(v({},y),w),{uiSchema:C(v({},y.uiSchema),{title:(l=y.uiSchema)!=null&&l.title?`${t((c=y.uiSchema)==null?void 0:c.title)} ID`:w.name})})):a.splice(f,0,C(v({},y),{name:y.foreignKey,type:"bigInt",isForeignKey:!0,interface:y.interface,uiSchema:C(v({},y.uiSchema),{title:(u=y.uiSchema)!=null&&u.title?`${t((p=y.uiSchema)==null?void 0:p.title)} ID`:y.name})}))}else if(y.type==="context"&&y.collectionName==="users"){const w=(m=a.find($=>$.type==="belongsTo"&&$.target==="users"&&$.foreignKey===y.name))!=null?m:{};a.splice(f,0,C(v({},y),{type:y.dataType,interface:w.interface,uiSchema:C(v({},w.uiSchema),{title:(h=w.uiSchema)!=null&&h.title?`${t((g=w.uiSchema)==null?void 0:g.title)} ID`:y.name})}))}}return a.filter(f=>f.interface&&!f.hidden)}function sy(e){const t=uo(e.field,e.appends),o=xe(v({collection:e.field.target,types:e.types,appends:t},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>Rn(e.field,s,t))||(e.disabled=!0))}function xe(e){const{fields:t,collection:o,types:n,appends:s=[],compile:a,getCollectionFields:l,fieldNames:c=Pe}=e,u=tr(o,{compile:a,getCollectionFields:l}),p=t!=null?t:u,m=sy.bind({compile:a,getCollectionFields:l,fieldNames:c});return er({fields:p,types:n,appends:s,compile:a,getCollectionFields:l}).map(g=>{var $;const f=a((($=g.uiSchema)==null?void 0:$.title)||g.name),y=uo(g,s),w=!co(g)||!y.length&&!s.includes(g.name);return{[c.label]:f,key:g.name,[c.value]:g.name,isLeaf:w,loadChildren:w?null:m,field:g,appends:s,types:n}})}function ot({value:e,onChange:t,renderSchemaComponent:o}){const n=ae();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}const nt=()=>null;function ay(s){var a=s,{node:e,resultTitle:t,insert:o}=a,n=q(a,["node","resultTitle","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{var l;o({type:"void",name:e.id,title:e.title,"x-component":"CardItem","x-component-props":{title:(l=e.title)!=null?l:`#${e.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:t,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeId.${e.id}}}`}}}})}}))}function iy({dataSource:e}){var s;const t=I.useFieldSchema(),{execution:o}=z();if(!o)return t.title;const n=L.parse(e)({$jobsMapByNodeId:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})});return r.jsx("pre",{className:i.css`
|
|
409
409
|
margin: 0;
|
|
410
410
|
`,children:JSON.stringify(n,null,2)})}nt.Initializer=ay,nt.Result=iy;function ly(e,t){const o=`${e.name}.`;return["hasOne","belongsTo"].includes(e.type)&&(t?t.includes(e.name)||t.some(n=>n.startsWith(o)):!0)||["hasMany","belongsToMany"].includes(e.type)}function cy(){const e=i.useCompile();return[io,lo].map(t=>{var n;const o=(n=t.useOptions({types:[ly]}))==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 uy(n){var s=n,{value:e,onChange:t}=s,o=q(s,["value","onChange"]);const{setValuesIn:a}=I.useForm(),{getCollection:l}=i.useCollectionManager(),c=cy(),[u,p]=b.useState(c),{associatedKey:m="",name:h}=e!=null?e:{};let g=[];const f=m.match(/^{{(.*)}}$/);f&&(g=[...f[1].trim().split(".").slice(0,-1),h]);const y=$=>K(this,null,function*(){var S;const k=$[$.length-1];!((S=k.children)!=null&&S.length)&&!k.isLeaf&&k.loadChildren&&(yield k.loadChildren(k),p(A=>[...A]))});b.useEffect(()=>{(()=>K(this,null,function*(){var S;if(!g||u.length<=1)return;let k=null;for(let A=0;A<g.length;A++){const M=g[A];try{A===0?k=u.find(D=>D.value===M):(k.loadChildren&&!((S=k.children)!=null&&S.length)&&(yield k.loadChildren(k)),k=k.children.find(D=>D.value===M))}catch(D){console.error(D)}}p([...u])}))()},[e,u.length]);const w=b.useCallback(($,k)=>{if(!($!=null&&$.length)){a("collection",null),t({});return}const{field:S}=k.pop(),{collectionName:A,target:M,name:D}=S,F=l(A).fields.find(N=>N.primaryKey);a("collection",M),t({name:D,associatedKey:`{{${$.slice(0,-1).join(".")}.${F.name}}}`,associatedCollection:A})},[t]);return r.jsx(x.Cascader,C(v({},o),{value:g,options:u,onChange:w,loadData:y}))}const dy={title:`{{t("Aggregate", { ns: "${d}" })}}`,type:"aggregate",group:"collection",description:`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${d}" })}}`,fieldset:{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${d}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${d}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:C(v({},de),{title:`{{t("Data of collection", { ns: "${d}" })}}`,"x-component-props":C(v({},de["x-component-props"]),{className:null}),"x-reactions":[...de["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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:C(v({},_e),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{SchemaComponentContext:i.SchemaComponentContext,FilterDynamicComponent:ot,FieldsSelect:Vt,ValueBlock:nt,AssociatedConfig:uy},useVariables({id:e,title:t},{types:o,fieldNames:n=Pe}){return o&&!o.some(s=>s in tt||Object.values(tt).some(a=>a.has(s)))?null:{[n.value]:`${e}`,[n.label]:t}},useInitializers(e){var t;return e.config.collection?{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:nt.Initializer,node:e,resultTitle:T("Query result")}:null}};function $t(e){const s=e,{options:t=[]}=s,o=q(s,["options"]),n=i.useCompile();return r.jsx(x.Radio.Group,C(v({},o),{children:t.map(a=>r.jsxs(x.Radio,{value:a.value,children:[r.jsx("span",{className:i.css`
|
|
411
411
|
& + .anticon {
|
|
412
412
|
margin-left: 0.25em;
|
|
413
413
|
}
|
|
414
|
-
`,children:n(a.label)}),a.tooltip&&r.jsx(x.Tooltip,{title:n(a.tooltip),children:r.jsx(P.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))}))}const
|
|
414
|
+
`,children:n(a.label)}),a.tooltip&&r.jsx(x.Tooltip,{title:n(a.tooltip),children:r.jsx(P.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))}))}const or=e=>{const t=Je.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
|
|
415
415
|
&:after {
|
|
416
416
|
content: ':';
|
|
417
417
|
}
|
|
418
418
|
& + a {
|
|
419
419
|
margin-left: 0.25em;
|
|
420
420
|
}
|
|
421
|
-
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function py(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}const my=({value:e,onChange:t})=>{const{t:o}=te.useTranslation(),{getCollectionFields:n,getCollection:s}=i.useCollectionManager(),a=ae({types:[py.bind({getCollectionFields:n,getCollection:s})]});return r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(Se.FormItem,{colon:!0,label:o("Expression type",{ns:d}),children:r.jsxs(x.Radio.Group,{value:e===!1?!1:e||"",onChange:l=>{t(l.target.value)},children:[r.jsx(x.Radio,{value:!1,children:o("Static",{ns:d})}),r.jsx(x.Radio,{value:e||"",children:o("Dynamic",{ns:d})})]})}),e!==!1?r.jsx(Se.FormItem,{label:o("Select dynamic expression",{ns:d}),extra:o("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:d}),children:r.jsx(i.Variable.Input,{value:e||"",onChange:l=>t(l),scope:a})}):null]})},fy={title:`{{t("Calculation", { ns: "${d}" })}}`,type:"calculation",group:"control",description:`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression can be static or dynamic one from an expression collections.", { ns: "${d}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Je.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,t,{form:o}){const{values:n}=o,{evaluate:s}=Je.evaluators.get(n.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return T("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"ScopeSelect","x-component-props":{changeOnSelect:!0},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:
|
|
421
|
+
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function py(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}const my=({value:e,onChange:t})=>{const{t:o}=te.useTranslation(),{getCollectionFields:n,getCollection:s}=i.useCollectionManager(),a=ae({types:[py.bind({getCollectionFields:n,getCollection:s})]});return r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(Se.FormItem,{colon:!0,label:o("Expression type",{ns:d}),children:r.jsxs(x.Radio.Group,{value:e===!1?!1:e||"",onChange:l=>{t(l.target.value)},children:[r.jsx(x.Radio,{value:!1,children:o("Static",{ns:d})}),r.jsx(x.Radio,{value:e||"",children:o("Dynamic",{ns:d})})]})}),e!==!1?r.jsx(Se.FormItem,{label:o("Select dynamic expression",{ns:d}),extra:o("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:d}),children:r.jsx(i.Variable.Input,{value:e||"",onChange:l=>t(l),scope:a})}):null]})},fy={title:`{{t("Calculation", { ns: "${d}" })}}`,type:"calculation",group:"control",description:`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression can be static or dynamic one from an expression collections.", { ns: "${d}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Je.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,t,{form:o}){const{values:n}=o,{evaluate:s}=Je.evaluators.get(n.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return T("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"ScopeSelect","x-component-props":{changeOnSelect:!0},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:or},components:{CalculationExpression(e){const t=ae();return r.jsx(i.Variable.TextArea,v({scope:t,changeOnSelect:!0},e))},ScopeSelect(e){const t=ae({types:[{type:"reference",options:{collection:"*",entity:!0}}]});return r.jsx(i.Variable.Input,v({scope:t},e))},CalculationResult({dataSource:e}){var n;const{execution:t}=z();if(!t)return T("Calculation result");const o=L.parse(e)({$jobsMapByNodeId:((n=t.jobs)!=null?n:[]).reduce((s,a)=>Object.assign(s,{[a.nodeId]:a.result}),{})});return r.jsx("pre",{className:i.css`
|
|
422
422
|
margin: 0;
|
|
423
|
-
`,children:JSON.stringify(o,null,2)})},RadioWithTooltip:$t,DynamicConfig:my},useVariables({id:e,title:t},{types:o,fieldNames:n=i.defaultFieldNames}){return o&&!o.some(s=>s in tt||Object.values(tt).some(a=>a.has(s)))?null:{[n.value]:`${e}`,[n.label]:t}},useInitializers(e){var t;return{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:nt.Initializer,node:e,resultTitle:T("Calculation result")}}},R=new L.Registry;R.register("equal",{name:"=",type:"boolean",group:"boolean"}),R.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),R.register("gt",{name:">",type:"boolean",group:"boolean"}),R.register("gte",{name:"≥",type:"boolean",group:"boolean"}),R.register("lt",{name:"<",type:"boolean",group:"boolean"}),R.register("lte",{name:"≤",type:"boolean",group:"boolean"}),R.register("add",{name:"+",type:"number",group:"number"}),R.register("minus",{name:"-",type:"number",group:"number"}),R.register("multiple",{name:"*",type:"number",group:"number"}),R.register("divide",{name:"/",type:"number",group:"number"}),R.register("mod",{name:"%",type:"number",group:"number"}),R.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),R.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),R.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),R.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),R.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),R.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),R.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const hy=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${d}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${d}" })}}`},{value:"date",title:`{{t("Date", { ns: "${d}" })}}`}];function
|
|
423
|
+
`,children:JSON.stringify(o,null,2)})},RadioWithTooltip:$t,DynamicConfig:my},useVariables({id:e,title:t},{types:o,fieldNames:n=i.defaultFieldNames}){return o&&!o.some(s=>s in tt||Object.values(tt).some(a=>a.has(s)))?null:{[n.value]:`${e}`,[n.label]:t}},useInitializers(e){var t;return{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:nt.Initializer,node:e,resultTitle:T("Calculation result")}}},R=new L.Registry;R.register("equal",{name:"=",type:"boolean",group:"boolean"}),R.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),R.register("gt",{name:">",type:"boolean",group:"boolean"}),R.register("gte",{name:"≥",type:"boolean",group:"boolean"}),R.register("lt",{name:"<",type:"boolean",group:"boolean"}),R.register("lte",{name:"≤",type:"boolean",group:"boolean"}),R.register("add",{name:"+",type:"number",group:"number"}),R.register("minus",{name:"-",type:"number",group:"number"}),R.register("multiple",{name:"*",type:"number",group:"number"}),R.register("divide",{name:"/",type:"number",group:"number"}),R.register("mod",{name:"%",type:"number",group:"number"}),R.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),R.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),R.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),R.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),R.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),R.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),R.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const hy=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${d}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${d}" })}}`},{value:"date",title:`{{t("Date", { ns: "${d}" })}}`}];function nr(e){return Array.from(R.getEntities()).filter(([t,o])=>o.group===e)}function yy({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=ae();return r.jsxs("fieldset",{className:i.css`
|
|
424
424
|
display: flex;
|
|
425
425
|
gap: 0.5em;
|
|
426
426
|
align-items: center;
|
|
427
427
|
flex-wrap: wrap;
|
|
428
|
-
`,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(x.Select,{value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:T("Calculator"),popupMatchSelectWidth:!1,className:"auto-width",children:hy.filter(a=>!!
|
|
428
|
+
`,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(x.Select,{value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:T("Calculator"),popupMatchSelectWidth:!1,className:"auto-width",children:hy.filter(a=>!!nr(a.value).length).map(a=>r.jsx(x.Select.OptGroup,{label:n(a.title),children:nr(a.value).map(([l,{name:c}])=>r.jsx(x.Select.Option,{value:l,children:n(c)},l))},a.value))}),r.jsx(i.Variable.Input,{value:t[1],onChange:a=>o({calculator:e,operands:[t[0],a]}),scope:s,useTypedConstant:!0})]})}function gy({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
|
|
429
429
|
display: flex;
|
|
430
430
|
position: relative;
|
|
431
431
|
margin: 0.5em 0;
|
|
432
|
-
`,children:[e.group?r.jsx(
|
|
432
|
+
`,children:[e.group?r.jsx(rr,{value:e.group,onChange:a=>t(C(v({},e),{group:a}))}):r.jsx(yy,{operands:s,calculator:n,onChange:t}),r.jsx(x.Button,{onClick:o,type:"link",icon:r.jsx(P.CloseCircleOutlined,{})})]})}function rr({value:e,onChange:t}){const{t:o}=te.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(C(v({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(C(v({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),t(C(v({},e),{calculations:[...s]}))}function u(p,m){s.splice(p,1,m),t(C(v({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
|
|
433
433
|
position: relative;
|
|
434
434
|
width: 100%;
|
|
435
435
|
.node-type-condition-group {
|
|
@@ -455,13 +455,13 @@
|
|
|
455
455
|
margin-right: 1em;
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
`,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function vy({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(
|
|
458
|
+
`,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function vy({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(rr,{value:o.group,onChange:n=>t(C(v({},o),{group:n}))})}const by={title:`{{t("Condition", { ns: "${d}" })}}`,type:"condition",group:"control",description:`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${d}" })}}`,fieldset:{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${d}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${d}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${d}" })}}`}],...Array.from(Je.evaluators.getEntities())].reduce((e,[t,o])=>e.concat(v({value:t},o)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,t,{form:o}){const{values:n}=o,{evaluate:s}=Je.evaluators.get(n.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return T("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},view:{},options:[{label:`{{t('Continue when "Yes"', { ns: "${d}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${d}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],component:function({data:t}){const{t:o}=te.useTranslation(),{nodes:n}=z(),{styles:s}=se(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),u=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(at,{data:t,children:l?null:r.jsxs("div",{className:i.cx(s.nodeSubtreeClass),children:[r.jsxs("div",{className:i.cx(s.branchBlockClass,i.css`
|
|
459
459
|
> * > .workflow-branch-lines {
|
|
460
460
|
> button {
|
|
461
461
|
display: none;
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
`),children:[r.jsx(Ee,{from:t,entry:u,branchIndex:0}),r.jsx(Ee,{from:t,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:o("No")}),r.jsx("span",{style:{left:"4em"},children:o("Yes")})]})]})})},scope:{renderEngineReference:
|
|
464
|
+
`),children:[r.jsx(Ee,{from:t,entry:u,branchIndex:0}),r.jsx(Ee,{from:t,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:o("No")}),r.jsx("span",{style:{left:"4em"},children:o("Yes")})]})]})})},scope:{renderEngineReference:or,useWorkflowVariableOptions:ae},components:{CalculationConfig:vy,CalculationExpression(e){const t=ae();return r.jsx(i.Variable.TextArea,v({scope:t},e))},RadioWithTooltip:$t}};function xy(e){const{getCollectionFields:t}=i.useCollectionManager(),{path:o}=I.useField(),n=o.segments[o.segments.length-1],{values:s}=I.useForm(),a=t(s==null?void 0:s.collection),{type:l}=a.find(p=>p.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(p){const m=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?m:m.split(/[,\s]+/))}return r.jsx(x.Input,C(v({},e),{value:c,onChange:u}))}const sr=I.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=te.useTranslation(),l=i.useCompile(),c=I.useForm(),{getCollection:u,getCollectionFields:p}=i.useCollectionManager(),m=ae(),{values:h}=c,g=h==null?void 0:h.collection,f=p(g).filter(S=>S.uiSchema),y=n?f.filter(n.bind(h)):f,w=b.useMemo(()=>y.filter(S=>!e||!(S.name in e)),[y,e]),$=t||c.disabled,k=b.useMemo(()=>({onClick:({key:S})=>{o(C(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(S=>{var A,M;return{key:S.name,label:l((M=(A=S.uiSchema)==null?void 0:A.title)!=null?M:S.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:i.css`
|
|
465
465
|
margin-top: 0.5em;
|
|
466
466
|
|
|
467
467
|
> .ant-formily-item {
|
|
@@ -475,10 +475,10 @@
|
|
|
475
475
|
.ant-form-item-control-input-content {
|
|
476
476
|
display: flex;
|
|
477
477
|
}
|
|
478
|
-
`,children:[r.jsx(i.Variable.Input,{scope:m,value:e[S.name],changeOnSelect:!0,onChange:_=>{o(C(v({},e),{[S.name]:_}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":A,"x-validator"(){return""}}}}})}),$?null:r.jsx(x.Button,{type:"link",icon:r.jsx(P.CloseCircleOutlined,{}),onClick:()=>{var N;const U=e,{[N=S.name]:_}=U,F=q(U,[
|
|
478
|
+
`,children:[r.jsx(i.Variable.Input,{scope:m,value:e[S.name],changeOnSelect:!0,onChange:_=>{o(C(v({},e),{[S.name]:_}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":A,"x-validator"(){return""}}}}})}),$?null:r.jsx(x.Button,{type:"link",icon:r.jsx(P.CloseCircleOutlined,{}),onClick:()=>{var N;const U=e,{[N=S.name]:_}=U,F=q(U,[Kr(N)]);o(F)}})]},S.name)}),w.length?r.jsx(x.Dropdown,{menu:k,children:r.jsx(x.Button,{icon:r.jsx(P.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:T("Please select collection first")})})},{displayName:"CollectionFieldSet"}),Cy={title:`{{t("Create record", { ns: "${d}" })}}`,type:"create",group:"collection",description:`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{values:wo,appends:je}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{CollectionFieldset:sr},useVariables({id:e,title:t,config:o},n){var u,p;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager(),l=`${e}`,[c]=xe(C(v({},n),{fields:[{collectionName:o.collection,name:l,type:"hasOne",target:o.collection,uiSchema:{title:t}}],appends:[l,...((p=(u=o.params)==null?void 0:u.appends)==null?void 0:p.map(m=>`${l}.${m}`))||[]],compile:s,getCollectionFields:a}));return c},useInitializers(e){var t;return e.config.collection?{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Me,collection:e.config.collection,dataSource:`{{$jobsMapByNodeId.${e.id}}}`}:null},initializers:{}},ar=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function wy(e){return ar.slice().reverse().find(t=>!(e%t.value))}function $y({value:e=6e4,onChange:t}){const o=wy(e),n=Math.round(e/o.value);return r.jsxs("fieldset",{className:i.css`
|
|
479
479
|
display: flex;
|
|
480
480
|
gap: 0.5em;
|
|
481
|
-
`,children:[r.jsx(x.InputNumber,{min:1,value:n,onChange:s=>t(Math.round(s*o.value)),className:"auto-width"}),r.jsx(x.Select,{popupMatchSelectWidth:!1,value:o.value,onChange:s=>t(Math.round(n*s)),className:"auto-width",children:
|
|
481
|
+
`,children:[r.jsx(x.InputNumber,{min:1,value:n,onChange:s=>t(Math.round(s*o.value)),className:"auto-width"}),r.jsx(x.Select,{popupMatchSelectWidth:!1,value:o.value,onChange:s=>t(Math.round(n*s)),className:"auto-width",children:ar.map(s=>r.jsx(x.Select.Option,{value:s.value,children:T(s.label)},s.value))})]})}const Sy={title:`{{t("Delay", { ns: "${d}" })}}`,type:"delay",group:"control",description:`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${d}" })}}`,fieldset:{duration:{type:"number",title:`{{t("Duration", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${d}" })}}`,value:oe.RESOLVED},{label:`{{t("Fail and exit", { ns: "${d}" })}}`,value:oe.FAILED}],required:!0,default:oe.RESOLVED}},view:{},scope:{},components:{Duration:$y}};function po(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 mo(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return mo(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}const ky={title:'{{t("Delete record")}}',type:"destroy",group:"collection",description:`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{filter:C(v({},_e),{"x-validator"(e){return mo(e)?"":`{{t("Please add at least one condition", { ns: "${d}" })}}`}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:ot}};function Ay(e,t){let o=e,n=null;for(let s=0;s<t.length;s++){const a=t[s],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}const Ty={title:`{{t("Loop", { ns: "${d}" })}}`,type:"loop",group:"control",description:`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${d}" })}}`,fieldset:{target:{type:"string",title:`{{t("Loop target", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",changeOnSelect:!0,useTypedConstant:["string","number","null"],className:i.css`
|
|
482
482
|
width: 100%;
|
|
483
483
|
|
|
484
484
|
.variable {
|
|
@@ -493,13 +493,13 @@
|
|
|
493
493
|
`),children:[r.jsx(Ee,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:i.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(P.ArrowUpOutlined,{})})]})]}),r.jsx("div",{className:i.css`
|
|
494
494
|
position: relative;
|
|
495
495
|
height: 2em;
|
|
496
|
-
`})]})})},scope:{useWorkflowVariableOptions:ae},components:{},useScopeVariables(e,t){const o=i.useCompile(),{target:n}=e.config;if(!n)return null;const{fieldNames:s=Pe}=t;let a={key:"item",[s.value]:"item",[s.label]:T("Loop target")};if(typeof n=="string"&&n.startsWith("{{")&&n.endsWith("}}")){const l=n.slice(2,-2).split(".").map(p=>p.trim()),c=[io,lo].map(p=>{const m=p.useOptions(t).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:m,disabled:m&&!m.length}}),u=Ay(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:T("Loop index")},{key:"length",[s.value]:"length",[s.label]:T("Loop length")}]}};function Oy(e){const{execution:t}=z(),o=b.useMemo(()=>{var s;return{$context:t==null?void 0:t.context,$jobsMapByNodeId:((s=t==null?void 0:t.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})}},[t]);return b.useMemo(()=>L.parse(e)(o),[t])}function ar(e){const t=I.useField(),o=b.useRef(null),{appends:n,updateAssociationValues:s}=i.useAssociationNames(),a=Oy(e.dataSource),l=b.useMemo(()=>me.createForm({values:a,readPretty:!0}),[a]),c={appends:n},u={loading:!1,data:{data:a}},m=i.useAPIClient().resource(e.collection),h=b.useContext(i.BlockRequestContext);return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:a,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:m,__parent:h},children:r.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function ir(e){var k,S,A;const t=i.useRecord(),o=I.useFieldSchema(),n=I.useField(),s=b.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys((k=o.toJSON().properties)!=null?k:{}),u=(S=t==null?void 0:t.result)==null?void 0:S[c],{findComponent:p}=i.useDesignable(),m=p((A=n.component)==null?void 0:A[0])||b.Fragment,h=b.useMemo(()=>me.createForm({initialValues:u}),[u]),g=v({appends:a},e.params),f={loading:!1,data:{data:u}},w=i.useAPIClient().resource(e.collection),$=b.useContext(i.BlockRequestContext);return!t.status||u?r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:u,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:n,service:f,resource:w,__parent:$},children:r.jsx(i.FormBlockContext.Provider,{value:{params:g,form:h,field:n,service:f,updateAssociationValues:l,formBlockRef:s},children:r.jsxs(m,C(v({},n.componentProps),{children:[r.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:s,children:r.jsx(I.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})}):null}function Fy(n){var s=n,{insert:e,schema:t}=s,o=q(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return K(this,arguments,function*({item:u}){const m=u.template?yield a(u):null,h=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:m}));delete h["x-acl-action-props"],delete h["x-acl-action"];const[g]=Object.keys(h.properties);h.properties[g].properties.actions["x-decorator"]="ActionBarProvider",h.properties[g].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Lt(h,f=>{f["x-uid"]&&delete f["x-uid"]}),e(h)})}return r.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function lr(e){var t;return r.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:r.jsx(Fy,v({},e))})}function Iy(){const{name:e,title:t}=i.useCollection();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Dy={title:`{{t("Create record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`createForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Create record", { ns: "${d}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:lr}))}},initializers:{},components:{CreateFormDesigner:Iy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]={type:"create",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function cr(e){var p,m,h,g;const[t,o]=b.useState((m=(p=e.collection)==null?void 0:p.fields)!=null?m:[]),n=i.useRecord(),s=I.useField(),a=I.useFieldSchema(),[l]=Object.keys((h=a.toJSON().properties)!=null?h:{}),c=(g=n==null?void 0:n.result)==null?void 0:g[l],u=b.useMemo(()=>me.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:r.jsx(i.RecordProvider,{record:c,parent:!1,children:r.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Ny(o){var n=o,{insert:e}=n,t=q(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:L.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[L.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const ur={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 Py(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:s="others"}=n;t[s]=t[s]||{},xo.set(t,[s,o],n)}),Object.keys(ur).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:ur[o],children:Object.keys(t[o]||{}).map(n=>{const s=t[o][n];return v({value:n,title:s.title,name:n},t[o][n])}).sort((n,s)=>n.order-s.order)}))}function Ey(){const{interfaces:e}=i.useCollectionManager();return Py(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({key:n.name,type:"item",title:n.title,component:_y,fieldInterface:n.name}))}))}const dr=b.createContext({});function My(e){const{insertPosition:t="beforeEnd",component:o}=e,n=Ey(),s=b.useContext(i.CollectionContext),[a,l]=b.useState(null),[c,u]=b.useState(),{setCollectionFields:p}=b.useContext(i.FormBlockContext);return r.jsxs(dr.Provider,{value:{onAddField(m){const w=xo.cloneDeep(m),{properties:$}=w,k=$,{unique:h,type:g}=k,f=q(k,["unique","type"]),y=q(w,["properties"]);delete f.name["x-disabled"],l(C(v({},y),{properties:f}))},setCallback:u},children:[r.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:n,component:o,title:"{{t('Configure fields')}}"}),r.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(v({},a.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=I.useForm();return{run(){return K(this,null,function*(){u(null),l(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:h}=I.useForm();return{run(){return K(this,null,function*(){var k,S,A,M;const{default:f}=a,y=L.uid();if(f.name=(k=m.name)!=null?k:y,f.uiSchema.title=(A=(S=m.uiSchema)==null?void 0:S.title)!=null?A:y,f.interface=a.name,(M=s.fields)==null?void 0:M.find(D=>D.name===f.name)){h("name").take().setFeedback({type:"error",messages:[T("Field name existed in form")]});return}const $=L.merge(f,m);p([...s.fields,$]),c({name:f.name,type:f.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:$},"x-collection-field":`${s.name}.${f.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function _y(e){const{item:t,insert:o}=e,{onAddField:n,setCallback:s}=b.useContext(dr),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return r.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),n(l)}},t.fieldInterface)}const pr={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Ny}},initializers:{AddCustomFormField:My},components:{CustomFormBlockProvider:cr},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c;const[s]=Object.keys(n.properties),a=n.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var p,m;return(m=(p=u["x-component-props"])==null?void 0:p.field)!=null?m:u["x-interface-options"]}),t[s]={type:"custom",title:((c=n["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,m;return{status:u["x-decorator-props"].value,values:(m=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:m.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:cr}}};function jy(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:n}=te.useTranslation(),{dn:s}=i.useDesignable();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.ActionModalItem,{title:n("Filter settings",{ns:d}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var l;return{options:i.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,s.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),s.refresh()}}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const By={title:`{{t("Update record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`updateForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Update record", { ns: "${d}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:lr}))}},initializers:{},components:{FilterDynamicComponent:ot,UpdateFormDesigner:jy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]=C(v({},n["x-decorator-props"]),{type:"update",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}})})}),t}},block:{scope:{},components:{}}},Ce=new L.Registry;Ce.register("customForm",pr),Ce.register("createForm",Dy),Ce.register("updateForm",By);function Vy(){const{workflow:e}=z(),t=Qn();return t.useInitializers?t.useInitializers(e.config):null}const Ly={customForm:pr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function zy(){var n,s;const e=I.useFieldSchema(),t=(s=Ly[(n=e["x-designer-props"])==null?void 0:n.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function Uy(e){const t=we(),o=st(t),n=[Vy()].filter(Boolean),s=o.map(c=>{var p;const u=H.get(c.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,c)}).filter(Boolean),a=[...n,...s.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${d}" })}}`,children:s}]:[]].filter(Boolean),l=[...a.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:a}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(Ce.getValues()).map(c=>{const{useInitializer:u}=c.config;return u()})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:l,title:"{{t('Add block')}}"}))}function Gy(){var w,$,k;const e=b.useContext(i.SchemaComponentContext),{t}=te.useTranslation(),o=I.useFieldSchema(),n=ae({fieldNames:{label:"title",value:"name"}}),[s,a]=b.useState(!1),[l,c]=b.useState((k=($=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:$.schema)!=null?k:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=b.useState(null),{components:m}=i.useSchemaOptionsContext();b.useEffect(()=>{p(new I.Schema({properties:{grid:l}}))},[l]);const h=b.useMemo(()=>{var A,M;const S=(M=(A=o==null?void 0:o["x-action-settings"])==null?void 0:A.assignedValues)==null?void 0:M.values;return me.createForm({initialValues:L.lodash.cloneDeep(S),values:L.lodash.cloneDeep(S)})},[]),g=t("Assign field values");function f(){a(!1)}function y(){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=h.values,a(!1),setTimeout(()=>{var S;(S=e.refresh)==null||S.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaSettings.Item,{onClick:()=>a(!0),children:g}),r.jsx(x.Modal,{width:"50%",title:g,open:s,onCancel:f,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:f,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:y,children:t("Submit")})]}),children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(I.FormProvider,{form:h,children:r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:T("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&u&&r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(L.lodash.get(u.toJSON(),"properties.grid"))}}),children:r.jsx(i.SchemaComponent,{schema:u,components:m})})]})})})})]})}function Wy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(Gy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Hy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=q(a,["action","actionProps","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{o({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function mr(n){var s=n,{action:e,actionProps:t}=s,o=q(s,["action","actionProps"]);return r.jsx(i.InitializerWithSwitch,C(v({},o),{schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function qy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:oe.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Hy,action:oe.RESOLVED,actionProps:{type:"primary"}},{key:oe.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:mr,action:oe.REJECTED,actionProps:{danger:!0}},{key:oe.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:mr,action:oe.PENDING}],title:"{{t('Configure actions')}}"}))}function Ky(){return{run(){}}}function Jy({value:e,onChange:t}){const o=b.useContext(i.SchemaComponentContext),n=Qn(),s=we(),a=st(s),l=I.useForm(),{workflow:c}=z(),u={},p={};a.forEach(h=>{const g=H.get(h.type);Object.assign(u,g.initializers),Object.assign(p,g.components)});const m=b.useMemo(()=>new I.Schema({properties:{drawer:{type:"void",title:'{{t("Configure form")}}',"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${d}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]);return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh(){var f;(f=o.refresh)==null||f.call(o);const{tabs:h}=L.lodash.get(m.toJSON(),"properties.drawer.properties"),g=Array.from(Ce.getValues()).reduce((y,w)=>Object.assign(y,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)}}),children:r.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:Uy,AddActionButton:qy},n.initializers),u),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.initializers),{})),children:r.jsx(i.SchemaComponent,{schema:m,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.components),{})),{FormBlockProvider:ir,DetailsBlockProvider:ar,ManualActionStatusProvider(h){return h.children},ActionBarProvider(h){return h.children},SimpleDesigner:zy,ManualActionDesigner:Wy}),scope:{useSubmit:Ky,useDetailsBlockProps:i.useFormBlockContext}})})})}function Yy(e){const{workflow:t}=z(),[o,n]=b.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),children:t.executed?T("View user interface"):T("Configure user interface")}),r.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:n},children:e.children})]})}function Zy({value:e,onChange:t}){return r.jsxs("fieldset",{className:i.css`
|
|
496
|
+
`})]})})},scope:{useWorkflowVariableOptions:ae},components:{},useScopeVariables(e,t){const o=i.useCompile(),{target:n}=e.config;if(!n)return null;const{fieldNames:s=Pe}=t;let a={key:"item",[s.value]:"item",[s.label]:T("Loop target")};if(typeof n=="string"&&n.startsWith("{{")&&n.endsWith("}}")){const l=n.slice(2,-2).split(".").map(p=>p.trim()),c=[io,lo].map(p=>{const m=p.useOptions(t).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:m,disabled:m&&!m.length}}),u=Ay(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:T("Loop index")},{key:"length",[s.value]:"length",[s.label]:T("Loop length")}]}};function Oy(e){const{execution:t}=z(),o=b.useMemo(()=>{var s;return{$context:t==null?void 0:t.context,$jobsMapByNodeId:((s=t==null?void 0:t.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})}},[t]);return b.useMemo(()=>L.parse(e)(o),[t])}function ir(e){const t=I.useField(),o=b.useRef(null),{appends:n,updateAssociationValues:s}=i.useAssociationNames(),a=Oy(e.dataSource),l=b.useMemo(()=>me.createForm({values:a,readPretty:!0}),[a]),c={appends:n},u={loading:!1,data:{data:a}},m=i.useAPIClient().resource(e.collection),h=b.useContext(i.BlockRequestContext);return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:a,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:m,__parent:h},children:r.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function lr(e){var k,S,A;const t=i.useRecord(),o=I.useFieldSchema(),n=I.useField(),s=b.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys((k=o.toJSON().properties)!=null?k:{}),u=(S=t==null?void 0:t.result)==null?void 0:S[c],{findComponent:p}=i.useDesignable(),m=p((A=n.component)==null?void 0:A[0])||b.Fragment,h=b.useMemo(()=>me.createForm({initialValues:u}),[u]),g=v({appends:a},e.params),f={loading:!1,data:{data:u}},w=i.useAPIClient().resource(e.collection),$=b.useContext(i.BlockRequestContext);return!t.status||u?r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:u,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:n,service:f,resource:w,__parent:$},children:r.jsx(i.FormBlockContext.Provider,{value:{params:g,form:h,field:n,service:f,updateAssociationValues:l,formBlockRef:s},children:r.jsxs(m,C(v({},n.componentProps),{children:[r.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:s,children:r.jsx(I.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})}):null}function Fy(n){var s=n,{insert:e,schema:t}=s,o=q(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return K(this,arguments,function*({item:u}){const m=u.template?yield a(u):null,h=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:m}));delete h["x-acl-action-props"],delete h["x-acl-action"];const[g]=Object.keys(h.properties);h.properties[g].properties.actions["x-decorator"]="ActionBarProvider",h.properties[g].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Lt(h,f=>{f["x-uid"]&&delete f["x-uid"]}),e(h)})}return r.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function cr(e){var t;return r.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:r.jsx(Fy,v({},e))})}function Iy(){const{name:e,title:t}=i.useCollection();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Dy={title:`{{t("Create record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`createForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Create record", { ns: "${d}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:cr}))}},initializers:{},components:{CreateFormDesigner:Iy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]={type:"create",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function ur(e){var p,m,h,g;const[t,o]=b.useState((m=(p=e.collection)==null?void 0:p.fields)!=null?m:[]),n=i.useRecord(),s=I.useField(),a=I.useFieldSchema(),[l]=Object.keys((h=a.toJSON().properties)!=null?h:{}),c=(g=n==null?void 0:n.result)==null?void 0:g[l],u=b.useMemo(()=>me.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:r.jsx(i.RecordProvider,{record:c,parent:!1,children:r.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Ny(o){var n=o,{insert:e}=n,t=q(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:L.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[L.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const dr={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 Py(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:s="others"}=n;t[s]=t[s]||{},xo.set(t,[s,o],n)}),Object.keys(dr).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:dr[o],children:Object.keys(t[o]||{}).map(n=>{const s=t[o][n];return v({value:n,title:s.title,name:n},t[o][n])}).sort((n,s)=>n.order-s.order)}))}function Ey(){const{interfaces:e}=i.useCollectionManager();return Py(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({key:n.name,type:"item",title:n.title,component:_y,fieldInterface:n.name}))}))}const pr=b.createContext({});function My(e){const{insertPosition:t="beforeEnd",component:o}=e,n=Ey(),s=b.useContext(i.CollectionContext),[a,l]=b.useState(null),[c,u]=b.useState(),{setCollectionFields:p}=b.useContext(i.FormBlockContext);return r.jsxs(pr.Provider,{value:{onAddField(m){const w=xo.cloneDeep(m),{properties:$}=w,k=$,{unique:h,type:g}=k,f=q(k,["unique","type"]),y=q(w,["properties"]);delete f.name["x-disabled"],l(C(v({},y),{properties:f}))},setCallback:u},children:[r.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:n,component:o,title:"{{t('Configure fields')}}"}),r.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(v({},a.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=I.useForm();return{run(){return K(this,null,function*(){u(null),l(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:h}=I.useForm();return{run(){return K(this,null,function*(){var k,S,A,M;const{default:f}=a,y=L.uid();if(f.name=(k=m.name)!=null?k:y,f.uiSchema.title=(A=(S=m.uiSchema)==null?void 0:S.title)!=null?A:y,f.interface=a.name,(M=s.fields)==null?void 0:M.find(D=>D.name===f.name)){h("name").take().setFeedback({type:"error",messages:[T("Field name existed in form")]});return}const $=L.merge(f,m);p([...s.fields,$]),c({name:f.name,type:f.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:$},"x-collection-field":`${s.name}.${f.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function _y(e){const{item:t,insert:o}=e,{onAddField:n,setCallback:s}=b.useContext(pr),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return r.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),n(l)}},t.fieldInterface)}const mr={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Ny}},initializers:{AddCustomFormField:My},components:{CustomFormBlockProvider:ur},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c;const[s]=Object.keys(n.properties),a=n.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var p,m;return(m=(p=u["x-component-props"])==null?void 0:p.field)!=null?m:u["x-interface-options"]}),t[s]={type:"custom",title:((c=n["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,m;return{status:u["x-decorator-props"].value,values:(m=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:m.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:ur}}};function jy(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:n}=te.useTranslation(),{dn:s}=i.useDesignable();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.ActionModalItem,{title:n("Filter settings",{ns:d}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var l;return{options:i.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,s.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),s.refresh()}}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const By={title:`{{t("Update record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`updateForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Update record", { ns: "${d}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:cr}))}},initializers:{},components:{FilterDynamicComponent:ot,UpdateFormDesigner:jy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]=C(v({},n["x-decorator-props"]),{type:"update",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}})})}),t}},block:{scope:{},components:{}}},Ce=new L.Registry;Ce.register("customForm",mr),Ce.register("createForm",Dy),Ce.register("updateForm",By);function Vy(){const{workflow:e}=z(),t=Qn();return t.useInitializers?t.useInitializers(e.config):null}const Ly={customForm:mr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function zy(){var n,s;const e=I.useFieldSchema(),t=(s=Ly[(n=e["x-designer-props"])==null?void 0:n.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function Uy(e){const t=we(),o=st(t),n=[Vy()].filter(Boolean),s=o.map(c=>{var p;const u=H.get(c.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,c)}).filter(Boolean),a=[...n,...s.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${d}" })}}`,children:s}]:[]].filter(Boolean),l=[...a.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:a}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(Ce.getValues()).map(c=>{const{useInitializer:u}=c.config;return u()})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:l,title:"{{t('Add block')}}"}))}function Gy(){var w,$,k;const e=b.useContext(i.SchemaComponentContext),{t}=te.useTranslation(),o=I.useFieldSchema(),n=ae({fieldNames:{label:"title",value:"name"}}),[s,a]=b.useState(!1),[l,c]=b.useState((k=($=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:$.schema)!=null?k:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=b.useState(null),{components:m}=i.useSchemaOptionsContext();b.useEffect(()=>{p(new I.Schema({properties:{grid:l}}))},[l]);const h=b.useMemo(()=>{var A,M;const S=(M=(A=o==null?void 0:o["x-action-settings"])==null?void 0:A.assignedValues)==null?void 0:M.values;return me.createForm({initialValues:L.lodash.cloneDeep(S),values:L.lodash.cloneDeep(S)})},[]),g=t("Assign field values");function f(){a(!1)}function y(){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=h.values,a(!1),setTimeout(()=>{var S;(S=e.refresh)==null||S.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaSettings.Item,{onClick:()=>a(!0),children:g}),r.jsx(x.Modal,{width:"50%",title:g,open:s,onCancel:f,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:f,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:y,children:t("Submit")})]}),children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(I.FormProvider,{form:h,children:r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:T("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&u&&r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(L.lodash.get(u.toJSON(),"properties.grid"))}}),children:r.jsx(i.SchemaComponent,{schema:u,components:m})})]})})})})]})}function Wy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(Gy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Hy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=q(a,["action","actionProps","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{o({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function fr(n){var s=n,{action:e,actionProps:t}=s,o=q(s,["action","actionProps"]);return r.jsx(i.InitializerWithSwitch,C(v({},o),{schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function qy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:oe.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Hy,action:oe.RESOLVED,actionProps:{type:"primary"}},{key:oe.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:fr,action:oe.REJECTED,actionProps:{danger:!0}},{key:oe.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:fr,action:oe.PENDING}],title:"{{t('Configure actions')}}"}))}function Ky(){return{run(){}}}function Jy({value:e,onChange:t}){const o=b.useContext(i.SchemaComponentContext),n=Qn(),s=we(),a=st(s),l=I.useForm(),{workflow:c}=z(),u={},p={};a.forEach(h=>{const g=H.get(h.type);Object.assign(u,g.initializers),Object.assign(p,g.components)});const m=b.useMemo(()=>new I.Schema({properties:{drawer:{type:"void",title:'{{t("Configure form")}}',"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${d}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]);return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh(){var f;(f=o.refresh)==null||f.call(o);const{tabs:h}=L.lodash.get(m.toJSON(),"properties.drawer.properties"),g=Array.from(Ce.getValues()).reduce((y,w)=>Object.assign(y,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)}}),children:r.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:Uy,AddActionButton:qy},n.initializers),u),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.initializers),{})),children:r.jsx(i.SchemaComponent,{schema:m,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.components),{})),{FormBlockProvider:lr,DetailsBlockProvider:ir,ManualActionStatusProvider(h){return h.children},ActionBarProvider(h){return h.children},SimpleDesigner:zy,ManualActionDesigner:Wy}),scope:{useSubmit:Ky,useDetailsBlockProps:i.useFormBlockContext}})})})}function Yy(e){const{workflow:t}=z(),[o,n]=b.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),children:t.executed?T("View user interface"):T("Configure user interface")}),r.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:n},children:e.children})]})}function Zy({value:e,onChange:t}){return r.jsxs("fieldset",{className:i.css`
|
|
497
497
|
.ant-radio-group {
|
|
498
498
|
.anticon {
|
|
499
499
|
margin-left: 0.5em;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
`,children:[r.jsx(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:o}})=>{console.log(o),t(Number(o))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:T("Separately")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:!1,children:r.jsxs(x.Tooltip,{title:T("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:T("Collaboratively")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(Se.FormLayout,{layout:"vertical",children:r.jsx(i.FormItem,{label:T("Negotiation"),children:r.jsxs(x.Radio.Group,{value:e,onChange:t,children:[r.jsx(x.Radio,{value:1,children:r.jsxs(x.Tooltip,{title:T("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:T("All pass")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:-1,children:r.jsxs(x.Tooltip,{title:T("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:T("Any pass")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function Qy(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Xy({multiple:e=!1,value:t=[],onChange:o}){const n=ae({types:[Qy]});return r.jsx(i.Variable.Input,{scope:n,value:t[0],onChange:s=>{o([s])},children:r.jsx(i.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:s=>{o(s!=null?[s]:[])},className:"auto-width"})})}const
|
|
502
|
+
`,children:[r.jsx(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:o}})=>{console.log(o),t(Number(o))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:T("Separately")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:!1,children:r.jsxs(x.Tooltip,{title:T("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:T("Collaboratively")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(Se.FormLayout,{layout:"vertical",children:r.jsx(i.FormItem,{label:T("Negotiation"),children:r.jsxs(x.Radio.Group,{value:e,onChange:t,children:[r.jsx(x.Radio,{value:1,children:r.jsxs(x.Tooltip,{title:T("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:T("All pass")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:-1,children:r.jsxs(x.Tooltip,{title:T("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:T("Any pass")}),r.jsx(P.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function Qy(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Xy({multiple:e=!1,value:t=[],onChange:o}){const n=ae({types:[Qy]});return r.jsx(i.Variable.Input,{scope:n,value:t[0],onChange:s=>{o([s])},children:r.jsx(i.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:s=>{o(s!=null?[s]:[])},className:"auto-width"})})}const hr=i.BlockInitializers.items.find(e=>e.key==="media");hr.children.find(e=>e.key==="workflowTodos")||hr.children.push({key:"workflowTodos",type:"item",title:`{{t("Workflow todos", { ns: "${d}" })}}`,component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"});const Ry={title:`{{t("Manual", { ns: "${d}" })}}`,type:"manual",group:"manual",description:`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${d}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Yy,SchemaConfig:Jy,ModeConfig:Zy,AssigneesSelect:Xy},useVariables({id:e,title:t,config:o},{types:n,fieldNames:s=Pe}){var p;const a=i.useCompile(),{getCollectionFields:l}=i.useCollectionManager(),c=Object.keys((p=o.forms)!=null?p:{});if(!c.length)return null;const u=c.map(m=>{var y;const h=o.forms[m],g=xe({fields:(y=h.collection)==null?void 0:y.fields,collection:h.collection,types:n,compile:a,getCollectionFields:l}),f=a(h.title)||m;return g.length?{key:m,value:m,label:f,title:f,children:g}:null}).filter(Boolean);return u.length?{[s.value]:`${e}`,[s.label]:t,[s.children]:u}:null},useInitializers(e){var s;const{getCollection:t}=i.useCollectionManager(),o=Object.keys((s=e.config.forms)!=null?s:{});if(!o.length||e.config.mode)return null;const n=o.map(a=>{var u;const l=e.config.forms[a],{fields:c=[]}=t(l.collection);return c.length?{type:"item",title:(u=l.title)!=null?u:a,component:Me,collection:l.collection,dataSource:`{{$jobsMapByNodeId.${e.id}.${a}}}`}:null}).filter(Boolean);return n.length?{key:"forms",type:"subMenu",title:e.title,children:n}:null},initializers:{}},eg={title:`{{t("Parallel branch", { ns: "${d}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${d}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${d}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${d}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${d}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${d}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${d}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${d}" })}}`}]},default:"all"}},view:{},component:function({data:t}){const{styles:o}=se(),{id:n,config:{mode:s}}=t,{workflow:a,nodes:l}=z(),c=l.reduce((g,f)=>f.upstreamId===n&&f.branchIndex!=null?g.concat(f):g,[]).sort((g,f)=>g.branchIndex-f.branchIndex),[u,p]=b.useState(Math.max(2,c.length)),m=Array(Math.max(0,u-c.length)).fill(null),h=c[c.length-1];return r.jsx(at,{data:t,children:r.jsxs("div",{className:i.cx(o.nodeSubtreeClass),children:[r.jsxs("div",{className:i.cx(o.branchBlockClass),children:[c.map(g=>r.jsx(Ee,{from:t,entry:g,branchIndex:g.branchIndex},g.id)),m.map((g,f)=>r.jsx(Ee,{from:t,branchIndex:(h?h.branchIndex:0)+f+1,controller:c.length+f>1?r.jsx("div",{className:i.css`
|
|
503
503
|
padding-top: 2em;
|
|
504
504
|
|
|
505
505
|
> button {
|
|
@@ -520,14 +520,14 @@
|
|
|
520
520
|
.anticon {
|
|
521
521
|
transform: rotate(-45deg);
|
|
522
522
|
}
|
|
523
|
-
`,onClick:()=>p(u+1),disabled:a.executed})})})]})})},components:{RadioWithTooltip:$t}},tg={title:`{{t("Query record", { ns: "${d}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${d}" })}}`,fieldset:{collection:de,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${d}" })}}`,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: "${d}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:
|
|
523
|
+
`,onClick:()=>p(u+1),disabled:a.executed})})})]})})},components:{RadioWithTooltip:$t}},tg={title:`{{t("Query record", { ns: "${d}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${d}" })}}`,fieldset:{collection:de,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${d}" })}}`,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: "${d}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:Xr,pagination:Rr,appends:je},"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: "${d}" })}}`}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource,useWorkflowVariableOptions:ae,useSortableFields(){const e=i.useCompile(),{getCollectionFields:t,getInterface:o}=i.useCollectionManager(),{values:n}=I.useForm();return t(n.collection).filter(a=>{if(!a.interface)return!1;const l=o(a.interface);return!!(l!=null&&l.sortable)}).map(a=>{var l,c;return{value:a.name,label:(l=a==null?void 0:a.uiSchema)!=null&&l.title?e((c=a==null?void 0:a.uiSchema)==null?void 0:c.title):a.name}})}},components:{ArrayItems:Se.ArrayItems,FilterDynamicComponent:ot,SchemaComponentContext:i.SchemaComponentContext},useVariables({id:e,title:t,config:o},n){var u,p;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager(),l=`${e}`,[c]=xe(C(v({},n),{fields:[{collectionName:o.collection,name:l,type:"hasOne",target:o.collection,uiSchema:{title:t}}],appends:[l,...((p=(u=o.params)==null?void 0:u.appends)==null?void 0:p.map(m=>`${l}.${m}`))||[]],compile:s,getCollectionFields:a}));return c},useInitializers(e){var t;return!e.config.collection||e.config.multiple?null:{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Me,collection:e.config.collection,dataSource:`{{$jobsMapByNodeId.${e.id}}}`}},initializers:{}},og={title:`{{t("HTTP request", { ns: "${d}" })}}`,type:"request",group:"extended",description:`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${d}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${d}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"RequestBody","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${d}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${d}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${d}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore fail request and continue workflow", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{useWorkflowVariableOptions:ae},components:{ArrayItems:Se.ArrayItems,RequestBody(e){const t=ae();return r.jsx(i.Variable.JSON,v({scope:t},e))}}},ng={title:`{{t("SQL action", { ns: "${d}" })}}`,type:"sql",group:"extended",description:`{{t("Execute a SQL statement in database.", { ns: "${d}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"SQLInput","x-component-props":{rows:20,className:i.css`
|
|
524
524
|
font-size: 80%;
|
|
525
525
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
526
|
-
`}}},scope:{},components:{SQLInput(e){const t=ae();return r.jsx(i.Variable.RawTextArea,v({scope:t},e))}}};function rg(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager(),a=I.useForm(),{collection:l}=a.values,c=s(l),u=I.useField();function p({target:m}){const h=u.query(".values").take();if(!h)return;const g=c.reduce((f,y)=>(y.name in h.value&&(m.value||!["hasOne","hasMany","belongsToMany"].includes(y.type))&&(f[y.name]=h.value[y.name]),f),{});a.setValuesIn("params.values",g),e(m.value)}return r.jsx($t,C(v({},t),{onChange:p}))}const sg={title:`{{t("Update record", { ns: "${d}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${d}" })}}`,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: "${d}" })}}`},{label:`{{t("Update one by one", { ns: "${d}" })}}`,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: "${d}" })}}`}]},default:!1},filter:C(v({},_e),{title:`{{t("Only update records matching conditions", { ns: "${d}" })}}`,"x-validator"(e){return mo(e)?"":T("Please add at least one condition")}}),values:C(v({},wo),{"x-component-props":{filter(e){var t;return((t=this.params)==null?void 0:t.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:ot,CollectionFieldset:
|
|
526
|
+
`}}},scope:{},components:{SQLInput(e){const t=ae();return r.jsx(i.Variable.RawTextArea,v({scope:t},e))}}};function rg(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager(),a=I.useForm(),{collection:l}=a.values,c=s(l),u=I.useField();function p({target:m}){const h=u.query(".values").take();if(!h)return;const g=c.reduce((f,y)=>(y.name in h.value&&(m.value||!["hasOne","hasMany","belongsToMany"].includes(y.type))&&(f[y.name]=h.value[y.name]),f),{});a.setValuesIn("params.values",g),e(m.value)}return r.jsx($t,C(v({},t),{onChange:p}))}const sg={title:`{{t("Update record", { ns: "${d}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${d}" })}}`,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: "${d}" })}}`},{label:`{{t("Update one by one", { ns: "${d}" })}}`,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: "${d}" })}}`}]},default:!1},filter:C(v({},_e),{title:`{{t("Only update records matching conditions", { ns: "${d}" })}}`,"x-validator"(e){return mo(e)?"":T("Please add at least one condition")}}),values:C(v({},wo),{"x-component-props":{filter(e){var t;return((t=this.params)==null?void 0:t.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:ot,CollectionFieldset:sr,IndividualHooksRadioWithTooltip:rg}};var yr={exports:{}};/*!
|
|
527
527
|
Copyright (c) 2018 Jed Watson.
|
|
528
528
|
Licensed under the MIT License (MIT), see
|
|
529
529
|
http://jedwatson.github.io/classnames
|
|
530
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var a=arguments[s];if(a){var l=typeof a;if(l==="string"||l==="number")n.push(a);else if(Array.isArray(a)){if(a.length){var c=o.apply(null,a);c&&n.push(c)}}else if(l==="object"){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){n.push(a.toString());continue}for(var u in a)t.call(a,u)&&a[u]&&n.push(u)}}}return n.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(
|
|
530
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var a=arguments[s];if(a){var l=typeof a;if(l==="string"||l==="number")n.push(a);else if(Array.isArray(a)){if(a.length){var c=o.apply(null,a);c&&n.push(c)}}else if(l==="object"){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){n.push(a.toString());continue}for(var u in a)t.call(a,u)&&a[u]&&n.push(u)}}}return n.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(yr);var ag=yr.exports;const ig=So(ag),lg=i.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
531
531
|
border: none;
|
|
532
532
|
.ant-tag {
|
|
533
533
|
width: 100%;
|
|
@@ -539,7 +539,7 @@
|
|
|
539
539
|
}
|
|
540
540
|
`,noStatusButtonClass:e`
|
|
541
541
|
border-width: 2px;
|
|
542
|
-
`}));function rt(e){var n;const{styles:t}=lg();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:s})}return r.jsx(x.Button,C(v({},e),{shape:"circle",size:"small",className:ig(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const H=new L.Registry;H.register("calculation",fy),H.register("condition",by),H.register("parallel",eg),H.register("loop",Ty),H.register("delay",Sy),H.register("manual",Ry),H.register("query",tg),H.register("create",Cy),H.register("update",sg),H.register("destroy",ky),H.register("aggregate",dy),H.register("request",og),H.register("sql",ng);function cg(){const e=I.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return K(this,null,function*(){var c,u;if(a.executed){x.message.error(T("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setVisible(!1),n()})}}}const fo=b.createContext({});function we(){return b.useContext(fo)}function st(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}function
|
|
542
|
+
`}));function rt(e){var n;const{styles:t}=lg();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:s})}return r.jsx(x.Button,C(v({},e),{shape:"circle",size:"small",className:ig(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const H=new L.Registry;H.register("calculation",fy),H.register("condition",by),H.register("parallel",eg),H.register("loop",Ty),H.register("delay",Sy),H.register("manual",Ry),H.register("query",tg),H.register("create",Cy),H.register("update",sg),H.register("destroy",ky),H.register("aggregate",dy),H.register("request",og),H.register("sql",ng);function cg(){const e=I.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return K(this,null,function*(){var c,u;if(a.executed){x.message.error(T("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setVisible(!1),n()})}}}const fo=b.createContext({});function we(){return b.useContext(fo)}function st(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}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}function vr({data:e}){const{styles:t}=se(),{component:o=at,endding:n}=H.get(e.type);return r.jsx(fo.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(o,{data:e}),n?r.jsx("div",{className:i.css`
|
|
543
543
|
flex-grow: 1;
|
|
544
544
|
display: flex;
|
|
545
545
|
flex-direction: column;
|
|
@@ -554,7 +554,7 @@
|
|
|
554
554
|
font-size: 1.5em;
|
|
555
555
|
line-height: 100%;
|
|
556
556
|
}
|
|
557
|
-
`,children:r.jsx(P.CloseOutlined,{})}):r.jsx(
|
|
557
|
+
`,children:r.jsx(P.CloseOutlined,{})}):r.jsx(Cr,{upstream:e})]})})}function br(){var p;const{t:e}=te.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(p=z())!=null?p:{},a=we(),{modal:l}=x.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function m(){return K(this,null,function*(){var y;yield(y=c.destroy)==null?void 0:y.call(c,{filterByTk:a.id}),s()})}const h=n.filter(y=>y===a?!1:L.parse(y.config).parameters.filter(({key:k})=>k.startsWith(`$jobsMapByNodeId.${a.id}.`)||k===`$jobsMapByNodeId.${a.id}`).length);if(h.length){l.error({title:T("Can not delete"),content:T("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(y=>`#${y.id}`).join(", ")})});return}const f=!n.find(y=>y.upstream===a&&y.branchIndex!=null)?e("Are you sure you want to delete it?"):T("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:f,onOk:m})})}return o.executed?null:r.jsx(x.Button,{type:"text",shape:"circle",icon:r.jsx(P.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function xr(){var a;const{execution:e,setViewJob:t}=z(),{jobs:o}=(a=we())!=null?a:{},{styles:n}=se();if(!e)return null;if(!o.length)return r.jsx(rt,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(x.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(rt,{statusMap:ut,status:l.status}),r.jsx("time",{children:L.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(rt,{statusMap:ut,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(rt,{statusMap:ut,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function at(e){var k,S;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(k=z())!=null?k:{},{styles:c}=se(),u=H.get(t.type),p=a.executed?'{{t("View")}}':'{{t("Configure")}}',m=n(u.title),[h,g]=b.useState((S=t.title)!=null?S:m),[f,y]=b.useState(!1);function w(A){return K(this,null,function*(){var D,_;const M=A||m;g(M),M!==t.title&&(yield(_=(D=s.resource("flow_nodes")).update)==null?void 0:_.call(D,{filterByTk:t.id,values:{title:M}}),l())})}function $(A){if(A.target===A.currentTarget){y(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let D=A.target;D&&D!==A.currentTarget&&D!==document.documentElement;D=D.parentNode)if(Array.from(D.classList).some(_=>M.has(_))){y(!0),A.stopPropagation();return}}return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:i.cx(c.nodeCardClass,{configuring:f}),onClick:$,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(x.Tag,{children:m}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{disabled:a.executed,value:h,onChange:A=>g(A.target.value),onBlur:A=>w(A.target.value),autoSize:!0})}),r.jsx(br,{}),r.jsx(xr,{}),r.jsx(i.ActionContextProvider,{value:{visible:f,setVisible:y},children:r.jsx(i.SchemaComponent,{scope:u.scope,components:u.components,schema:{type:"void",properties:C(v({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":p,"x-component":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${u.type}_${t.id}`]:{type:"void",title:t.title,"x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{disabled:a.executed,useValues(A){const{config:M}=we();return i.useRequest(()=>Promise.resolve({data:M}),A)}},properties:C(v({},a.executed?{alert:{type:"void","x-component":x.Alert,"x-component-props":{type:"warning",showIcon:!0,message:`{{t("Node in executed workflow cannot be modified", { ns: "${d}" })}}`,className:i.css`
|
|
558
558
|
width: 100%;
|
|
559
559
|
font-size: 85%;
|
|
560
560
|
margin-bottom: 2em;
|
|
@@ -570,11 +570,11 @@
|
|
|
570
570
|
min-width: 6em;
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
`},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:cg}}}}})}})}})})]}),o]})}function
|
|
573
|
+
`},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:cg}}}}})}})}})})]}),o]})}function Cr({upstream:e,branchIndex:t=null}){var g;const o=i.useCompile(),n=i.useAPIClient(),{workflow:s,refresh:a}=(g=z())!=null?g:{},l=Array.from(H.getValues()),{styles:c}=se(),u=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${d}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${d}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${d}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${d}" })}}`}].filter(f=>l.filter(y=>y.group===f.key).length).map(f=>{const y=l.filter(w=>w.group===f.key);return C(v({},f),{type:"group",children:y.map(w=>({key:w.type,label:w.title,type:w.options?"subMenu":null,children:w.options?w.options.map($=>({key:$.key,label:$.label})):null}))})}),[l]),p=b.useMemo(()=>s?n.resource("workflows.nodes",s.id):null,[s==null?void 0:s.id]),m=b.useCallback(y=>K(this,[y],function*({keyPath:f}){var A,M,D;const w=f.pop(),$={},[k]=f,S=H.get(w);if(k){const{value:_}=(M=(A=S.options)==null?void 0:A.find(F=>F.key===k))!=null?M:{};Object.assign($,_)}p&&(yield p.create({values:{type:w,upstreamId:(D=e==null?void 0:e.id)!=null?D:null,branchIndex:t,title:o(S.title),config:$}}),a())}),[t,p==null?void 0:p.create,e==null?void 0:e.id]),h=b.useMemo(()=>({onClick:m,items:o(u)}),[u,m]);return s?r.jsx("div",{className:c.addButtonClass,children:r.jsx(x.Dropdown,{trigger:["click"],menu:h,disabled:s.executed,overlayClassName:i.css`
|
|
574
574
|
.ant-dropdown-menu-root{
|
|
575
575
|
max-height: 30em;
|
|
576
576
|
overflow-y: auto;
|
|
577
577
|
}
|
|
578
|
-
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(P.PlusOutlined,{})})})}):null}function Ee({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null}){const{styles:s}=se(),a=[];for(let l=t;l;l=l.downstream)a.push(l);return r.jsxs("div",{className:i.cx(s.branchClass),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(xr,{upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:a.map(l=>r.jsx(gr,{data:l},l.id))})]})}function Cr({entry:e}){const{styles:t}=se();return r.jsxs("div",{className:"workflow-canvas",children:[r.jsx(ty,{}),r.jsx("div",{className:t.branchBlockClass,children:r.jsx(Ee,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:T("End")})]})}function ug(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function dg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=se(),{node:s={}}=t!=null?t:{},a=H.get(s.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:r.jsxs("div",{className:n.nodeTitleClass,children:[r.jsx(x.Tag,{children:e(a==null?void 0:a.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:n.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pg(e){const{execution:t}=z(),o=i.useAPIClient(),n=he.useNavigate(),{styles:s}=se(),[a,l]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{l(m.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:m})=>{m!=t.id&&n(`/admin/settings/workflow/executions/${m}`)},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${m.id}`}),r.jsx("time",{children:L.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(rt,{statusMap:jt,status:m.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(P.DownOutlined,{})]})}):null}function mg(){var f;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:n}=i.useDocumentTitle(),[s,a]=b.useState(null);if(b.useEffect(()=>{var S;const{workflow:k}=(S=t==null?void 0:t.data)!=null?S:{};n==null||n(`${k!=null&&k.title?`${k.title} - `:""}${T("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?r.jsx("div",{children:T("Loading")}):r.jsx("div",{children:T("Load failed")});const y=(f=t==null?void 0:t.data)!=null?f:{},{jobs:l=[],workflow:w={}}=y,$=w,{nodes:c=[],revisions:u=[]}=$,p=q($,["nodes","revisions"]),m=q(y,["jobs","workflow"]);po(c),ug(c,l);const h=c.find(k=>!k.upstream),g=jt[m.status];return r.jsxs(Ye.Provider,{value:{workflow:p.type?p:null,nodes:c,execution:m,viewJob:s,setViewJob:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${p.id}`,children:p.title})},{title:r.jsx(pg,{})}]})}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:g.color,children:e(g.label)}),r.jsx("time",{children:L.str2moment(m.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Cr,{entry:h}),r.jsx(dg,{})]})}const wr=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.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:mg}})})},$r=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/executions/${t}`,onClick:()=>o(!1),children:e("View")})},fg={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${d}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${e}`,onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:_t}}]},Sr={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${d}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=te.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return K(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${d}" })}}`,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: "${d}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${d}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function hg(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:a}=z(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))}function yg(){var D;const e=he.useNavigate(),{t}=te.useTranslation(),{data:o,refresh:n,loading:s}=i.useResourceActionContext(),{resource:a}=i.useResourceContext(),{setTitle:l}=i.useDocumentTitle(),[c,u]=b.useState(!1),{styles:p}=se(),{modal:m}=x.App.useApp();if(b.useEffect(()=>{var N;const{title:F}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${T("Workflow")}${F?`: ${F}`:""}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return r.jsx("div",{children:T(s?"Loading":"Load failed")});const _=(D=o==null?void 0:o.data)!=null?D:{},{nodes:h=[],revisions:g=[]}=_,f=q(_,["nodes","revisions"]);po(h);const y=h.find(F=>!F.upstream);function w({key:F}){F!=f.id&&e(`/admin/settings/workflow/workflows/${F}`)}function $(F){return K(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:F}}),n()})}function k(){return K(this,null,function*(){const{data:{data:F}}=yield a.revision({filterByTk:f.id,filter:{key:f.key}});x.message.success(t("Operation succeeded")),e(`/admin/settings/workflow/workflows/${F.id}`)})}function S(){return K(this,null,function*(){const F=f.current?T("Delete a main version will cause all other revisions to be deleted too."):"";m.confirm({title:t("Are you sure you want to delete it?"),content:F,onOk(){return K(this,null,function*(){var U;yield a.destroy({filterByTk:f.id}),x.message.success(t("Operation succeeded")),e(f.current?"/admin/settings/workflow/workflows":`/admin/settings/workflow/workflows/${(U=g.find(ie=>ie.current))==null?void 0:U.id}`)})}})})}function A(N){return K(this,arguments,function*({key:F}){switch(F){case"history":u(!0);return;case"revision":return k();case"delete":return S()}})}const M=f.executed&&!g.find(F=>!F.executed&&new Date(F.createdAt)>new Date(f.createdAt));return r.jsxs(Ye.Provider,{value:{workflow:f,nodes:h,refresh:n},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx("strong",{children:f.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${f.id}`],className:i.cx(p.dropdownClass,p.workflowVersionDropdownClass),items:g.sort((F,N)=>N.id-F.id).map((F,N)=>({key:`${F.id}`,icon:F.current?r.jsx(P.RightOutlined,{}):null,className:i.cx({executed:F.executed,unexecuted:!F.executed,enabled:F.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${F.id}`}),r.jsx("time",{children:L.str2moment(F.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text",children:[r.jsx("label",{children:T("Version")}),r.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),r.jsx(P.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:f.enabled,onChange:$,checkedChildren:T("On"),unCheckedChildren:T("Off")}),r.jsx(x.Dropdown,{menu:{items:[{key:"history",label:T("Execution history"),disabled:!f.allExecuted},{key:"revision",label:T("Copy to new version"),disabled:!M},{key:"delete",label:t("Delete")}],onClick:A},children:r.jsx(x.Button,{type:"text",icon:r.jsx(P.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:c,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:Sr,components:{ExecutionResourceProvider:hg,ExecutionLink:$r}})})]})]}),r.jsx(Cr,{entry:y})]})}const kr=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:yg}})})},gg=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const a=i.useRecord(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))},vg=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${t}`,onClick:()=>o(!1),children:e("View")})};function bg(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[a,l]=b.useState(!1),c=I.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:xg}=i.interfacesProperties,Cg={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${d}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${d}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:v({},xg),invariable:!0},Ar={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: "${d}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${d}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${d}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${d}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Ae={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${d}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},wg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Ar,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Ar},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Ae.title,type:Ae.type,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:"a"},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Sr}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Ae.title,enabled:Ae.enabled,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${d}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${d}" })}}`,"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}=te.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=I.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:a,values:l}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Tr(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=jt[e.value])!=null?a:{};return r.jsx(x.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function $g(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Tr,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Sg(t){var e=q(t,[]);return r.jsx(x.Select,C(v({},e),{mode:e.multiple?"multiple":null,optionLabelProp:"label",tagRender:Tr,children:_t.filter(o=>!!o.value&&o.value!==be.ABORTED).map(o=>r.jsx(x.Select.Option,C(v({},o),{children:r.jsx($g,v({},o))}),o.value))}))}const kg=b.createContext({});function Ag(){const e=b.useContext(i.SchemaComponentContext);return r.jsx(x.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:wg,components:{WorkflowLink:vg,ExecutionResourceProvider:gg,ExecutionLink:$r,OpenDrawer:bg,ExecutionStatusSelect:Sg},scope:{getTriggersOptions:oy}})})})}const Tg=e=>{const t=b.useContext(i.PluginManagerContext),o=b.useContext(i.CollectionManagerContext);return r.jsx(i.SettingsCenterProvider,{settings:{workflow:{icon:"PartitionOutlined",title:T("Workflow"),tabs:{workflows:{isBookmark:!0,title:T("Workflow"),component:Ag}}}},children:r.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:r.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Cg})}),children:r.jsx(kg.Provider,{value:{triggers:ge,instructions:H},children:e.children})})})})},Og=I.observer(e=>{const{onChange:t}=e,o=I.useField(),n=I.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();I.useFormEffects(()=>{me.onFormInitialValuesChange(h=>{c(h.getValuesIn(a))}),me.onFieldInputValueChange(a,h=>{c(h.value),t(null)})});const m=xe({collection:l,compile:u,getCollectionFields:p});return r.jsx(i.Variable.TextArea,C(v({},e),{scope:m}))},{displayName:"InternalExpression"});function Fg(e){const{t}=te.useTranslation(),o=i.useRecord(),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=b.useMemo(()=>xe({collection:o.sourceCollection,compile:n,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:d})})}const Ig=I.connect(Og,I.mapReadPretty(Fg)),Dg={title:`{{t("Task", { ns: "${d}" })}}`,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"}}]},Ng={title:`{{t("Workflow", { ns: "${d}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Pg={title:`{{t("Workflow todos", { ns: "${d}" })}}`,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: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-component":"Select",enum:Bt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Eg=I.observer(()=>{var t,o,n;const e=I.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"}),Mg=I.observer(()=>{var t,o,n;const e=I.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"}),_g=I.observer(()=>{var t,o,n;const e=I.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"}),ho=()=>r.jsx(i.SchemaComponent,{components:{NodeColumn:Eg,WorkflowColumn:Mg,UserColumn:_g},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${d}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${d}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${d}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function jg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=z(),{status:n,result:s,userId:a}=o,l=I.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return n?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Bg=b.createContext(null);function Vg({value:e,children:t}){const{userJob:o}=z(),n=I.useField(),s=I.useFieldSchema();return b.useEffect(()=>{o.status&&(n.disabled=!0,n.visible=o.status===e&&o.result._===s.name)},[o,e,n]),r.jsx(Bg.Provider,{value:e,children:t})}function Lg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:n}=I.useForm(),s=I.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=z(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return K(this,null,function*(){l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function zg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[n,s]=b.useState(null),[a,l]=b.useState(null);b.useEffect(()=>{var m,h;o&&((h=(m=t.resource("users_jobs")).get)==null||h.call(m,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var S;const A=(S=g==null?void 0:g.data)!=null?S:{},{node:f,workflow:M={}}=A,D=M,{nodes:y=[]}=D,w=q(D,["nodes"]),_=A,{execution:$}=_,k=q(_,["node","workflow","execution"]);po(y),l(f),s({userJob:k,workflow:w,nodes:y,execution:$})}))},[o]);const u=st(n==null?void 0:n.nodes.find(m=>m.id===a.id)).reduce((m,{type:h})=>Object.assign(m,H.get(h).components),{});return a&&n?r.jsx(Ye.Provider,{value:n,children:r.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:ir,DetailsBlockProvider:ar,ActionBarProvider:jg,ManualActionStatusProvider:Vg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.components),{})),u),scope:v({useSubmit:Lg,useFormBlockProps:Ug,useDetailsBlockProps:Gg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):r.jsx(x.Spin,{})}function Ug(){var a;const{userJob:e}=z(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:n}=i.useFormBlockContext(),s=e.status?t?"readPretty":"disabled":((a=o==null?void 0:o.data)==null?void 0:a.id)!==e.userId?"disabled":"editable";return b.useEffect(()=>{n==null||n.setPattern(s)},[s,n]),{form:n}}function Gg(){const{form:e}=i.useFormBlockContext();return{form:e}}function Wg(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),n=ut[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:Kr.css`
|
|
578
|
+
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(P.PlusOutlined,{})})})}):null}function Ee({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null}){const{styles:s}=se(),a=[];for(let l=t;l;l=l.downstream)a.push(l);return r.jsxs("div",{className:i.cx(s.branchClass),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Cr,{upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:a.map(l=>r.jsx(vr,{data:l},l.id))})]})}function wr({entry:e}){const{styles:t}=se();return r.jsxs("div",{className:"workflow-canvas",children:[r.jsx(oy,{}),r.jsx("div",{className:t.branchBlockClass,children:r.jsx(Ee,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:T("End")})]})}function ug(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function dg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=se(),{node:s={}}=t!=null?t:{},a=H.get(s.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:r.jsxs("div",{className:n.nodeTitleClass,children:[r.jsx(x.Tag,{children:e(a==null?void 0:a.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:n.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pg(e){const{execution:t}=z(),o=i.useAPIClient(),n=he.useNavigate(),{styles:s}=se(),[a,l]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{l(m.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:m})=>{m!=t.id&&n(`/admin/settings/workflow/executions/${m}`)},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${m.id}`}),r.jsx("time",{children:L.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(rt,{statusMap:jt,status:m.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(P.DownOutlined,{})]})}):null}function mg(){var f;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:n}=i.useDocumentTitle(),[s,a]=b.useState(null);if(b.useEffect(()=>{var S;const{workflow:k}=(S=t==null?void 0:t.data)!=null?S:{};n==null||n(`${k!=null&&k.title?`${k.title} - `:""}${T("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?r.jsx("div",{children:T("Loading")}):r.jsx("div",{children:T("Load failed")});const y=(f=t==null?void 0:t.data)!=null?f:{},{jobs:l=[],workflow:w={}}=y,$=w,{nodes:c=[],revisions:u=[]}=$,p=q($,["nodes","revisions"]),m=q(y,["jobs","workflow"]);po(c),ug(c,l);const h=c.find(k=>!k.upstream),g=jt[m.status];return r.jsxs(Ye.Provider,{value:{workflow:p.type?p:null,nodes:c,execution:m,viewJob:s,setViewJob:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${p.id}`,children:p.title})},{title:r.jsx(pg,{})}]})}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:g.color,children:e(g.label)}),r.jsx("time",{children:L.str2moment(m.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(wr,{entry:h}),r.jsx(dg,{})]})}const $r=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.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:mg}})})},Sr=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/executions/${t}`,onClick:()=>o(!1),children:e("View")})},fg={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${d}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${e}`,onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:_t}}]},kr={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${d}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=te.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return K(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${d}" })}}`,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: "${d}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${d}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function hg(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:a}=z(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))}function yg(){var D;const e=he.useNavigate(),{t}=te.useTranslation(),{data:o,refresh:n,loading:s}=i.useResourceActionContext(),{resource:a}=i.useResourceContext(),{setTitle:l}=i.useDocumentTitle(),[c,u]=b.useState(!1),{styles:p}=se(),{modal:m}=x.App.useApp();if(b.useEffect(()=>{var N;const{title:F}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${T("Workflow")}${F?`: ${F}`:""}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return r.jsx("div",{children:T(s?"Loading":"Load failed")});const _=(D=o==null?void 0:o.data)!=null?D:{},{nodes:h=[],revisions:g=[]}=_,f=q(_,["nodes","revisions"]);po(h);const y=h.find(F=>!F.upstream);function w({key:F}){F!=f.id&&e(`/admin/settings/workflow/workflows/${F}`)}function $(F){return K(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:F}}),n()})}function k(){return K(this,null,function*(){const{data:{data:F}}=yield a.revision({filterByTk:f.id,filter:{key:f.key}});x.message.success(t("Operation succeeded")),e(`/admin/settings/workflow/workflows/${F.id}`)})}function S(){return K(this,null,function*(){const F=f.current?T("Delete a main version will cause all other revisions to be deleted too."):"";m.confirm({title:t("Are you sure you want to delete it?"),content:F,onOk(){return K(this,null,function*(){var U;yield a.destroy({filterByTk:f.id}),x.message.success(t("Operation succeeded")),e(f.current?"/admin/settings/workflow/workflows":`/admin/settings/workflow/workflows/${(U=g.find(ie=>ie.current))==null?void 0:U.id}`)})}})})}function A(N){return K(this,arguments,function*({key:F}){switch(F){case"history":u(!0);return;case"revision":return k();case"delete":return S()}})}const M=f.executed&&!g.find(F=>!F.executed&&new Date(F.createdAt)>new Date(f.createdAt));return r.jsxs(Ye.Provider,{value:{workflow:f,nodes:h,refresh:n},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx("strong",{children:f.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${f.id}`],className:i.cx(p.dropdownClass,p.workflowVersionDropdownClass),items:g.sort((F,N)=>N.id-F.id).map((F,N)=>({key:`${F.id}`,icon:F.current?r.jsx(P.RightOutlined,{}):null,className:i.cx({executed:F.executed,unexecuted:!F.executed,enabled:F.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${F.id}`}),r.jsx("time",{children:L.str2moment(F.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text",children:[r.jsx("label",{children:T("Version")}),r.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),r.jsx(P.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:f.enabled,onChange:$,checkedChildren:T("On"),unCheckedChildren:T("Off")}),r.jsx(x.Dropdown,{menu:{items:[{key:"history",label:T("Execution history"),disabled:!f.allExecuted},{key:"revision",label:T("Copy to new version"),disabled:!M},{key:"delete",label:t("Delete")}],onClick:A},children:r.jsx(x.Button,{type:"text",icon:r.jsx(P.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:c,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:kr,components:{ExecutionResourceProvider:hg,ExecutionLink:Sr}})})]})]}),r.jsx(wr,{entry:y})]})}const Ar=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:yg}})})},gg=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const a=i.useRecord(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))},vg=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${t}`,onClick:()=>o(!1),children:e("View")})};function bg(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[a,l]=b.useState(!1),c=I.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:xg}=i.interfacesProperties,Cg={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${d}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${d}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:v({},xg),invariable:!0},Tr={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: "${d}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${d}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${d}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${d}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Ae={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${d}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},wg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Tr,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Tr},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Ae.title,type:Ae.type,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:"a"},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:kr}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Ae.title,enabled:Ae.enabled,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${d}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${d}" })}}`,"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}=te.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=I.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:a,values:l}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Or(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=jt[e.value])!=null?a:{};return r.jsx(x.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function $g(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Or,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Sg(t){var e=q(t,[]);return r.jsx(x.Select,C(v({},e),{mode:e.multiple?"multiple":null,optionLabelProp:"label",tagRender:Or,children:_t.filter(o=>!!o.value&&o.value!==be.ABORTED).map(o=>r.jsx(x.Select.Option,C(v({},o),{children:r.jsx($g,v({},o))}),o.value))}))}const kg=b.createContext({});function Ag(){const e=b.useContext(i.SchemaComponentContext);return r.jsx(x.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:wg,components:{WorkflowLink:vg,ExecutionResourceProvider:gg,ExecutionLink:Sr,OpenDrawer:bg,ExecutionStatusSelect:Sg},scope:{getTriggersOptions:Xn}})})})}const Tg=e=>{const t=b.useContext(i.PluginManagerContext),o=b.useContext(i.CollectionManagerContext);return r.jsx(i.SettingsCenterProvider,{settings:{workflow:{icon:"PartitionOutlined",title:T("Workflow"),tabs:{workflows:{isBookmark:!0,title:T("Workflow"),component:Ag}}}},children:r.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:r.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Cg})}),children:r.jsx(kg.Provider,{value:{triggers:ge,instructions:H},children:e.children})})})})},Og=I.observer(e=>{const{onChange:t}=e,o=I.useField(),n=I.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();I.useFormEffects(()=>{me.onFormInitialValuesChange(h=>{c(h.getValuesIn(a))}),me.onFieldInputValueChange(a,h=>{c(h.value),t(null)})});const m=xe({collection:l,compile:u,getCollectionFields:p});return r.jsx(i.Variable.TextArea,C(v({},e),{scope:m}))},{displayName:"InternalExpression"});function Fg(e){const{t}=te.useTranslation(),o=i.useRecord(),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=b.useMemo(()=>xe({collection:o.sourceCollection,compile:n,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:d})})}const Ig=I.connect(Og,I.mapReadPretty(Fg)),Dg={title:`{{t("Task", { ns: "${d}" })}}`,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"}}]},Ng={title:`{{t("Workflow", { ns: "${d}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Pg={title:`{{t("Workflow todos", { ns: "${d}" })}}`,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: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-component":"Select",enum:Bt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Eg=I.observer(()=>{var t,o,n;const e=I.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"}),Mg=I.observer(()=>{var t,o,n;const e=I.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"}),_g=I.observer(()=>{var t,o,n;const e=I.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"}),ho=()=>r.jsx(i.SchemaComponent,{components:{NodeColumn:Eg,WorkflowColumn:Mg,UserColumn:_g},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${d}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${d}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${d}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function jg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=z(),{status:n,result:s,userId:a}=o,l=I.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return n?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Bg=b.createContext(null);function Vg({value:e,children:t}){const{userJob:o}=z(),n=I.useField(),s=I.useFieldSchema();return b.useEffect(()=>{o.status&&(n.disabled=!0,n.visible=o.status===e&&o.result._===s.name)},[o,e,n]),r.jsx(Bg.Provider,{value:e,children:t})}function Lg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:n}=I.useForm(),s=I.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=z(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return K(this,null,function*(){l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function zg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[n,s]=b.useState(null),[a,l]=b.useState(null);b.useEffect(()=>{var m,h;o&&((h=(m=t.resource("users_jobs")).get)==null||h.call(m,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var S;const A=(S=g==null?void 0:g.data)!=null?S:{},{node:f,workflow:M={}}=A,D=M,{nodes:y=[]}=D,w=q(D,["nodes"]),_=A,{execution:$}=_,k=q(_,["node","workflow","execution"]);po(y),l(f),s({userJob:k,workflow:w,nodes:y,execution:$})}))},[o]);const u=st(n==null?void 0:n.nodes.find(m=>m.id===a.id)).reduce((m,{type:h})=>Object.assign(m,H.get(h).components),{});return a&&n?r.jsx(Ye.Provider,{value:n,children:r.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:lr,DetailsBlockProvider:ir,ActionBarProvider:jg,ManualActionStatusProvider:Vg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.components),{})),u),scope:v({useSubmit:Lg,useFormBlockProps:Ug,useDetailsBlockProps:Gg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):r.jsx(x.Spin,{})}function Ug(){var a;const{userJob:e}=z(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:n}=i.useFormBlockContext(),s=e.status?t?"readPretty":"disabled":((a=o==null?void 0:o.data)==null?void 0:a.id)!==e.userId?"disabled":"editable";return b.useEffect(()=>{n==null||n.setPattern(s)},[s,n]),{form:n}}function Gg(){const{form:e}=i.useFormBlockContext();return{form:e}}function Wg(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),n=ut[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:Jr.css`
|
|
579
579
|
margin-right: 0.5em;
|
|
580
|
-
`,children:bo(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(x.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Hg(){var a;const e=b.useContext(i.SchemaComponentContext),{id:t,node:o,workflow:n,status:s}=i.useRecord();return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{reset(){},designable:!1}),children:r.jsx(i.SchemaComponent,{components:{FooterStatus:Wg,FlowContextProvider:zg},schema:{type:"void",name:`drawer-${t}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-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 qg({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,n=q(a,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(i.CollectionManagerProvider,C(v({},n),{collections:[...o,Dg,Ng,Pg],children:r.jsx(i.TableBlockProvider,C(v({},s),{children:t}))}))}ho.Drawer=Hg,ho.Decorator=qg;const Kg=o=>{var n=o,{insert:e}=n,t=q(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({icon:r.jsx(P.TableOutlined,{})},t),{onClick:()=>{e({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class
|
|
580
|
+
`,children:bo(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(x.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Hg(){var a;const e=b.useContext(i.SchemaComponentContext),{id:t,node:o,workflow:n,status:s}=i.useRecord();return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{reset(){},designable:!1}),children:r.jsx(i.SchemaComponent,{components:{FooterStatus:Wg,FlowContextProvider:zg},schema:{type:"void",name:`drawer-${t}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-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 qg({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,n=q(a,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(i.CollectionManagerProvider,C(v({},n),{collections:[...o,Dg,Ng,Pg],children:r.jsx(i.TableBlockProvider,C(v({},s),{children:t}))}))}ho.Drawer=Hg,ho.Decorator=qg;const Kg=o=>{var n=o,{insert:e}=n,t=q(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({icon:r.jsx(P.TableOutlined,{})},t),{onClick:()=>{e({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Fr extends i.Plugin{load(){return K(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(Tg)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:_h})}addComponents(){this.app.addComponents({WorkflowPage:Ar,ExecutionPage:$r,WorkflowTodo:ho,WorkflowTodoBlockInitializer:Kg,DynamicExpression:Ig})}addRoutes(){this.app.router.add("admin.settings.workflow.workflows.id",{path:"/admin/settings/workflow/workflows/:id",element:r.jsx(Ar,{})}),this.app.router.add("admin.settings.workflow.executions.id",{path:"/admin/settings/workflow/executions/:id",element:r.jsx($r,{})})}}O.Branch=Ee,O.FlowContext=Ye,O.JobButton=xr,O.Node=vr,O.NodeContext=fo,O.NodeDefaultView=at,O.RemoveButton=br,O.WorkflowPlugin=Fr,O.default=Fr,O.getTriggersOptions=Xn,O.instructions=H,O.triggers=ge,O.useAvailableUpstreams=st,O.useFlowContext=z,O.useNodeContext=we,O.useUpstreamScopes=gr,O.useWorkflowVariableOptions=ae,Object.defineProperties(O,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|