@knoflows/engine 0.1.1-alpha.1 → 0.1.1-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.
Files changed (70) hide show
  1. package/dist/engine.js +31 -19
  2. package/dist/migrations/20260923070000_local_repo_default_reviewers/migration.sql +1 -0
  3. package/dist/migrations/20260923072051_hard_beast/migration.sql +2 -0
  4. package/dist/migrations/20260923072051_hard_beast/snapshot.json +1408 -0
  5. package/package.json +4 -4
  6. package/static/assets/i18n/en.json +23 -0
  7. package/static/assets/i18n/es.json +23 -0
  8. package/static/chunk-5P9quDD0.js +1 -0
  9. package/static/chunk-B1I44qNh.js +1 -0
  10. package/static/{chunk-BDDp2BQi.js → chunk-B67hwr1X.js} +1 -1
  11. package/static/{chunk-Dqjhd0t8.js → chunk-B7mctPQM.js} +1 -1
  12. package/static/{chunk-CepRGzVJ.js → chunk-BAPXVTBt.js} +1 -1
  13. package/static/chunk-BNQus_d_.js +1 -0
  14. package/static/chunk-Bh5et471.js +1 -0
  15. package/static/{chunk-96ta9Sdz.js → chunk-BidviQhN.js} +1 -1
  16. package/static/chunk-BldTY6RI.js +1 -0
  17. package/static/chunk-BmEXmF8m.js +1 -0
  18. package/static/chunk-BqhxU3er.js +1 -0
  19. package/static/{chunk-CuBg4N16.js → chunk-Bv65hEw_.js} +1 -1
  20. package/static/{chunk-wu6SvZ0s.js → chunk-C07s4-rF.js} +1 -1
  21. package/static/chunk-C5eZIOiF.js +1 -0
  22. package/static/{chunk-CtFtOXy4.js → chunk-C61nx2gP.js} +1 -1
  23. package/static/{chunk-BZBN-IEB.js → chunk-CI75Yj8J.js} +1 -1
  24. package/static/chunk-CNip9Ktj.js +1 -0
  25. package/static/chunk-CP6elnGc.js +1 -0
  26. package/static/{chunk-DKjiFhsx.js → chunk-Cf14heGp.js} +1 -1
  27. package/static/chunk-CiB-X52X.js +1 -0
  28. package/static/chunk-Cj5izLCS.js +1 -0
  29. package/static/{chunk-8INlEe9b.js → chunk-CxnyhsKe.js} +1 -1
  30. package/static/chunk-CyvupcYz.js +1 -0
  31. package/static/{chunk-DDkLmxql.js → chunk-D1sSb3lO.js} +1 -1
  32. package/static/{chunk-djGmnQaE.js → chunk-D5BPM_KC.js} +1 -1
  33. package/static/{chunk-Bayax3su.js → chunk-D9f8Ltay.js} +3 -3
  34. package/static/{chunk-BbtIjpMQ.js → chunk-DBtN2lWe.js} +3 -3
  35. package/static/chunk-DD_o_6mU.js +1 -0
  36. package/static/chunk-DRe_kA_l.js +1 -0
  37. package/static/{chunk-BJVGVLQp.js → chunk-Dt7AgNFd.js} +1 -1
  38. package/static/chunk-Dxa2JdVP.js +1 -0
  39. package/static/{chunk-DF1Zujdm.js → chunk-DyGh8J3-.js} +1 -1
  40. package/static/chunk-IZZsw-Ul.js +1 -0
  41. package/static/{chunk-BrckDrlX.js → chunk-MciiAFro.js} +1 -1
  42. package/static/{chunk-lQWDKNhr.js → chunk-RWVebRsq.js} +1 -1
  43. package/static/chunk-doY5ozP9.js +1 -0
  44. package/static/{chunk-XJrnAloK.js → chunk-g20-BKKx.js} +6 -6
  45. package/static/chunk-lPfYUUfU.js +1 -0
  46. package/static/chunk-vnmh6IU3.js +1 -0
  47. package/static/chunk-zWWkMLc1.js +1 -0
  48. package/static/index.html +1 -1
  49. package/static/{main-Q5LNROCU.js → main-GFNB573R.js} +1 -1
  50. package/static/chunk-1s-6iZs8.js +0 -1
  51. package/static/chunk-9I0-e_3z.js +0 -1
  52. package/static/chunk-B3UE2A3I.js +0 -1
  53. package/static/chunk-BgIY3xBH.js +0 -1
  54. package/static/chunk-Ce3aSFve.js +0 -1
  55. package/static/chunk-CqhV23s2.js +0 -1
  56. package/static/chunk-CsJt5dbK.js +0 -1
  57. package/static/chunk-D-L7yklF.js +0 -1
  58. package/static/chunk-DFHhTmIq.js +0 -1
  59. package/static/chunk-DP75g4hD.js +0 -1
  60. package/static/chunk-DX21GXyA.js +0 -1
  61. package/static/chunk-DaP135hJ.js +0 -1
  62. package/static/chunk-Dgi_aaUY.js +0 -1
  63. package/static/chunk-DiKEYJdn.js +0 -1
  64. package/static/chunk-Dl_fBMXY.js +0 -1
  65. package/static/chunk-DuhskOh7.js +0 -1
  66. package/static/chunk-DvI50p6W.js +0 -1
  67. package/static/chunk-Ou4ZHVyl.js +0 -1
  68. package/static/chunk-rTfgntJ9.js +0 -1
  69. package/static/chunk-wWwVqMLO.js +0 -1
  70. package/static/chunk-wqJvNV4X.js +0 -1
