@nocobase/plugin-workflow 0.13.0-alpha.9 → 0.14.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(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,R,I,L,me,he,bo,Se,Je,xo,Kr){"use strict";var Qg=Object.defineProperty,Xg=Object.defineProperties;var Rg=Object.getOwnPropertyDescriptors;var Et=Object.getOwnPropertySymbols;var Wr=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable;var Gr=(O,r,i)=>r in O?Qg(O,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):O[r]=i,v=(O,r)=>{for(var i in r||(r={}))Wr.call(r,i)&&Gr(O,i,r[i]);if(Et)for(var i of Et(r))Hr.call(r,i)&&Gr(O,i,r[i]);return O},C=(O,r)=>Xg(O,Rg(r));var qr=O=>typeof O=="symbol"?O:O+"",K=(O,r)=>{var i={};for(var P in O)Wr.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&&Hr.call(O,P)&&(i[P]=O[P]);return i};var G=(O,r,i)=>new Promise((P,x)=>{var b=L=>{try{I(i.next(L))}catch(me){x(me)}},R=L=>{try{I(i.throw(L))}catch(me){x(me)}},I=L=>L.done?P(L.value):Promise.resolve(L.value).then(b,R);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 R.useTranslation(d)}const Jr=i.createStyles(({css:e,token:t})=>({container:e`
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,R,I,L,me,he,bo,Se,Je,xo,Kr){"use strict";var Qg=Object.defineProperty,Xg=Object.defineProperties;var Rg=Object.getOwnPropertyDescriptors;var Et=Object.getOwnPropertySymbols;var Wr=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable;var Gr=(O,r,i)=>r in O?Qg(O,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):O[r]=i,v=(O,r)=>{for(var i in r||(r={}))Wr.call(r,i)&&Gr(O,i,r[i]);if(Et)for(var i of Et(r))Hr.call(r,i)&&Gr(O,i,r[i]);return O},C=(O,r)=>Xg(O,Rg(r));var qr=O=>typeof O=="symbol"?O:O+"",K=(O,r)=>{var i={};for(var P in O)Wr.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&&Hr.call(O,P)&&(i[P]=O[P]);return i};var W=(O,r,i)=>new Promise((P,x)=>{var b=L=>{try{I(i.next(L))}catch(me){x(me)}},R=L=>{try{I(i.throw(L))}catch(me){x(me)}},I=L=>L.done?P(L.value):Promise.resolve(L.value).then(b,R);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 R.useTranslation(d)}const Jr=i.createStyles(({css:e,token:t})=>({container:e`
2
2
  margin-bottom: 1.5em;
3
3
  padding: 1em;
4
4
  background-color: ${t.colorFillAlter};
@@ -344,12 +344,12 @@
344
344
  border-radius: 50%;
345
345
  background-color: ${t.colorText};
346
346
  color: ${t.colorBgContainer};
347
- `}));function Yr(){return!0}const Vt=I.observer(e=>{const c=e,{filter:t=Yr}=c,o=K(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 Zr(s){var a=s,{insert:e,collection:t,dataSource:o}=a,n=K(a,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager(),u=i.useRecordCollectionDataSourceItems("FormItem"),p=c(t);function m(g){return G(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(Zr,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`
347
+ `}));function Yr(){return!0}const Vt=I.observer(e=>{const c=e,{filter:t=Yr}=c,o=K(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 Zr(s){var a=s,{insert:e,collection:t,dataSource:o}=a,n=K(a,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager(),u=i.useRecordCollectionDataSourceItems("FormItem"),p=c(t);function m(g){return W(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(Zr,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]",H={};H[Hl]=H[ql]=H[Kl]=H[Jl]=H[Yl]=H[Zl]=H[Ql]=H[Xl]=H[Rl]=!0,H[Il]=H[Dl]=H[Gl]=H[Nl]=H[Wl]=H[Pl]=H[El]=H[Ml]=H[_l]=H[jl]=H[Bl]=H[Vl]=H[Ll]=H[zl]=H[Ul]=!1;function ec(e){return Fl(e)&&Ol(e.length)&&!!H[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]",W={};W[bn]=W[Xp]=W[um]=W[dm]=W[Rp]=W[em]=W[pm]=W[mm]=W[fm]=W[hm]=W[ym]=W[nm]=W[rm]=W[Cn]=W[sm]=W[am]=W[im]=W[lm]=W[gm]=W[vm]=W[bm]=W[xm]=!0,W[tm]=W[xn]=W[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(!W[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 G(this,null,function*(){var V,ne,J,Z,Q,te;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,(te=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||te.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:()=>G(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}=R.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:i.css`
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]",H={};H[Hl]=H[ql]=H[Kl]=H[Jl]=H[Yl]=H[Zl]=H[Ql]=H[Xl]=H[Rl]=!0,H[Il]=H[Dl]=H[Gl]=H[Nl]=H[Wl]=H[Pl]=H[El]=H[Ml]=H[_l]=H[jl]=H[Bl]=H[Vl]=H[Ll]=H[zl]=H[Ul]=!1;function ec(e){return Fl(e)&&Ol(e.length)&&!!H[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 W(this,null,function*(){var V,ne,J,Z,Q,te;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,(te=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||te.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:()=>W(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}=R.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
355
  `,children:[r.jsx(Vt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:_h,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 jh({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`
@@ -393,10 +393,10 @@
393
393
  .ant-picker {
394
394
  width: auto;
395
395
  }
396
- `},properties:Zh[o]}}},components:{OnField:Mn,RepeatField:Yh,EndsByField:jh}})]})},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:Xh},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 Rh(){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 G(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 ey(){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`
396
+ `},properties:Zh[o]}}},components:{OnField:Mn,RepeatField:Yh,EndsByField:jh}})]})},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:Xh},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 Rh(){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 W(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 ey(){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 ty=()=>{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 G(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(ey,{}),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`
399
+ `},"x-read-pretty":!0}}}}}})}const ty=()=>{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 W(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(ey,{}),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,9 +405,9 @@
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:Rh}}}})})}}},scope:w,components:$})})]})};function Qn(){const{workflow:e}=z();return ge.get(e.type)}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=q.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}},oy={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Pe}=e,o=we(),n=yr(o),s=[];return n.forEach(a=>{var u,p;const l=q.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}},ny={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 Xn(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 Rn({fields:e,types:t,appends:o,compile:n,getCollectionFields:s}){return e.filter(a=>{if(t!=null&&t.length)return t.some(l=>Xn(a,l,o));if(co(a)){const l=uo(a,o),c=o.includes(a.name);return(l.length||c)&&Rn({fields:er(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[oy,io,lo,ny].map(l=>{const c=l.useOptions(o).filter(Boolean);return{[t.label]:n(l.label),[t.value]:l.value,key:l[t.value],[t.children]:c,disabled:c&&!c.length}})}function er(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 ry(e){return G(this,null,function*(){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=>Xn(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=er(o,{compile:a,getCollectionFields:l}),p=t!=null?t:u,m=ry.bind({compile:a,getCollectionFields:l,fieldNames:c});return Rn({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 sy(s){var a=s,{node:e,resultTitle:t,insert:o}=a,n=K(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 ay({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`
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:Rh}}}})})}}},scope:w,components:$})})]})};function Qn(){const{workflow:e}=z();return ge.get(e.type)}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=q.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}},oy={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Pe}=e,o=we(),n=yr(o),s=[];return n.forEach(a=>{var u,p;const l=q.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}},ny={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 Xn(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 Rn({fields:e,types:t,appends:o,compile:n,getCollectionFields:s}){return e.filter(a=>{if(t!=null&&t.length)return t.some(l=>Xn(a,l,o));if(co(a)){const l=uo(a,o),c=o.includes(a.name);return(l.length||c)&&Rn({fields:er(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[oy,io,lo,ny].map(l=>{const c=l.useOptions(o).filter(Boolean);return{[t.label]:n(l.label),[t.value]:l.value,key:l[t.value],[t.children]:c,disabled:c&&!c.length}})}function er(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 ry(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=>Xn(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=er(o,{compile:a,getCollectionFields:l}),p=t!=null?t:u,m=ry.bind({compile:a,getCollectionFields:l,fieldNames:c});return Rn({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 sy(s){var a=s,{node:e,resultTitle:t,insert:o}=a,n=K(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 ay({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
- `,children:JSON.stringify(n,null,2)})}nt.Initializer=sy,nt.Result=ay;function iy(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 ly(){const e=i.useCompile();return[io,lo].map(t=>{var n;const o=(n=t.useOptions({types:[iy]}))==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 cy(n){var s=n,{value:e,onChange:t}=s,o=K(s,["value","onChange"]);const{setValuesIn:a}=I.useForm(),{getCollection:l}=i.useCollectionManager(),c=ly(),[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=$=>G(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(()=>{(()=>G(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 uy={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:cy},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=K(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`
410
+ `,children:JSON.stringify(n,null,2)})}nt.Initializer=sy,nt.Result=ay;function iy(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 ly(){const e=i.useCompile();return[io,lo].map(t=>{var n;const o=(n=t.useOptions({types:[iy]}))==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 cy(n){var s=n,{value:e,onChange:t}=s,o=K(s,["value","onChange"]);const{setValuesIn:a}=I.useForm(),{getCollection:l}=i.useCollectionManager(),c=ly(),[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=$=>W(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(()=>{(()=>W(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 uy={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:cy},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=K(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
  }
@@ -418,7 +418,7 @@
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 dy(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 py=({value:e,onChange:t})=>{const{t:o}=R.useTranslation(),{getCollectionFields:n,getCollection:s}=i.useCollectionManager(),a=ae({types:[dy.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]})},my={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:tr},components:{CalculationExpression(e){const t=ae();return r.jsx(i.Variable.TextArea,v({scope:t},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`
421
+ `,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function dy(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 py=({value:e,onChange:t})=>{const{t:o}=R.useTranslation(),{getCollectionFields:n,getCollection:s}=i.useCollectionManager(),a=ae({types:[dy.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]})},my={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:tr},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
423
  `,children:JSON.stringify(o,null,2)})},RadioWithTooltip:$t,DynamicConfig:py},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")}}},ee=new L.Registry;ee.register("equal",{name:"=",type:"boolean",group:"boolean"}),ee.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ee.register("gt",{name:">",type:"boolean",group:"boolean"}),ee.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ee.register("lt",{name:"<",type:"boolean",group:"boolean"}),ee.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ee.register("add",{name:"+",type:"number",group:"number"}),ee.register("minus",{name:"-",type:"number",group:"number"}),ee.register("multiple",{name:"*",type:"number",group:"number"}),ee.register("divide",{name:"/",type:"number",group:"number"}),ee.register("mod",{name:"%",type:"number",group:"number"}),ee.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ee.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ee.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ee.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ee.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ee.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ee.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const fy=[{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 or(e){return Array.from(ee.getEntities()).filter(([t,o])=>o.group===e)}function hy({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=ae();return r.jsxs("fieldset",{className:i.css`
424
424
  display: flex;
@@ -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],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=K(U,[qr(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"}),xy={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:rr},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:{}},sr=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Cy(e){return sr.slice().reverse().find(t=>!(e%t.value))}function wy({value:e=6e4,onChange:t}){const o=Cy(e),n=Math.round(e/o.value);return r.jsxs("fieldset",{className:i.css`
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=K(U,[qr(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"}),xy={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:rr},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:{}},sr=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Cy(e){return sr.slice().reverse().find(t=>!(e%t.value))}function wy({value:e=6e4,onChange:t}){const o=Cy(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:sr.map(s=>r.jsx(x.Select.Option,{value:s.value,children:T(s.label)},s.value))})]})}const $y={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:wy}};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 Sy={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 ky(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)break;n=l,l.children&&(o=l.children)}return n}const Ay={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`
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:sr.map(s=>r.jsx(x.Select.Option,{value:s.value,children:T(s.label)},s.value))})]})}const $y={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:wy}};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 Sy={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 ky(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 Ay={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,7 +493,7 @@
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.title),[s.value]:p.value,key:p.value,[s.children]:m,disabled:m&&!m.length}}),u=ky(c,l);a=Object.assign(v({},a),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 Ty(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=Ty(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 Oy(n){var s=n,{insert:e,schema:t}=s,o=K(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return G(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(Oy,v({},e))})}function Fy(){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 Iy={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:Fy},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 Dy(o){var n=o,{insert:e}=n,t=K(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"},"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 Ny(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 Py(){const{interfaces:e}=i.useCollectionManager();return Ny(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:My,fieldInterface:n.name}))}))}const dr=b.createContext({});function Ey(e){const{insertPosition:t="beforeEnd",component:o}=e,n=Py(),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=K(k,["unique","type"]),y=K(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 G(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 G(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 My(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:Dy}},initializers:{AddCustomFormField:Ey},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 _y(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:n}=R.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 jy={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:_y},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",Iy),Ce.register("updateForm",jy);function By(){const{workflow:e}=z(),t=Qn();return t.useInitializers?t.useInitializers(e.config):null}const Vy={customForm:pr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Ly(){var n,s;const e=I.useFieldSchema(),t=(s=Vy[(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 zy(e){const t=we(),o=st(t),n=[By()].filter(Boolean),s=o.map(c=>{var p;const u=q.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 Uy(){var w,$,k;const e=b.useContext(i.SchemaComponentContext),{t}=R.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 Gy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(Uy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Wy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=K(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=K(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 Hy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:oe.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Wy,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 qy(){return{run(){}}}function Ky({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=q.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:zy,AddActionButton:Hy},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:Ly,ManualActionDesigner:Gy}),scope:{useSubmit:qy,useDetailsBlockProps:i.useFormBlockContext}})})})}function Jy(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 Yy({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=ky(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 Ty(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=Ty(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 Oy(n){var s=n,{insert:e,schema:t}=s,o=K(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return W(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(Oy,v({},e))})}function Fy(){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 Iy={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:Fy},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 Dy(o){var n=o,{insert:e}=n,t=K(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"},"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 Ny(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 Py(){const{interfaces:e}=i.useCollectionManager();return Ny(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:My,fieldInterface:n.name}))}))}const dr=b.createContext({});function Ey(e){const{insertPosition:t="beforeEnd",component:o}=e,n=Py(),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=K(k,["unique","type"]),y=K(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 W(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 W(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 My(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:Dy}},initializers:{AddCustomFormField:Ey},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 _y(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:n}=R.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 jy={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:_y},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",Iy),Ce.register("updateForm",jy);function By(){const{workflow:e}=z(),t=Qn();return t.useInitializers?t.useInitializers(e.config):null}const Vy={customForm:pr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Ly(){var n,s;const e=I.useFieldSchema(),t=(s=Vy[(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 zy(e){const t=we(),o=st(t),n=[By()].filter(Boolean),s=o.map(c=>{var p;const u=q.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 Uy(){var w,$,k;const e=b.useContext(i.SchemaComponentContext),{t}=R.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 Gy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(Uy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Wy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=K(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=K(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 Hy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:oe.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Wy,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 qy(){return{run(){}}}function Ky({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=q.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:zy,AddActionButton:Hy},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:Ly,ManualActionDesigner:Gy}),scope:{useSubmit:qy,useDetailsBlockProps:i.useFormBlockContext}})})})}function Jy(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 Yy({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;
@@ -539,7 +539,7 @@
539
539
  }
540
540
  `,noStatusButtonClass:e`
541
541
  border-width: 2px;
542
- `}));function rt(e){var n;const{styles:t}=ig();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:ag(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const q=new L.Registry;q.register("calculation",my),q.register("condition",vy),q.register("parallel",Ry),q.register("loop",Ay),q.register("delay",$y),q.register("manual",Xy),q.register("query",eg),q.register("create",xy),q.register("update",rg),q.register("destroy",Sy),q.register("aggregate",uy),q.register("request",tg),q.register("sql",og);function lg(){const e=I.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return G(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 yr(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 gr({data:e}){const{styles:t}=se(),{component:o=at,endding:n}=q.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`
542
+ `}));function rt(e){var n;const{styles:t}=ig();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:ag(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const q=new L.Registry;q.register("calculation",my),q.register("condition",vy),q.register("parallel",Ry),q.register("loop",Ay),q.register("delay",$y),q.register("manual",Xy),q.register("query",eg),q.register("create",xy),q.register("update",rg),q.register("destroy",Sy),q.register("aggregate",uy),q.register("request",tg),q.register("sql",og);function lg(){const e=I.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return W(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 yr(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 gr({data:e}){const{styles:t}=se(),{component:o=at,endding:n}=q.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(xr,{upstream:e})]})})}function vr(){var p;const{t:e}=R.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 G(this,null,function*(){function m(){return G(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 br(){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=q.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 G(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(vr,{}),r.jsx(br,{}),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`
557
+ `,children:r.jsx(P.CloseOutlined,{})}):r.jsx(xr,{upstream:e})]})})}function vr(){var p;const{t:e}=R.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 W(this,null,function*(){function m(){return W(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 br(){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=q.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 W(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(vr,{}),r.jsx(br,{}),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:lg}}}}})}})}})})]}),o]})}function xr({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(q.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=>G(this,[y],function*({keyPath:f}){var A,M,D;const w=f.pop(),$={},[k]=f,S=q.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`
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:lg}}}}})}})}})})]}),o]})}function xr({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(q.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=>W(this,[y],function*({keyPath:f}){var A,M,D;const w=f.pop(),$={},[k]=f,S=q.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 cg(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 ug(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=se(),{node:s={}}=t!=null?t:{},a=q.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 dg(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 pg(){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=K($,["nodes","revisions"]),m=K(y,["jobs","workflow"]);po(c),cg(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(dg,{})}]})}),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(ug,{})]})}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:pg}})})},$r=()=>{const{t:e}=R.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")})},mg={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:mg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return G(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 fg(n){var s=n,{request:e,filter:t={}}=s,o=K(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 hg(){var D;const e=he.useNavigate(),{t}=R.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=K(_,["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 G(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:F}}),n()})}function k(){return G(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 G(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 G(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 G(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:fg,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:hg}})})},yg=n=>{var s=n,{request:e,filter:t={}}=s,o=K(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))},gg=()=>{const{t:e}=R.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 vg(n){var s=n,{component:e="div",children:t}=s,o=K(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:bg}=i.interfacesProperties,xg={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({},bg),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-component":"Select","x-decorator":"FormItem",enum:Array.from(ge.getEntities()).map(([e,{title:t}])=>({value:e,label:t,color:"gold"})),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}}}}},Cg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Ar,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{pageSize:20,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 }}"}}}}}}}},sync:{type:"void",title:`{{t("Sync", { ns: "${d}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${d}" }) }}`},"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{resource:t}=i.useResourceContext();return{run(){return G(this,null,function*(){yield t.sync(),x.message.success(e("Operation succeeded"))})}}}}},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}=R.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 G(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 wg(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 $g(t){var e=K(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(wg,v({},o))}),o.value))}))}const Sg=b.createContext({});function kg(){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:Cg,components:{Tooltip:x.Tooltip,WorkflowLink:gg,ExecutionResourceProvider:yg,ExecutionLink:$r,OpenDrawer:vg,ExecutionStatusSelect:$g}})})})}const Ag=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:kg}}}},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:xg})}),children:r.jsx(Sg.Provider,{value:{triggers:ge,instructions:q},children:e.children})})})})},Tg=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 Og(e){const{t}=R.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 Fg=I.connect(Tg,I.mapReadPretty(Og)),Ig={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"}}]},Dg={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}}]},Ng={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}}}]},Pg=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"}),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:"WorkflowColumn"}),Mg=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:Pg,WorkflowColumn:Eg,UserColumn:Mg},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 _g(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 jg=b.createContext(null);function Bg({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(jg.Provider,{value:e,children:t})}function Vg(){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 G(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 Lg(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=K(D,["nodes"]),_=A,{execution:$}=_,k=K(_,["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,q.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:_g,ManualActionStatusProvider:Bg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.components),{})),u),scope:v({useSubmit:Vg,useFormBlockProps:zg,useDetailsBlockProps:Ug},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 zg(){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 Ug(){const{form:e}=i.useFormBlockContext();return{form:e}}function Gg(){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(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 cg(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 ug(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=se(),{node:s={}}=t!=null?t:{},a=q.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 dg(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 pg(){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=K($,["nodes","revisions"]),m=K(y,["jobs","workflow"]);po(c),cg(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(dg,{})}]})}),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(ug,{})]})}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:pg}})})},$r=()=>{const{t:e}=R.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")})},mg={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:mg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return W(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 fg(n){var s=n,{request:e,filter:t={}}=s,o=K(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 hg(){var D;const e=he.useNavigate(),{t}=R.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=K(_,["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 W(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:F}}),n()})}function k(){return W(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 W(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 W(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 W(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:fg,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:hg}})})},yg=n=>{var s=n,{request:e,filter:t={}}=s,o=K(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))},gg=()=>{const{t:e}=R.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 vg(n){var s=n,{component:e="div",children:t}=s,o=K(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:bg}=i.interfacesProperties,xg={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({},bg),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-component":"Select","x-decorator":"FormItem",enum:Array.from(ge.getEntities()).map(([e,{title:t}])=>({value:e,label:t,color:"gold"})),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}}}}},Cg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Ar,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{pageSize:20,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 }}"}}}}}}}},sync:{type:"void",title:`{{t("Sync", { ns: "${d}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${d}" }) }}`},"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{resource:t}=i.useResourceContext();return{run(){return W(this,null,function*(){yield t.sync(),x.message.success(e("Operation succeeded"))})}}}}},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}=R.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 W(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 wg(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 $g(t){var e=K(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(wg,v({},o))}),o.value))}))}const Sg=b.createContext({});function kg(){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:Cg,components:{Tooltip:x.Tooltip,WorkflowLink:gg,ExecutionResourceProvider:yg,ExecutionLink:$r,OpenDrawer:vg,ExecutionStatusSelect:$g}})})})}const Ag=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:kg}}}},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:xg})}),children:r.jsx(Sg.Provider,{value:{triggers:ge,instructions:q},children:e.children})})})})},Tg=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 Og(e){const{t}=R.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 Fg=I.connect(Tg,I.mapReadPretty(Og)),Ig={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"}}]},Dg={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}}]},Ng={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}}}]},Pg=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"}),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:"WorkflowColumn"}),Mg=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:Pg,WorkflowColumn:Eg,UserColumn:Mg},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 _g(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 jg=b.createContext(null);function Bg({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(jg.Provider,{value:e,children:t})}function Vg(){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 W(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 Lg(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=K(D,["nodes"]),_=A,{execution:$}=_,k=K(_,["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,q.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:_g,ManualActionStatusProvider:Bg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.components),{})),u),scope:v({useSubmit:Vg,useFormBlockProps:zg,useDetailsBlockProps:Ug},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 zg(){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 Ug(){const{form:e}=i.useFormBlockContext();return{form:e}}function Gg(){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`
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 Wg(){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:Gg,FlowContextProvider:Lg},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 Hg({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,n=K(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"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(i.CollectionManagerProvider,C(v({},n),{collections:[...o,Ig,Dg,Ng],children:r.jsx(i.TableBlockProvider,C(v({},s),{children:t}))}))}ho.Drawer=Wg,ho.Decorator=Hg;const qg=o=>{var n=o,{insert:e}=n,t=K(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 Or extends i.Plugin{load(){return G(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.use(Ag)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:Mh})}addComponents(){this.app.addComponents({WorkflowPage:kr,ExecutionPage:wr,WorkflowTodo:ho,WorkflowTodoBlockInitializer:qg,DynamicExpression:Fg})}addRoutes(){this.app.router.add("admin.settings.workflow.workflows.id",{path:"/admin/settings/workflow/workflows/:id",element:r.jsx(kr,{})}),this.app.router.add("admin.settings.workflow.executions.id",{path:"/admin/settings/workflow/executions/:id",element:r.jsx(wr,{})})}}O.Branch=Ee,O.FlowContext=Ye,O.JobButton=br,O.Node=gr,O.NodeContext=fo,O.NodeDefaultView=at,O.RemoveButton=vr,O.WorkflowPlugin=Or,O.default=Or,O.instructions=q,O.triggers=ge,O.useAvailableUpstreams=st,O.useFlowContext=z,O.useNodeContext=we,O.useUpstreamScopes=yr,O.useWorkflowVariableOptions=ae,Object.defineProperties(O,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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 Wg(){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:Gg,FlowContextProvider:Lg},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 Hg({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,n=K(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"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(i.CollectionManagerProvider,C(v({},n),{collections:[...o,Ig,Dg,Ng],children:r.jsx(i.TableBlockProvider,C(v({},s),{children:t}))}))}ho.Drawer=Wg,ho.Decorator=Hg;const qg=o=>{var n=o,{insert:e}=n,t=K(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 Or extends i.Plugin{load(){return W(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.use(Ag)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:Mh})}addComponents(){this.app.addComponents({WorkflowPage:kr,ExecutionPage:wr,WorkflowTodo:ho,WorkflowTodoBlockInitializer:qg,DynamicExpression:Fg})}addRoutes(){this.app.router.add("admin.settings.workflow.workflows.id",{path:"/admin/settings/workflow/workflows/:id",element:r.jsx(kr,{})}),this.app.router.add("admin.settings.workflow.executions.id",{path:"/admin/settings/workflow/executions/:id",element:r.jsx(wr,{})})}}O.Branch=Ee,O.FlowContext=Ye,O.JobButton=br,O.Node=gr,O.NodeContext=fo,O.NodeDefaultView=at,O.RemoveButton=vr,O.WorkflowPlugin=Or,O.default=Or,O.instructions=q,O.triggers=ge,O.useAvailableUpstreams=st,O.useFlowContext=z,O.useNodeContext=we,O.useUpstreamScopes=yr,O.useWorkflowVariableOptions=ae,Object.defineProperties(O,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});