Files
nextcloud-server-mirror/dist/workflowengine-workflowengine.mjs
2026-11-04 20:22:53 +00:00

7 lines
33 KiB
JavaScript

import{e as M,L as Ue,v as U,j as V,E as Y,o as v,f as C,n as f,p as b,g as Le,t as R,l as T,w as E,s as Q,u as t,h as I,r as Me,B as Oe,aj as ze,R as Se,z as te,A as ae,q as F,K as Ae,G as ce,H as de,al as Ne,X as fe,m as ve,M as qe,ae as Pe,b as We,J as De,P as ie,ad as we,Q as je,U as re,c as He,am as Ge,a as Be}from"./pinia-BeMUBY7J.chunk.mjs";import{F as xe,G as Ze,aa as Je,X as Qe,aL as Xe,aM as Ke}from"./sr-DO1r0q_c.chunk.mjs";import{g as Ye,a as eo}from"./th-xm605lYx.chunk.mjs";import{c as q,d as Ee,l as D,a as oo,e as oe}from"./tr-BYfz54C4.chunk.mjs";import{t as l}from"./bn-Bv2TbhnR.chunk.mjs";import{N as X}from"./ne-ByX4q_H_.chunk.mjs";import{N as _e}from"./fileSorting-BdweoF5J.chunk.mjs";import{N as j}from"./ro-DmFr_EpW.chunk.mjs";import{N as ge}from"./NcSettingsSection-CSSml3bq.chunk.mjs";import{C as ke}from"./index-CJqyQtjZ.chunk.mjs";import{o as lo}from"./index-x38jcf8R.chunk.mjs";import{N as to}from"./NcActionButton-CFimrayZ.chunk.mjs";import{b as ao}from"./vi-BHQK49V1.chunk.mjs";import{N as G,a as he}from"./index-DOnbj6QD.chunk.mjs";import{c as J}from"./mediaPreloader-BTSNZfDn.chunk.mjs";import{c as se}from"./index-DL58vPm2.chunk.mjs";import{s as no}from"./index-BYZoytoX.chunk.mjs";import{N as io}from"./NcSelectTags-CV3_8Fys.chunk.mjs";import"./pl-BC8vetYy.chunk.mjs";import"./ContentCopy-DQbZeoRU.chunk.mjs";import"./check-DE-hsm7F.chunk.mjs";import"./_l10n-CQg6pS4Q.chunk.mjs";import"./NcPopover-MIK6mPB6.chunk.mjs";import"./Check-CIV3fpXW.chunk.mjs";import"./ArrowRight-Bse2ENkR.chunk.mjs";import"./toAuthenticatorAttachment-NzLJQmDE.chunk.mjs";import"./NcInputField-CwC8lEEc.chunk.mjs";import"./lt-BZECWd2W.chunk.mjs";import"./TrashCanOutline-nBv5Q4UH.chunk.mjs";import"./sk-ptnME07m.chunk.mjs";import"./NcPasswordField-DSwqfsBk.chunk.mjs";import"./ja-BE4dH_28.chunk.mjs";const me="var(--color-main-text)",ro=4.5;function so(e){return e==="transparent"?me:e==="var(--color-primary-element)"?"var(--color-primary-element-text)":null}function uo(e){try{return ke(e).contrast(ke("#ffffff"))>ro?"#ffffff":"#000000"}catch{return me}}function co(e){return e==="#000000"?"invert(100%)":"none"}const mo=M({__name:"Operation",props:{operation:{},colored:{type:Boolean}},setup(e){Ue(i=>({v1e1a9daa:c.value,v41a7785c:s.value,v313d5b6a:u.value}));const n=e,a=U(),c=U(me),s=V(()=>n.colored?n.operation.color||"var(--color-primary-element)":"transparent");Y(s,async()=>{const i=so(s.value);if(i!==null){c.value=i;return}let d=s.value;d.startsWith("#")||(await Oe(),d=window.getComputedStyle(a.value).backgroundColor),c.value=uo(d)},{immediate:!0});const u=V(()=>co(c.value));return(i,d)=>(v(),C("div",{ref_key:"operationElement",ref:a,class:f([i.$style.actions__item,{[i.$style.colored]:e.colored}])},[b("div",{class:f([i.$style.icon,e.operation.iconClass]),style:Le({backgroundImage:e.operation.iconClass?"":`url(${e.operation.icon})`})},null,6),b("div",{class:f(i.$style.actions__item__description)},[b("h3",null,R(e.operation.name),1),b("small",null,R(e.operation.description),1),e.colored?(v(),T(t(X),{key:0},{default:E(()=>[Q(R(t(l)("workflowengine","Add new flow")),1)]),_:1})):I("",!0)],2),b("div",{class:f(i.$style.actions__item_options)},[Me(i.$slots,"default")],2)],2))}}),po="_actions__item_kim13_5",fo="_icon_kim13_15",vo="_actions__item__description_kim13_25",wo="_actions__item_options_kim13_32",_o="_colored_kim13_51",go={actions__item:po,icon:fo,actions__item__description:vo,actions__item_options:wo,colored:_o},ko={$style:go},Fe=q(mo,[["__cssModules",ko]]);function Te(e,n){const a=Object.entries(n);function c(u){a.forEach(([i,d])=>u?.addEventListener(i,d))}function s(u){a.forEach(([i,d])=>u?.removeEventListener(i,d))}Y(e,(u,i)=>{s(i),c(u)},{immediate:!0,flush:"post"}),ze(()=>s(e.value))}const K=Ye().detectLogLevel().setApp("workflowengine").build(),Re={ADMIN:0};function le(e,n=""){const a=e===Re.ADMIN?"global":"user";return Ee("apps/workflowengine/api/v1/workflows/{scopeValue}",{scopeValue:a})+n+"?format=json"}const ho="var(--color-primary-element)";function yo(e){return e.flatMap(n=>n.events.map(a=>({id:`${n.id}::${a.eventName}`,entity:n,...a})))}const ee=Se("workflowengine",()=>{const e=D("workflowengine","scope"),n=D("workflowengine","appstoreenabled"),a=D("workflowengine","entities"),c=yo(a),s=D("workflowengine","checks"),u=U([]),i=U(D("workflowengine","operators")),d=U({}),g=V(()=>u.value.filter(o=>i.value[o.class]!==void 0).sort((o,m)=>o.id-m.id));function $(o){return i.value[o.class]}function A(o){return a.find(m=>o.fixedEntity===m.id)}function _(o){return Object.values(s).filter(m=>m.supportedEntities.length===0||m.supportedEntities.includes(o)).map(m=>d.value[m.id]).reduce((m,x)=>(m[x.class]=x,m),{})}function h(o){d.value={...d.value,[o.class]:o}}function r(o){const m=i.value[o.id];if(m===void 0)return;const x={...o,...m};i.value={...i.value,[o.id]:{...x,color:x.color??ho}}}function y(o){const m=u.value.findIndex(Z=>Z.id===o.id);if(m===-1)return;const x={...o,events:typeof o.events=="string"?JSON.parse(o.events):o.events};u.value.splice(m,1,x)}function p(o,m){Object.assign(o,m)}function w(o){o.checks.push({class:null,operator:null,value:""})}function L(o,m){const x=o.checks.indexOf(m);x>-1&&o.checks.splice(x,1)}function z(o,m,x){o.entity=m,o.events=x}function N(o,m){o.operation=m}function S(o){const m=u.value.findIndex(x=>x.id===o.id);m!==-1&&u.value.splice(m,1)}async function B(){const{data:o}=await J.get(le(e));u.value.push(...Object.values(o.ocs.data).flat().map(m=>({...m,valid:!0})))}async function P(o){await se();let m,x=[];o.isComplex===!1&&o.fixedEntity===""&&(m=a.find(Z=>o.entities&&o.entities[0]===Z.id)??a[0],x=[m.events[0].eventName]),u.value.push({id:-Date.now(),class:o.id,entity:m?m.id:o.fixedEntity,events:x,name:"",checks:[{class:null,operator:null,value:""}],operation:o.operation||"",valid:!0})}async function W(o){await se();const{data:m}=o.id<0?await J.post(le(e),o):await J.put(le(e,`/${o.id}`),o);o.id=m.ocs.data.id,y(o)}async function k(o){await se(),await J.delete(le(e,`/${o.id}`)),S(o)}function O(o,m){o.valid=m,y(o)}return{scope:e,appstoreEnabled:n,entities:a,events:c,checks:s,rules:u,operations:i,pluginChecks:d,configuredRules:g,operationForRule:$,entityForOperation:A,checksForEntity:_,addPluginCheck:h,addPluginOperator:r,fetchRules:B,createNewRule:P,updateRule:y,removeRule:S,updateCheck:p,addCheck:w,removeCheck:L,setRuleTrigger:z,setRuleOperation:N,pushUpdateRule:W,deleteRule:k,setValid:O}}),bo=["disabled","placeholder","value"],Vo=M({__name:"Check",props:{check:{},rule:{}},emits:["update","validate","remove"],setup(e,{emit:n}){const a=e,c=n,s=ee(),u=te("checkElement"),i=te("valueElement"),d=te("checkSelector"),g=U(!1),$=U(!1),A=U(void 0),_=V(()=>s.checksForEntity(a.rule.entity)),h=V(()=>Object.values(_.value)),r=V(()=>a.check.class===null?null:_.value[a.check.class]??null),y=V(()=>{if(!r.value)return[];const{operators:o}=r.value;return typeof o=="function"?o(a.check):o}),p=V(()=>y.value.find(o=>o.operator===a.check.operator)??null),w=V(()=>{if(a.check.class!==null)return _.value[a.check.class]?.element}),L=V(()=>r.value?.placeholder?.(a.check)??"");function z(){g.value=!0}lo(u,()=>{g.value=!1});function N(){r.value?.validate?$.value=!!r.value.validate(a.check):$.value=A.value??!0,s.updateCheck(a.check,{invalid:!$.value}),c("validate",$.value)}function S(o){s.updateCheck(a.check,o),N(),c("update",a.check)}function B(o){if(o===null)return;!o.element&&!o.validate&&o.component&&K.error(`Check plugin "${o.class}" only provides the removed "component" option. Provide a custom element through "element" instead.`);const m=typeof o.operators=="function"?o.operators(a.check):o.operators,x=m.some(Z=>Z.operator===a.check.operator)?a.check.operator:m[0]?.operator??null;o.class!==a.check.class&&(A.value=void 0),S({class:o.class,operator:x})}function P(o){o!==null&&S({operator:o.operator})}function W(o){S({value:o.detail[0]})}function k(o){A.value=o,N()}function O(o){S({value:o.target.value})}return Te(i,{"update:model-value":W,valid:()=>k(!0),invalid:()=>k(!1)}),Y(()=>a.check.operator,N),ae(()=>{a.check.class===null&&d.value?.focus?.(),N()}),(o,m)=>(v(),C("div",{ref_key:"checkElement",ref:u,class:f(o.$style.check),onClick:z},[F(t(G),{ref_key:"checkSelector",ref:d,"aria-label-combobox":t(l)("workflowengine","Filter"),class:f(o.$style.filter),clearable:!1,modelValue:r.value,options:h.value,placeholder:t(l)("workflowengine","Select a filter"),label:"name","onUpdate:modelValue":B},null,8,["aria-label-combobox","class","modelValue","options","placeholder"]),F(t(G),{"aria-label-combobox":t(l)("workflowengine","Comparator"),class:f(o.$style.comparator),clearable:!1,disabled:!r.value,modelValue:p.value,options:y.value,placeholder:t(l)("workflowengine","Select a comparator"),label:"name","onUpdate:modelValue":P},null,8,["aria-label-combobox","class","disabled","modelValue","options","placeholder"]),w.value?(v(),T(Ae(w.value),{key:0,ref_key:"valueElement",ref:i,class:f(o.$style.option),disabled:!r.value||void 0,"model-value":e.check.value,operator:e.check.operator},null,8,["class","disabled","model-value","operator"])):(v(),C("input",{key:1,class:f([o.$style.option,{[o.$style.invalid]:!$.value}]),disabled:!r.value,placeholder:L.value,value:e.check.value,type:"text",onInput:O},null,42,bo)),g.value||!r.value?(v(),T(t(ao),{key:2},{default:E(()=>[F(t(to),{title:t(l)("workflowengine","Remove filter"),onClick:m[0]||(m[0]=x=>c("remove"))},{icon:E(()=>[F(t(j),{path:t(xe),size:20},null,8,["path"])]),_:1},8,["title"])]),_:1})):I("",!0)],2))}}),Co="_check_maebz_1",$o="_filter_maebz_13",Lo="_comparator_maebz_17",Ao="_option_maebz_22",xo="_invalid_maebz_35",Eo={check:Co,filter:$o,comparator:Lo,option:Ao,invalid:xo},Fo={$style:Eo},To=q(Vo,[["__cssModules",Fo]]),Ro={key:0},Io=["src"],Uo=["src"],Mo=["src"],Oo=M({__name:"Event",props:{rule:{}},emits:["update"],setup(e,{emit:n}){const a=e,c=n,s=ee(),u=V(()=>s.operationForRule(a.rule)),i=V(()=>s.entityForOperation(u.value)),d=V(()=>s.events),g=V(()=>d.value.filter(_=>_.entity.id===a.rule.entity&&a.rule.events.includes(_.eventName))),$=l("workflowengine","Select a trigger");function A(_){if(_.length===0){no(l("workflowengine","At least one event must be selected"));return}const h=a.rule.entity,r=[...new Set(_.map(p=>p.entity.id))],y=r.length>1?r.filter(p=>p!==h)[0]:r[0];s.setRuleTrigger(a.rule,y,_.filter(p=>p.entity.id===y).map(p=>p.eventName)),c("update",a.rule)}return(_,h)=>(v(),C("div",{class:f(_.$style.event)},[u.value.isComplex&&u.value.fixedEntity!==""?(v(),C("div",Ro,[b("img",{class:f(_.$style.optionIcon),src:i.value?.icon,alt:""},null,10,Io),b("span",{class:f([_.$style.optionTitle,_.$style.singleTitle])},R(u.value.triggerHint),3)])):(v(),T(t(G),{key:1,"aria-label-combobox":t(l)("workflowengine","Trigger"),class:f(_.$style.trigger),disabled:d.value.length<=1,modelValue:g.value,multiple:!0,options:d.value,placeholder:t($),label:"displayName","onUpdate:modelValue":A},{option:E(r=>[b("img",{class:f(_.$style.optionIcon),src:r.entity.icon,alt:""},null,10,Uo),b("span",{class:f(_.$style.optionTitle)},R(r.displayName),3)]),"selected-option":E(r=>[b("img",{class:f(_.$style.optionIcon),src:r.entity.icon,alt:""},null,10,Mo),b("span",{class:f(_.$style.optionTitle)},R(r.displayName),3)]),_:1},8,["aria-label-combobox","class","disabled","modelValue","options","placeholder"]))],2))}}),zo="_event_e1fp9_1",So="_trigger_e1fp9_8",No="_optionTitle_e1fp9_12",qo="_singleTitle_e1fp9_17",Po="_optionIcon_e1fp9_22",Wo={event:zo,trigger:So,optionTitle:No,singleTitle:qo,optionIcon:Po},Do={$style:Wo},jo=q(Oo,[["__cssModules",Do]]),Ho=["value"],Go=M({__name:"Rule",props:{rule:{}},setup(e){const n=e,a=ee(),c=U(null),s=U(n.rule.id<0),u=U(null),i=U(""),d=te("operationElement"),g=V(()=>a.operationForRule(n.rule)),$=V(()=>c.value||!n.rule.valid||n.rule.checks.length===0||n.rule.checks.some(k=>k.invalid===!0)?{title:l("workflowengine","The configuration is invalid"),icon:xe,variant:"warning",tooltip:c.value??void 0}:s.value?{title:l("workflowengine","Save"),icon:Je,variant:"primary",tooltip:void 0}:{title:l("workflowengine","Active"),icon:Ze,variant:"success",tooltip:void 0}),A=V(()=>{const k=n.rule.checks.at(-1);return k===void 0||k.class!==null}),_=new WeakMap;let h=0;function r(k){let O=_.get(k);return O===void 0&&(h+=1,O=h,_.set(k,O)),O}function y(){c.value=null,a.updateRule(n.rule)}function p(){s.value=!0,c.value=null,a.updateRule(n.rule)}function w(k){i.value=k.detail[0],a.setRuleOperation(n.rule,i.value),p()}async function L(){try{await a.pushUpdateRule(n.rule),s.value=!1,c.value=null,u.value=structuredClone(P(n.rule))}catch(k){K.error("Failed to save operation",{error:k}),c.value=W(k)}}async function z(){try{await a.deleteRule(n.rule)}catch(k){K.error("Failed to delete operation",{error:k}),c.value=W(k)}}function N(){if(n.rule.id<0){a.removeRule(n.rule);return}i.value=u.value.operation,a.updateRule(u.value),u.value=structuredClone(P(n.rule)),s.value=!1}function S(k){a.removeCheck(n.rule,k),p()}function B(){a.addCheck(n.rule)}function P(k){return JSON.parse(JSON.stringify(k))}function W(k){return k.response?.data?.ocs?.meta?.message??null}return Te(d,{"update:model-value":w}),ae(()=>{u.value=structuredClone(P(n.rule)),g.value?.element&&(i.value=n.rule.operation)}),(k,O)=>g.value?(v(),C("div",{key:0,class:f(k.$style.rule),style:Le({borderInlineStartColor:g.value.color||""})},[b("div",{class:f(k.$style.trigger)},[b("p",null,[b("span",null,R(t(l)("workflowengine","When")),1),F(jo,{rule:e.rule,onUpdate:p},null,8,["rule"])]),(v(!0),C(ce,null,de(e.rule.checks,o=>(v(),C("p",{key:r(o)},[b("span",null,R(t(l)("workflowengine","and")),1),F(To,{check:o,rule:e.rule,onUpdate:p,onValidate:y,onRemove:m=>S(o)},null,8,["check","rule","onRemove"])]))),128)),b("p",null,[O[0]||(O[0]=b("span",null,null,-1)),A.value?(v(),C("input",{key:0,class:f(k.$style.addCheck),value:t(l)("workflowengine","Add a new filter"),type:"button",onClick:B},null,10,Ho)):I("",!0)])],2),b("div",{class:f(["icon-confirm",[k.$style.flowIcon]])},null,2),b("div",{class:f(k.$style.action)},[F(Fe,{operation:g.value},{default:E(()=>[g.value.element?(v(),T(Ae(g.value.element),{key:0,ref_key:"operationElement",ref:d,"model-value":i.value},null,8,["model-value"])):I("",!0)]),_:1},8,["operation"]),b("div",{class:f(k.$style.buttons)},[e.rule.id<-1||s.value?(v(),T(t(X),{key:0,onClick:N},{default:E(()=>[Q(R(t(l)("workflowengine","Cancel")),1)]),_:1})):s.value?I("",!0):(v(),T(t(X),{key:1,onClick:z},{default:E(()=>[Q(R(t(l)("workflowengine","Delete")),1)]),_:1})),F(t(X),{title:$.value.tooltip,variant:$.value.variant,onClick:L},{icon:E(()=>[F(t(j),{path:$.value.icon,size:20},null,8,["path"])]),default:E(()=>[Q(" "+R($.value.title),1)]),_:1},8,["title","variant"])],2),c.value?(v(),C("p",{key:0,class:f(k.$style.errorMessage)},R(c.value),3)):I("",!0)],2)],6)):I("",!0)}}),Bo="_buttons_iqw5o_1",Zo="_errorMessage_iqw5o_12",Jo="_flowIcon_iqw5o_17",Qo="_rule_iqw5o_24",Xo="_trigger_iqw5o_32",Ko="_action_iqw5o_33",Yo="_addCheck_iqw5o_66",el={buttons:Bo,errorMessage:Zo,flowIcon:Jo,rule:Qo,trigger:Xo,action:Ko,addCheck:Yo},ol={$style:el},ll=q(Go,[["__cssModules",ol]]),ye=`<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path d="M 3.0839844 3 C 2.0812854 3 1.25 3.8312754 1.25 4.8339844 L 1.25 7 L 1.0136719 7 C -0.33862677 6.980875 -0.33862677 9.0191 1.0136719 9 L 1.25 9 L 1.25 11.166016 C 1.25 12.168715 2.0812754 13 3.0839844 13 L 7.4160156 13 C 8.4187146 13 9.25 12.168725 9.25 11.166016 L 9.25 9 L 10.060547 9 L 7.75 6.6894531 L 7.75 11.166016 C 7.75 11.363655 7.6136554 11.5 7.4160156 11.5 L 3.0839844 11.5 C 2.8863446 11.5 2.75 11.363655 2.75 11.166016 L 2.75 4.8339844 C 2.75 4.6363446 2.8863446 4.5 3.0839844 4.5 L 5.5605469 4.5 L 4.0605469 3 L 3.0839844 3 z M 6.1816406 3 L 9.25 6.0683594 L 9.25 4.8339844 C 9.25 3.8312854 8.4187246 3 7.4160156 3 L 6.1816406 3 z M 11.5 3.5 C 10.602601 3.5 10.159605 4.5908975 10.802734 5.2167969 L 12.585938 7 L 10.181641 7 L 12.181641 9 L 12.585938 9 L 12.382812 9.203125 L 13.796875 10.617188 L 15.707031 8.7070312 C 16.094031 8.3192316 16.098031 7.6841684 15.707031 7.2929688 L 12.216797 3.8027344 C 12.028497 3.6092346 11.77 3.50002 11.5 3.5 z M 11.324219 10.261719 L 10.802734 10.783203 C 9.8211054 11.725712 11.274208 13.178865 12.216797 12.197266 L 12.738281 11.675781 L 11.324219 10.261719 z " />
<path d="M 0,1.0606601 1.06066,0 16.00033,14.93967 14.93967,16.00033 Z" />
</svg>
`,tl={key:0,class:"settings-hint"},al={href:"https://nextcloud.com/developer/"},nl=["href"],be=3,il=M({__name:"Workflow",setup(e){const n=ee(),a=Ne(),c=U(!1),s=oo("settings/apps/workflow"),u=D("workflowengine","doc-url"),i=!!eo()?.isAdmin,d=V(()=>n.configuredRules),g=V(()=>n.operations),$=V(()=>Object.keys(g.value).length>be),A=V(()=>{const p=Object.values(g.value);return c.value?p:p.slice(0,be)}),_=V(()=>n.scope===Re.ADMIN),h=V(()=>n.appstoreEnabled&&i),r={enterActiveClass:a.slideEnterActive,leaveActiveClass:a.slideLeaveActive,enterFromClass:a.slideEnterFrom,enterToClass:a.slideEnterTo,leaveFromClass:a.slideLeaveFrom,leaveToClass:a.slideLeaveTo};function y(p){n.createNewRule(p)}return ae(()=>{n.fetchRules()}),(p,w)=>(v(),C("div",{class:f(p.$style.workflowengine)},[F(t(ge),{docUrl:t(u),name:t(l)("workflowengine","Available flows")},{default:E(()=>[_.value?(v(),C("p",tl,[b("a",al,R(t(l)("workflowengine","For details on how to write your own flow, check out the development documentation.")),1)])):I("",!0),!t(i)&&A.value.length===0?(v(),T(t(_e),{key:1,description:t(l)("workflowengine","Ask your administrator to install new flows."),name:t(l)("workflowengine","No flows installed")},{icon:E(()=>[F(t(j),{svg:t(ye),size:20},null,8,["svg"])]),_:1},8,["description","name"])):(v(),T(fe,ve({key:2},r,{class:p.$style.actions,tag:"div"}),{default:E(()=>[(v(!0),C(ce,null,de(A.value,L=>(v(),T(Fe,{key:L.id,class:f(p.$style.card),operation:L,colored:"",onClick:z=>y(L)},null,8,["class","operation","onClick"]))),128)),h.value?(v(),C("a",{key:"add",class:f([p.$style.card,p.$style.more]),href:t(s)},[F(t(j),{class:f(p.$style.moreIcon),path:t(Qe),size:50},null,8,["class","path"]),b("div",null,[b("h3",null,R(t(l)("workflowengine","More flows")),1),b("small",null,R(t(l)("workflowengine","Browse the App Store")),1)])],10,nl)):I("",!0)]),_:1},16,["class"])),$.value?(v(),C("div",{key:3,class:f(p.$style.showMore)},[F(t(X),{onClick:w[0]||(w[0]=L=>c.value=!c.value)},{icon:E(()=>[F(t(j),{path:c.value?t(Xe):t(Ke),size:20},null,8,["path"])]),default:E(()=>[Q(" "+R(c.value?t(l)("workflowengine","Show less"):t(l)("workflowengine","Show more")),1)]),_:1})],2)):I("",!0)]),_:1},8,["docUrl","name"]),A.value.length>0?(v(),T(t(ge),{key:0,name:_.value?t(l)("workflowengine","Configured flows"):t(l)("workflowengine","Your flows"),class:f(p.$style.operations)},{default:E(()=>[d.value.length>0?(v(),T(fe,qe(ve({key:0},r)),{default:E(()=>[(v(!0),C(ce,null,de(d.value,L=>(v(),T(ll,{key:L.id,rule:L},null,8,["rule"]))),128))]),_:1},16)):(v(),T(t(_e),{key:1,name:t(l)("workflowengine","No flows configured")},{icon:E(()=>[F(t(j),{svg:t(ye),size:20},null,8,["svg"])]),_:1},8,["name"]))]),_:1},8,["name","class"])):I("",!0)],2))}}),rl="_actions__item_43boi_5",sl="_icon_43boi_15",ul="_actions__item__description_43boi_25",cl="_actions__item_options_43boi_32",dl="_colored_43boi_51",ml="_operations_43boi_74",pl="_workflowengine_43boi_78",fl="_actions_43boi_5",vl="_card_43boi_88",wl="_more_43boi_93",_l="_moreIcon_43boi_98",gl="_showMore_43boi_102",kl="_slideEnterActive_43boi_106",hl="_slideLeaveActive_43boi_111",yl="_slideEnterTo_43boi_116",bl="_slideLeaveFrom_43boi_117",Vl="_slideEnterFrom_43boi_122",Cl="_slideLeaveTo_43boi_123",$l={actions__item:rl,icon:sl,actions__item__description:ul,actions__item_options:cl,colored:dl,operations:ml,workflowengine:pl,actions:fl,card:vl,more:wl,moreIcon:_l,showMore:gl,slideEnterActive:kl,slideLeaveActive:hl,slideEnterTo:yl,slideLeaveFrom:bl,slideEnterFrom:Vl,slideLeaveTo:Cl},Ll={$style:$l},Al=q(il,[["__cssModules",Ll]]);function ne(e,n,a={}){const c=a.parse??(d=>d),s=a.format??(d=>d==null?"":String(d)),u=U(c(e())),i=()=>{u.value=c(e())};return Y(e,i),{newValue:u,syncFromModel:i,emitValue:(d=u.value)=>{u.value=d,n(s(d))}}}const xl=["src"],El=["src"],Fl=["placeholder","value"],Tl=M({__name:"SelectWithCustomValue",props:{modelValue:{default:""},predefinedValues:{},customLabel:{},comboboxLabel:{},placeholder:{},customPlaceholder:{default:void 0}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,c=n,{newValue:s,emitValue:u}=ne(()=>a.modelValue,r=>c("update:modelValue",r)),i=V(()=>({icon:"icon-settings-dark",label:a.customLabel,id:""})),d=V(()=>[...a.predefinedValues,i.value]),g=V(()=>a.predefinedValues.find(r=>r.id===s.value)),$=V(()=>g.value!==void 0),A=V(()=>g.value??{...i.value,id:s.value});function _(r){r!==null&&u(r.id)}function h(r){u(r.target.value)}return(r,y)=>(v(),C("div",null,[F(t(G),{"aria-label-combobox":e.comboboxLabel,class:f(r.$style.select),clearable:!1,modelValue:A.value,options:d.value,placeholder:e.placeholder,label:"label","onUpdate:modelValue":_},{option:E(p=>[p.icon?(v(),C("span",{key:0,class:f([r.$style.icon,p.icon])},null,2)):p.iconUrl?(v(),C("span",{key:1,class:f(r.$style.iconImage)},[b("img",{src:p.iconUrl,alt:""},null,8,xl)],2)):I("",!0),b("span",{class:f(r.$style.title)},[F(t(he),{name:String(p.label)},null,8,["name"])],2)]),"selected-option":E(p=>[p.icon?(v(),C("span",{key:0,class:f([r.$style.icon,p.icon])},null,2)):p.iconUrl?(v(),C("span",{key:1,class:f(r.$style.iconImage)},[b("img",{src:p.iconUrl,alt:""},null,8,El)],2)):I("",!0),b("span",{class:f(r.$style.title)},[F(t(he),{name:String(p.label)},null,8,["name"])],2)]),_:1},8,["aria-label-combobox","class","modelValue","options","placeholder"]),$.value?I("",!0):(v(),C("input",{key:0,class:f(r.$style.customValue),placeholder:e.customPlaceholder,value:t(s),type:"text",onInput:h},null,42,Fl))]))}}),Rl="_select_1n0ym_1",Il="_customValue_1n0ym_2",Ul="_icon_1n0ym_10",Ml="_iconImage_1n0ym_11",Ol="_title_1n0ym_22",zl={select:Rl,customValue:Il,icon:Ul,iconImage:Ml,title:Ol},Sl={$style:zl},pe=q(Tl,[["__cssModules",Sl]]),Nl=M({__name:"FileMimeType",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e){const n=[{iconUrl:oe("core","filetypes/audio"),label:l("workflowengine","Audio"),id:"/audio\\/.*/"},{icon:"icon-folder",label:l("workflowengine","Folder"),id:"httpd/unix-directory"},{icon:"icon-picture",label:l("workflowengine","Images"),id:"/image\\/.*/"},{iconUrl:oe("core","filetypes/x-office-document"),label:l("workflowengine","Office documents"),id:"/(vnd\\.(ms-|openxmlformats-|oasis\\.opendocument).*)$/"},{iconUrl:oe("core","filetypes/application-pdf"),label:l("workflowengine","PDF documents"),id:"application/pdf"},{iconUrl:oe("core","filetypes/video"),label:l("workflowengine","Video"),id:"/video\\/.*/"}];return(a,c)=>(v(),T(pe,{comboboxLabel:t(l)("workflowengine","File type"),customLabel:t(l)("workflowengine","Custom MIME type"),customPlaceholder:t(l)("workflowengine","e.g. httpd/unix-directory"),modelValue:e.modelValue,placeholder:t(l)("workflowengine","Select a file type"),predefinedValues:n,"onUpdate:modelValue":c[0]||(c[0]=s=>a.$emit("update:modelValue",s))},null,8,["comboboxLabel","customLabel","customPlaceholder","modelValue","placeholder"]))}}),ql=M({__name:"FileSystemTag",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,c=n,{newValue:s,emitValue:u}=ne(()=>a.modelValue,i=>c("update:modelValue",i),{parse:i=>i===""?null:Number.parseInt(i),format:i=>String(i||"")});return(i,d)=>(v(),T(t(io),{modelValue:t(s),"onUpdate:modelValue":[d[0]||(d[0]=g=>Pe(s)?s.value=g:null),d[1]||(d[1]=g=>t(u)())],"aria-label-combobox":t(l)("workflowengine","Tag"),limit:null,multiple:!1},null,8,["modelValue","aria-label-combobox"]))}});function H(e,n){if(window.customElements.get(n))throw K.error(`Custom element with ID ${n} is already defined!`),new Error(`Custom element with ID ${n} is already defined!`);return window.customElements.define(n,We(e,{shadowRoot:!1})),n}const Pl=/^\/(.*)\/([gui]{0,3})$/,Wl=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/,Dl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/;function jl(e){return e?Pl.exec(e)!==null:!1}function Hl(e){return e?Wl.exec(e)!==null:!1}function Gl(e){return e?Dl.exec(e)!==null:!1}function Bl(e){return e.operator==="matches"||e.operator==="!matches"?jl(e.value):!0}function Ve(){return[{operator:"matches",name:l("workflowengine","matches")},{operator:"!matches",name:l("workflowengine","does not match")},{operator:"is",name:l("workflowengine","is")},{operator:"!is",name:l("workflowengine","is not")}]}const Zl=[{class:"OCA\\WorkflowEngine\\Check\\FileName",name:l("workflowengine","File name"),operators:Ve,placeholder:e=>e.operator==="matches"||e.operator==="!matches"?"/^dummy-.+$/i":"filename.txt",validate:Bl},{class:"OCA\\WorkflowEngine\\Check\\FileMimeType",name:l("workflowengine","File MIME type"),operators:Ve,element:H(Nl,"oca-workflowengine-checks-file_mime_type")},{class:"OCA\\WorkflowEngine\\Check\\FileSize",name:l("workflowengine","File size (upload)"),operators:[{operator:"less",name:l("workflowengine","less")},{operator:"!greater",name:l("workflowengine","less or equals")},{operator:"!less",name:l("workflowengine","greater or equals")},{operator:"greater",name:l("workflowengine","greater")}],placeholder:()=>"5 MB",validate:e=>e.value?e.value.match(/^[0-9]+[ ]?[kmgt]?b$/i)!==null:!1},{class:"OCA\\WorkflowEngine\\Check\\RequestRemoteAddress",name:l("workflowengine","Request remote address"),operators:[{operator:"matchesIPv4",name:l("workflowengine","matches IPv4")},{operator:"!matchesIPv4",name:l("workflowengine","does not match IPv4")},{operator:"matchesIPv6",name:l("workflowengine","matches IPv6")},{operator:"!matchesIPv6",name:l("workflowengine","does not match IPv6")}],placeholder:e=>e.operator==="matchesIPv6"||e.operator==="!matchesIPv6"?"::1/128":"127.0.0.1/32",validate:e=>e.operator==="matchesIPv6"||e.operator==="!matchesIPv6"?Gl(e.value):Hl(e.value)},{class:"OCA\\WorkflowEngine\\Check\\FileSystemTags",name:l("workflowengine","File system tag"),operators:[{operator:"is",name:l("workflowengine","is tagged with")},{operator:"!is",name:l("workflowengine","is not tagged with")}],element:H(ql,"oca-workflowengine-file_system_tag")}];function Jl(){return["UTC",...Intl.supportedValuesOf("timeZone")]}function Ce(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Ql(e){if(!e)return!1;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}const Xl=["aria-label"],Kl=["aria-label"],Yl=M({__name:"RequestTime",props:{modelValue:{default:"[]"}},emits:["update:modelValue","valid","invalid"],setup(e,{emit:n}){const a=e,c=n,s=/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/,u=Jl(),i=U(!1);function d(h){try{const r=JSON.parse(h);if(r.length===2)return{startTime:r[0].split(" ",2)[0],endTime:r[1].split(" ",2)[0],timezone:r[0].split(" ",2)[1]}}catch{}return{startTime:null,endTime:null,timezone:Ce()}}const{newValue:g,emitValue:$}=ne(()=>a.modelValue,h=>c("update:modelValue",h),{parse:d,format:({startTime:h,endTime:r,timezone:y})=>`["${h} ${y}","${r} ${y}"]`});function A(){const{startTime:h,endTime:r,timezone:y}=g.value;return i.value=!!h&&s.test(h)&&!!r&&s.test(r)&&Ql(y),i.value?c("valid"):c("invalid"),i.value}function _(){g.value.timezone===null&&(g.value.timezone=Ce()),A()&&$()}return De(A),(h,r)=>(v(),C("div",{class:f(h.$style.timeslot)},[ie(b("input",{"onUpdate:modelValue":r[0]||(r[0]=y=>t(g).startTime=y),"aria-label":t(l)("workflowengine","Start time"),class:f([h.$style.time,h.$style.startTime]),placeholder:"e.g. 08:00",type:"text",onInput:_},null,42,Xl),[[we,t(g).startTime]]),ie(b("input",{"onUpdate:modelValue":r[1]||(r[1]=y=>t(g).endTime=y),"aria-label":t(l)("workflowengine","End time"),class:f(h.$style.time),placeholder:"e.g. 18:00",type:"text",onInput:_},null,42,Kl),[[we,t(g).endTime]]),i.value?I("",!0):(v(),C("p",{key:0,class:f(h.$style.invalidHint)},R(t(l)("workflowengine","Please enter a valid time span")),3)),ie(F(t(G),{modelValue:t(g).timezone,"onUpdate:modelValue":[r[2]||(r[2]=y=>t(g).timezone=y),_],"aria-label-combobox":t(l)("workflowengine","Timezone"),class:f(h.$style.timezone),clearable:!1,options:t(u)},null,8,["modelValue","aria-label-combobox","class","options"]),[[je,i.value]])],2))}}),et="_timeslot_1c8g7_1",ot="_timezone_1c8g7_8",lt="_time_1c8g7_1",tt="_startTime_1c8g7_20",at="_invalidHint_1c8g7_25",nt={timeslot:et,timezone:ot,time:lt,startTime:tt,invalidHint:at},it={$style:nt},rt=q(Yl,[["__cssModules",it]]),st=M({__name:"RequestURL",props:{modelValue:{default:""},operator:{default:""}},emits:["update:modelValue"],setup(e){const n=e,a=[{icon:"icon-files-dark",id:"webdav",label:l("workflowengine","Files WebDAV")}],c=V(()=>n.operator==="matches"||n.operator==="!matches"?"/^https\\:\\/\\/localhost\\/index\\.php$/i":"https://localhost/index.php");return(s,u)=>(v(),T(pe,{comboboxLabel:t(l)("workflowengine","Request URL"),customLabel:t(l)("workflowengine","Custom URL"),customPlaceholder:c.value,modelValue:e.modelValue,placeholder:t(l)("workflowengine","Select a request URL"),predefinedValues:a,"onUpdate:modelValue":u[0]||(u[0]=i=>s.$emit("update:modelValue",i))},null,8,["comboboxLabel","customLabel","customPlaceholder","modelValue","placeholder"]))}}),ut=M({__name:"RequestUserAgent",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e){const n=[{id:"android",label:l("workflowengine","Android client"),icon:"icon-phone"},{id:"ios",label:l("workflowengine","iOS client"),icon:"icon-phone"},{id:"desktop",label:l("workflowengine","Desktop client"),icon:"icon-desktop"},{id:"mail",label:l("workflowengine","Thunderbird & Outlook addons"),icon:"icon-mail"}];return(a,c)=>(v(),T(pe,{comboboxLabel:t(l)("workflowengine","User agent"),customLabel:t(l)("workflowengine","Custom user agent"),modelValue:e.modelValue,placeholder:t(l)("workflowengine","Select a user agent"),predefinedValues:n,"onUpdate:modelValue":c[0]||(c[0]=s=>a.$emit("update:modelValue",s))},null,8,["comboboxLabel","customLabel","modelValue","placeholder"]))}}),ct=M({__name:"RequestUserGroup",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,c=n,s=re([]),u=re([]),i=re({isLoading:!1}),{newValue:d,emitValue:g}=ne(()=>a.modelValue,w=>c("update:modelValue",w)),$=V(()=>s.find(w=>w.id===d.value)??null);function A(w){s.some(L=>L.id===w.id)||s.push(w)}function _(w){return s.some(L=>L.id===w)}function h(w){u.includes(w)||u.push(w)}async function r(){let w;do w=u.shift(),w!==void 0&&_(w)&&(w=void 0);while(!w&&u.length>0);w&&await y(w)}async function y(w){if(i.isLoading){w&&h(w);return}i.isLoading=!0;try{const{data:L}=await J.get(Ee("cloud/groups/details?limit=20&search={searchQuery}",{searchQuery:w}));L.ocs.data.groups.forEach(z=>{A({id:z.id,displayname:z.displayname})}),i.isLoading=!1,await r()}catch(L){i.isLoading=!1,K.error("Error while loading group list",{error:L})}}function p(w){w!==null&&g(w.id)}return Y(d,w=>{w&&$.value===null&&y(w)}),ae(async()=>{s.length===0&&await y(""),$.value===null&&d.value&&await y(d.value)}),(w,L)=>(v(),C("div",null,[F(t(G),{"aria-label-combobox":t(l)("workflowengine","Select groups"),"aria-label-listbox":t(l)("workflowengine","Groups"),class:f(w.$style.select),clearable:!1,loading:i.isLoading&&s.length===0,modelValue:$.value,options:s,placeholder:t(l)("workflowengine","Type to search for group …"),label:"displayname",onSearch:y,"onUpdate:modelValue":p},null,8,["aria-label-combobox","aria-label-listbox","class","loading","modelValue","options","placeholder"])]))}}),dt="_select_im0uy_2",mt={select:dt},pt={$style:mt},ft=q(ct,[["__cssModules",pt]]),vt=[{class:"OCA\\WorkflowEngine\\Check\\RequestURL",name:l("workflowengine","Request URL"),operators:[{operator:"is",name:l("workflowengine","is")},{operator:"!is",name:l("workflowengine","is not")},{operator:"matches",name:l("workflowengine","matches")},{operator:"!matches",name:l("workflowengine","does not match")}],element:H(st,"oca-workflowengine-checks-request_url")},{class:"OCA\\WorkflowEngine\\Check\\RequestTime",name:l("workflowengine","Request time"),operators:[{operator:"in",name:l("workflowengine","between")},{operator:"!in",name:l("workflowengine","not between")}],element:H(rt,"oca-workflowengine-checks-request_time")},{class:"OCA\\WorkflowEngine\\Check\\RequestUserAgent",name:l("workflowengine","Request user agent"),operators:[{operator:"is",name:l("workflowengine","is")},{operator:"!is",name:l("workflowengine","is not")},{operator:"matches",name:l("workflowengine","matches")},{operator:"!matches",name:l("workflowengine","does not match")}],element:H(ut,"oca-workflowengine-checks-request_user_agent")},{class:"OCA\\WorkflowEngine\\Check\\UserGroupMembership",name:l("workflowengine","Group membership"),operators:[{operator:"is",name:l("workflowengine","is member of")},{operator:"!is",name:l("workflowengine","is not member of")}],element:H(ft,"oca-workflowengine-checks-request_user_group")}],wt=[...Zl,...vt],Ie=He();Ge(Ie);const $e=ee(),ue=window.OCA;ue.WorkflowEngine={...ue.WorkflowEngine,registerCheck(e){$e.addPluginCheck(e)},registerOperator(e){$e.addPluginOperator(e)}},wt.forEach(e=>ue.WorkflowEngine.registerCheck(e)),Be(Al).use(Ie).mount("#workflowengine");
//# sourceMappingURL=workflowengine-workflowengine.mjs.map