@@ -1,5 +1,5 @@
1
- import {T}from'./chunk-DiKEYJdn.js';import {w,L as L$1}from'./chunk-DX21GXyA.js';import {H as He$1}from'./chunk-DP75g4hD.js';import {f}from'./chunk-96ta9Sdz.js';import {C,a as C1,R as J1,b6 as U,b8 as y,b as at$1,V as Ve$1,bo as O,bp as de,ba as Se$1,q as qo,U as Uw,u as ue,s,r as r$1,c as bi,Z as ZE,d as $8,e as al,bb as er,f as rl,g as $i,v as v3,Y as pf,a0 as bd,a1 as sp,a2 as fp,h as ex,F as Fm,A as Am,K as Kt,j as _i,I as Iw,J as Jc,P as Pw,m as mh,l as _D,o as gI,L as Lh,p as Fw,w as lh,z as rl$1,M as MD,H as HD,G as FD,k as iE,x as xD,y as aE,B as AD,N as ND,n as uh,O as Fu,Q as ju,al as Sh,D as ch,aR as xw}from'./main-Q5LNROCU.js';import {b}from'./chunk-BJVGVLQp.js';import {a as ai,z}from'./chunk-wu6SvZ0s.js';import {U as Uu,x as xg,w as w_,j as j_,b as B$,X as X$}from'./chunk-XJrnAloK.js';import'./chunk-djGmnQaE.js';var Ve=()=>[],L=(t,o)=>o.id,ke=(t,o)=>o.name;function Se(t,o){t&1&&(_i(0,"p",6),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),Lh(Fw(2,1,"common.loading")));}function ze(t,o){if(t&1&&(_i(0,"p",7),Iw(1),Jc()),t&2){let e=HD();gI(),Lh(e.loadError());}}function Pe(t,o){if(t&1&&(_i(0,"li"),Iw(1),Jc()),t&2){let e=o.$implicit;gI(),Lh(e);}}function Ne(t,o){if(t&1&&(_i(0,"section",8)(1,"h2"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"ul"),xD(5,Pe,2,1,"li",null,ND),Jc()()),t&2){let e=HD(2);gI(2),Lh(Fw(3,1,"views.editor.validation")),gI(3),AD(e.validationErrors());}}function qe(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.name);}}function Re(t,o){t&1&&(_i(0,"p",14),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.noEligibleInstances")," "));}function De(t,o){t&1&&(_i(0,"p",17),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.instanceNeeded")," "));}function Ae(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.displayName);}}function Fe(t,o){if(t&1){let e=FD();_i(0,"div",16),_D(1,De,3,3,"p",17),_i(2,"span"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"nz-select",18),Pw(6,"transloco"),mh("ngModelChange",function(n){Fu(e);let s=HD(3);return ju(s.onInstanceChange(n))}),xD(7,Ae,1,2,"nz-option",12,L),Jc(),iE(),Jc();}if(t&2){let e=HD(3);Sh("field-attention",e.needsInstanceAttention()),gI(),MD(e.needsInstanceAttention()?1:-1),gI(2),Lh(Fw(4,6,"views.editor.instance")),gI(2),lh("nzPlaceHolder",Fw(6,8,"views.editor.instancePlaceholder"))("ngModel",e.providerInstanceId()),aE(),gI(2),AD(e.eligibleInstances());}}function Oe(t,o){if(t&1&&_D(0,Re,3,3,"p",14)(1,Fe,9,10,"div",15),t&2){let e=HD(2);MD(e.eligibleInstances().length===0?0:1);}}function Le(t,o){if(t&1){let e=FD();_i(0,"div",13)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"div",19)(5,"button",20),mh("click",function(){Fu(e);let n=HD(2);return ju(n.setQueryMode("template"))}),Iw(6),Pw(7,"transloco"),Jc(),_i(8,"button",21),mh("click",function(){Fu(e);let n=HD(2);return ju(n.setQueryMode("raw"))}),Iw(9),Pw(10,"transloco"),Jc()()();}if(t&2){let e=HD(2);gI(2),Lh(Fw(3,5,"views.editor.queryMode")),gI(3),lh("nzType",e.queryMode()==="template"?"primary":"default"),gI(),rl$1(" ",Fw(7,7,"views.editor.queryMode.template")," "),gI(2),lh("nzType",e.queryMode()==="raw"?"primary":"default"),gI(),rl$1(" ",Fw(10,9,"views.editor.queryMode.raw")," ");}}function Be(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.label);}}function je(t,o){if(t&1){let e=FD();_i(0,"label",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"textarea",23),mh("ngModelChange",function(n){Fu(e);let s=HD(4);return ju(s.queryText.set(n))}),Jc(),iE(),_i(5,"span",24),Iw(6),Pw(7,"transloco"),Jc()();}if(t&2){let e=HD(4);gI(2),Lh(Fw(3,3,"views.editor.query")),gI(2),lh("ngModel",e.queryText()),aE(),gI(2),Lh(Fw(7,5,"views.editor.manualListHint"));}}function $e(t,o){t&1&&(_i(0,"span",25),Iw(1,"*"),Jc());}function We(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e)("nzLabel",e);}}function Je(t,o){if(t&1){let e=FD();_i(0,"nz-select",28),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),xD(1,We,1,2,"nz-option",12,ND),Jc(),iE();}if(t&2){let e=HD().$implicit,i=HD(5);lh("ngModel",i.templateParamValue(e.name)),ch("data-testid","template-param-"+e.name),aE(),gI(),AD(e.options??xw(2,Ve));}}function Ue(t,o){if(t&1){let e=FD();_i(0,"button",33),mh("click",function(){Fu(e);let n=HD(2).$implicit,s=HD(5);return ju(s.useAllKnownRepos(n.name))}),Iw(1),Pw(2,"transloco"),Jc();}t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.useAllKnownRepos")," "));}function Ke(t,o){t&1&&(_i(0,"p",32),Iw(1),Jc()),t&2&&(gI(),Lh(o));}function Qe(t,o){if(t&1){let e=FD();_i(0,"div",29)(1,"nz-select",30),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),Jc(),iE(),_D(2,Ue,3,3,"button",31),Jc(),_D(3,Ke,2,1,"p",32);}if(t&2){let e,i=HD().$implicit,n=HD(5);gI(),lh("nzOptions",n.knownRepoSlugOptions())("ngModel",n.templateParamListValue(i.name)),ch("data-testid","template-param-"+i.name),aE(),gI(),MD(n.showUseAllKnownRepos()&&i.name==="repoSlugs"?2:-1),gI(),MD((e=n.knownReposLimitMessage())?3:-1,e);}}function He(t,o){if(t&1){let e=FD();_i(0,"input",34),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),Jc(),iE();}if(t&2){let e=HD().$implicit,i=HD(5);lh("ngModel",i.templateParamValue(e.name)),ch("data-testid","template-param-"+e.name),aE();}}function Ge(t,o){if(t&1&&(_i(0,"label",9)(1,"span"),Iw(2),_D(3,$e,2,0,"span",25),Jc(),_D(4,Je,3,3,"nz-select",26)(5,Qe,4,5)(6,He,1,2,"input",27),Jc()),t&2){let e=o.$implicit;gI(2),rl$1(" ",e.label," "),gI(),MD(e.required?3:-1),gI(),MD(e.type==="select"?4:e.type==="string[]"?5:6);}}function Ye(t,o){if(t&1&&xD(0,Ge,7,3,"label",9,ke),t&2){let e=HD();AD(e.params);}}function Ze(t,o){if(t&1&&_D(0,je,8,7,"label",9)(1,Ye,2,0),t&2){let e=HD(3);MD(e.isRawSeedTemplate()?0:1);}}function Xe(t,o){if(t&1){let e=FD();_i(0,"div",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"nz-select",22),mh("ngModelChange",function(n){Fu(e);let s=HD(2);return ju(s.selectTemplate(n))}),xD(5,Be,1,2,"nz-option",12,L),Jc(),iE(),Jc(),_D(7,Ze,2,1);}if(t&2){let e,i=HD(2);gI(2),Lh(Fw(3,3,"views.editor.template")),gI(2),lh("ngModel",i.selectedTemplateId()),aE(),gI(),AD(i.templates()),gI(2),MD((e=i.selectedTemplate())?7:-1,e);}}function et(t,o){if(t&1){let e=FD();_i(0,"label",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"textarea",23),mh("ngModelChange",function(n){Fu(e);let s=HD(2);return ju(s.queryText.set(n))}),Jc(),iE(),_i(5,"span",35),Iw(6),Pw(7,"transloco"),Jc()();}if(t&2){let e=HD(2);gI(2),Lh(Fw(3,3,"views.editor.query")),gI(2),lh("ngModel",e.queryText()),aE(),gI(2),Lh(Fw(7,5,"views.editor.queryHint"));}}function tt(t,o){if(t&1){let e=FD();_D(0,Ne,7,3,"section",8),_i(1,"label",9)(2,"span"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"input",10),mh("ngModelChange",function(n){Fu(e);let s=HD();return ju(s.name.set(n))}),Jc(),iE(),Jc(),_i(6,"div",9)(7,"span"),Iw(8),Pw(9,"transloco"),Jc(),_i(10,"nz-select",11),mh("ngModelChange",function(n){Fu(e);let s=HD();return ju(s.onWorkflowChange(n))}),xD(11,qe,1,2,"nz-option",12,L),Jc(),iE(),Jc(),_D(13,Oe,2,1),_D(14,Le,11,11,"div",13),_D(15,Xe,8,5)(16,et,8,7,"label",9);}if(t&2){let e=HD();MD(e.validationErrors().length>0?0:-1),gI(3),Lh(Fw(4,8,"views.editor.name")),gI(2),lh("ngModel",e.name()),aE(),gI(3),Lh(Fw(9,10,"views.editor.workflow")),gI(2),lh("ngModel",e.workflowId()),aE(),gI(),AD(e.bindableWorkflows()),gI(2),MD(e.selectedWorkflow()&&e.settings()?13:-1),gI(),MD(e.hasTemplates()?14:-1),gI(),MD(e.queryMode()==="template"&&e.hasTemplates()?15:16);}}function it(t){let o=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e=crypto.randomUUID().slice(0,8);return o.length>0?`${o}-${e}`:`view-${e}`}var Ie=[];function nt(t){let o={};for(let e of t.params)e.type==="select"?o[e.name]=e.options?.[0]??"":e.type==="string[]"?o[e.name]=[]:o[e.name]="";return o}function Ee(t,o){let e=r$1(r$1({},nt(t)),o);for(let i of t.params){if(i.type!=="string[]")continue;let n=e[i.name];e[i.name]=Array.isArray(n)?n.map(s=>String(s)):[];}return e}function ot(t){let o=t?.trim()??"";return o.length>0?o:null}var Dt=(()=>{class t{constructor(){this.route=C(C1),this.router=C(J1),this.viewsApi=C(U),this.nav=C(y),this.workflowsApi=C(b),this.settingsApi=C(f),this.providersApi=C(w),this.message=C(He$1),this.destroyRef=C(at$1),this.transloco=C(Ve$1),this.language=C(O),this.routeId=de(this.route.paramMap.pipe(Se$1(e=>e.get("id"))),{initialValue:this.route.snapshot.paramMap.get("id")}),this.name=qo(""),this.workflowId=qo(""),this.providerInstanceId=qo(null),this.workflows=qo([]),this.subjectType=qo(null),this.queryText=qo(`{
1
+ import {T}from'./chunk-CyvupcYz.js';import {w,L as L$1}from'./chunk-doY5ozP9.js';import {H as He$1}from'./chunk-DRe_kA_l.js';import {f}from'./chunk-BidviQhN.js';import {C,a as C1,R as J1,b6 as U,b8 as y,b as at$1,V as Ve$1,bo as O,bp as de,ba as Se$1,q as qo,U as Uw,u as ue,s,r as r$1,c as bi,Z as ZE,d as $8,e as al,bb as er,f as rl,g as $i,v as v3,a0 as pf,a1 as bd,a2 as sp,a3 as fp,h as ex,F as Fm,A as Am,K as Kt,j as _i,I as Iw,J as Jc,P as Pw,m as mh,l as _D,n as gI,L as Lh,o as Fw,p as lh,x as rl$1,M as MD,H as HD,y as FD,k as iE,z as xD,w as aE,D as AD,N as ND,B as uh,O as Fu,Q as ju,S as Sh,E as ch,aR as xw}from'./main-GFNB573R.js';import {b}from'./chunk-Dt7AgNFd.js';import {a as ai,z}from'./chunk-C07s4-rF.js';import {U as Uu,d as Ig,N as N_,E as E_,Y as Y$,f as t_}from'./chunk-g20-BKKx.js';import'./chunk-D5BPM_KC.js';var Ve=()=>[],L=(t,o)=>o.id,ke=(t,o)=>o.name;function Se(t,o){t&1&&(_i(0,"p",6),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),Lh(Fw(2,1,"common.loading")));}function ze(t,o){if(t&1&&(_i(0,"p",7),Iw(1),Jc()),t&2){let e=HD();gI(),Lh(e.loadError());}}function Pe(t,o){if(t&1&&(_i(0,"li"),Iw(1),Jc()),t&2){let e=o.$implicit;gI(),Lh(e);}}function Ne(t,o){if(t&1&&(_i(0,"section",8)(1,"h2"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"ul"),xD(5,Pe,2,1,"li",null,ND),Jc()()),t&2){let e=HD(2);gI(2),Lh(Fw(3,1,"views.editor.validation")),gI(3),AD(e.validationErrors());}}function qe(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.name);}}function Re(t,o){t&1&&(_i(0,"p",14),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.noEligibleInstances")," "));}function De(t,o){t&1&&(_i(0,"p",17),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.instanceNeeded")," "));}function Ae(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.displayName);}}function Fe(t,o){if(t&1){let e=FD();_i(0,"div",16),_D(1,De,3,3,"p",17),_i(2,"span"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"nz-select",18),Pw(6,"transloco"),mh("ngModelChange",function(n){Fu(e);let s=HD(3);return ju(s.onInstanceChange(n))}),xD(7,Ae,1,2,"nz-option",12,L),Jc(),iE(),Jc();}if(t&2){let e=HD(3);Sh("field-attention",e.needsInstanceAttention()),gI(),MD(e.needsInstanceAttention()?1:-1),gI(2),Lh(Fw(4,6,"views.editor.instance")),gI(2),lh("nzPlaceHolder",Fw(6,8,"views.editor.instancePlaceholder"))("ngModel",e.providerInstanceId()),aE(),gI(2),AD(e.eligibleInstances());}}function Oe(t,o){if(t&1&&_D(0,Re,3,3,"p",14)(1,Fe,9,10,"div",15),t&2){let e=HD(2);MD(e.eligibleInstances().length===0?0:1);}}function Le(t,o){if(t&1){let e=FD();_i(0,"div",13)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"div",19)(5,"button",20),mh("click",function(){Fu(e);let n=HD(2);return ju(n.setQueryMode("template"))}),Iw(6),Pw(7,"transloco"),Jc(),_i(8,"button",21),mh("click",function(){Fu(e);let n=HD(2);return ju(n.setQueryMode("raw"))}),Iw(9),Pw(10,"transloco"),Jc()()();}if(t&2){let e=HD(2);gI(2),Lh(Fw(3,5,"views.editor.queryMode")),gI(3),lh("nzType",e.queryMode()==="template"?"primary":"default"),gI(),rl$1(" ",Fw(7,7,"views.editor.queryMode.template")," "),gI(2),lh("nzType",e.queryMode()==="raw"?"primary":"default"),gI(),rl$1(" ",Fw(10,9,"views.editor.queryMode.raw")," ");}}function Be(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e.id)("nzLabel",e.label);}}function je(t,o){if(t&1){let e=FD();_i(0,"label",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"textarea",23),mh("ngModelChange",function(n){Fu(e);let s=HD(4);return ju(s.queryText.set(n))}),Jc(),iE(),_i(5,"span",24),Iw(6),Pw(7,"transloco"),Jc()();}if(t&2){let e=HD(4);gI(2),Lh(Fw(3,3,"views.editor.query")),gI(2),lh("ngModel",e.queryText()),aE(),gI(2),Lh(Fw(7,5,"views.editor.manualListHint"));}}function $e(t,o){t&1&&(_i(0,"span",25),Iw(1,"*"),Jc());}function We(t,o){if(t&1&&uh(0,"nz-option",12),t&2){let e=o.$implicit;lh("nzValue",e)("nzLabel",e);}}function Je(t,o){if(t&1){let e=FD();_i(0,"nz-select",28),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),xD(1,We,1,2,"nz-option",12,ND),Jc(),iE();}if(t&2){let e=HD().$implicit,i=HD(5);lh("ngModel",i.templateParamValue(e.name)),ch("data-testid","template-param-"+e.name),aE(),gI(),AD(e.options??xw(2,Ve));}}function Ue(t,o){if(t&1){let e=FD();_i(0,"button",33),mh("click",function(){Fu(e);let n=HD(2).$implicit,s=HD(5);return ju(s.useAllKnownRepos(n.name))}),Iw(1),Pw(2,"transloco"),Jc();}t&2&&(gI(),rl$1(" ",Fw(2,1,"views.editor.useAllKnownRepos")," "));}function Ke(t,o){t&1&&(_i(0,"p",32),Iw(1),Jc()),t&2&&(gI(),Lh(o));}function Qe(t,o){if(t&1){let e=FD();_i(0,"div",29)(1,"nz-select",30),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),Jc(),iE(),_D(2,Ue,3,3,"button",31),Jc(),_D(3,Ke,2,1,"p",32);}if(t&2){let e,i=HD().$implicit,n=HD(5);gI(),lh("nzOptions",n.knownRepoSlugOptions())("ngModel",n.templateParamListValue(i.name)),ch("data-testid","template-param-"+i.name),aE(),gI(),MD(n.showUseAllKnownRepos()&&i.name==="repoSlugs"?2:-1),gI(),MD((e=n.knownReposLimitMessage())?3:-1,e);}}function He(t,o){if(t&1){let e=FD();_i(0,"input",34),mh("ngModelChange",function(n){Fu(e);let s=HD().$implicit,y=HD(5);return ju(y.setTemplateParam(s.name,n))}),Jc(),iE();}if(t&2){let e=HD().$implicit,i=HD(5);lh("ngModel",i.templateParamValue(e.name)),ch("data-testid","template-param-"+e.name),aE();}}function Ge(t,o){if(t&1&&(_i(0,"label",9)(1,"span"),Iw(2),_D(3,$e,2,0,"span",25),Jc(),_D(4,Je,3,3,"nz-select",26)(5,Qe,4,5)(6,He,1,2,"input",27),Jc()),t&2){let e=o.$implicit;gI(2),rl$1(" ",e.label," "),gI(),MD(e.required?3:-1),gI(),MD(e.type==="select"?4:e.type==="string[]"?5:6);}}function Ye(t,o){if(t&1&&xD(0,Ge,7,3,"label",9,ke),t&2){let e=HD();AD(e.params);}}function Ze(t,o){if(t&1&&_D(0,je,8,7,"label",9)(1,Ye,2,0),t&2){let e=HD(3);MD(e.isRawSeedTemplate()?0:1);}}function Xe(t,o){if(t&1){let e=FD();_i(0,"div",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"nz-select",22),mh("ngModelChange",function(n){Fu(e);let s=HD(2);return ju(s.selectTemplate(n))}),xD(5,Be,1,2,"nz-option",12,L),Jc(),iE(),Jc(),_D(7,Ze,2,1);}if(t&2){let e,i=HD(2);gI(2),Lh(Fw(3,3,"views.editor.template")),gI(2),lh("ngModel",i.selectedTemplateId()),aE(),gI(),AD(i.templates()),gI(2),MD((e=i.selectedTemplate())?7:-1,e);}}function et(t,o){if(t&1){let e=FD();_i(0,"label",9)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"textarea",23),mh("ngModelChange",function(n){Fu(e);let s=HD(2);return ju(s.queryText.set(n))}),Jc(),iE(),_i(5,"span",35),Iw(6),Pw(7,"transloco"),Jc()();}if(t&2){let e=HD(2);gI(2),Lh(Fw(3,3,"views.editor.query")),gI(2),lh("ngModel",e.queryText()),aE(),gI(2),Lh(Fw(7,5,"views.editor.queryHint"));}}function tt(t,o){if(t&1){let e=FD();_D(0,Ne,7,3,"section",8),_i(1,"label",9)(2,"span"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"input",10),mh("ngModelChange",function(n){Fu(e);let s=HD();return ju(s.name.set(n))}),Jc(),iE(),Jc(),_i(6,"div",9)(7,"span"),Iw(8),Pw(9,"transloco"),Jc(),_i(10,"nz-select",11),mh("ngModelChange",function(n){Fu(e);let s=HD();return ju(s.onWorkflowChange(n))}),xD(11,qe,1,2,"nz-option",12,L),Jc(),iE(),Jc(),_D(13,Oe,2,1),_D(14,Le,11,11,"div",13),_D(15,Xe,8,5)(16,et,8,7,"label",9);}if(t&2){let e=HD();MD(e.validationErrors().length>0?0:-1),gI(3),Lh(Fw(4,8,"views.editor.name")),gI(2),lh("ngModel",e.name()),aE(),gI(3),Lh(Fw(9,10,"views.editor.workflow")),gI(2),lh("ngModel",e.workflowId()),aE(),gI(),AD(e.bindableWorkflows()),gI(2),MD(e.selectedWorkflow()&&e.settings()?13:-1),gI(),MD(e.hasTemplates()?14:-1),gI(),MD(e.queryMode()==="template"&&e.hasTemplates()?15:16);}}function it(t){let o=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e=crypto.randomUUID().slice(0,8);return o.length>0?`${o}-${e}`:`view-${e}`}var Ie=[];function nt(t){let o={};for(let e of t.params)e.type==="select"?o[e.name]=e.options?.[0]??"":e.type==="string[]"?o[e.name]=[]:o[e.name]="";return o}function Ee(t,o){let e=r$1(r$1({},nt(t)),o);for(let i of t.params){if(i.type!=="string[]")continue;let n=e[i.name];e[i.name]=Array.isArray(n)?n.map(s=>String(s)):[];}return e}function ot(t){let o=t?.trim()??"";return o.length>0?o:null}var Dt=(()=>{class t{constructor(){this.route=C(C1),this.router=C(J1),this.viewsApi=C(U),this.nav=C(y),this.workflowsApi=C(b),this.settingsApi=C(f),this.providersApi=C(w),this.message=C(He$1),this.destroyRef=C(at$1),this.transloco=C(Ve$1),this.language=C(O),this.routeId=de(this.route.paramMap.pipe(Se$1(e=>e.get("id"))),{initialValue:this.route.snapshot.paramMap.get("id")}),this.name=qo(""),this.workflowId=qo(""),this.providerInstanceId=qo(null),this.workflows=qo([]),this.subjectType=qo(null),this.queryText=qo(`{
2
2
 
3
- }`),this.queryMode=qo("template"),this.templates=qo([]),this.selectedTemplateId=qo(null),this.templateParams=qo({}),this.settings=qo(null),this.loadError=qo(null),this.validationErrors=qo([]),this.saving=qo(false),this.loading=qo(true),this.bindableWorkflows=Uw(()=>this.workflows().filter(e=>e.appliesTo!=="none")),this.selectedWorkflow=Uw(()=>this.bindableWorkflows().find(e=>e.id===this.workflowId())??null),this.subjectTypeOptions=Uw(()=>Uu(this.selectedWorkflow()?.appliesTo??"none")),this.eligibleInstances=Uw(()=>L$1(this.settings(),this.subjectTypeOptions())),this.selectedInstance=Uw(()=>this.eligibleInstances().find(e=>e.id===this.providerInstanceId())??null),this.needsInstanceAttention=Uw(()=>this.selectedWorkflow()!=null&&this.settings()!=null&&this.eligibleInstances().length>0&&this.selectedInstance()==null),this.isNew=Uw(()=>!this.routeId()),this.pageTitle=Uw(()=>(this.language.currentLang(),this.isNew()?this.transloco.translate("views.editor.titleNew"):this.transloco.translate("views.editor.titleEdit",{name:this.name().trim()}))),this.selectedTemplate=Uw(()=>this.templates().find(e=>e.id===this.selectedTemplateId())??null),this.hasTemplates=Uw(()=>this.templates().length>0),this.isRawSeedTemplate=Uw(()=>this.selectedTemplateId()==="manual-list"),this.knownRepoSlugs=Uw(()=>{let e=this.selectedInstance();return !e||e.type!=="bitbucket"?Ie:xg(e.config)}),this.showUseAllKnownRepos=Uw(()=>this.knownRepoSlugs().length>0),this.knownRepoSlugOptions=Uw(()=>this.knownRepoSlugs().map(e=>({label:e,value:e}))),this.knownReposLimitMessage=qo(null),this.workflowsApi.list().pipe(ue(this.destroyRef)).subscribe({next:e=>this.workflows.set(e),error:e=>{this.workflows.set([]),this.message.error(this.errorMessage(e,this.transloco.translate("views.editor.loadFailed")));}}),this.settingsApi.getSettings().pipe(ue(this.destroyRef)).subscribe({next:e=>{this.settings.set(e),this.refreshTemplates();},error:e=>{this.settings.set(w_),this.refreshTemplates(),this.message.error(this.errorMessage(e,this.transloco.translate("views.editor.loadFailed")));}}),this.route.paramMap.pipe(ue(this.destroyRef)).subscribe(e=>{let i=e.get("id");if(this.validationErrors.set([]),this.loadError.set(null),this.pendingProvenance=void 0,!i){this.name.set(""),this.workflowId.set(""),this.providerInstanceId.set(null),this.subjectType.set(null),this.queryText.set(`{
3
+ }`),this.queryMode=qo("template"),this.templates=qo([]),this.selectedTemplateId=qo(null),this.templateParams=qo({}),this.settings=qo(null),this.loadError=qo(null),this.validationErrors=qo([]),this.saving=qo(false),this.loading=qo(true),this.bindableWorkflows=Uw(()=>this.workflows().filter(e=>e.appliesTo!=="none")),this.selectedWorkflow=Uw(()=>this.bindableWorkflows().find(e=>e.id===this.workflowId())??null),this.subjectTypeOptions=Uw(()=>Uu(this.selectedWorkflow()?.appliesTo??"none")),this.eligibleInstances=Uw(()=>L$1(this.settings(),this.subjectTypeOptions())),this.selectedInstance=Uw(()=>this.eligibleInstances().find(e=>e.id===this.providerInstanceId())??null),this.needsInstanceAttention=Uw(()=>this.selectedWorkflow()!=null&&this.settings()!=null&&this.eligibleInstances().length>0&&this.selectedInstance()==null),this.isNew=Uw(()=>!this.routeId()),this.pageTitle=Uw(()=>(this.language.currentLang(),this.isNew()?this.transloco.translate("views.editor.titleNew"):this.transloco.translate("views.editor.titleEdit",{name:this.name().trim()}))),this.selectedTemplate=Uw(()=>this.templates().find(e=>e.id===this.selectedTemplateId())??null),this.hasTemplates=Uw(()=>this.templates().length>0),this.isRawSeedTemplate=Uw(()=>this.selectedTemplateId()==="manual-list"),this.knownRepoSlugs=Uw(()=>{let e=this.selectedInstance();return !e||e.type!=="bitbucket"?Ie:Ig(e.config)}),this.showUseAllKnownRepos=Uw(()=>this.knownRepoSlugs().length>0),this.knownRepoSlugOptions=Uw(()=>this.knownRepoSlugs().map(e=>({label:e,value:e}))),this.knownReposLimitMessage=qo(null),this.workflowsApi.list().pipe(ue(this.destroyRef)).subscribe({next:e=>this.workflows.set(e),error:e=>{this.workflows.set([]),this.message.error(this.errorMessage(e,this.transloco.translate("views.editor.loadFailed")));}}),this.settingsApi.getSettings().pipe(ue(this.destroyRef)).subscribe({next:e=>{this.settings.set(e),this.refreshTemplates();},error:e=>{this.settings.set(N_),this.refreshTemplates(),this.message.error(this.errorMessage(e,this.transloco.translate("views.editor.loadFailed")));}}),this.route.paramMap.pipe(ue(this.destroyRef)).subscribe(e=>{let i=e.get("id");if(this.validationErrors.set([]),this.loadError.set(null),this.pendingProvenance=void 0,!i){this.name.set(""),this.workflowId.set(""),this.providerInstanceId.set(null),this.subjectType.set(null),this.queryText.set(`{
4
4
 
5
- }`),this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.loading.set(false),this.refreshTemplates();return}this.loading.set(true),this.viewsApi.get(i).subscribe({next:n=>{this.name.set(n.name),this.workflowId.set(n.workflowId),this.providerInstanceId.set(ot(n.providerInstanceId)),this.subjectType.set(n.subjectType),this.queryText.set(JSON.stringify(n.query,null,2)),this.pendingProvenance=n.queryTemplate,this.queryMode.set(n.queryTemplate?"template":"raw"),this.loading.set(false),this.refreshTemplates();},error:n=>{this.loading.set(false),this.loadError.set(this.errorMessage(n,this.transloco.translate("views.editor.loadFailed")));}});});}subjectTypeKey(e){return `workflow-editor.subjectType.${e}`}onWorkflowChange(e){this.workflowId.set(e);let i=Uu(this.bindableWorkflows().find(s=>s.id===e)?.appliesTo??"none");this.pendingProvenance=void 0,this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.knownReposLimitMessage.set(null);let n=L$1(this.settings(),i);if(n.length===1)this.applyInstance(n[0]);else {let s=this.providerInstanceId(),y=n.find(P=>P.id===s);y?this.applyInstance(y):(this.providerInstanceId.set(null),this.subjectType.set(null));}this.refreshTemplates();}onInstanceChange(e){let i=this.eligibleInstances().find(n=>n.id===e);this.pendingProvenance=void 0,this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.knownReposLimitMessage.set(null),i&&this.applyInstance(i),this.refreshTemplates();}applyInstance(e){this.providerInstanceId.set(e.id),j_(e)&&this.subjectType.set(e.subjectType);}setQueryMode(e){this.queryMode.set(e),e==="template"&&!this.selectedTemplateId()&&this.templates()[0]&&this.selectTemplate(this.templates()[0].id);}selectTemplate(e){let i=this.templates().find(n=>n.id===e);this.selectedTemplateId.set(e),this.templateParams.set(i?Ee(i,{}):{}),this.knownReposLimitMessage.set(null),e==="manual-list"&&this.resolveRawSeedTemplate();}templateParamValue(e){let i=this.templateParams()[e];return i==null?"":String(i)}templateParamListValue(e){let i=this.templateParams()[e];return Array.isArray(i)?i:Ie}setTemplateParam(e,i){this.templateParams.set(s(r$1({},this.templateParams()),{[e]:i}));}useAllKnownRepos(e){let i=this.knownRepoSlugs();if(i.length>B$){this.knownReposLimitMessage.set(this.transloco.translate("views.editor.knownReposOverLimit",{count:i.length,limit:B$}));return}this.knownReposLimitMessage.set(null),this.setTemplateParam(e,[...i]);}save(){if(!this.selectedInstance()){this.validationErrors.set([this.transloco.translate("views.editor.pickInstance")]);return}if(this.queryMode()==="template"&&this.hasTemplates()){this.saveFromTemplate();return}this.saveFromRawJson();}saveFromTemplate(){let e=this.selectedTemplate(),i=this.providerInstanceId();if(!e||!i){this.validationErrors.set([this.transloco.translate("views.editor.pickTemplate")]);return}let n=e.params.filter(s=>s.required?at(this.templateParams()[s.name]):false);if(n.length>0){this.validationErrors.set(n.map(s=>this.transloco.translate("views.editor.missingParam",{label:s.label})));return}if(e.id==="manual-list"){this.saveFromRawJson({templateId:e.id,params:this.templateParams()});return}this.validationErrors.set([]),this.saving.set(true),this.providersApi.resolveQueryTemplate(i,e.id,this.templateParams()).subscribe({next:s=>{this.persist({query:s.query,queryTemplate:{templateId:e.id,params:this.templateParams()}});},error:s=>{this.saving.set(false),this.message.error(this.errorMessage(s,this.transloco.translate("views.editor.resolveFailed")));}});}saveFromRawJson(e){let i;try{i=JSON.parse(this.queryText());}catch(n){this.validationErrors.set([this.transloco.translate("views.editor.invalidJson")]);return}if(i===null||typeof i!="object"||Array.isArray(i)){this.validationErrors.set([this.transloco.translate("views.editor.invalidJson")]);return}this.persist({query:i,queryTemplate:e});}persist(e){let i=this.routeId(),n=this.subjectType(),s=r$1({id:i??it(this.name()),name:this.name().trim(),subjectType:n??"",providerInstanceId:this.providerInstanceId()??"",workflowId:this.workflowId(),query:e.query},e.queryTemplate?{queryTemplate:e.queryTemplate}:{}),y=X$.safeParse(s);if(!y.success){this.saving.set(false),this.validationErrors.set(T(y.error));return}this.validationErrors.set([]),this.saving.set(true);let P=y.data;(this.isNew()||!i?this.viewsApi.create(P):this.viewsApi.update(i,P)).subscribe({next:R=>{this.saving.set(false),this.nav.refresh(),this.message.success(this.transloco.translate(this.isNew()?"views.editor.created":"views.editor.saved")),this.isNew()&&this.router.navigate(["/views",R.id,"edit"]);},error:R=>{this.saving.set(false),this.message.error(this.errorMessage(R,this.transloco.translate("views.editor.saveFailed")));}});}refreshTemplates(){let e=this.providerInstanceId();if(!e){this.templates.set([]),this.applyLoadedTemplates([]);return}this.providersApi.listQueryTemplates(e).subscribe({next:i=>{this.templates.set(i),this.applyLoadedTemplates(i);},error:()=>{this.templates.set([]),this.applyLoadedTemplates([]);}});}resolveRawSeedTemplate(){let e=this.providerInstanceId();e&&this.providersApi.resolveQueryTemplate(e,"manual-list",{}).subscribe({next:i=>{this.selectedTemplateId()==="manual-list"&&this.queryText.set(JSON.stringify(i.query,null,2));},error:i=>{this.message.error(this.errorMessage(i,this.transloco.translate("views.editor.resolveFailed")));}});}applyLoadedTemplates(e){let i=this.pendingProvenance;if(i){let n=e.find(s=>s.id===i.templateId);n?(this.queryMode.set("template"),this.selectedTemplateId.set(n.id),this.templateParams.set(Ee(n,i.params))):(this.queryMode.set("raw"),this.selectedTemplateId.set(null)),this.pendingProvenance=void 0;return}if(this.queryMode()!=="raw"){if(e.length===0){this.queryMode.set("raw"),this.selectedTemplateId.set(null),this.templateParams.set({});return}e.some(n=>n.id===this.selectedTemplateId())||this.selectTemplate(e[0].id);}}errorMessage(e,i){return e instanceof bi||e instanceof Error?e.message:i}static{this.\u0275fac=function(i){return new(i||t)};}static{this.\u0275cmp=ZE({type:t,selectors:[["app-view-editor"]],decls:15,vars:10,consts:[["data-testid","view-editor",1,"editor"],[1,"header"],["data-testid","page-title"],[1,"header-actions"],["routerLink","/views"],["nz-button","","nzType","primary","type","button","data-testid","save-button",3,"click","nzLoading","disabled"],["data-testid","loading"],["data-testid","load-error",1,"error"],["data-testid","validation-errors",1,"errors"],[1,"field"],["nz-input","","data-testid","view-name",3,"ngModelChange","ngModel"],["data-testid","view-workflow",3,"ngModelChange","ngModel"],[3,"nzValue","nzLabel"],["data-testid","query-mode-toggle",1,"field"],["data-testid","view-instance-empty",1,"error"],["data-testid","view-instance-field",1,"field",3,"field-attention"],["data-testid","view-instance-field",1,"field"],["data-testid","view-instance-needed",1,"attention"],["data-testid","view-instance",3,"ngModelChange","nzPlaceHolder","ngModel"],[1,"mode-toggle"],["nz-button","","type","button","data-testid","query-mode-template",3,"click","nzType"],["nz-button","","type","button","data-testid","query-mode-raw",3,"click","nzType"],["data-testid","view-template",3,"ngModelChange","ngModel"],["nz-input","","rows","8","data-testid","view-query",3,"ngModelChange","ngModel"],["data-testid","manual-list-hint",1,"hint"],[1,"required"],[3,"ngModel"],["nz-input","",3,"ngModel"],[3,"ngModelChange","ngModel"],[1,"param-with-action"],["nzMode","tags",3,"ngModelChange","nzOptions","ngModel"],["nz-button","","type","button","data-testid","use-all-known-repos"],["data-testid","known-repos-limit",1,"error"],["nz-button","","type","button","data-testid","use-all-known-repos",3,"click"],["nz-input","",3,"ngModelChange","ngModel"],[1,"hint"]],template:function(i,n){i&1&&(_i(0,"main",0)(1,"header",1)(2,"div")(3,"h1",2),Iw(4),Jc()(),_i(5,"div",3)(6,"a",4),Iw(7),Pw(8,"transloco"),Jc(),_i(9,"button",5),mh("click",function(){return n.save()}),Iw(10),Pw(11,"transloco"),Jc()()(),_D(12,Se,3,3,"p",6)(13,ze,2,1,"p",7)(14,tt,17,12),Jc()),i&2&&(gI(4),Lh(n.pageTitle()),gI(3),Lh(Fw(8,6,"views.editor.backToList")),gI(2),lh("nzLoading",n.saving())("disabled",n.loading()||!!n.loadError()),gI(),rl$1(" ",Fw(11,8,"common.save")," "),gI(2),MD(n.loading()?12:n.loadError()?13:14));},dependencies:[$8,al,er,rl,$i,v3,pf,bd,sp,fp,ai,z,ex,Fm,Am,Kt],styles:[".editor[_ngcontent-%COMP%]{padding:1.25rem 1.5rem 3rem;display:flex;flex-direction:column;gap:1rem}.header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center}.field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem;margin:.5rem 0}.field[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.85rem;color:#57534e}.hint[_ngcontent-%COMP%]{font-size:.8rem;color:#78716c}.field-attention[_ngcontent-%COMP%]{border:1px solid #f59e0b;background:#fffbeb;padding:.75rem 1rem;border-radius:.35rem}.attention[_ngcontent-%COMP%]{margin:0;color:#b45309;font-size:.85rem}.mode-toggle[_ngcontent-%COMP%]{display:flex;gap:.5rem}.param-with-action[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.param-with-action[_ngcontent-%COMP%] nz-select[_ngcontent-%COMP%]{flex:1;min-width:0}.required[_ngcontent-%COMP%]{color:#9f1239}.errors[_ngcontent-%COMP%]{border:1px solid #fecdd3;background:#fff1f2;padding:.75rem 1rem}.errors[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0 0 .35rem;font-size:1rem}.error[_ngcontent-%COMP%]{color:#9f1239}textarea[_ngcontent-%COMP%]{font-family:ui-monospace,Consolas,monospace}"]});}}return t})();function at(t){return t==null?true:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.every(o=>String(o).trim()===""):false}export{Dt as ViewEditorComponent};
5
+ }`),this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.loading.set(false),this.refreshTemplates();return}this.loading.set(true),this.viewsApi.get(i).subscribe({next:n=>{this.name.set(n.name),this.workflowId.set(n.workflowId),this.providerInstanceId.set(ot(n.providerInstanceId)),this.subjectType.set(n.subjectType),this.queryText.set(JSON.stringify(n.query,null,2)),this.pendingProvenance=n.queryTemplate,this.queryMode.set(n.queryTemplate?"template":"raw"),this.loading.set(false),this.refreshTemplates();},error:n=>{this.loading.set(false),this.loadError.set(this.errorMessage(n,this.transloco.translate("views.editor.loadFailed")));}});});}subjectTypeKey(e){return `workflow-editor.subjectType.${e}`}onWorkflowChange(e){this.workflowId.set(e);let i=Uu(this.bindableWorkflows().find(s=>s.id===e)?.appliesTo??"none");this.pendingProvenance=void 0,this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.knownReposLimitMessage.set(null);let n=L$1(this.settings(),i);if(n.length===1)this.applyInstance(n[0]);else {let s=this.providerInstanceId(),y=n.find(P=>P.id===s);y?this.applyInstance(y):(this.providerInstanceId.set(null),this.subjectType.set(null));}this.refreshTemplates();}onInstanceChange(e){let i=this.eligibleInstances().find(n=>n.id===e);this.pendingProvenance=void 0,this.queryMode.set("template"),this.selectedTemplateId.set(null),this.templateParams.set({}),this.knownReposLimitMessage.set(null),i&&this.applyInstance(i),this.refreshTemplates();}applyInstance(e){this.providerInstanceId.set(e.id),E_(e)&&this.subjectType.set(e.subjectType);}setQueryMode(e){this.queryMode.set(e),e==="template"&&!this.selectedTemplateId()&&this.templates()[0]&&this.selectTemplate(this.templates()[0].id);}selectTemplate(e){let i=this.templates().find(n=>n.id===e);this.selectedTemplateId.set(e),this.templateParams.set(i?Ee(i,{}):{}),this.knownReposLimitMessage.set(null),e==="manual-list"&&this.resolveRawSeedTemplate();}templateParamValue(e){let i=this.templateParams()[e];return i==null?"":String(i)}templateParamListValue(e){let i=this.templateParams()[e];return Array.isArray(i)?i:Ie}setTemplateParam(e,i){this.templateParams.set(s(r$1({},this.templateParams()),{[e]:i}));}useAllKnownRepos(e){let i=this.knownRepoSlugs();if(i.length>Y$){this.knownReposLimitMessage.set(this.transloco.translate("views.editor.knownReposOverLimit",{count:i.length,limit:Y$}));return}this.knownReposLimitMessage.set(null),this.setTemplateParam(e,[...i]);}save(){if(!this.selectedInstance()){this.validationErrors.set([this.transloco.translate("views.editor.pickInstance")]);return}if(this.queryMode()==="template"&&this.hasTemplates()){this.saveFromTemplate();return}this.saveFromRawJson();}saveFromTemplate(){let e=this.selectedTemplate(),i=this.providerInstanceId();if(!e||!i){this.validationErrors.set([this.transloco.translate("views.editor.pickTemplate")]);return}let n=e.params.filter(s=>s.required?at(this.templateParams()[s.name]):false);if(n.length>0){this.validationErrors.set(n.map(s=>this.transloco.translate("views.editor.missingParam",{label:s.label})));return}if(e.id==="manual-list"){this.saveFromRawJson({templateId:e.id,params:this.templateParams()});return}this.validationErrors.set([]),this.saving.set(true),this.providersApi.resolveQueryTemplate(i,e.id,this.templateParams()).subscribe({next:s=>{this.persist({query:s.query,queryTemplate:{templateId:e.id,params:this.templateParams()}});},error:s=>{this.saving.set(false),this.message.error(this.errorMessage(s,this.transloco.translate("views.editor.resolveFailed")));}});}saveFromRawJson(e){let i;try{i=JSON.parse(this.queryText());}catch(n){this.validationErrors.set([this.transloco.translate("views.editor.invalidJson")]);return}if(i===null||typeof i!="object"||Array.isArray(i)){this.validationErrors.set([this.transloco.translate("views.editor.invalidJson")]);return}this.persist({query:i,queryTemplate:e});}persist(e){let i=this.routeId(),n=this.subjectType(),s=r$1({id:i??it(this.name()),name:this.name().trim(),subjectType:n??"",providerInstanceId:this.providerInstanceId()??"",workflowId:this.workflowId(),query:e.query},e.queryTemplate?{queryTemplate:e.queryTemplate}:{}),y=t_.safeParse(s);if(!y.success){this.saving.set(false),this.validationErrors.set(T(y.error));return}this.validationErrors.set([]),this.saving.set(true);let P=y.data;(this.isNew()||!i?this.viewsApi.create(P):this.viewsApi.update(i,P)).subscribe({next:R=>{this.saving.set(false),this.nav.refresh(),this.message.success(this.transloco.translate(this.isNew()?"views.editor.created":"views.editor.saved")),this.isNew()&&this.router.navigate(["/views",R.id,"edit"]);},error:R=>{this.saving.set(false),this.message.error(this.errorMessage(R,this.transloco.translate("views.editor.saveFailed")));}});}refreshTemplates(){let e=this.providerInstanceId();if(!e){this.templates.set([]),this.applyLoadedTemplates([]);return}this.providersApi.listQueryTemplates(e).subscribe({next:i=>{this.templates.set(i),this.applyLoadedTemplates(i);},error:()=>{this.templates.set([]),this.applyLoadedTemplates([]);}});}resolveRawSeedTemplate(){let e=this.providerInstanceId();e&&this.providersApi.resolveQueryTemplate(e,"manual-list",{}).subscribe({next:i=>{this.selectedTemplateId()==="manual-list"&&this.queryText.set(JSON.stringify(i.query,null,2));},error:i=>{this.message.error(this.errorMessage(i,this.transloco.translate("views.editor.resolveFailed")));}});}applyLoadedTemplates(e){let i=this.pendingProvenance;if(i){let n=e.find(s=>s.id===i.templateId);n?(this.queryMode.set("template"),this.selectedTemplateId.set(n.id),this.templateParams.set(Ee(n,i.params))):(this.queryMode.set("raw"),this.selectedTemplateId.set(null)),this.pendingProvenance=void 0;return}if(this.queryMode()!=="raw"){if(e.length===0){this.queryMode.set("raw"),this.selectedTemplateId.set(null),this.templateParams.set({});return}e.some(n=>n.id===this.selectedTemplateId())||this.selectTemplate(e[0].id);}}errorMessage(e,i){return e instanceof bi||e instanceof Error?e.message:i}static{this.\u0275fac=function(i){return new(i||t)};}static{this.\u0275cmp=ZE({type:t,selectors:[["app-view-editor"]],decls:15,vars:10,consts:[["data-testid","view-editor",1,"editor"],[1,"header"],["data-testid","page-title"],[1,"header-actions"],["routerLink","/views"],["nz-button","","nzType","primary","type","button","data-testid","save-button",3,"click","nzLoading","disabled"],["data-testid","loading"],["data-testid","load-error",1,"error"],["data-testid","validation-errors",1,"errors"],[1,"field"],["nz-input","","data-testid","view-name",3,"ngModelChange","ngModel"],["data-testid","view-workflow",3,"ngModelChange","ngModel"],[3,"nzValue","nzLabel"],["data-testid","query-mode-toggle",1,"field"],["data-testid","view-instance-empty",1,"error"],["data-testid","view-instance-field",1,"field",3,"field-attention"],["data-testid","view-instance-field",1,"field"],["data-testid","view-instance-needed",1,"attention"],["data-testid","view-instance",3,"ngModelChange","nzPlaceHolder","ngModel"],[1,"mode-toggle"],["nz-button","","type","button","data-testid","query-mode-template",3,"click","nzType"],["nz-button","","type","button","data-testid","query-mode-raw",3,"click","nzType"],["data-testid","view-template",3,"ngModelChange","ngModel"],["nz-input","","rows","8","data-testid","view-query",3,"ngModelChange","ngModel"],["data-testid","manual-list-hint",1,"hint"],[1,"required"],[3,"ngModel"],["nz-input","",3,"ngModel"],[3,"ngModelChange","ngModel"],[1,"param-with-action"],["nzMode","tags",3,"ngModelChange","nzOptions","ngModel"],["nz-button","","type","button","data-testid","use-all-known-repos"],["data-testid","known-repos-limit",1,"error"],["nz-button","","type","button","data-testid","use-all-known-repos",3,"click"],["nz-input","",3,"ngModelChange","ngModel"],[1,"hint"]],template:function(i,n){i&1&&(_i(0,"main",0)(1,"header",1)(2,"div")(3,"h1",2),Iw(4),Jc()(),_i(5,"div",3)(6,"a",4),Iw(7),Pw(8,"transloco"),Jc(),_i(9,"button",5),mh("click",function(){return n.save()}),Iw(10),Pw(11,"transloco"),Jc()()(),_D(12,Se,3,3,"p",6)(13,ze,2,1,"p",7)(14,tt,17,12),Jc()),i&2&&(gI(4),Lh(n.pageTitle()),gI(3),Lh(Fw(8,6,"views.editor.backToList")),gI(2),lh("nzLoading",n.saving())("disabled",n.loading()||!!n.loadError()),gI(),rl$1(" ",Fw(11,8,"common.save")," "),gI(2),MD(n.loading()?12:n.loadError()?13:14));},dependencies:[$8,al,er,rl,$i,v3,pf,bd,sp,fp,ai,z,ex,Fm,Am,Kt],styles:[".editor[_ngcontent-%COMP%]{padding:1.25rem 1.5rem 3rem;display:flex;flex-direction:column;gap:1rem}.header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center}.field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem;margin:.5rem 0}.field[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.85rem;color:#57534e}.hint[_ngcontent-%COMP%]{font-size:.8rem;color:#78716c}.field-attention[_ngcontent-%COMP%]{border:1px solid #f59e0b;background:#fffbeb;padding:.75rem 1rem;border-radius:.35rem}.attention[_ngcontent-%COMP%]{margin:0;color:#b45309;font-size:.85rem}.mode-toggle[_ngcontent-%COMP%]{display:flex;gap:.5rem}.param-with-action[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.param-with-action[_ngcontent-%COMP%] nz-select[_ngcontent-%COMP%]{flex:1;min-width:0}.required[_ngcontent-%COMP%]{color:#9f1239}.errors[_ngcontent-%COMP%]{border:1px solid #fecdd3;background:#fff1f2;padding:.75rem 1rem}.errors[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0 0 .35rem;font-size:1rem}.error[_ngcontent-%COMP%]{color:#9f1239}textarea[_ngcontent-%COMP%]{font-family:ui-monospace,Consolas,monospace}"]});}}return t})();function at(t){return t==null?true:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.every(o=>String(o).trim()===""):false}export{Dt as ViewEditorComponent};
@@ -0,0 +1 @@
1
+ import {_ as _n,C as Cn}from'./chunk-MciiAFro.js';import {C,b6 as U,b7 as m,b8 as y,V as Ve,b as at,q as qo,u as ue,aW as Ng,c as bi,Z as ZE,d as $8,v as v3,a0 as pf,a1 as bd,a2 as sp,K as Kt,j as _i,I as Iw,P as Pw,J as Jc,l as _D,n as gI,L as Lh,o as Fw,x as rl,M as MD,H as HD,z as xD,p as lh,D as AD,y as FD,m as mh,E as ch,O as Fu,Q as ju}from'./main-GFNB573R.js';import {b}from'./chunk-Dt7AgNFd.js';import {W,I}from'./chunk-zWWkMLc1.js';import {p as pc,a as as,d as dc,K as Kl,c as cc,J as Ji,l as ls}from'./chunk-DyGh8J3-.js';import'./chunk-D5BPM_KC.js';function ee(t,p){return [...t.map(i=>({type:"view",id:i.id,name:i.name,workflowId:i.workflowId,subjectType:i.subjectType})),...p.map(i=>({type:"shortcut",id:i.id,name:i.name,workflowId:i.workflowId,subjectType:null}))].sort((i,c)=>i.name.localeCompare(c.name))}var te=(t,p)=>p.type+p.id;function ie(t,p){t&1&&(_i(0,"p",5),Iw(1),Pw(2,"transloco"),Jc()),t&2&&(gI(),Lh(Fw(2,1,"common.loading")));}function ne(t,p){if(t&1&&(_i(0,"p",6),Iw(1),Jc()),t&2){let e=HD();gI(),Lh(e.loadError());}}function oe(t,p){if(t&1&&(_i(0,"p",7),Iw(1),Jc()),t&2){let e=HD(2);gI(),Lh(e.deleteError());}}function ae(t,p){t&1&&(_i(0,"section",8)(1,"p"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"div",2)(5,"a",10),Iw(6),Pw(7,"transloco"),Jc(),_i(8,"a",11),Iw(9),Pw(10,"transloco"),Jc()()()),t&2&&(gI(2),Lh(Fw(3,3,"manage.views.emptyState")),gI(4),rl(" ",Fw(7,5,"manage.views.createView")," "),gI(3),rl(" ",Fw(10,7,"manage.views.createShortcut")," "));}function re(t,p){if(t&1&&(Iw(0),Pw(1,"transloco")),t&2){let e=HD().$implicit,i=HD(3);rl(" ",Fw(1,1,i.subjectTypeKey(e.subjectType))," ");}}function se(t,p){t&1&&(Iw(0),Pw(1,"transloco")),t&2&&rl(" ",Fw(1,1,"manage.views.noSubjectType")," ");}function de(t,p){if(t&1){let e=FD();_i(0,"tr")(1,"td"),Iw(2),Jc(),_i(3,"td")(4,"nz-tag"),Iw(5),Pw(6,"transloco"),Jc()(),_i(7,"td"),Iw(8),Jc(),_i(9,"td"),_D(10,re,2,3)(11,se,2,3),Jc(),_i(12,"td",12)(13,"a",13),Iw(14),Pw(15,"transloco"),Jc(),_i(16,"button",14),Pw(17,"transloco"),Pw(18,"transloco"),Pw(19,"transloco"),mh("nzOnConfirm",function(){let c=Fu(e).$implicit,v=HD(3);return ju(v.deleteItem(c))}),Iw(20),Pw(21,"transloco"),Jc()()();}if(t&2){let e=p.$implicit,i=HD(3);ch("data-testid","item-"+e.type+"-"+e.id),gI(),ch("data-testid","name-"+e.type+"-"+e.id),gI(),Lh(e.name),gI(2),ch("data-testid","type-"+e.type+"-"+e.id),gI(),Lh(Fw(6,17,i.typeKey(e.type))),gI(2),ch("data-testid","workflow-"+e.type+"-"+e.id),gI(),rl(" ",i.workflowName(e)," "),gI(),ch("data-testid","subject-type-"+e.type+"-"+e.id),gI(),MD(e.subjectType?10:11),gI(3),lh("routerLink",i.editLink(e)),ch("data-testid","edit-"+e.type+"-"+e.id),gI(),rl(" ",Fw(15,19,"manage.views.edit")," "),gI(2),lh("nzPopconfirmTitle",Fw(17,21,i.deleteConfirmKey(e)))("nzOkText",Fw(18,23,"manage.views.delete"))("nzCancelText",Fw(19,25,"common.cancel")),ch("data-testid","delete-"+e.type+"-"+e.id),gI(4),rl(" ",Fw(21,27,"manage.views.delete")," ");}}function pe(t,p){if(t&1&&(_i(0,"nz-table",9)(1,"thead")(2,"tr")(3,"th"),Iw(4),Pw(5,"transloco"),Jc(),_i(6,"th"),Iw(7),Pw(8,"transloco"),Jc(),_i(9,"th"),Iw(10),Pw(11,"transloco"),Jc(),_i(12,"th"),Iw(13),Pw(14,"transloco"),Jc(),_i(15,"th"),Iw(16),Pw(17,"transloco"),Jc()()(),_i(18,"tbody"),xD(19,de,22,29,"tr",null,te),Jc()()),t&2){let e=HD(2);lh("nzData",e.items())("nzFrontPagination",false)("nzShowPagination",false),gI(4),Lh(Fw(5,8,"manage.views.column.name")),gI(3),Lh(Fw(8,10,"manage.views.column.type")),gI(3),Lh(Fw(11,12,"manage.views.column.workflow")),gI(3),Lh(Fw(14,14,"manage.views.column.subjectType")),gI(3),Lh(Fw(17,16,"manage.views.column.actions")),gI(3),AD(e.items());}}function le(t,p){if(t&1&&(_D(0,oe,2,1,"p",7),_D(1,ae,11,9,"section",8)(2,pe,21,18,"nz-table",9)),t&2){let e=HD();MD(e.deleteError()?0:-1),gI(),MD(e.items().length===0?1:2);}}var Pe=(()=>{class t{constructor(){this.viewsApi=C(U),this.shortcutsApi=C(m),this.nav=C(y),this.workflowsApi=C(b),this.transloco=C(Ve),this.destroyRef=C(at),this.items=qo([]),this.workflows=qo([]),this.loading=qo(true),this.loadError=qo(null),this.deleteError=qo(null),this.load();}typeKey(e){return `manage.views.type.${e}`}subjectTypeKey(e){return `workflow-editor.subjectType.${e}`}workflowName(e){return this.workflows().find(i=>i.id===e.workflowId)?.name??e.workflowId}editLink(e){return e.type==="view"?["/views",e.id,"edit"]:["/shortcuts",e.id,"edit"]}deleteConfirmKey(e){return e.type==="view"?"manage.views.deleteConfirmView":"manage.views.deleteConfirmShortcut"}deleteItem(e){this.deleteError.set(null),(e.type==="view"?this.viewsApi.delete(e.id):this.shortcutsApi.delete(e.id)).pipe(ue(this.destroyRef)).subscribe({next:()=>{this.nav.refresh(),this.items.update(c=>c.filter(v=>!(v.type===e.type&&v.id===e.id)));},error:c=>{this.deleteError.set(this.errorMessage(c,this.transloco.translate("manage.views.deleteFailed")));}});}load(){this.loading.set(true),this.loadError.set(null),Ng({views:this.viewsApi.list(),shortcuts:this.shortcutsApi.list(),workflows:this.workflowsApi.list()}).pipe(ue(this.destroyRef)).subscribe({next:({views:e,shortcuts:i,workflows:c})=>{this.items.set(ee(e,i)),this.workflows.set(c),this.loading.set(false);},error:e=>{this.loading.set(false),this.loadError.set(this.errorMessage(e,this.transloco.translate("manage.views.loadFailed")));}});}errorMessage(e,i){return e instanceof bi||e instanceof Error?e.message:i}static{this.\u0275fac=function(i){return new(i||t)};}static{this.\u0275cmp=ZE({type:t,selectors:[["app-views-and-shortcuts-manage"]],decls:15,vars:10,consts:[["data-testid","views-shortcuts-manage",1,"list-page"],[1,"header"],[1,"header-actions"],["nz-button","","nzType","primary","routerLink","/views/new","data-testid","create-view"],["nz-button","","routerLink","/shortcuts/new","data-testid","create-shortcut"],["data-testid","loading"],["data-testid","load-error",1,"error"],["data-testid","delete-error",1,"error"],["data-testid","empty-state",1,"empty"],["data-testid","managed-items",3,"nzData","nzFrontPagination","nzShowPagination"],["nz-button","","nzType","primary","routerLink","/views/new","data-testid","empty-create-view"],["nz-button","","routerLink","/shortcuts/new","data-testid","empty-create-shortcut"],[1,"actions"],["nz-button","","nzType","link",3,"routerLink"],["nz-button","","nzType","link","nzDanger","","type","button","nz-popconfirm","",3,"nzOnConfirm","nzPopconfirmTitle","nzOkText","nzCancelText"]],template:function(i,c){i&1&&(_i(0,"main",0)(1,"header",1)(2,"h1"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"div",2)(6,"a",3),Iw(7),Pw(8,"transloco"),Jc(),_i(9,"a",4),Iw(10),Pw(11,"transloco"),Jc()()(),_D(12,ie,3,3,"p",5)(13,ne,2,1,"p",6)(14,le,3,2),Jc()),i&2&&(gI(3),Lh(Fw(4,4,"manage.views.title")),gI(4),rl(" ",Fw(8,6,"manage.views.createView")," "),gI(3),rl(" ",Fw(11,8,"manage.views.createShortcut")," "),gI(2),MD(c.loading()?12:c.loadError()?13:14));},dependencies:[$8,v3,pf,bd,sp,_n,Cn,pc,as,dc,Kl,cc,Ji,ls,W,I,Kt],styles:[".list-page[_ngcontent-%COMP%]{padding:1.25rem 1.5rem 3rem;display:flex;flex-direction:column;gap:1rem}.header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start}.header-actions[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.5rem;justify-content:center}.empty[_ngcontent-%COMP%]{text-align:center;padding:2.5rem 1rem;border:1px dashed #d6d3d1;background:#fff9}.empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 1rem;color:#57534e}.error[_ngcontent-%COMP%]{color:#9f1239}.actions[_ngcontent-%COMP%]{white-space:nowrap}[_nghost-%COMP%] .ant-table-tbody>tr>td{white-space:normal;vertical-align:top}"]});}}return t})();export{Pe as ViewsAndShortcutsManageComponent};
@@ -0,0 +1 @@
1
+ import {$}from'./chunk-D5BPM_KC.js';import {s,r as r$1,ch as Sy,i as ie,C,bt as Ee,d5 as go,dg as Ul,dh as Fd,di as kn,aC as zt,bQ as Wr,Z as ZE,c3 as th,j as _i,z as xD,N as ND,J as Jc,aP as Mh,S as Sh,n as gI,D as AD,ap as re,aa as Z0,be as E3,bR as eD,af as Le$1,bs as G0,bf as _r,a4 as Ah,a5 as Th,as as st,at as Ee$1,m as mh,l as _D,aw as rh,aQ as aw,aG as lw,M as MD,p as lh,cM as Rw,bH as wh,bI as zD,y as FD,b as at,B as uh,aJ as tl,aK as nl,H as HD,O as Fu,Q as ju,aU as vv}from'./main-GFNB573R.js';var ce=["animationElement"],me=(n,o)=>({$implicit:n,data:o});function le(n,o){n&1&&uh(0,"nz-icon",4);}function pe(n,o){n&1&&uh(0,"nz-icon",5);}function de(n,o){n&1&&uh(0,"nz-icon",6);}function he(n,o){n&1&&uh(0,"nz-icon",7);}function fe(n,o){n&1&&uh(0,"nz-icon",8);}function ue(n,o){if(n&1&&(tl(0),uh(1,"span",10),nl()),n&2){let e=HD();gI(),lh("innerHTML",e.instance.content,vv);}}function ge(n,o){if(n&1){let e=FD();_i(0,"nz-message",2),mh("destroyed",function(i){Fu(e);let s=HD();return ju(s.remove(i.id,i.userAction))}),Jc();}if(n&2){let e=o.$implicit;lh("instance",e);}}var ve=0,M=class{container;nzSingletonService=C($);injector=C(Ee);remove(o){this.container&&(o?this.container.remove(o):this.container.removeAll());}getInstanceId(){return `${this.componentPrefix}-${ve++}`}withContainer(o){let e=this.nzSingletonService.getSingletonWithKey(this.componentPrefix);if(e)return e;let t=go(this.injector,{hasBackdrop:false,scrollStrategy:Fd(),positionStrategy:Ul(this.injector)}),i=new kn(o,null,this.injector),s=t.attach(i),re=t.hostElement;return re.style.zIndex="1010",e||(this.container=e=s.instance,this.nzSingletonService.registerSingletonWithKey(this.componentPrefix,e),this.container.afterAllInstancesRemoved.subscribe(()=>{this.container=void 0,this.nzSingletonService.unregisterSingletonWithKey(this.componentPrefix),t.dispose();})),e}},Ce=(()=>{class n{config;instances=[];_afterAllInstancesRemoved=new re;afterAllInstancesRemoved=this._afterAllInstancesRemoved.asObservable();cdr=C(Z0);nzConfigService=C(E3);constructor(){this.subscribeConfigChange();}create(e){let t=this.onCreate(e);return this.instances.length>=this.config.nzMaxStack&&(this.instances=this.instances.slice(1)),this.instances=[...this.instances,t],this.readyInstances(),t}remove(e,t=false){this.instances.map((i,s)=>({index:s,instance:i})).filter(({instance:i})=>i.messageId===e).forEach(({index:i,instance:s})=>{this.instances.splice(i,1),this.instances=[...this.instances],this.onRemove(s,t),this.readyInstances();}),this.instances.length||this.onAllInstancesRemoved();}removeAll(){this.instances.forEach(e=>this.onRemove(e,false)),this.instances=[],this.readyInstances(),this.onAllInstancesRemoved();}onCreate(e){return e.options=this.mergeOptions(e.options),e.onClose=new re,e}onRemove(e,t){e.onClose.next(t),e.onClose.complete();}onAllInstancesRemoved(){this._afterAllInstancesRemoved.next(),this._afterAllInstancesRemoved.complete();}readyInstances(){this.cdr.detectChanges();}mergeOptions(e){let{nzDuration:t,nzAnimate:i,nzPauseOnHover:s}=this.config;return r$1({nzDuration:t,nzAnimate:i,nzPauseOnHover:s},e)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=eD({type:n})}return n})(),ye=(()=>{class n{destroyRef=C(at);elementRef=C(_r);options;autoClose;userAction=false;eraseTimer;eraseTimingStart;eraseTTL;constructor(){this.destroyRef.onDestroy(()=>{this.autoClose&&this.clearEraseTimeout();});}ngOnInit(){this.options=this.instance.options,this.options.nzAnimate&&this._startEnterAnimation(),this.autoClose=this.options.nzDuration>0,this.autoClose&&(this.initErase(),this.startEraseTimeout());}onEnter(){this.autoClose&&this.options.nzPauseOnHover&&(this.clearEraseTimeout(),this.updateTTL());}onLeave(){this.autoClose&&this.options.nzPauseOnHover&&this.startEraseTimeout();}destroy(e=false){this.userAction=e,this.options.nzAnimate?this._startLeaveAnimation(()=>this.destroyed.next({id:this.instance.messageId,userAction:e})):this.destroyed.next({id:this.instance.messageId,userAction:e});}initErase(){this.eraseTTL=this.options.nzDuration,this.eraseTimingStart=Date.now();}updateTTL(){this.autoClose&&(this.eraseTTL-=Date.now()-this.eraseTimingStart);}startEraseTimeout(){this.eraseTTL>0?(this.clearEraseTimeout(),this.eraseTimer=setTimeout(()=>this.destroy(),this.eraseTTL),this.eraseTimingStart=Date.now()):this.destroy();}clearEraseTimeout(){this.eraseTimer!==null&&(clearTimeout(this.eraseTimer),this.eraseTimer=void 0);}_startEnterAnimation(){let e=this.animationElement().nativeElement;e.classList.add(this._animationClassMap.enter);let t=i=>{this.matchAnimationKeyframe(i,this._animationKeyframeMap.enter)&&(e.removeEventListener("animationend",t),e.classList.remove(this._animationClassMap.enter));};e.addEventListener("animationend",t);}_startLeaveAnimation(e){let t=this.animationElement().nativeElement;t.classList.remove(this._animationClassMap.enter),t.classList.add(this._animationClassMap.leave);let i=s=>{this.matchAnimationKeyframe(s,this._animationKeyframeMap.leave)&&(t.removeEventListener("animationend",i),e());};t.addEventListener("animationend",i);}matchAnimationKeyframe(e,t){return typeof t=="string"?e.animationName===t:t.includes(e.animationName)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=eD({type:n})}return n})(),ze=(()=>{class n extends ye{instance;destroyed=new Le$1;index;animationElement=G0.required("animationElement",{read:_r});_animationKeyframeMap={enter:"MessageMoveIn",leave:"MessageMoveOut"};_animationClassMap={enter:"ant-message-move-up-enter",leave:"ant-message-move-up-leave"};static \u0275fac=(()=>{let e;return function(i){return (e||(e=Sy(n)))(i||n)}})();static \u0275cmp=ZE({type:n,selectors:[["nz-message"]],viewQuery:function(t,i){t&1&&wh(i.animationElement,ce,5,_r),t&2&&zD();},inputs:{instance:"instance"},outputs:{destroyed:"destroyed"},exportAs:["nzMessage"],features:[th],decls:10,vars:12,consts:[["animationElement",""],[1,"ant-message-notice",3,"mouseenter","mouseleave"],[1,"ant-message-notice-content"],[1,"ant-message-custom-content"],["nzType","check-circle"],["nzType","info-circle"],["nzType","exclamation-circle"],["nzType","close-circle"],["nzType","loading"],[4,"nzStringTemplateOutlet","nzStringTemplateOutletContext"],[3,"innerHTML"]],template:function(t,i){if(t&1&&(_i(0,"div",1,0),mh("mouseenter",function(){return i.onEnter()})("mouseleave",function(){return i.onLeave()}),_i(2,"div",2)(3,"div",3),_D(4,le,1,0,"nz-icon",4)(5,pe,1,0,"nz-icon",5)(6,de,1,0,"nz-icon",6)(7,he,1,0,"nz-icon",7)(8,fe,1,0,"nz-icon",8),rh(9,ue,2,1,"ng-container",9),Jc()()()),t&2){let s;aw(i.instance.options?.nzStyle),lw(i.instance.options?.nzClass),gI(3),lw("ant-message-"+i.instance.type),gI(),MD((s=i.instance.type)==="success"?4:s==="info"?5:s==="warning"?6:s==="error"?7:s==="loading"?8:-1),gI(5),lh("nzStringTemplateOutlet",i.instance.content)("nzStringTemplateOutletContext",Rw(9,me,i,i.instance.options?.nzData));}},dependencies:[Ah,Th,st,Ee$1],encapsulation:2})}return n})(),f="message",_e={nzAnimate:true,nzDuration:3e3,nzMaxStack:7,nzPauseOnHover:true,nzTop:24,nzDirection:"ltr"},Te=(()=>{class n extends Ce{dir=this.nzConfigService.getConfigForComponent(f)?.nzDirection||"ltr";top;constructor(){super(),this.updateConfig();}subscribeConfigChange(){zt(f,()=>{this.updateConfig(),this.dir=this.nzConfigService.getConfigForComponent(f)?.nzDirection||this.dir;});}updateConfig(){this.config=r$1(r$1(r$1({},_e),this.config),this.nzConfigService.getConfigForComponent(f)),this.top=Wr(this.config.nzTop),this.cdr.markForCheck();}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=ZE({type:n,selectors:[["nz-message-container"]],exportAs:["nzMessageContainer"],features:[th],decls:3,vars:4,consts:[[1,"ant-message"],[3,"instance"],[3,"destroyed","instance"]],template:function(t,i){t&1&&(_i(0,"div",0),xD(1,ge,1,1,"nz-message",1,ND),Jc()),t&2&&(Mh("top",i.top),Sh("ant-message-rtl",i.dir==="rtl"),gI(),AD(i.instances));},dependencies:[ze],encapsulation:2})}return n})(),He=(()=>{class n extends M{componentPrefix="message-";success(e,t){return this.createInstance({type:"success",content:e},t)}error(e,t){return this.createInstance({type:"error",content:e},t)}info(e,t){return this.createInstance({type:"info",content:e},t)}warning(e,t){return this.createInstance({type:"warning",content:e},t)}loading(e,t){return this.createInstance({type:"loading",content:e},t)}create(e,t,i){return this.createInstance({type:e,content:t},i)}createInstance(e,t){return this.container=this.withContainer(Te),this.container.create(s(r$1({},e),{createdAt:new Date,messageId:this.getInstanceId(),options:t}))}static \u0275fac=(()=>{let e;return function(i){return (e||(e=Sy(n)))(i||n)}})();static \u0275prov=ie({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();export{He as H};
@@ -1 +1 @@
1
- import {C,b4 as N2,aV as ix,b_ as u,b5 as cx,i as ie}from'./main-Q5LNROCU.js';var b=(()=>{class r{constructor(){this.http=C(N2),this.baseUrl=`${ix.apiBaseUrl}/workflows`;}list(t){return this.http.get(this.baseUrl,{params:u(t)}).pipe(cx())}get(t){return this.http.get(`${this.baseUrl}/${encodeURIComponent(t)}`).pipe(cx())}create(t){return this.http.post(this.baseUrl,t).pipe(cx())}update(t,i){return this.http.patch(`${this.baseUrl}/${encodeURIComponent(t)}`,i).pipe(cx())}delete(t){return this.http.delete(`${this.baseUrl}/${encodeURIComponent(t)}`).pipe(cx())}exportDefinition(t){return this.http.get(`${this.baseUrl}/${encodeURIComponent(t)}/export`).pipe(cx())}importDefinition(t){return this.http.post(`${this.baseUrl}/import`,t).pipe(cx())}getInstructions(){return this.http.get(`${this.baseUrl}/instructions`,{responseType:"text"}).pipe(cx())}static{this.\u0275fac=function(i){return new(i||r)};}static{this.\u0275prov=ie({token:r,factory:r.\u0275fac,providedIn:"root"});}}return r})();export{b};
1
+ import {C,b4 as N2,aV as ix,b_ as u,b5 as cx,i as ie}from'./main-GFNB573R.js';var b=(()=>{class r{constructor(){this.http=C(N2),this.baseUrl=`${ix.apiBaseUrl}/workflows`;}list(t){return this.http.get(this.baseUrl,{params:u(t)}).pipe(cx())}get(t){return this.http.get(`${this.baseUrl}/${encodeURIComponent(t)}`).pipe(cx())}create(t){return this.http.post(this.baseUrl,t).pipe(cx())}update(t,i){return this.http.patch(`${this.baseUrl}/${encodeURIComponent(t)}`,i).pipe(cx())}delete(t){return this.http.delete(`${this.baseUrl}/${encodeURIComponent(t)}`).pipe(cx())}exportDefinition(t){return this.http.get(`${this.baseUrl}/${encodeURIComponent(t)}/export`).pipe(cx())}importDefinition(t){return this.http.post(`${this.baseUrl}/import`,t).pipe(cx())}getInstructions(){return this.http.get(`${this.baseUrl}/instructions`,{responseType:"text"}).pipe(cx())}static{this.\u0275fac=function(i){return new(i||r)};}static{this.\u0275prov=ie({token:r,factory:r.\u0275fac,providedIn:"root"});}}return r})();export{b};
@@ -0,0 +1 @@
1
+ import {l}from'./chunk-D19C8Gcb.js';import {T}from'./chunk-CyvupcYz.js';import {_ as _n,C as Cn}from'./chunk-MciiAFro.js';import {C,V as Ve,b as at,b0 as jn,R as J1,q as qo,u as ue$1,aS as v,aY as Dg,c as bi,Z as ZE,d as $8,e as al,f as rl,g as $i,v as v3,a0 as pf,a1 as bd,a2 as sp,a3 as fp,b1 as ts,h as ex,F as Fm,A as Am,K as Kt$1,y as FD,j as _i,I as Iw,P as Pw,J as Jc,m as mh,l as _D,n as gI,L as Lh,o as Fw,p as lh,x as rl$1,M as MD,b2 as Le,b3 as Wn,az as jw,G as Aw,H as HD,z as xD,N as ND,k as iE,w as aE,D as AD,b4 as N2,aV as ix,b5 as cx,i as ie$1,B as uh,E as ch,aO as SD,aP as Mh,O as Fu,Q as ju,aH as QD}from'./main-GFNB573R.js';import {b}from'./chunk-Dt7AgNFd.js';import {N as Nt,K as Ke}from'./chunk-BmEXmF8m.js';import {a as ai,z}from'./chunk-C07s4-rF.js';import {W,I}from'./chunk-zWWkMLc1.js';import {o as og,m as m_}from'./chunk-g20-BKKx.js';import {p as pc,a as as,d as dc,K as Kl,c as cc,J as Ji,l as ls}from'./chunk-DyGh8J3-.js';import'./chunk-D5BPM_KC.js';var Vt=e=>({name:e}),Ft=(()=>{class e{constructor(){this.modalRef=C(Le),this.data=C(Wn);}cancel(){this.modalRef.close(void 0);}choose(t){this.modalRef.close(t);}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275cmp=ZE({type:e,selectors:[["app-workflow-import-conflict"]],decls:14,vars:15,consts:[["data-testid","import-conflict-dialog"],["data-testid","import-conflict-message"],[1,"dialog-actions"],["nz-button","","type","button","data-testid","import-conflict-cancel",3,"click"],["nz-button","","type","button","data-testid","import-conflict-create-new",3,"click"],["nz-button","","nzType","primary","type","button","data-testid","import-conflict-update",3,"click"]],template:function(i,a){i&1&&(_i(0,"div",0)(1,"p",1),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"div",2)(5,"button",3),mh("click",function(){return a.cancel()}),Iw(6),Pw(7,"transloco"),Jc(),_i(8,"button",4),mh("click",function(){return a.choose("create_new")}),Iw(9),Pw(10,"transloco"),Jc(),_i(11,"button",5),mh("click",function(){return a.choose("update")}),Iw(12),Pw(13,"transloco"),Jc()()()),i&2&&(gI(2),rl$1(" ",jw(3,4,"workflows.import.conflictBody",Aw(13,Vt,a.data.name))," "),gI(4),rl$1(" ",Fw(7,7,"common.cancel")," "),gI(3),rl$1(" ",Fw(10,9,"workflows.import.createNew")," "),gI(3),rl$1(" ",Fw(13,11,"workflows.import.update")," "));},dependencies:[pf,bd,sp,fp,Kt$1],styles:["p[_ngcontent-%COMP%]{margin:0 0 1.25rem;color:#44403c}.dialog-actions[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.5rem}"]});}}return e})();var jt=(()=>{class e{constructor(){this.http=C(N2),this.baseUrl=`${ix.apiBaseUrl}/workflow-library`;}list(){return this.http.get(this.baseUrl).pipe(cx())}add(t){return this.http.post(`${this.baseUrl}/${encodeURIComponent(t)}/add`,{}).pipe(cx())}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275prov=ie$1({token:e,factory:e.\u0275fac,providedIn:"root"});}}return e})();var Kt=(e,d)=>d.id;function Ut(e,d){e&1&&(_i(0,"p",2),Iw(1),Pw(2,"transloco"),Jc()),e&2&&(gI(),Lh(Fw(2,1,"common.loading")));}function Jt(e,d){if(e&1&&(_i(0,"p",3),Iw(1),Jc()),e&2){let t=HD();gI(),Lh(t.loadError());}}function Zt(e,d){if(e&1&&(_i(0,"p",4),Iw(1),Jc()),e&2){let t=HD(2);gI(),Lh(t.addError());}}function qt(e,d){if(e&1&&(_i(0,"nz-tag"),Iw(1),Pw(2,"transloco"),Jc()),e&2){let t=d.$implicit,i=HD(3);gI(),Lh(Fw(2,1,i.subjectTypeKey(t)));}}function Gt(e,d){if(e&1&&(_i(0,"li")(1,"span"),Iw(2),Jc(),_i(3,"span",14),Iw(4),Pw(5,"transloco"),Jc()()),e&2){let t=d.$implicit,i=HD(4);Mh("margin-left",t.depth,"rem"),gI(2),Lh(t.name),gI(2),Lh(Fw(5,4,i.stepTypeKey(t.type)));}}function Qt(e,d){if(e&1&&(_i(0,"ol",12),xD(1,Gt,6,6,"li",13,SD),Jc()),e&2){let t=HD().$implicit,i=HD(2);ch("data-testid","library-steps-"+t.id),gI(),AD(i.previewSteps(t));}}function Xt(e,d){if(e&1){let t=FD();_i(0,"nz-card")(1,"div",6)(2,"h2"),Iw(3),Jc(),_i(4,"nz-tag"),Iw(5),Pw(6,"transloco"),Jc()(),_i(7,"p",7),Iw(8),Jc(),_i(9,"div",8),xD(10,qt,3,3,"nz-tag",null,ND),Jc(),_i(12,"div",9)(13,"button",10),mh("click",function(){let a=Fu(t).$implicit,u=HD(2);return ju(u.togglePreview(a.id))}),Iw(14),Pw(15,"transloco"),Jc(),_i(16,"button",11),mh("click",function(){let a=Fu(t).$implicit,u=HD(2);return ju(u.addToMyWorkflows(a.id))}),Iw(17),Pw(18,"transloco"),Jc()(),_D(19,Qt,3,1,"ol",12),Jc();}if(e&2){let t=d.$implicit,i=HD(2);ch("data-testid","library-entry-"+t.id),gI(2),ch("data-testid","library-name-"+t.id),gI(),Lh(t.name),gI(),ch("data-testid","library-source-"+t.id),gI(),Lh(Fw(6,13,i.sourceKey(t.source))),gI(2),ch("data-testid","library-description-"+t.id),gI(),rl$1(" ",t.description," "),gI(2),AD(i.appliesToValues(t)),gI(3),ch("data-testid","library-preview-"+t.id),gI(),rl$1(" ",Fw(15,15,i.isExpanded(t.id)?"workflow-library.hideSteps":"workflow-library.previewSteps")," "),gI(2),lh("disabled",i.addingId()!==null),ch("data-testid","library-add-"+t.id),gI(),rl$1(" ",Fw(18,17,i.addingId()===t.id?"workflow-library.adding":"workflow-library.add")," "),gI(2),MD(i.isExpanded(t.id)?19:-1);}}function Yt(e,d){if(e&1&&(_D(0,Zt,2,1,"p",4),_i(1,"div",5),xD(2,Xt,20,19,"nz-card",null,Kt),Jc()),e&2){let t=HD();MD(t.addError()?0:-1),gI(2),AD(t.entries());}}var Ot=(()=>{class e{constructor(){this.libraryApi=C(jt),this.router=C(J1),this.transloco=C(Ve),this.destroyRef=C(at),this.modalRef=C(Le,{optional:true}),this.entries=qo([]),this.loading=qo(true),this.loadError=qo(null),this.addError=qo(null),this.addingId=qo(null),this.expandedIds=qo(new Set),this.libraryApi.list().pipe(ue$1(this.destroyRef)).subscribe({next:t=>{this.entries.set(t),this.loading.set(false);},error:t=>{this.loading.set(false),this.loadError.set(this.errorMessage(t,this.transloco.translate("workflow-library.loadFailed")));}});}sourceKey(t){return `workflow-library.source.${t}`}appliesToValues(t){let i=t.workflowDefinition.appliesTo;return i==="none"?["none"]:Array.isArray(i)?i:[i]}subjectTypeKey(t){return `workflow-editor.subjectType.${t}`}stepTypeKey(t){return `step-list.stepType.${t}`}isExpanded(t){return this.expandedIds().has(t)}togglePreview(t){this.expandedIds.update(i=>{let a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a});}previewSteps(t){return At(t.workflowDefinition.steps,0)}addToMyWorkflows(t){this.addingId()||(this.addError.set(null),this.addingId.set(t),this.libraryApi.add(t).pipe(ue$1(this.destroyRef)).subscribe({next:i=>{this.addingId.set(null),this.modalRef?.close(),this.router.navigate(["/workflows",i.id,"edit"]);},error:i=>{this.addingId.set(null),this.addError.set(this.errorMessage(i,this.transloco.translate("workflow-library.addFailed")));}}));}errorMessage(t,i){return t instanceof bi||t instanceof Error?t.message:i}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275cmp=ZE({type:e,selectors:[["app-workflow-library-browser"]],decls:7,vars:4,consts:[["data-testid","workflow-library-browser",1,"library"],[1,"lede"],["data-testid","library-loading"],["data-testid","library-load-error",1,"error"],["data-testid","library-add-error",1,"error"],[1,"cards"],[1,"card-head"],[1,"description"],[1,"applies-to"],[1,"card-actions"],["nz-button","","nzType","link","type","button",3,"click"],["nz-button","","nzType","primary","type","button",3,"click","disabled"],[1,"steps-preview"],[3,"margin-left"],[1,"step-type"]],template:function(i,a){i&1&&(_i(0,"div",0)(1,"p",1),Iw(2),Pw(3,"transloco"),Jc(),_D(4,Ut,3,3,"p",2)(5,Jt,2,1,"p",3)(6,Yt,4,1),Jc()),i&2&&(gI(2),Lh(Fw(3,2,"workflow-library.lede")),gI(2),MD(a.loading()?4:a.loadError()?5:6));},dependencies:[$8,pf,bd,sp,fp,Nt,Ke,W,I,Kt$1],styles:[".library[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem}.lede[_ngcontent-%COMP%]{margin:0;color:#57534e}.cards[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem}.card-head[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:flex-start;gap:.75rem}.card-head[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:1.05rem;font-weight:600}.description[_ngcontent-%COMP%]{margin:.5rem 0 0;color:#57534e}.applies-to[_ngcontent-%COMP%]{margin-top:.5rem}.card-actions[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin-top:.5rem}.steps-preview[_ngcontent-%COMP%]{margin:.75rem 0 0;padding-left:1.25rem;color:#44403c}.steps-preview[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;margin:.25rem 0}.step-type[_ngcontent-%COMP%]{color:#78716c;font-size:.85rem}.error[_ngcontent-%COMP%]{color:#9f1239}"]});}}return e})();function At(e,d){let t=[];for(let i of e)t.push({name:i.name,type:i.type,depth:d}),i.type==="loop"&&Array.isArray(i.steps)&&t.push(...At(i.steps,d+1));return t}var Rt=(()=>{class e{constructor(){this.http=C(N2),this.baseUrl=`${ix.apiBaseUrl}/internal-workflows`;}createWorkflowStatus(){return this.http.get(`${this.baseUrl}/create-workflow/status`).pipe(cx())}startCreateWorkflow(t){return this.http.post(`${this.baseUrl}/create-workflow`,{description:t}).pipe(cx())}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275prov=ie$1({token:e,factory:e.\u0275fac,providedIn:"root"});}}return e})();function te(e,d){e&1&&(_i(0,"p",2),Iw(1),Pw(2,"transloco"),Jc()),e&2&&(gI(),Lh(Fw(2,1,"create-workflow-ai.loading")));}function ee(e,d){if(e&1&&(_i(0,"p",3),Iw(1),Pw(2,"transloco"),Jc()),e&2){let t=HD();gI(),rl$1(" ",t.unavailableReason()??Fw(2,1,"create-workflow-ai.needsDefaultAgent")," ");}}function ie(e,d){if(e&1&&(_i(0,"p",6),Iw(1),Jc()),e&2){let t=HD(2);gI(),Lh(t.error());}}function oe(e,d){if(e&1){let t=FD();_i(0,"label",4)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"textarea",5),Pw(5,"transloco"),mh("input",function(a){Fu(t);let u=HD();return ju(u.onDescriptionInput(a))}),Jc()(),_D(6,ie,2,1,"p",6),_i(7,"div",7)(8,"button",8),mh("click",function(){Fu(t);let a=HD();return ju(a.start())}),Iw(9),Pw(10,"transloco"),Pw(11,"transloco"),Jc()();}if(e&2){let t=HD();gI(2),Lh(Fw(3,7,"create-workflow-ai.descriptionLabel")),gI(2),lh("value",t.description())("placeholder",Fw(5,9,"create-workflow-ai.descriptionPlaceholder")),gI(2),MD(t.error()?6:-1),gI(2),lh("disabled",!t.description().trim()||t.starting())("nzLoading",t.starting()),gI(),rl$1(" ",t.starting()?Fw(10,11,"create-workflow-ai.starting"):Fw(11,13,"create-workflow-ai.start")," ");}}var $t=(()=>{class e{constructor(){this.api=C(Rt),this.router=C(J1),this.transloco=C(Ve),this.destroyRef=C(at),this.modalRef=C(Le,{optional:true}),this.description=qo(""),this.available=qo(false),this.unavailableReason=qo(null),this.statusLoading=qo(true),this.starting=qo(false),this.error=qo(null),this.api.createWorkflowStatus().pipe(ue$1(this.destroyRef)).subscribe({next:t=>{this.statusLoading.set(false),this.available.set(t.available),this.unavailableReason.set(t.reason??null);},error:t=>{this.statusLoading.set(false),this.available.set(false),this.unavailableReason.set(this.errorMessage(t,this.transloco.translate("create-workflow-ai.statusFailed")));}});}onDescriptionInput(t){this.description.set(t.target.value);}start(){let t=this.description().trim();!t||!this.available()||this.starting()||(this.starting.set(true),this.error.set(null),this.api.startCreateWorkflow(t).pipe(ue$1(this.destroyRef)).subscribe({next:i=>{this.starting.set(false),this.modalRef?.close(),this.router.navigate(["/jobs",i.id]);},error:i=>{this.starting.set(false),this.error.set(this.errorMessage(i,this.transloco.translate("create-workflow-ai.startFailed")));}}));}errorMessage(t,i){return t instanceof bi?t.message:i}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275cmp=ZE({type:e,selectors:[["app-create-workflow-ai"]],decls:7,vars:4,consts:[["data-testid","create-workflow-ai",1,"create-ai"],[1,"lede"],["data-testid","create-ai-loading"],["data-testid","create-ai-unavailable",1,"unavailable"],[1,"field"],["nz-input","","rows","8","data-testid","create-ai-description",3,"input","value","placeholder"],["data-testid","create-ai-error",1,"error"],[1,"actions"],["nz-button","","nzType","primary","type","button","data-testid","create-ai-start",3,"click","disabled","nzLoading"]],template:function(i,a){i&1&&(_i(0,"div",0)(1,"p",1),Iw(2),Pw(3,"transloco"),Jc(),_D(4,te,3,3,"p",2)(5,ee,3,3,"p",3)(6,oe,12,15),Jc()),i&2&&(gI(2),Lh(Fw(3,2,"create-workflow-ai.lede")),gI(2),MD(a.statusLoading()?4:a.available()?6:5));},dependencies:[$8,al,pf,bd,sp,fp,ai,z,Kt$1],styles:[".create-ai[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem}.lede[_ngcontent-%COMP%]{margin:0;color:var(--ant-color-text-secondary, #666)}.field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.unavailable[_ngcontent-%COMP%], .error[_ngcontent-%COMP%]{margin:0;color:var(--ant-color-error, #cf1322)}.actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end}"]});}}return e})();var ne=e=>({count:e}),re=e=>["/workflows",e,"edit"],ae=(e,d)=>d.id;function le(e,d){if(e&1&&(_i(0,"p",10),Iw(1),Jc()),e&2){let t=HD();gI(),Lh(t.actionError());}}function se(e,d){e&1&&(_i(0,"p",11),Iw(1),Pw(2,"transloco"),Jc()),e&2&&(gI(),Lh(Fw(2,1,"common.loading")));}function pe(e,d){if(e&1&&(_i(0,"p",12),Iw(1),Jc()),e&2){let t=HD();gI(),Lh(t.loadError());}}function de(e,d){if(e&1&&(uh(0,"nz-option",15),Pw(1,"transloco")),e&2){let t=d.$implicit,i=HD(2);lh("nzValue",t)("nzLabel",Fw(1,2,i.subjectHandlingFilterKey(t)));}}function ce(e,d){if(e&1&&(_i(0,"p",16),Iw(1),Jc()),e&2){let t=HD(2);gI(),Lh(t.deleteError());}}function me(e,d){if(e&1){let t=FD();_i(0,"section",17)(1,"p"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"div",19)(5,"button",20),mh("click",function(){Fu(t);let a=HD(2);return ju(a.openLibrary())}),Iw(6),Pw(7,"transloco"),Jc(),_i(8,"a",21),Iw(9),Pw(10,"transloco"),Jc()()();}e&2&&(gI(2),Lh(Fw(3,3,"workflows.list.emptyState")),gI(4),rl$1(" ",Fw(7,5,"workflows.list.emptyBrowseLibrary")," "),gI(3),rl$1(" ",Fw(10,7,"workflows.list.emptyCreateButton")," "));}function fe(e,d){if(e&1&&(_i(0,"span"),Iw(1),Jc()),e&2){let t=HD().$implicit;ch("data-testid","description-"+t.id),gI(),Lh(t.description);}}function ue(e,d){if(e&1&&(_i(0,"span",23),Iw(1),Pw(2,"transloco"),Jc()),e&2){let t=HD().$implicit;ch("data-testid","description-"+t.id),gI(),Lh(Fw(2,2,"workflows.list.noDescription"));}}function we(e,d){if(e&1&&(_i(0,"nz-tag"),Iw(1),Pw(2,"transloco"),Jc()),e&2){let t=d.$implicit,i=HD().$implicit,a=HD(3);ch("data-testid","applies-to-"+i.id),gI(),Lh(Fw(2,2,a.subjectTypeKey(t)));}}function _e(e,d){if(e&1){let t=FD();_i(0,"tr")(1,"td")(2,"span"),Iw(3),Jc()(),_i(4,"td",22),_D(5,fe,2,2,"span")(6,ue,3,4,"span",23),Jc(),_i(7,"td"),xD(8,we,3,4,"nz-tag",null,ND),Jc(),_i(10,"td")(11,"nz-tag"),Iw(12),Pw(13,"transloco"),Jc()(),_i(14,"td")(15,"span"),Iw(16),Pw(17,"transloco"),Jc()(),_i(18,"td",24)(19,"a",25),Iw(20),Pw(21,"transloco"),Jc(),_i(22,"button",26),mh("click",function(){let a=Fu(t).$implicit,u=HD(3);return ju(u.exportWorkflow(a))}),Iw(23),Pw(24,"transloco"),Jc(),_i(25,"button",27),Pw(26,"transloco"),Pw(27,"transloco"),Pw(28,"transloco"),mh("nzOnConfirm",function(){let a=Fu(t).$implicit,u=HD(3);return ju(u.deleteWorkflow(a.id))}),Iw(29),Pw(30,"transloco"),Jc()()();}if(e&2){let t=d.$implicit,i=HD(3);ch("data-testid","workflow-"+t.id),gI(2),ch("data-testid","name-"+t.id),gI(),Lh(t.name),gI(2),MD(t.description?.trim()?5:6),gI(3),AD(i.appliesToValues(t)),gI(3),ch("data-testid","subject-handling-"+t.id),gI(),Lh(Fw(13,18,i.subjectHandlingKey(t.subjectHandling))),gI(3),ch("data-testid","step-count-"+t.id),gI(),Lh(jw(17,20,"workflows.list.stepCount",Aw(35,ne,t.steps.length))),gI(3),lh("routerLink",Aw(37,re,t.id)),ch("data-testid","edit-"+t.id),gI(),rl$1(" ",Fw(21,23,"workflows.list.edit")," "),gI(2),ch("data-testid","export-"+t.id),gI(),rl$1(" ",Fw(24,25,"workflows.list.export")," "),gI(2),lh("nzPopconfirmTitle",Fw(26,27,"workflows.list.deleteConfirm"))("nzOkText",Fw(27,29,"workflows.list.delete"))("nzCancelText",Fw(28,31,"common.cancel")),ch("data-testid","delete-"+t.id),gI(4),rl$1(" ",Fw(30,33,"workflows.list.delete")," ");}}function ge(e,d){if(e&1&&(_i(0,"nz-table",18)(1,"thead")(2,"tr")(3,"th"),Iw(4),Pw(5,"transloco"),Jc(),_i(6,"th"),Iw(7),Pw(8,"transloco"),Jc(),_i(9,"th"),Iw(10),Pw(11,"transloco"),Jc(),_i(12,"th"),Iw(13),Pw(14,"transloco"),Jc(),_i(15,"th"),Iw(16),Pw(17,"transloco"),Jc(),_i(18,"th"),Iw(19),Pw(20,"transloco"),Jc()()(),_i(21,"tbody"),xD(22,_e,31,39,"tr",null,ae),Jc()()),e&2){let t=HD(2);lh("nzData",t.workflows())("nzFrontPagination",false)("nzShowPagination",false),gI(4),Lh(Fw(5,9,"workflows.list.column.name")),gI(3),Lh(Fw(8,11,"workflows.list.column.description")),gI(3),Lh(Fw(11,13,"workflow-editor.appliesTo")),gI(3),Lh(Fw(14,15,"workflow-editor.subjectHandling.label")),gI(3),Lh(Fw(17,17,"workflows.list.column.steps")),gI(3),Lh(Fw(20,19,"workflows.list.column.actions")),gI(3),AD(t.workflows());}}function xe(e,d){if(e&1){let t=FD();_i(0,"div",13)(1,"span"),Iw(2),Pw(3,"transloco"),Jc(),_i(4,"nz-select",14),mh("ngModelChange",function(a){Fu(t);let u=HD();return ju(u.setSubjectHandlingFilter(a))}),xD(5,de,2,4,"nz-option",15,ND),Jc(),iE(),Jc(),_D(7,ce,2,1,"p",16),_D(8,me,11,9,"section",17)(9,ge,24,21,"nz-table",18);}if(e&2){let t=HD();gI(2),Lh(Fw(3,4,"workflows.list.filterBySubjectHandling")),gI(2),lh("ngModel",t.subjectHandlingFilter()),aE(),gI(),AD(t.subjectHandlingOptions),gI(2),MD(t.deleteError()?7:-1),gI(),MD(t.workflows().length===0?8:9);}}var Fi=(()=>{class e{constructor(){this.workflowsApi=C(b),this.transloco=C(Ve),this.destroyRef=C(at),this.modal=C(jn),this.router=C(J1),this.workflows=qo([]),this.loading=qo(true),this.loadError=qo(null),this.deleteError=qo(null),this.actionError=qo(null),this.importing=qo(false),this.subjectHandlingFilter=qo("all"),this.subjectHandlingOptions=["all","per-subject","collection"],this.load();}setSubjectHandlingFilter(t){this.subjectHandlingFilter.set(t),this.load();}appliesToValues(t){let i=t.appliesTo;return i==="none"?["none"]:Array.isArray(i)?i:[i]}subjectTypeKey(t){return `workflow-editor.subjectType.${t}`}subjectHandlingKey(t){return `workflow-editor.subjectHandling.${t}`}subjectHandlingFilterKey(t){return t==="all"?"workflows.list.filterAll":`workflow-editor.subjectHandling.${t}`}deleteWorkflow(t){this.deleteError.set(null),this.workflowsApi.delete(t).pipe(ue$1(this.destroyRef)).subscribe({next:()=>{this.workflows.update(i=>i.filter(a=>a.id!==t));},error:i=>{this.deleteError.set(this.errorMessage(i,this.transloco.translate("workflows.list.deleteFailed")));}});}openLibrary(){this.modal.create({nzTitle:this.transloco.translate("workflow-library.title"),nzContent:Ot,nzFooter:null,nzWidth:720});}openCreateWithAi(){this.modal.create({nzTitle:this.transloco.translate("create-workflow-ai.title"),nzContent:$t,nzFooter:null,nzWidth:640});}exportWorkflow(t){this.actionError.set(null),this.workflowsApi.exportDefinition(t.id).pipe(ue$1(this.destroyRef)).subscribe({next:i=>{l(`${og(i.name)}.json`,JSON.stringify(i,null,2),"application/json");},error:i=>{this.actionError.set(this.errorMessage(i,this.transloco.translate("workflows.list.exportFailed")));}});}downloadInstructions(){this.actionError.set(null),this.workflowsApi.getInstructions().pipe(ue$1(this.destroyRef)).subscribe({next:t=>{l("knoflows-workflow-agent-instructions.md",t,"text/markdown;charset=utf-8");},error:t=>{this.actionError.set(this.errorMessage(t,this.transloco.translate("workflows.list.instructionsFailed")));}});}onImportFile(t){let i=t.target,a=i.files?.[0];i.value="",!(!a||this.importing())&&this.readAndImport(a);}importJsonText(t){this.actionError.set(null);let i;try{i=JSON.parse(t);}catch(u){this.actionError.set(this.transloco.translate("workflows.list.importInvalidJson"));return}let a=m_.safeParse(i);if(!a.success){let u=T(a.error);this.actionError.set(`${this.transloco.translate("workflows.list.importInvalidSchema")}: ${u[0]??""}`);return}this.postImport(i);}readAndImport(t){return v(this,null,function*(){try{this.importJsonText(yield t.text());}catch(i){this.actionError.set(this.transloco.translate("workflows.list.importInvalidJson"));}})}postImport(t,i){this.importing.set(true),this.actionError.set(null),this.workflowsApi.importDefinition(i?{workflowDefinition:t,resolution:i}:{workflowDefinition:t}).pipe(ue$1(this.destroyRef)).subscribe({next:a=>{this.importing.set(false),this.router.navigate(["/workflows",a.id,"edit"]);},error:a=>{this.importing.set(false);let u=this.importConflict(a);if(u&&!i){this.openImportConflict(t,u.name);return}this.actionError.set(this.errorMessage(a,this.transloco.translate("workflows.list.importFailed")));}});}openImportConflict(t,i){(this.modal.create({nzTitle:this.transloco.translate("workflows.import.conflictTitle"),nzContent:Ft,nzData:{name:i},nzFooter:null}).afterClose??Dg(void 0)).pipe(ue$1(this.destroyRef)).subscribe(E=>{(E==="update"||E==="create_new")&&this.postImport(t,E);});}importConflict(t){if(!(t instanceof bi)||t.httpStatus!==409||!t.details)return null;let i=t.details.conflictingWorkflowId,a=t.details.conflictingWorkflowName;return typeof i!="string"||typeof a!="string"?null:{id:i,name:a}}load(){let t=this.subjectHandlingFilter();this.loading.set(true),this.loadError.set(null),this.workflowsApi.list(t==="all"?void 0:{subjectHandling:t}).pipe(ue$1(this.destroyRef)).subscribe({next:i=>{this.workflows.set(i),this.loading.set(false);},error:i=>{this.loading.set(false),this.loadError.set(this.errorMessage(i,this.transloco.translate("workflows.list.loadFailed")));}});}errorMessage(t,i){return t instanceof bi||t instanceof Error?t.message:i}static{this.\u0275fac=function(i){return new(i||e)};}static{this.\u0275cmp=ZE({type:e,selectors:[["app-workflow-list"]],decls:27,vars:21,consts:[["importFileInput",""],["data-testid","workflows-list",1,"list-page"],[1,"header"],[1,"header-actions"],["type","file","accept","application/json,.json","hidden","","data-testid","import-file",3,"change"],["nz-button","","type","button","data-testid","import-workflow",3,"click","disabled"],["nz-button","","type","button","data-testid","download-instructions",3,"click"],["nz-button","","type","button","data-testid","browse-library",3,"click"],["nz-button","","type","button","data-testid","create-workflow-ai",3,"click"],["nz-button","","nzType","primary","routerLink","/workflows/new","data-testid","create-workflow"],["data-testid","action-error",1,"error"],["data-testid","loading"],["data-testid","load-error",1,"error"],[1,"field"],["data-testid","subject-handling-filter",3,"ngModelChange","ngModel"],[3,"nzValue","nzLabel"],["data-testid","delete-error",1,"error"],["data-testid","empty-state",1,"empty"],["data-testid","workflow-items",3,"nzData","nzFrontPagination","nzShowPagination"],[1,"empty-actions"],["nz-button","","type","button","data-testid","empty-browse-library",3,"click"],["nz-button","","nzType","primary","routerLink","/workflows/new","data-testid","empty-create"],[1,"description-cell"],[1,"muted"],[1,"actions"],["nz-button","","nzType","link",3,"routerLink"],["nz-button","","nzType","link","type","button",3,"click"],["nz-button","","nzType","link","nzDanger","","type","button","nz-popconfirm","",3,"nzOnConfirm","nzPopconfirmTitle","nzOkText","nzCancelText"]],template:function(i,a){if(i&1){let u=FD();_i(0,"main",1)(1,"header",2)(2,"h1"),Iw(3),Pw(4,"transloco"),Jc(),_i(5,"div",3)(6,"input",4,0),mh("change",function(X){return a.onImportFile(X)}),Jc(),_i(8,"button",5),mh("click",function(){Fu(u);let X=QD(7);return ju(X.click())}),Iw(9),Pw(10,"transloco"),Jc(),_i(11,"button",6),mh("click",function(){return a.downloadInstructions()}),Iw(12),Pw(13,"transloco"),Jc(),_i(14,"button",7),mh("click",function(){return a.openLibrary()}),Iw(15),Pw(16,"transloco"),Jc(),_i(17,"button",8),mh("click",function(){return a.openCreateWithAi()}),Iw(18),Pw(19,"transloco"),Jc(),_i(20,"a",9),Iw(21),Pw(22,"transloco"),Jc()()(),_D(23,le,2,1,"p",10),_D(24,se,3,3,"p",11)(25,pe,2,1,"p",12)(26,xe,10,6),Jc();}i&2&&(gI(3),Lh(Fw(4,9,"workflows.list.title")),gI(5),lh("disabled",a.importing()),gI(),rl$1(" ",Fw(10,11,"workflows.list.import")," "),gI(3),rl$1(" ",Fw(13,13,"workflows.list.downloadInstructions")," "),gI(3),rl$1(" ",Fw(16,15,"workflows.list.browseLibrary")," "),gI(3),rl$1(" ",Fw(19,17,"workflows.list.createWithAi")," "),gI(3),rl$1(" ",Fw(22,19,"workflows.list.createButton")," "),gI(2),MD(a.actionError()?23:-1),gI(),MD(a.loading()?24:a.loadError()?25:26));},dependencies:[$8,al,rl,$i,v3,pf,bd,sp,fp,ts,_n,Cn,ex,Fm,Am,pc,as,dc,Kl,cc,Ji,ls,W,I,Kt$1],styles:[".list-page[_ngcontent-%COMP%]{padding:1.25rem 1.5rem 3rem;display:flex;flex-direction:column;gap:1rem}.header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start}.header-actions[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;flex-shrink:0;justify-content:flex-end}.field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem;max-width:16rem}.field[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.85rem;color:#57534e}.muted[_ngcontent-%COMP%]{color:#a8a29e;font-style:italic}.empty[_ngcontent-%COMP%]{text-align:center;padding:2.5rem 1rem;border:1px dashed #d6d3d1;background:#fff9}.empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 1rem;color:#57534e}.empty-actions[_ngcontent-%COMP%]{display:flex;justify-content:center;flex-wrap:wrap;gap:.75rem}.error[_ngcontent-%COMP%]{color:#9f1239}.actions[_ngcontent-%COMP%]{white-space:nowrap}[_nghost-%COMP%] td.description-cell{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;text-overflow:unset;max-width:28rem;vertical-align:top}[_nghost-%COMP%] .ant-table-tbody>tr>td{white-space:normal;vertical-align:top}"]});}}return e})();export{Fi as WorkflowListComponent,Fi as WorkflowsManageComponent};