@whoz-oss/coday-client 3.10.0 → 3.12.0

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 (77) hide show
  1. package/browser/{chunk-DyD311Os.js → chunk-2R-L-8TB.js} +1 -1
  2. package/browser/{chunk-EUKNlco8.js → chunk-B64oBHQ_.js} +1 -1
  3. package/browser/{chunk-YSBUI5Fn.js → chunk-B6GXI9z-.js} +1 -1
  4. package/browser/{chunk-Cksl5AD8.js → chunk-B9IQiMog.js} +1 -1
  5. package/browser/{chunk-8Uub9JWj.js → chunk-BESIk8ll.js} +6 -6
  6. package/browser/{chunk-Cm1-CoCU.js → chunk-BM9I1k6S.js} +1 -1
  7. package/browser/{chunk-BJzVFbX0.js → chunk-BOq6QumJ.js} +5 -5
  8. package/browser/{chunk-BdHdehhQ.js → chunk-BQ7Z34pK.js} +1 -1
  9. package/browser/{chunk-BJWqi_bR.js → chunk-BR4Pl8xo.js} +1 -1
  10. package/browser/{chunk-Bd2CH26d.js → chunk-BSY9MBD-.js} +6 -6
  11. package/browser/{chunk-CUISPpfB.js → chunk-BUALjXbx.js} +1 -1
  12. package/browser/{chunk-loSw75E5.js → chunk-BUJvZgLu.js} +1 -1
  13. package/browser/{chunk-D5aCMhSf.js → chunk-BUpmxKd8.js} +1 -1
  14. package/browser/{chunk-wlytGgOb.js → chunk-BWqySSd7.js} +1 -1
  15. package/browser/chunk-Bf1Bttqy.js +9 -0
  16. package/browser/chunk-Bsv9CCXL.js +1 -0
  17. package/browser/{chunk-Cdb2CX2Q.js → chunk-BxnUTBZC.js} +1 -1
  18. package/browser/{chunk-Bampatce.js → chunk-Bz081WAa.js} +3 -3
  19. package/browser/{chunk-CThSpKxi.js → chunk-BzcZylVP.js} +3 -3
  20. package/browser/{chunk-C6ZQFaHV.js → chunk-CCFtehVS.js} +2 -2
  21. package/browser/{chunk-Dkhotd2g.js → chunk-CCQglZL5.js} +1 -1
  22. package/browser/{chunk-DqUBpSwH.js → chunk-CGJJDRqH.js} +1 -1
  23. package/browser/{chunk-7R07nDPZ.js → chunk-CJIcHr4L.js} +1 -1
  24. package/browser/{chunk-BIM6FY9C.js → chunk-CNRDeQvk.js} +1 -1
  25. package/browser/{chunk-nhFfwaIm.js → chunk-CS_CmKL0.js} +1 -1
  26. package/browser/{chunk-DR_6ChV2.js → chunk-CSa65gP2.js} +1 -1
  27. package/browser/{chunk-BGWBjvwQ.js → chunk-CZutweoy.js} +2 -2
  28. package/browser/{chunk-TVb3vD1X.js → chunk-CaAK8DtC.js} +1 -1
  29. package/browser/{chunk-CiUdI8_s.js → chunk-CfO-PCnU.js} +1 -1
  30. package/browser/{chunk-DxZvzVYB.js → chunk-CkXXby9d.js} +2 -2
  31. package/browser/{chunk-BZz5YcIe.js → chunk-CkwB4YzM.js} +1 -1
  32. package/browser/{chunk-Bc0GuFnm.js → chunk-CnFhM0Nt.js} +1 -1
  33. package/browser/{chunk-DJEez-Yg.js → chunk-Co3aK_ug.js} +1 -1
  34. package/browser/chunk-Cqva3eF5.js +2 -0
  35. package/browser/{chunk-B0MWdje6.js → chunk-Cqy-kSp8.js} +1 -1
  36. package/browser/{chunk-D-WJGEwY.js → chunk-D2wlWOWp.js} +1 -1
  37. package/browser/{chunk-BJAZmQ7l.js → chunk-DEr2MMdQ.js} +1 -1
  38. package/browser/{chunk-DlBSfQiR.js → chunk-DGbegOkt.js} +1 -1
  39. package/browser/{chunk-Ba945z-E.js → chunk-DJtRPrJe.js} +1 -1
  40. package/browser/{chunk-LGfFQHFU.js → chunk-DKfZ0J0-.js} +1 -1
  41. package/browser/{chunk-B66h5RwF.js → chunk-DMo8nEUq.js} +1 -1
  42. package/browser/{chunk-Bsfux6Ph.js → chunk-DQj9SXnH.js} +1 -1
  43. package/browser/chunk-DfyXf4Lw.js +1 -0
  44. package/browser/{chunk-D7ubXpF6.js → chunk-Di5brgj6.js} +1 -1
  45. package/browser/{chunk-QtmhX0X1.js → chunk-DoW9c054.js} +1 -1
  46. package/browser/{chunk-CWKiaMQh.js → chunk-Duz7aHYs.js} +2 -2
  47. package/browser/chunk-DzSHyN8O.js +1 -0
  48. package/browser/chunk-DzXp5mWz.js +1 -0
  49. package/browser/{chunk-DLGt0phX.js → chunk-E-XRHTIB.js} +1 -1
  50. package/browser/{chunk-C516j1og.js → chunk-GHUL_MFq.js} +1 -1
  51. package/browser/{chunk-BwivPJC3.js → chunk-HHbcGqdi.js} +1 -1
  52. package/browser/{chunk-GAwnZGMd.js → chunk-Hhxvnnlp.js} +1 -1
  53. package/browser/{chunk-DbP7sgsG.js → chunk-LgALnta4.js} +2 -2
  54. package/browser/{chunk-ybjAFl7I.js → chunk-Lt-5ZOWn.js} +1 -1
  55. package/browser/{chunk-CGBTxglZ.js → chunk-MtaKFhdm.js} +1 -1
  56. package/browser/{chunk-Dvnd0JmL.js → chunk-N-tYgqQC.js} +1 -1
  57. package/browser/{chunk-CfqdY4Mw.js → chunk-NLyO0ldw.js} +1 -1
  58. package/browser/{chunk-CC3VBVuU.js → chunk-QDqqdtZx.js} +1 -1
  59. package/browser/{chunk-tOt8zs3G.js → chunk-RPuzC8Su.js} +1 -1
  60. package/browser/{chunk-DIahKei4.js → chunk-UX95uV76.js} +1 -1
  61. package/browser/{chunk-CnlsBi4s.js → chunk-Wd2dgg4g.js} +5 -5
  62. package/browser/chunk-b9_We0yK.js +1 -0
  63. package/browser/{chunk-DNFP1xT9.js → chunk-iUyWeEFy.js} +1 -1
  64. package/browser/{chunk-CIgFq37k.js → chunk-iamu8zs_.js} +1 -1
  65. package/browser/{chunk-Y92IHTQj.js → chunk-nRV2u7bW.js} +2 -2
  66. package/browser/{chunk-CjRw0M6d.js → chunk-rjkvu4Y6.js} +3 -3
  67. package/browser/index.html +1 -1
  68. package/browser/main-4SCUMPDY.js +1811 -0
  69. package/package.json +1 -1
  70. package/browser/chunk-5c_jmV57.js +0 -1
  71. package/browser/chunk-Brb8CVHb.js +0 -1
  72. package/browser/chunk-BrxgjRsW.js +0 -1
  73. package/browser/chunk-CaXQnKEW.js +0 -1
  74. package/browser/chunk-Cc8mup8X.js +0 -2
  75. package/browser/chunk-DWsrvadK.js +0 -1
  76. package/browser/chunk-MIRdYHA6.js +0 -9
  77. package/browser/main-SY6UM2GV.js +0 -1811
@@ -1 +1 @@
1
- import {A,k as kt,b as bt}from'./chunk-BJWqi_bR.js';import {S as St}from'./chunk-CjRw0M6d.js';import {E as Et,y as yt$1,G as Ge}from'./chunk-CnlsBi4s.js';import {g,G,P,U,N,p as pe$1,K as c,w as we,H as Hi,F as F$1,m as mT,b as U$1,A as Aw,h as hr,e as pr,v as vs,W as WC,j as fl,k as Ag,n as eC,q as oC,X as XE,r as Tg,t as tC,x as iC,y as Hg,C as Cg,u as ue$1,ca as _e$1,Y as x,an as ce$1,ap as Vy,l as le$1,V,o as bg,a9 as dC,aa as If,ac as mC,ab as wf,a8 as Zg,a5 as yl}from'./main-SY6UM2GV.js';import'./chunk-DxZvzVYB.js';import'./chunk-C6ZQFaHV.js';import'./chunk-Bampatce.js';import'./chunk-Bd2CH26d.js';import {y as yt,w as wt}from'./chunk-DbP7sgsG.js';var R=class n{threadState=g(U);codayService=g(Ge);threadList=F$1(this.threadState.threadList$,{initialValue:[]});selectedThread=F$1(this.threadState.selectedThread$,{initialValue:null});isThinking=F$1(this.codayService.isThinking$,{initialValue:false});inviteEvent=F$1(this.codayService.currentInviteEvent$.pipe(ue$1(t=>t?.invite===_e$1?null:t)),{initialValue:null});tasks=mT(()=>{let t=this.threadList(),e=this.selectedThread(),r=this.isThinking(),o=this.inviteEvent();return t.filter(i=>!i.parentThreadId).map(i=>{let m=!!e&&i.id===e.id;return {id:i.id,name:i.name,summary:i.summary,modifiedDate:i.modifiedDate,starring:i.starring??[],users:i.users??[],status:this.deriveStatus(i,m,r,!!o),isActive:m,worktreeProject:i.worktreeProject}}).sort((i,m)=>{let q=kt[i.status]-kt[m.status];return q!==0?q:i.modifiedDate>m.modifiedDate?-1:1})});deriveStatus(t,e,r,o){let i=Date.now()-new Date(t.modifiedDate).getTime();return t.closedByUser?"done":t.pendingInvite?"waiting-you":e?r?"in-progress":"paused":i<bt?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=g(P);threadState=g(U);destroy$=new ce$1;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(Vy(this.destroy$)).subscribe(t=>{let e=t?.name??null;e!==this.currentProject&&(this.disconnect(),e&&this.connect(e));});}connect(t,e=5e3){this.currentProject=t;let r=`/api/projects/${encodeURIComponent(t)}/event-stream`;console.log(`[PROJECT_SSE] Connecting to ${r}`),this.eventSource=new EventSource(r),this.eventSource.onmessage=o=>{try{let i=JSON.parse(o.data),m=le$1(i);if(!m)return;m instanceof V&&(console.log("[PROJECT_SSE] ThreadUpdateEvent \u2014 refreshing thread list"),this.threadState.refreshThreadList());}catch(i){console.warn("[PROJECT_SSE] Failed to parse event:",i);}},this.eventSource.onerror=()=>{this.eventSource?.readyState===EventSource.CLOSED&&(console.warn(`[PROJECT_SSE] Connection closed for ${t}, reconnecting in ${e}ms`),this.eventSource=null,setTimeout(()=>{this.currentProject===t&&this.connect(t,Math.min(e*2,6e4));},e));};}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null,console.log(`[PROJECT_SSE] Disconnected from project ${this.currentProject}`)),this.currentProject=null;}ngOnDestroy(){this.disconnect(),this.destroy$.next(),this.destroy$.complete();}static \u0275fac=function(e){return new(e||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var ce=(n,t)=>t.key,de=(n,t)=>t.status,le=(n,t)=>t.id;function pe(n,t){n&1&&bg(0,"mat-spinner",6);}function me(n,t){n&1&&(vs(0,"mat-icon"),WC(1,"add"),fl());}function ue(n,t){if(n&1&&(vs(0,"span",16),WC(1),fl()),n&2){let e=mC().$implicit,r=mC();XE(),Zg(r.filterCounts()[e.key]);}}function ge(n,t){if(n&1){let e=dC();vs(0,"button",15),Ag("click",function(){let o=If(e).$implicit,i=mC();return wf(i.setFilter(o.key))}),vs(1,"mat-icon",10),WC(2),fl(),vs(3,"span"),WC(4),fl(),eC(5,ue,2,1,"span",16),fl();}if(n&2){let e=t.$implicit,r=mC();Hg("active",r.activeFilter()===e.key),Cg("aria-selected",r.activeFilter()===e.key),XE(2),Zg(e.icon),XE(2),Zg(e.label),XE(),tC(r.filterCounts()[e.key]>0?5:-1);}}function _e(n,t){n&1&&(vs(0,"div",12),bg(1,"mat-spinner",17),vs(2,"p"),WC(3,"Loading tasks\u2026"),fl()());}function fe(n,t){if(n&1){let e=dC();vs(0,"p"),WC(1,"No tasks yet. Start your first one!"),fl(),vs(2,"button",19),Ag("click",function(){If(e);let o=mC(2);return wf(o.createTask())}),vs(3,"mat-icon"),WC(4,"add"),fl(),WC(5," New Task "),fl();}}function he(n,t){n&1&&(vs(0,"p"),WC(1,"No tasks in this category."),fl());}function ke(n,t){if(n&1&&(vs(0,"div",13)(1,"mat-icon",18),WC(2,"rocket_launch"),fl(),eC(3,fe,6,0)(4,he,2,0,"p"),fl()),n&2){let e=mC();XE(3),tC(e.activeFilter()==="all"?3:4);}}function ve(n,t){if(n&1){let e=dC();vs(0,"app-task-card",25),Ag("stopRequested",function(o){If(e);let i=mC(3);return wf(i.onStopRequested(o))})("deleteRequested",function(o){If(e);let i=mC(3);return wf(i.onDeleteRequested(o))})("starToggled",function(o){If(e);let i=mC(3);return wf(i.onStarToggled(o))})("markDoneRequested",function(o){If(e);let i=mC(3);return wf(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){If(e);let i=mC(3);return wf(i.onMarkActiveRequested(o))}),fl();}if(n&2){let e=t.$implicit;Tg("task",e);}}function Ce(n,t){if(n&1&&(vs(0,"section",20)(1,"h2",21)(2,"mat-icon",22),WC(3),fl(),WC(4),vs(5,"span",23),WC(6),fl()(),vs(7,"div",14),oC(8,ve,1,1,"app-task-card",24,le),fl()()),n&2){let e=t.$implicit;XE(3),Zg(e.icon),XE(),yl(" ",e.label," "),XE(2),Zg(e.tasks.length),XE(2),iC(e.tasks);}}function be(n,t){if(n&1&&oC(0,Ce,10,3,"section",20,de),n&2){let e=mC();iC(e.taskGroups());}}function ye(n,t){if(n&1){let e=dC();vs(0,"app-task-card",25),Ag("stopRequested",function(o){If(e);let i=mC(2);return wf(i.onStopRequested(o))})("deleteRequested",function(o){If(e);let i=mC(2);return wf(i.onDeleteRequested(o))})("starToggled",function(o){If(e);let i=mC(2);return wf(i.onStarToggled(o))})("markDoneRequested",function(o){If(e);let i=mC(2);return wf(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){If(e);let i=mC(2);return wf(i.onMarkActiveRequested(o))}),fl();}if(n&2){let e=t.$implicit;Tg("task",e);}}function xe(n,t){if(n&1&&(vs(0,"div",14),oC(1,ye,1,1,"app-task-card",24,le),fl()),n&2){let e=mC();XE(),iC(e.filteredTasks());}}var Te=[{key:"all",label:"All",icon:"grid_view"},{key:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt"},{key:"in-progress",label:"In progress",icon:"pending"},{key:"paused",label:"Paused",icon:"pause_circle"},{key:"done",label:"Done",icon:"check_circle"}],se=class n{router=g(G);projectState=g(P);threadState=g(U);threadApi=g(N);taskStatus=g(R);userService=g(pe$1);projectApi=g(c);destroyRef=g(we);_projectEventStream=g(F);filters=Te;activeFilter=Hi("all");starredOnly=Hi(false);isCreating=Hi(false);isLoadingList=F$1(this.threadState.isLoadingThreadList$,{initialValue:false});username=F$1(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=mT(()=>{let t=this.activeFilter(),e=this.username(),r=this.allTasks();return this.starredOnly()&&e&&(r=r.filter(o=>o.starring.includes(e))),t==="all"?r:r.filter(o=>o.status===t)});filterCounts=mT(()=>{let t=this.username(),e=this.allTasks();return this.starredOnly()&&t&&(e=e.filter(r=>r.starring.includes(t))),{all:e.length,"waiting-you":e.filter(r=>r.status==="waiting-you").length,"in-progress":e.filter(r=>r.status==="in-progress").length,paused:e.filter(r=>r.status==="paused").length,done:e.filter(r=>r.status==="done").length}});taskGroups=mT(()=>{let t=this.username(),e=this.allTasks();this.starredOnly()&&t&&(e=e.filter(o=>o.starring.includes(t)));let r=[{status:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt",tasks:[]},{status:"in-progress",label:"In progress",icon:"pending",tasks:[]},{status:"done",label:"Done",icon:"check_circle",tasks:[]},{status:"paused",label:"Paused",icon:"pause_circle",tasks:[]},{status:"error",label:"Error",icon:"error",tasks:[]}];for(let o of e){let i=r.find(m=>m.status===o.status);i&&i.tasks.push(o);}return r.filter(o=>o.tasks.length>0)});ngOnInit(){this.userService.fetchCurrentUser().pipe(U$1(this.destroyRef)).subscribe({error:t=>console.warn("[TASK-CONTROL] Could not fetch user:",t)});}setFilter(t){this.activeFilter.set(t);}toggleStarredFilter(){this.starredOnly.update(t=>!t);}createTask(){let t=this.projectState.getSelectedProjectId();!t||this.isCreating()||(this.isCreating.set(true),this.threadApi.createThread().pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(false),this.router.navigate(["project",t,"thread",e.thread.id]);},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(false);}}));}onStopRequested(t){this.threadApi.stopThread(t).pipe(U$1(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)});}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:e=>console.error("[TASK-CONTROL] Failed to delete thread:",e)});}onStarToggled(t){let e=this.username();if(!e)return;let r=this.allTasks().find(m=>m.id===t);if(!r)return;let o=r.starring.includes(e),i=o?this.threadApi.unstarThread(t):this.threadApi.starThread(t);this.threadState.updateStarLocal(t,!o,e),i.pipe(U$1(this.destroyRef)).subscribe({error:m=>{console.error("[TASK-CONTROL] Failed to toggle star:",m),this.threadState.refreshThreadList();}});}onMarkDoneRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadDone(e,t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as done:",r)});}onMarkActiveRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadActive(e,t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as active:",r)});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Aw({type:n,selectors:[["app-task-control"]],decls:25,vars:6,consts:[[1,"task-control"],[1,"tc-header"],[1,"tc-title-row"],[1,"tc-title"],[1,"title-icon"],["mat-flat-button","","aria-label","Start a new task",1,"new-task-btn",3,"click","disabled"],["diameter","16"],["role","tablist","aria-label","Filter tasks",1,"tc-filters"],["role","tab",1,"filter-chip",3,"active"],["role","switch","aria-label","Show starred tasks only",1,"filter-chip","starred-filter",3,"click"],[1,"filter-icon"],[1,"tc-grid-wrapper"],[1,"tc-loading"],[1,"tc-empty"],[1,"tc-grid"],["role","tab",1,"filter-chip",3,"click"],[1,"filter-badge"],["diameter","40"],[1,"empty-icon"],["mat-flat-button","",1,"new-task-btn",3,"click"],[1,"tc-group"],[1,"tc-group-title"],[1,"group-icon"],[1,"group-count"],[3,"task"],[3,"stopRequested","deleteRequested","starToggled","markDoneRequested","markActiveRequested","task"]],template:function(e,r){e&1&&(vs(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),WC(6,"rocket_launch"),fl(),WC(7," Task Control "),fl(),vs(8,"button",5),Ag("click",function(){return r.createTask()}),eC(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),WC(11," New Task "),fl()(),vs(12,"nav",7),oC(13,ge,6,6,"button",8,ce),vs(15,"button",9),Ag("click",function(){return r.toggleStarredFilter()}),vs(16,"mat-icon",10),WC(17,"star"),fl(),vs(18,"span"),WC(19,"Starred"),fl()()()(),vs(20,"main",11),eC(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),fl()()()),e&2&&(XE(8),Tg("disabled",r.isCreating()),XE(),tC(r.isCreating()?9:10),XE(4),iC(r.filters),XE(2),Hg("active",r.starredOnly()),Cg("aria-checked",r.starredOnly()),XE(6),tC(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24));},dependencies:[A,St,yt,wt,hr,pr,Et,yt$1],styles:[".glass-panel[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow)}.glass-interactive[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-interactive[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-interactive[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-card[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);border-radius:20px;padding:1.5rem}.glass-button[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-button[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-button[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-button[_ngcontent-%COMP%]{border-radius:12px;padding:.75rem 1.5rem;font-weight:600;cursor:pointer}.glass-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed;transform:none}.glass-button[_ngcontent-%COMP%]:disabled:hover{transform:none}.smooth-theme-transition[_ngcontent-%COMP%]{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden}.task-control[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;overflow:hidden;padding:1.5rem;gap:1.25rem;box-sizing:border-box}.tc-header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;flex-shrink:0}.tc-title-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:1rem}.tc-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text)}.tc-title[_ngcontent-%COMP%] .title-icon[_ngcontent-%COMP%]{font-size:1.5rem;width:1.5rem;height:1.5rem;color:var(--color-primary)}.new-task-btn[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;background:var(--color-primary);color:var(--color-text-inverse);border-radius:12px;font-weight:600;padding:0 1rem;height:36px;flex-shrink:0}.new-task-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.1rem;width:1.1rem;height:1.1rem}.new-task-btn[_ngcontent-%COMP%] mat-spinner[_ngcontent-%COMP%]{display:inline-block}.tc-filters[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-wrap:wrap}.filter-chip[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);display:flex;align-items:center;gap:.375rem;padding:.375rem .875rem;border-radius:100px;font-size:.8rem;font-weight:500;color:var(--color-text-secondary);cursor:pointer;border:1px solid var(--color-border);transition:background .15s ease,color .15s ease,border-color .15s ease;white-space:nowrap}.filter-chip[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{font-size:.9rem;width:.9rem;height:.9rem}.filter-chip[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-radius:100px;padding:0 .375rem;font-size:.7rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.filter-chip.active[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-color:var(--color-primary)}.filter-chip.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:var(--color-text-inverse)}.filter-chip.active[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:#ffffff4d;color:var(--color-text-inverse)}.filter-chip[_ngcontent-%COMP%]:hover:not(.active){background:var(--color-bg-hover);color:var(--color-text)}.starred-filter.active[_ngcontent-%COMP%]{background:#f5a62326;border-color:#f5a623;color:#f5a623}.starred-filter.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:#f5a623}.tc-group[_ngcontent-%COMP%]{margin-bottom:1.5rem}.tc-group[_ngcontent-%COMP%]:last-child{margin-bottom:0}.tc-group-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:.85rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.05em}.tc-group-title[_ngcontent-%COMP%] .group-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.tc-group-title[_ngcontent-%COMP%] .group-count[_ngcontent-%COMP%]{background:var(--color-bg-hover);border-radius:100px;padding:0 .375rem;font-size:.75rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.tc-grid-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--color-border) transparent}.tc-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem;padding-bottom:1rem}@media(max-width:600px){.tc-grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.tc-loading[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;height:100%;min-height:240px;color:var(--color-text-secondary);text-align:center}.tc-loading[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:.95rem}.empty-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;opacity:.3}"]})};export{se as TaskControlComponent};
1
+ import {A,k as kt,b as bt}from'./chunk-BR4Pl8xo.js';import {S as St}from'./chunk-rjkvu4Y6.js';import {E as Et,y as yt$1,G as Ge}from'./chunk-Wd2dgg4g.js';import {g,G,P,U,N,p as pe$1,Q as c,w as we,z as zi,F as F$1,y as yT,c as U$1,h as Rw,i as hr,j as pr,I as Is,q as qC,m as pl,A as Ag,t as tC,o as iC,J as JE,T as Tg,v as nC,x as sC,H as Hg,C as Cg,u as ue$1,ca as _e$1,Y as x,an as ce$1,ap as Vy,l as le$1,V,n as bg,a9 as fC,aa as If,ac as yC,ab as wf,a8 as Zg,a5 as vl}from'./main-4SCUMPDY.js';import'./chunk-CkXXby9d.js';import'./chunk-CCFtehVS.js';import'./chunk-Bz081WAa.js';import'./chunk-BSY9MBD-.js';import {y as yt,w as wt}from'./chunk-LgALnta4.js';var R=class n{threadState=g(U);codayService=g(Ge);threadList=F$1(this.threadState.threadList$,{initialValue:[]});selectedThread=F$1(this.threadState.selectedThread$,{initialValue:null});isThinking=F$1(this.codayService.isThinking$,{initialValue:false});inviteEvent=F$1(this.codayService.currentInviteEvent$.pipe(ue$1(t=>t?.invite===_e$1?null:t)),{initialValue:null});tasks=yT(()=>{let t=this.threadList(),e=this.selectedThread(),r=this.isThinking(),o=this.inviteEvent();return t.filter(i=>!i.parentThreadId).map(i=>{let m=!!e&&i.id===e.id;return {id:i.id,name:i.name,summary:i.summary,modifiedDate:i.modifiedDate,starring:i.starring??[],users:i.users??[],status:this.deriveStatus(i,m,r,!!o),isActive:m,worktreeProject:i.worktreeProject}}).sort((i,m)=>{let q=kt[i.status]-kt[m.status];return q!==0?q:i.modifiedDate>m.modifiedDate?-1:1})});deriveStatus(t,e,r,o){let i=Date.now()-new Date(t.modifiedDate).getTime();return t.closedByUser?"done":t.pendingInvite?"waiting-you":e?r?"in-progress":"paused":i<bt?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=g(P);threadState=g(U);destroy$=new ce$1;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(Vy(this.destroy$)).subscribe(t=>{let e=t?.name??null;e!==this.currentProject&&(this.disconnect(),e&&this.connect(e));});}connect(t,e=5e3){this.currentProject=t;let r=`/api/projects/${encodeURIComponent(t)}/event-stream`;console.log(`[PROJECT_SSE] Connecting to ${r}`),this.eventSource=new EventSource(r),this.eventSource.onmessage=o=>{try{let i=JSON.parse(o.data),m=le$1(i);if(!m)return;m instanceof V&&(console.log("[PROJECT_SSE] ThreadUpdateEvent \u2014 refreshing thread list"),this.threadState.refreshThreadList());}catch(i){console.warn("[PROJECT_SSE] Failed to parse event:",i);}},this.eventSource.onerror=()=>{this.eventSource?.readyState===EventSource.CLOSED&&(console.warn(`[PROJECT_SSE] Connection closed for ${t}, reconnecting in ${e}ms`),this.eventSource=null,setTimeout(()=>{this.currentProject===t&&this.connect(t,Math.min(e*2,6e4));},e));};}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null,console.log(`[PROJECT_SSE] Disconnected from project ${this.currentProject}`)),this.currentProject=null;}ngOnDestroy(){this.disconnect(),this.destroy$.next(),this.destroy$.complete();}static \u0275fac=function(e){return new(e||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var ce=(n,t)=>t.key,de=(n,t)=>t.status,le=(n,t)=>t.id;function pe(n,t){n&1&&bg(0,"mat-spinner",6);}function me(n,t){n&1&&(Is(0,"mat-icon"),qC(1,"add"),pl());}function ue(n,t){if(n&1&&(Is(0,"span",16),qC(1),pl()),n&2){let e=yC().$implicit,r=yC();JE(),Zg(r.filterCounts()[e.key]);}}function ge(n,t){if(n&1){let e=fC();Is(0,"button",15),Ag("click",function(){let o=If(e).$implicit,i=yC();return wf(i.setFilter(o.key))}),Is(1,"mat-icon",10),qC(2),pl(),Is(3,"span"),qC(4),pl(),tC(5,ue,2,1,"span",16),pl();}if(n&2){let e=t.$implicit,r=yC();Hg("active",r.activeFilter()===e.key),Cg("aria-selected",r.activeFilter()===e.key),JE(2),Zg(e.icon),JE(2),Zg(e.label),JE(),nC(r.filterCounts()[e.key]>0?5:-1);}}function _e(n,t){n&1&&(Is(0,"div",12),bg(1,"mat-spinner",17),Is(2,"p"),qC(3,"Loading tasks\u2026"),pl()());}function fe(n,t){if(n&1){let e=fC();Is(0,"p"),qC(1,"No tasks yet. Start your first one!"),pl(),Is(2,"button",19),Ag("click",function(){If(e);let o=yC(2);return wf(o.createTask())}),Is(3,"mat-icon"),qC(4,"add"),pl(),qC(5," New Task "),pl();}}function he(n,t){n&1&&(Is(0,"p"),qC(1,"No tasks in this category."),pl());}function ke(n,t){if(n&1&&(Is(0,"div",13)(1,"mat-icon",18),qC(2,"rocket_launch"),pl(),tC(3,fe,6,0)(4,he,2,0,"p"),pl()),n&2){let e=yC();JE(3),nC(e.activeFilter()==="all"?3:4);}}function ve(n,t){if(n&1){let e=fC();Is(0,"app-task-card",25),Ag("stopRequested",function(o){If(e);let i=yC(3);return wf(i.onStopRequested(o))})("deleteRequested",function(o){If(e);let i=yC(3);return wf(i.onDeleteRequested(o))})("starToggled",function(o){If(e);let i=yC(3);return wf(i.onStarToggled(o))})("markDoneRequested",function(o){If(e);let i=yC(3);return wf(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){If(e);let i=yC(3);return wf(i.onMarkActiveRequested(o))}),pl();}if(n&2){let e=t.$implicit;Tg("task",e);}}function Ce(n,t){if(n&1&&(Is(0,"section",20)(1,"h2",21)(2,"mat-icon",22),qC(3),pl(),qC(4),Is(5,"span",23),qC(6),pl()(),Is(7,"div",14),iC(8,ve,1,1,"app-task-card",24,le),pl()()),n&2){let e=t.$implicit;JE(3),Zg(e.icon),JE(),vl(" ",e.label," "),JE(2),Zg(e.tasks.length),JE(2),sC(e.tasks);}}function be(n,t){if(n&1&&iC(0,Ce,10,3,"section",20,de),n&2){let e=yC();sC(e.taskGroups());}}function ye(n,t){if(n&1){let e=fC();Is(0,"app-task-card",25),Ag("stopRequested",function(o){If(e);let i=yC(2);return wf(i.onStopRequested(o))})("deleteRequested",function(o){If(e);let i=yC(2);return wf(i.onDeleteRequested(o))})("starToggled",function(o){If(e);let i=yC(2);return wf(i.onStarToggled(o))})("markDoneRequested",function(o){If(e);let i=yC(2);return wf(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){If(e);let i=yC(2);return wf(i.onMarkActiveRequested(o))}),pl();}if(n&2){let e=t.$implicit;Tg("task",e);}}function xe(n,t){if(n&1&&(Is(0,"div",14),iC(1,ye,1,1,"app-task-card",24,le),pl()),n&2){let e=yC();JE(),sC(e.filteredTasks());}}var Te=[{key:"all",label:"All",icon:"grid_view"},{key:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt"},{key:"in-progress",label:"In progress",icon:"pending"},{key:"paused",label:"Paused",icon:"pause_circle"},{key:"done",label:"Done",icon:"check_circle"}],se=class n{router=g(G);projectState=g(P);threadState=g(U);threadApi=g(N);taskStatus=g(R);userService=g(pe$1);projectApi=g(c);destroyRef=g(we);_projectEventStream=g(F);filters=Te;activeFilter=zi("all");starredOnly=zi(false);isCreating=zi(false);isLoadingList=F$1(this.threadState.isLoadingThreadList$,{initialValue:false});username=F$1(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=yT(()=>{let t=this.activeFilter(),e=this.username(),r=this.allTasks();return this.starredOnly()&&e&&(r=r.filter(o=>o.starring.includes(e))),t==="all"?r:r.filter(o=>o.status===t)});filterCounts=yT(()=>{let t=this.username(),e=this.allTasks();return this.starredOnly()&&t&&(e=e.filter(r=>r.starring.includes(t))),{all:e.length,"waiting-you":e.filter(r=>r.status==="waiting-you").length,"in-progress":e.filter(r=>r.status==="in-progress").length,paused:e.filter(r=>r.status==="paused").length,done:e.filter(r=>r.status==="done").length}});taskGroups=yT(()=>{let t=this.username(),e=this.allTasks();this.starredOnly()&&t&&(e=e.filter(o=>o.starring.includes(t)));let r=[{status:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt",tasks:[]},{status:"in-progress",label:"In progress",icon:"pending",tasks:[]},{status:"done",label:"Done",icon:"check_circle",tasks:[]},{status:"paused",label:"Paused",icon:"pause_circle",tasks:[]},{status:"error",label:"Error",icon:"error",tasks:[]}];for(let o of e){let i=r.find(m=>m.status===o.status);i&&i.tasks.push(o);}return r.filter(o=>o.tasks.length>0)});ngOnInit(){this.userService.fetchCurrentUser().pipe(U$1(this.destroyRef)).subscribe({error:t=>console.warn("[TASK-CONTROL] Could not fetch user:",t)});}setFilter(t){this.activeFilter.set(t);}toggleStarredFilter(){this.starredOnly.update(t=>!t);}createTask(){let t=this.projectState.getSelectedProjectId();!t||this.isCreating()||(this.isCreating.set(true),this.threadApi.createThread().pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(false),this.router.navigate(["project",t,"thread",e.thread.id]);},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(false);}}));}onStopRequested(t){this.threadApi.stopThread(t).pipe(U$1(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)});}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:e=>console.error("[TASK-CONTROL] Failed to delete thread:",e)});}onStarToggled(t){let e=this.username();if(!e)return;let r=this.allTasks().find(m=>m.id===t);if(!r)return;let o=r.starring.includes(e),i=o?this.threadApi.unstarThread(t):this.threadApi.starThread(t);this.threadState.updateStarLocal(t,!o,e),i.pipe(U$1(this.destroyRef)).subscribe({error:m=>{console.error("[TASK-CONTROL] Failed to toggle star:",m),this.threadState.refreshThreadList();}});}onMarkDoneRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadDone(e,t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as done:",r)});}onMarkActiveRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadActive(e,t).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as active:",r)});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Rw({type:n,selectors:[["app-task-control"]],decls:25,vars:6,consts:[[1,"task-control"],[1,"tc-header"],[1,"tc-title-row"],[1,"tc-title"],[1,"title-icon"],["mat-flat-button","","aria-label","Start a new task",1,"new-task-btn",3,"click","disabled"],["diameter","16"],["role","tablist","aria-label","Filter tasks",1,"tc-filters"],["role","tab",1,"filter-chip",3,"active"],["role","switch","aria-label","Show starred tasks only",1,"filter-chip","starred-filter",3,"click"],[1,"filter-icon"],[1,"tc-grid-wrapper"],[1,"tc-loading"],[1,"tc-empty"],[1,"tc-grid"],["role","tab",1,"filter-chip",3,"click"],[1,"filter-badge"],["diameter","40"],[1,"empty-icon"],["mat-flat-button","",1,"new-task-btn",3,"click"],[1,"tc-group"],[1,"tc-group-title"],[1,"group-icon"],[1,"group-count"],[3,"task"],[3,"stopRequested","deleteRequested","starToggled","markDoneRequested","markActiveRequested","task"]],template:function(e,r){e&1&&(Is(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),qC(6,"rocket_launch"),pl(),qC(7," Task Control "),pl(),Is(8,"button",5),Ag("click",function(){return r.createTask()}),tC(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),qC(11," New Task "),pl()(),Is(12,"nav",7),iC(13,ge,6,6,"button",8,ce),Is(15,"button",9),Ag("click",function(){return r.toggleStarredFilter()}),Is(16,"mat-icon",10),qC(17,"star"),pl(),Is(18,"span"),qC(19,"Starred"),pl()()()(),Is(20,"main",11),tC(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),pl()()()),e&2&&(JE(8),Tg("disabled",r.isCreating()),JE(),nC(r.isCreating()?9:10),JE(4),sC(r.filters),JE(2),Hg("active",r.starredOnly()),Cg("aria-checked",r.starredOnly()),JE(6),nC(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24));},dependencies:[A,St,yt,wt,hr,pr,Et,yt$1],styles:[".glass-panel[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow)}.glass-interactive[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-interactive[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-interactive[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-card[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);border-radius:20px;padding:1.5rem}.glass-button[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-button[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-button[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-button[_ngcontent-%COMP%]{border-radius:12px;padding:.75rem 1.5rem;font-weight:600;cursor:pointer}.glass-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed;transform:none}.glass-button[_ngcontent-%COMP%]:disabled:hover{transform:none}.smooth-theme-transition[_ngcontent-%COMP%]{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden}.task-control[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;overflow:hidden;padding:1.5rem;gap:1.25rem;box-sizing:border-box}.tc-header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;flex-shrink:0}.tc-title-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:1rem}.tc-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text)}.tc-title[_ngcontent-%COMP%] .title-icon[_ngcontent-%COMP%]{font-size:1.5rem;width:1.5rem;height:1.5rem;color:var(--color-primary)}.new-task-btn[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;background:var(--color-primary);color:var(--color-text-inverse);border-radius:12px;font-weight:600;padding:0 1rem;height:36px;flex-shrink:0}.new-task-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.1rem;width:1.1rem;height:1.1rem}.new-task-btn[_ngcontent-%COMP%] mat-spinner[_ngcontent-%COMP%]{display:inline-block}.tc-filters[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-wrap:wrap}.filter-chip[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);display:flex;align-items:center;gap:.375rem;padding:.375rem .875rem;border-radius:100px;font-size:.8rem;font-weight:500;color:var(--color-text-secondary);cursor:pointer;border:1px solid var(--color-border);transition:background .15s ease,color .15s ease,border-color .15s ease;white-space:nowrap}.filter-chip[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{font-size:.9rem;width:.9rem;height:.9rem}.filter-chip[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-radius:100px;padding:0 .375rem;font-size:.7rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.filter-chip.active[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-color:var(--color-primary)}.filter-chip.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:var(--color-text-inverse)}.filter-chip.active[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:#ffffff4d;color:var(--color-text-inverse)}.filter-chip[_ngcontent-%COMP%]:hover:not(.active){background:var(--color-bg-hover);color:var(--color-text)}.starred-filter.active[_ngcontent-%COMP%]{background:#f5a62326;border-color:#f5a623;color:#f5a623}.starred-filter.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:#f5a623}.tc-group[_ngcontent-%COMP%]{margin-bottom:1.5rem}.tc-group[_ngcontent-%COMP%]:last-child{margin-bottom:0}.tc-group-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:.85rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.05em}.tc-group-title[_ngcontent-%COMP%] .group-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.tc-group-title[_ngcontent-%COMP%] .group-count[_ngcontent-%COMP%]{background:var(--color-bg-hover);border-radius:100px;padding:0 .375rem;font-size:.75rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.tc-grid-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--color-border) transparent}.tc-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem;padding-bottom:1rem}@media(max-width:600px){.tc-grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.tc-loading[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;height:100%;min-height:240px;color:var(--color-text-secondary);text-align:center}.tc-loading[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:.95rem}.empty-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;opacity:.3}"]})};export{se as TaskControlComponent};
@@ -1 +1 @@
1
- import {p}from'./chunk-MIRdYHA6.js';import {g,ao as V,J as dy,d4 as m,A as Aw,aw as pl,W as WC,ax as hl,X as XE,a8 as Zg}from'./main-SY6UM2GV.js';import'./chunk-Cdb2CX2Q.js';import'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';import'./chunk-DbP7sgsG.js';var A=class r{route=g(V);http=g(dy);config=g(m);message="Authentication in progress\u2026";ngOnInit(){let e=this.route.snapshot.queryParamMap.get("code"),t=this.route.snapshot.queryParamMap.get("state"),o=this.route.snapshot.queryParamMap.get("error"),i=this.route.snapshot.queryParamMap.get("error_description");if(o){console.warn("[AgentOS OAuth Callback] OAuth error:",o,i),this.notifyParentAndClose({success:false,error:i||o});return}if(!e){console.error("[AgentOS OAuth Callback] Missing authorization code"),this.message="OAuth callback error: missing authorization code.",this.notifyParentAndClose({success:false,error:"Missing authorization code"});return}this.http.post(`${this.config.basePath}/api/oauth/callback`,{code:e,state:t}).subscribe({next:()=>{console.log("[AgentOS OAuth Callback] Backend callback resolved"),this.notifyParentAndClose({success:true});},error:a=>{console.error("[AgentOS OAuth Callback] Backend callback failed:",a),this.notifyParentAndClose({success:false,error:a?.error?.message||a?.message||"Token exchange failed"});}});}notifyParentAndClose(e){if(this.message=e.success?"Authentication complete. You can close this window.":`Authentication failed: ${e.error??"unknown error"}. You can close this window.`,window.opener)try{window.opener.postMessage(e,window.location.origin);}catch(t){console.error("[AgentOS OAuth Callback] postMessage failed:",t),localStorage.setItem(p,JSON.stringify(e));}else console.warn("[AgentOS OAuth Callback] No window.opener \u2014 localStorage fallback"),localStorage.setItem(p,JSON.stringify(e));setTimeout(()=>window.close(),1e3);}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=Aw({type:r,selectors:[["agentos-oauth-callback"]],decls:2,vars:1,consts:[[2,"font-family","sans-serif","padding","2rem","text-align","center"]],template:function(t,o){t&1&&(pl(0,"p",0),WC(1),hl()),t&2&&(XE(),Zg(o.message));},encapsulation:2,changeDetection:1})};export{A as OAuthCallbackComponent};
1
+ import {p}from'./chunk-Bf1Bttqy.js';import {g,ao as V,M as dy,d4 as m,h as Rw,aw as hl,q as qC,ax as gl,J as JE,a8 as Zg}from'./main-4SCUMPDY.js';import'./chunk-BxnUTBZC.js';import'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';import'./chunk-LgALnta4.js';var A=class r{route=g(V);http=g(dy);config=g(m);message="Authentication in progress\u2026";ngOnInit(){let e=this.route.snapshot.queryParamMap.get("code"),t=this.route.snapshot.queryParamMap.get("state"),o=this.route.snapshot.queryParamMap.get("error"),i=this.route.snapshot.queryParamMap.get("error_description");if(o){console.warn("[AgentOS OAuth Callback] OAuth error:",o,i),this.notifyParentAndClose({success:false,error:i||o});return}if(!e){console.error("[AgentOS OAuth Callback] Missing authorization code"),this.message="OAuth callback error: missing authorization code.",this.notifyParentAndClose({success:false,error:"Missing authorization code"});return}this.http.post(`${this.config.basePath}/api/oauth/callback`,{code:e,state:t}).subscribe({next:()=>{console.log("[AgentOS OAuth Callback] Backend callback resolved"),this.notifyParentAndClose({success:true});},error:a=>{console.error("[AgentOS OAuth Callback] Backend callback failed:",a),this.notifyParentAndClose({success:false,error:a?.error?.message||a?.message||"Token exchange failed"});}});}notifyParentAndClose(e){if(this.message=e.success?"Authentication complete. You can close this window.":`Authentication failed: ${e.error??"unknown error"}. You can close this window.`,window.opener)try{window.opener.postMessage(e,window.location.origin);}catch(t){console.error("[AgentOS OAuth Callback] postMessage failed:",t),localStorage.setItem(p,JSON.stringify(e));}else console.warn("[AgentOS OAuth Callback] No window.opener \u2014 localStorage fallback"),localStorage.setItem(p,JSON.stringify(e));setTimeout(()=>window.close(),1e3);}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=Rw({type:r,selectors:[["agentos-oauth-callback"]],decls:2,vars:1,consts:[[2,"font-family","sans-serif","padding","2rem","text-align","center"]],template:function(t,o){t&1&&(hl(0,"p",0),qC(1),gl()),t&2&&(JE(),Zg(o.message));},encapsulation:2,changeDetection:1})};export{A as OAuthCallbackComponent};
@@ -0,0 +1,2 @@
1
+ import {n as ne}from'./chunk-CkXXby9d.js';import {g,Z as z$1,_ as Ue,h as Rw,$ as zt,a0 as jt,a1 as Vt,a2 as Nt,i as hr,j as pr,I as Is,q as qC,m as pl,t as tC,A as Ag,J as JE,H as Hg,a5 as vl,a8 as Zg,v as nC,T as Tg,a9 as fC,ai as Jg,aa as If,ac as yC,aj as XC,ab as wf,a3 as UI,ak as Xg,a6 as zI}from'./main-4SCUMPDY.js';import {y as yt,w as wt,t as ti,Z as Zn,c as cn}from'./chunk-LgALnta4.js';function G(c,p){if(c&1){let t=fC();Is(0,"mat-checkbox",5),Jg("ngModelChange",function(l){If(t);let f=yC();return XC(f.checkboxChecked,l)||(f.checkboxChecked=l),wf(l)}),qC(1),pl(),UI();}if(c&2){let t=yC();Xg("ngModel",t.checkboxChecked),zI(),JE(),Zg(t.data.checkboxLabel);}}var z=class c{dialogRef=g(z$1);data=g(Ue);checkboxChecked=false;confirm(){this.dialogRef.close({confirmed:true,checkboxChecked:this.checkboxChecked});}cancel(){this.dialogRef.close({confirmed:false});}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=Rw({type:c,selectors:[["app-confirm-dialog"]],decls:13,vars:8,consts:[["mat-dialog-title",""],[3,"ngModel"],["align","end"],["mat-button","",3,"click"],["mat-flat-button","",3,"click","color"],[3,"ngModelChange","ngModel"]],template:function(t,e){t&1&&(Is(0,"h2",0)(1,"mat-icon"),qC(2,"warning"),pl(),qC(3),pl(),Is(4,"mat-dialog-content")(5,"p"),qC(6),pl(),tC(7,G,2,2,"mat-checkbox",1),pl(),Is(8,"mat-dialog-actions",2)(9,"button",3),Ag("click",function(){return e.cancel()}),qC(10),pl(),Is(11,"button",4),Ag("click",function(){return e.confirm()}),qC(12),pl()()),t&2&&(JE(),Hg("destructive",!!e.data.isDestructive),JE(2),vl(" ",e.data.title,`
2
+ `),JE(3),Zg(e.data.message),JE(),nC(e.data.checkboxLabel?7:-1),JE(3),Zg(e.data.cancelLabel??"Cancel"),JE(),Tg("color",e.data.isDestructive?"warn":"primary"),JE(),vl(" ",e.data.confirmLabel??"Confirm"," "));},dependencies:[zt,jt,Vt,Nt,hr,pr,yt,wt,ne,ti,Zn,cn],styles:["h2[mat-dialog-title][_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}h2[mat-dialog-title][_ngcontent-%COMP%] mat-icon.destructive[_ngcontent-%COMP%]{color:var(--color-error, #f44336)}mat-dialog-content[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:var(--color-text-secondary);line-height:1.5}mat-dialog-content[_ngcontent-%COMP%] mat-checkbox[_ngcontent-%COMP%]{display:block;margin-top:8px;font-size:.875rem}"]})};export{z};
@@ -1 +1 @@
1
- import {I}from'./chunk-EUKNlco8.js';import {g,G,w as we,de as M,dd as $,aJ as Tr,H as Hi,bS as ma,aD as Ly,u as ue,b as U,A as Aw,aK as Nb,v as vs,bf as aT,k as Ag,j as fl,af as Dg,T as TC,r as Tg,bg as uT,ah as rT,n as eC,ac as mC,t as tC,a9 as dC,aa as If,ab as wf,ag as fT}from'./main-SY6UM2GV.js';import {W as Wn,S as Se}from'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';import'./chunk-DbP7sgsG.js';var V=()=>[];function F(n,t){if(n&1){let o=dC();vs(0,"agentos-ai-model-item",4),Ag("editRequested",function(e){If(o);let s=mC(2);return wf(s.onEdit(e))})("deleteRequested",function(e){If(o);let s=mC(2);return wf(s.deleteModel(e))}),fl();}n&2&&Tg("model",t);}function O(n,t){if(n&1&&eC(0,F,1,1,"agentos-ai-model-item",3),n&2){let o,i=t.$implicit,e=mC();tC((o=e.resolveModel(i.id))?0:-1,o);}}var S=class n{router=g(G);destroyRef=g(we);aiModelController=g(M);aiProviderController=g($);refresh$=new Tr(void 0);isLoading=Hi(true);data$=this.refresh$.pipe(ma(()=>(this.isLoading.set(true),Ly([this.aiModelController.listPlatformLevelAiModel(),this.aiProviderController.listAiProvider("none")]))));modelItems$=this.data$.pipe(ue(([t,o])=>{let i=new Map(o.map(e=>[e.id??"",e.name]));return t.map(e=>({id:e.id??"",name:e.alias??e.apiModelName,description:e.apiModelName,groupKey:e.aiProviderId,groupLabel:i.get(e.aiProviderId)??e.aiProviderId}))}));modelsById=new Map;constructor(){this.data$.pipe(U(this.destroyRef)).subscribe({next:([t])=>{this.modelsById=new Map(t.map(o=>[o.id??"",o])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","admin"]);}openCreateForm(){this.router.navigate(["/agentos","admin","ai-models","new"]);}deleteModel(t){this.aiModelController.deleteAiModel(t.id??"").pipe(U(this.destroyRef)).subscribe(()=>this.refresh$.next());}onEdit(t){t.id&&this.router.navigate(["/agentos","admin","ai-models",t.id,"edit"]);}resolveModel(t){return this.modelsById.get(t)??null}static \u0275fac=function(o){return new(o||n)};static \u0275cmp=Aw({type:n,selectors:[["agentos-platform-ai-models"]],decls:5,vars:7,consts:[["aiModelItemTpl",""],["title","Platform AI Models","emptyMessage","No platform AI models defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"model"],[3,"editRequested","deleteRequested","model"]],template:function(o,i){if(o&1&&(vs(0,"ds-entity-list",1),aT(1,"async"),Ag("createRequested",function(){return i.openCreateForm()}),vs(2,"ds-icon-button",2),Ag("action",function(){return i.goBack()}),fl()(),Dg(3,O,1,1,"ng-template",null,0,fT)),o&2){let e=TC(4);Tg("items",uT(1,4,i.modelItems$)??rT(6,V))("loading",i.isLoading())("showCreate",true)("itemTemplate",e);}},dependencies:[Wn,I,Se,Nb],styles:[".platform-ai-models__back[_ngcontent-%COMP%]{background:none;border:none;cursor:pointer;font-family:inherit;font-size:.875rem;color:var(--color-text-secondary, #6e6e73);padding:.25rem .5rem;border-radius:4px;transition:color .15s ease}.platform-ai-models__back[_ngcontent-%COMP%]:hover{color:var(--color-primary, #007aff)}"]})};export{S as PlatformAiModelsComponent};
1
+ import {I}from'./chunk-B64oBHQ_.js';import {g,G,w as we,de as M,dd as $,aJ as Tr,z as zi,bS as va,aD as Ly,u as ue,c as U,h as Rw,aK as xb,I as Is,bf as cT,A as Ag,m as pl,af as Dg,r as bC,T as Tg,bg as lT,ah as oT,t as tC,ac as yC,v as nC,a9 as fC,aa as If,ab as wf,ag as pT}from'./main-4SCUMPDY.js';import {W as Wn,S as Se}from'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';import'./chunk-LgALnta4.js';var V=()=>[];function F(n,t){if(n&1){let o=fC();Is(0,"agentos-ai-model-item",4),Ag("editRequested",function(e){If(o);let s=yC(2);return wf(s.onEdit(e))})("deleteRequested",function(e){If(o);let s=yC(2);return wf(s.deleteModel(e))}),pl();}n&2&&Tg("model",t);}function O(n,t){if(n&1&&tC(0,F,1,1,"agentos-ai-model-item",3),n&2){let o,i=t.$implicit,e=yC();nC((o=e.resolveModel(i.id))?0:-1,o);}}var S=class n{router=g(G);destroyRef=g(we);aiModelController=g(M);aiProviderController=g($);refresh$=new Tr(void 0);isLoading=zi(true);data$=this.refresh$.pipe(va(()=>(this.isLoading.set(true),Ly([this.aiModelController.listPlatformLevelAiModel(),this.aiProviderController.listAiProvider("none")]))));modelItems$=this.data$.pipe(ue(([t,o])=>{let i=new Map(o.map(e=>[e.id??"",e.name]));return t.map(e=>({id:e.id??"",name:e.alias??e.apiModelName,description:e.apiModelName,groupKey:e.aiProviderId,groupLabel:i.get(e.aiProviderId)??e.aiProviderId}))}));modelsById=new Map;constructor(){this.data$.pipe(U(this.destroyRef)).subscribe({next:([t])=>{this.modelsById=new Map(t.map(o=>[o.id??"",o])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","admin"]);}openCreateForm(){this.router.navigate(["/agentos","admin","ai-models","new"]);}deleteModel(t){this.aiModelController.deleteAiModel(t.id??"").pipe(U(this.destroyRef)).subscribe(()=>this.refresh$.next());}onEdit(t){t.id&&this.router.navigate(["/agentos","admin","ai-models",t.id,"edit"]);}resolveModel(t){return this.modelsById.get(t)??null}static \u0275fac=function(o){return new(o||n)};static \u0275cmp=Rw({type:n,selectors:[["agentos-platform-ai-models"]],decls:5,vars:7,consts:[["aiModelItemTpl",""],["title","Platform AI Models","emptyMessage","No platform AI models defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"model"],[3,"editRequested","deleteRequested","model"]],template:function(o,i){if(o&1&&(Is(0,"ds-entity-list",1),cT(1,"async"),Ag("createRequested",function(){return i.openCreateForm()}),Is(2,"ds-icon-button",2),Ag("action",function(){return i.goBack()}),pl()(),Dg(3,O,1,1,"ng-template",null,0,pT)),o&2){let e=bC(4);Tg("items",lT(1,4,i.modelItems$)??oT(6,V))("loading",i.isLoading())("showCreate",true)("itemTemplate",e);}},dependencies:[Wn,I,Se,xb],styles:[".platform-ai-models__back[_ngcontent-%COMP%]{background:none;border:none;cursor:pointer;font-family:inherit;font-size:.875rem;color:var(--color-text-secondary, #6e6e73);padding:.25rem .5rem;border-radius:4px;transition:color .15s ease}.platform-ai-models__back[_ngcontent-%COMP%]:hover{color:var(--color-primary, #007aff)}"]})};export{S as PlatformAiModelsComponent};
@@ -1 +1 @@
1
- import {g,bm as Sm,R as Re,H as Hi,m as mT,A as Aw,h as hr,i as Gn,v as vs,k as Ag,W as WC,j as fl,a3 as HI,n as eC,af as Dg,ag as fT,T as TC,X as XE,r as Tg,a6 as $I,t as tC,Z as z,bl as Mt,_ as Ue$1,am as Gm,$ as zt,a0 as jt,a1 as Vt,a2 as Nt,e as pr,bn as Xt,ai as Jg,aj as KC,q as oC,bo as nC,a8 as Zg,ak as Xg,x as iC,a5 as yl,ac as mC,a9 as dC,aa as If,ab as wf,bp as gl,bq as ml,ah as rT,b4 as oT,y as Hg}from'./main-SY6UM2GV.js';import {d}from'./chunk-loSw75E5.js';import {W,k as ke,s as se}from'./chunk-C6ZQFaHV.js';import {T as Tn,S as Sn,n as nt,a as ae,l as le,c as ce}from'./chunk-Bampatce.js';import {W as Wn,o as ot,i as it,I as In,D as De,B as Be,y as ya,E as En}from'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';import {y as yt,w as wt,t as ti,Z as Zn,c as cn,Y as Ye$1,a as wt$1,m as mn,g as gt}from'./chunk-DbP7sgsG.js';function Ue(s,i){if(s&1){let e=dC();vs(0,"div",9)(1,"mat-form-field",18)(2,"mat-label"),WC(3),fl(),vs(4,"textarea",19),Jg("ngModelChange",function(r){let m=If(e).$index,D=mC();return KC(D.commands[m],r)||(D.commands[m]=r),wf(r)}),fl(),HI(),vs(5,"mat-hint"),WC(6,"Use placeholder for dynamic values"),fl()(),vs(7,"button",20),Ag("click",function(){let r=If(e).$index,m=mC();return wf(m.removeCommand(r))}),vs(8,"mat-icon"),WC(9,"delete"),fl()()();}if(s&2){let e=i.$index,t=mC();XE(3),yl("Prompt ",e+1),XE(),Xg("ngModel",t.commands[e]),$I(),XE(3),Tg("disabled",t.commands.length===1);}}function Ne(s,i){if(s&1){let e=dC();vs(0,"div",10)(1,"h3"),WC(2,"Save to"),fl(),vs(3,"div",21)(4,"label",22)(5,"input",23),Jg("ngModelChange",function(r){If(e);let m=mC();return KC(m.source,r)||(m.source=r),wf(r)}),fl(),HI(),vs(6,"div",24)(7,"div",25)(8,"span",26),WC(9,"\u{1F464}"),fl(),vs(10,"span",27),WC(11,"Local"),fl()(),vs(12,"p",28),WC(13,"Personal prompt in ~/.coday/... (not committed)"),fl()()(),vs(14,"label",22)(15,"input",29),Jg("ngModelChange",function(r){If(e);let m=mC();return KC(m.source,r)||(m.source=r),wf(r)}),fl(),HI(),vs(16,"div",24)(17,"div",25)(18,"span",26),WC(19,"\u{1F4E6}"),fl(),vs(20,"span",27),WC(21,"Project"),fl()(),vs(22,"p",28),WC(23,"Shared prompt in ./prompts/ (committable)"),fl()()()(),vs(24,"p",30),WC(25,"Storage location is permanent and cannot be changed after creation"),fl()();}if(s&2){let e=mC();XE(4),Hg("selected",e.source==="local"),XE(),Xg("ngModel",e.source),$I(),XE(9),Hg("selected",e.source==="project"),XE(),Xg("ngModel",e.source),$I();}}function je(s,i){if(s&1&&(vs(0,"div",11)(1,"h3"),WC(2,"Storage Location"),fl(),vs(3,"div",31)(4,"span",26),WC(5),fl(),vs(6,"span",27),WC(7),fl()(),vs(8,"p",30),WC(9,"Cannot be changed after creation"),fl()()),s&2){let e=mC();XE(3),Hg("badge-local",e.source==="local")("badge-project",e.source==="project"),XE(2),Zg(e.source==="local"?"\u{1F464}":"\u{1F4E6}"),XE(2),Zg(e.source==="local"?"Local":"Project");}}function qe(s,i){if(s&1){let e=dC();vs(0,"div",12)(1,"label",32)(2,"input",33),Jg("ngModelChange",function(r){If(e);let m=mC();return KC(m.webhookEnabled,r)||(m.webhookEnabled=r),wf(r)}),fl(),HI(),vs(3,"span"),WC(4,"Enable webhook"),fl()(),vs(5,"p",30),WC(6,"Enable webhook to trigger this prompt via HTTP POST"),fl()();}if(s&2){let e=mC();XE(2),Xg("ngModel",e.webhookEnabled),$I();}}function He(s,i){if(s&1){let e=dC();vs(0,"div",13)(1,"div",34)(2,"mat-icon",35),WC(3,"link"),fl(),vs(4,"h4"),WC(5,"Webhook URL"),fl()(),vs(6,"div",36)(7,"p",37),WC(8),fl(),vs(9,"button",38),Ag("click",function(){If(e);let r=mC();return wf(r.copyWebhookUrl())}),vs(10,"mat-icon"),WC(11,"content_copy"),fl(),vs(12,"span"),WC(13,"Copy URL"),fl()()(),vs(14,"p",30),WC(15,"Use this URL to trigger the prompt via HTTP POST"),fl()();}if(s&2){let e=mC();XE(8),Zg(e.getWebhookUrl());}}function Ye(s,i){if(s&1&&(vs(0,"div",14)(1,"mat-icon"),WC(2,"error"),fl(),vs(3,"span"),WC(4),fl()()),s&2){let e=mC();XE(4),Zg(e.errorMessage);}}var S=class s{promptApi=g(d);dialogRef=g(z);configApi=g(W);snackBar=g(Mt);name="";description="";commands=[""];webhookEnabled=false;threadLifetime="";source="local";isSaving=false;errorMessage="";isAdmin=false;isEditMode=false;promptId="";data=g(Ue$1);constructor(){this.isEditMode=this.data.mode==="edit";}ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin=i.groups?.includes("CODAY_ADMIN")??false;},error:i=>{console.error("[PROMPT_FORM] Error loading user config:",i),this.isAdmin=false;}}),this.isEditMode&&this.data.prompt&&(this.promptId=this.data.prompt.id,this.name=this.data.prompt.name,this.description=this.data.prompt.description,this.commands=[...this.data.prompt.commands],this.webhookEnabled=this.data.prompt.webhookEnabled,this.source=this.data.prompt.source);}addCommand(){this.commands.push("");}removeCommand(i){this.commands.length>1&&this.commands.splice(i,1);}trackByIndex(i){return i}normalizeName(){this.name=this.name.replace(/[\s_.,;:!?()[\]{}]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase();}validateForm(){return this.name.trim()?this.description.trim()?this.commands.filter(e=>e.trim()).length===0?(this.errorMessage="At least one command is required",false):true:(this.errorMessage="Description is required",false):(this.errorMessage="Name is required",false)}save(){if(this.errorMessage="",!this.validateForm())return;let i=this.commands.filter(e=>e.trim());if(this.isSaving=true,this.isEditMode&&this.data.prompt){let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled};this.promptApi.updatePrompt(this.data.prompt.id,e).subscribe({next:()=>{this.isSaving=false,this.dialogRef.close(true);},error:t=>{console.error("Error updating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to update prompt",this.isSaving=false;}});}else {let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled,source:this.source};this.promptApi.createPrompt(e).subscribe({next:()=>{this.isSaving=false,this.dialogRef.close(true);},error:t=>{console.error("Error creating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to create prompt",this.isSaving=false;}});}}cancel(){this.dialogRef.close(false);}getWebhookUrl(){return `${window.location.origin}/api/webhooks/${this.promptId}/execute`}copyWebhookUrl(){if(!this.webhookEnabled){this.snackBar.open("Webhook is not enabled","Close",{duration:3e3});return}if(!this.promptId){this.snackBar.open("Prompt must be saved before getting webhook URL","Close",{duration:3e3});return}let i=this.getWebhookUrl();navigator.clipboard.writeText(i).then(()=>{this.snackBar.open("Webhook URL copied to clipboard!","Close",{duration:3e3});}).catch(e=>{console.error("Failed to copy webhook URL:",e),this.snackBar.open("Failed to copy URL","Close",{duration:3e3});});}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=Aw({type:s,selectors:[["app-prompt-form"]],decls:36,vars:11,consts:[["mat-dialog-title",""],[1,"form-container"],["appearance","outline",1,"full-width"],["matInput","","placeholder","my-prompt","required","",3,"ngModelChange","blur","ngModel"],["matInput","","placeholder","What does this prompt do?","rows","3","required","",3,"ngModelChange","ngModel"],[1,"commands-section"],[1,"section-header"],["mat-icon-button","","type","button","title","Add command",3,"click"],[1,"commands-list"],[1,"command-item"],[1,"source-section"],[1,"source-display"],[1,"webhook-section"],[1,"webhook-url-section"],[1,"error-message"],["align","end"],["mat-button","",3,"click","disabled"],["mat-raised-button","","color","primary",3,"click","disabled"],["appearance","outline",1,"command-field"],["matInput","","placeholder","Enter command with placeholders like \\{\\{key\\}\\}","rows","2",3,"ngModelChange","ngModel"],["mat-icon-button","","type","button","title","Remove command",1,"remove-btn",3,"click","disabled"],[1,"source-options"],[1,"source-option"],["type","radio","name","source","value","local",3,"ngModelChange","ngModel"],[1,"source-content"],[1,"source-header"],[1,"source-icon"],[1,"source-label"],[1,"source-description"],["type","radio","name","source","value","project",3,"ngModelChange","ngModel"],[1,"hint"],[1,"source-badge"],[1,"checkbox-label"],["type","checkbox",3,"ngModelChange","ngModel"],[1,"webhook-url-header"],[1,"webhook-icon"],[1,"webhook-url-content"],[1,"url-text"],["mat-raised-button","","color","accent","type","button",3,"click"]],template:function(e,t){e&1&&(vs(0,"h2",0),WC(1),fl(),vs(2,"mat-dialog-content")(3,"div",1)(4,"mat-form-field",2)(5,"mat-label"),WC(6,"Name"),fl(),vs(7,"input",3),Jg("ngModelChange",function(m){return KC(t.name,m)||(t.name=m),m}),Ag("blur",function(){return t.normalizeName()}),fl(),HI(),vs(8,"mat-hint"),WC(9,"A descriptive name (spaces and punctuation will be replaced with hyphens), will be used as command name"),fl()(),vs(10,"mat-form-field",2)(11,"mat-label"),WC(12,"Description"),fl(),vs(13,"textarea",4),Jg("ngModelChange",function(m){return KC(t.description,m)||(t.description=m),m}),fl(),HI(),vs(14,"mat-hint"),WC(15,"Explain the purpose of this prompt, helps for searchability"),fl()(),vs(16,"div",5)(17,"div",6)(18,"h3"),WC(19,"Prompts"),fl(),vs(20,"button",7),Ag("click",function(){return t.addCommand()}),vs(21,"mat-icon"),WC(22,"add"),fl()()(),vs(23,"div",8),oC(24,Ue,10,3,"div",9,nC),fl()(),eC(26,Ne,26,6,"div",10),eC(27,je,10,6,"div",11),eC(28,qe,7,1,"div",12),eC(29,He,16,1,"div",13),eC(30,Ye,5,1,"div",14),fl()(),vs(31,"mat-dialog-actions",15)(32,"button",16),Ag("click",function(){return t.cancel()}),WC(33,"Cancel"),fl(),vs(34,"button",17),Ag("click",function(){return t.save()}),WC(35),fl()()),e&2&&(XE(),Zg(t.isEditMode?"Edit Prompt":"Create Prompt"),XE(6),Xg("ngModel",t.name),$I(),XE(6),Xg("ngModel",t.description),$I(),XE(11),iC(t.commands),XE(2),tC(t.isEditMode?-1:26),XE(),tC(t.isEditMode?27:-1),XE(),tC(t.isAdmin?28:-1),XE(),tC(t.isEditMode&&t.webhookEnabled&&t.isAdmin?29:-1),XE(),tC(t.errorMessage?30:-1),XE(2),Tg("disabled",t.isSaving),XE(2),Tg("disabled",t.isSaving),XE(),yl(" ",t.isSaving?"Saving...":"Save"," "));},dependencies:[Gm,ti,Ye$1,wt$1,mn,Zn,gt,cn,zt,jt,Vt,Nt,hr,pr,Gn,Tn,Sn,nt,ae,le,ce,yt,wt,Xt],styles:[".form-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:0;min-width:500px}@media(max-width:768px){.form-container[_ngcontent-%COMP%]{min-width:auto}}.full-width[_ngcontent-%COMP%]{width:100%}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:.5rem}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.commands-section[_ngcontent-%COMP%] .commands-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .command-field[_ngcontent-%COMP%]{flex:1}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]{margin-top:8px}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.webhook-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:18px;height:18px;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:.95rem}.webhook-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.85rem;color:var(--color-text-secondary)}.webhook-url-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.75rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] .webhook-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;margin-bottom:.5rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] .url-text[_ngcontent-%COMP%]{flex:1;margin:0;padding:.75rem;background:var(--color-bg);border:1px solid var(--color-border);border-radius:4px;font-family:monospace;font-size:.85rem;word-break:break-all;color:var(--color-text)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{white-space:nowrap;display:flex;align-items:center;gap:.5rem}.webhook-url-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary)}.error-message[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:#f443361a;border:1px solid var(--color-error);border-radius:4px;color:var(--color-error)}.error-message[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.error-message[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 1rem;font-size:1rem;font-weight:600}.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{display:flex;gap:1rem;margin-bottom:.75rem}@media(max-width:768px){.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{flex-direction:column}}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:var(--color-bg);border:2px solid var(--color-border);border-radius:8px;cursor:pointer;transition:all .2s ease}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]:hover{border-color:var(--color-primary);background:var(--color-bg-hover)}.source-section[_ngcontent-%COMP%] .source-option.selected[_ngcontent-%COMP%]{border-color:var(--color-primary);background:var(--color-bg-hover);box-shadow:0 0 0 1px var(--color-primary)}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin-top:2px;cursor:pointer}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.25rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-label[_ngcontent-%COMP%]{font-weight:600;font-size:.95rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-description[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.thread-lifetime-disabled[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:#2196f30d;border:1px solid rgba(33,150,243,.2);border-radius:8px;margin-bottom:1rem}.thread-lifetime-disabled[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#2196f3cc;font-size:1.25rem;width:1.25rem;height:1.25rem;margin-top:2px}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;flex:1}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:.95rem;color:var(--color-text)}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{display:block;margin-top:.25rem;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-display[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-display[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:1rem;font-weight:600}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;padding:.5rem 1rem;border-radius:6px;font-size:.9rem;font-weight:500;margin-bottom:.5rem}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.1rem}.source-display[_ngcontent-%COMP%] .source-badge.badge-local[_ngcontent-%COMP%]{background:#2196f31a;color:#2196f3;border:1px solid rgba(33,150,243,.3)}.source-display[_ngcontent-%COMP%] .source-badge.badge-project[_ngcontent-%COMP%]{background:#4caf501a;color:#4caf50;border:1px solid rgba(76,175,80,.3)}.source-display[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}"],changeDetection:1})};var Ge=()=>[],Ke=s=>({id:s});function Je(s,i){if(s&1&&(vs(0,"div",6),WC(1),fl()),s&2){let e=mC();XE(),Zg(e.errorMessage());}}function Qe(s,i){if(s&1){let e=dC();vs(0,"ds-entity-card",8),Ag("selected",function(r){If(e);let m=mC();return wf(m.onEdit(r))}),gl(1,9),vs(2,"button",10),Ag("click",function(r){return r.stopPropagation()}),vs(3,"mat-icon"),WC(4,"more_vert"),fl()(),ml(),fl();}if(s&2){let e=i.$implicit;mC();let t=TC(11);Tg("id",e.id)("name",e.name)("description",e.description)("badges",e.badges??rT(6,Ge)),XE(2),Tg("matMenuTriggerFor",t)("matMenuTriggerData",oT(7,Ke,e.id));}}function Xe(s,i){if(s&1){let e=dC();vs(0,"button",11),Ag("click",function(){If(e);let r=mC().id,m=mC();return wf(m.onToggleWebhook(r))}),vs(1,"mat-icon"),WC(2),fl(),WC(3),fl();}if(s&2){let e=mC().id,t=mC();XE(2),Zg(t.isWebhookEnabled(e)?"link_off":"link"),XE(),yl(" ",t.isWebhookEnabled(e)?"Disable webhook":"Enable webhook"," ");}}function Ze(s,i){if(s&1){let e=dC();vs(0,"button",11),Ag("click",function(){let r=If(e).id,m=mC();return wf(m.onEdit(r))}),vs(1,"mat-icon"),WC(2,"edit"),fl(),WC(3," Edit "),fl(),eC(4,Xe,4,2,"button",12),vs(5,"button",13),Ag("click",function(){let r=If(e).id,m=mC();return wf(m.onDelete(r))}),vs(6,"mat-icon"),WC(7,"delete"),fl(),WC(8," Delete "),fl();}if(s&2){let e=mC();XE(4),tC(e.isAdmin()?4:-1);}}var Le="system",Ie=class s{promptApi=g(d);configApi=g(W);location=g(Sm);dialog=g(Re);prompts=Hi([]);isLoading=Hi(false);errorMessage=Hi(null);showOnlyMine=Hi(true);isAdmin=Hi(false);currentUsername=Hi("");promptItems=mT(()=>{let i=this.prompts(),e=this.currentUsername(),r=this.showOnlyMine()&&e?i.filter(p=>this.isMyPrompt(p)):i,D=[...new Set(r.map(p=>p.createdBy))].sort((p,k)=>p===e&&k!==e?-1:k===e&&p!==e||p===Le?1:k===Le?-1:p.localeCompare(k)),H=[];for(let p of D){let k=p===e?`${p} (you)`:p;for(let F of r.filter(Ae=>Ae.createdBy===p))H.push({id:F.id,name:F.name,description:F.description,badges:this.buildBadges(F),groupKey:p,groupLabel:k});}return H});ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin.set(i.groups?.includes("CODAY_ADMIN")??false),this.currentUsername.set(i.username??"");},error:()=>this.isAdmin.set(false)}),this.loadPrompts();}loadPrompts(){this.isLoading.set(true),this.promptApi.listPrompts().subscribe({next:i=>{this.prompts.set(i.filter(e=>!e.id.startsWith("builtin"))),this.isLoading.set(false);},error:i=>{this.errorMessage.set(i?.error?.error??"Failed to load prompts"),this.isLoading.set(false);}});}onBack(){this.location.back();}onCreate(){this.dialog.open(S,{width:"700px",maxHeight:"90vh",data:{mode:"create"}}).afterClosed().subscribe(e=>{e&&this.loadPrompts();});}onEdit(i){this.promptApi.getPrompt(i).subscribe({next:e=>{this.dialog.open(S,{width:"700px",maxHeight:"90vh",data:{mode:"edit",prompt:e}}).afterClosed().subscribe(r=>{r&&this.loadPrompts();});},error:e=>this.errorMessage.set(e?.error?.error??"Failed to load prompt")});}onDelete(i){confirm("Are you sure you want to delete this prompt?")&&this.promptApi.deletePrompt(i).subscribe({next:()=>this.loadPrompts(),error:e=>this.errorMessage.set(e?.error?.error??"Failed to delete prompt")});}onToggleWebhook(i){let e=this.prompts().find(r=>r.id===i);if(!e)return;(e.webhookEnabled?this.promptApi.disableWebhook(i):this.promptApi.enableWebhook(i)).subscribe({next:()=>this.loadPrompts(),error:r=>this.errorMessage.set(r?.error?.error??"Failed to toggle webhook")});}isWebhookEnabled(i){return this.prompts().find(e=>e.id===i)?.webhookEnabled??false}isMyPrompt(i){let e=t=>t.replace(/[.\s]+/g,"_").toLowerCase();return e(i.createdBy)===e(this.currentUsername())}buildBadges(i){let e=[];return i.source==="local"?e.push({label:"local",variant:"info"}):e.push({label:"project",variant:"success"}),i.webhookEnabled&&e.push({label:"webhook",variant:"warning"}),e}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=Aw({type:s,selectors:[["app-prompt-list"]],decls:13,vars:6,consts:[["promptCard",""],["cardMenu","matMenu"],[1,"prompt-list-page"],["title","Prompts","cardMinWidth","320px","contentMaxWidth","1400px","searchPlaceholder","Filter prompts\u2026","emptyMessage","No prompts found.",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","mat-icon-button","","title","Back",3,"click"],["toolbar-extras","","color","primary",1,"prompt-list__mine-toggle",3,"ngModelChange","ngModel"],[1,"prompt-list__error"],["matMenuContent",""],[3,"selected","id","name","description","badges"],["dsCardActions",""],["mat-icon-button","",3,"click","matMenuTriggerFor","matMenuTriggerData"],["mat-menu-item","",3,"click"],["mat-menu-item",""],["mat-menu-item","",1,"prompt-list__delete-item",3,"click"]],template:function(e,t){if(e&1&&(vs(0,"div",2)(1,"ds-entity-list",3),Ag("createRequested",function(){return t.onCreate()}),vs(2,"button",4),Ag("click",function(){return t.onBack()}),vs(3,"mat-icon"),WC(4,"chevron_left"),fl()(),vs(5,"mat-slide-toggle",5),Ag("ngModelChange",function(m){return t.showOnlyMine.set(m)}),WC(6," Mine "),fl(),HI(),fl(),eC(7,Je,2,1,"div",6),fl(),Dg(8,Qe,5,9,"ng-template",null,0,fT),vs(10,"mat-menu",null,1),Dg(12,Ze,9,1,"ng-template",7),fl()),e&2){let r=TC(9);XE(),Tg("items",t.promptItems())("loading",t.isLoading())("showCreate",true)("itemTemplate",r),XE(4),Tg("ngModel",t.showOnlyMine()),$I(),XE(2),tC(t.errorMessage()?7:-1);}},dependencies:[Wn,ot,it,hr,Gn,yt,wt,ke,se,In,De,Be,ya,En,ti,Zn,cn],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.prompt-list__mine-toggle[_ngcontent-%COMP%]{flex-shrink:0;font-size:.875rem}.prompt-list__delete-item[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.prompt-list__delete-item[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:inherit}.prompt-list__error[_ngcontent-%COMP%]{margin:1rem auto;max-width:900px;padding:.75rem 1rem;background:#dc262614;border:1px solid rgba(220,38,38,.25);border-radius:8px;color:var(--color-error, #ff3b30);font-size:.875rem}"],changeDetection:1})};export{Ie as PromptListComponent};
1
+ import {g,bm as Sm,R as Re,z as zi,y as yT,h as Rw,i as hr,k as Gn,I as Is,A as Ag,q as qC,m as pl,a3 as UI,t as tC,af as Dg,ag as pT,r as bC,J as JE,T as Tg,a6 as zI,v as nC,Z as z,bl as Mt,_ as Ue$1,am as Gm,$ as zt,a0 as jt,a1 as Vt,a2 as Nt,j as pr,bn as Xt,ai as Jg,aj as XC,o as iC,bo as rC,a8 as Zg,ak as Xg,x as sC,a5 as vl,ac as yC,a9 as fC,aa as If,ab as wf,bp as ml,bq as yl,ah as oT,b4 as iT,H as Hg}from'./main-4SCUMPDY.js';import {d}from'./chunk-BUJvZgLu.js';import {W,k as ke,s as se}from'./chunk-CCFtehVS.js';import {T as Tn,S as Sn,n as nt,a as ae,l as le,c as ce}from'./chunk-Bz081WAa.js';import {W as Wn,o as ot,i as it,I as In,D as De,B as Be,y as ya,E as En}from'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';import {y as yt,w as wt,t as ti,Z as Zn,c as cn,Y as Ye$1,a as wt$1,m as mn,g as gt}from'./chunk-LgALnta4.js';function Ue(s,i){if(s&1){let e=fC();Is(0,"div",9)(1,"mat-form-field",18)(2,"mat-label"),qC(3),pl(),Is(4,"textarea",19),Jg("ngModelChange",function(r){let m=If(e).$index,D=yC();return XC(D.commands[m],r)||(D.commands[m]=r),wf(r)}),pl(),UI(),Is(5,"mat-hint"),qC(6,"Use placeholder for dynamic values"),pl()(),Is(7,"button",20),Ag("click",function(){let r=If(e).$index,m=yC();return wf(m.removeCommand(r))}),Is(8,"mat-icon"),qC(9,"delete"),pl()()();}if(s&2){let e=i.$index,t=yC();JE(3),vl("Prompt ",e+1),JE(),Xg("ngModel",t.commands[e]),zI(),JE(3),Tg("disabled",t.commands.length===1);}}function Ne(s,i){if(s&1){let e=fC();Is(0,"div",10)(1,"h3"),qC(2,"Save to"),pl(),Is(3,"div",21)(4,"label",22)(5,"input",23),Jg("ngModelChange",function(r){If(e);let m=yC();return XC(m.source,r)||(m.source=r),wf(r)}),pl(),UI(),Is(6,"div",24)(7,"div",25)(8,"span",26),qC(9,"\u{1F464}"),pl(),Is(10,"span",27),qC(11,"Local"),pl()(),Is(12,"p",28),qC(13,"Personal prompt in ~/.coday/... (not committed)"),pl()()(),Is(14,"label",22)(15,"input",29),Jg("ngModelChange",function(r){If(e);let m=yC();return XC(m.source,r)||(m.source=r),wf(r)}),pl(),UI(),Is(16,"div",24)(17,"div",25)(18,"span",26),qC(19,"\u{1F4E6}"),pl(),Is(20,"span",27),qC(21,"Project"),pl()(),Is(22,"p",28),qC(23,"Shared prompt in ./prompts/ (committable)"),pl()()()(),Is(24,"p",30),qC(25,"Storage location is permanent and cannot be changed after creation"),pl()();}if(s&2){let e=yC();JE(4),Hg("selected",e.source==="local"),JE(),Xg("ngModel",e.source),zI(),JE(9),Hg("selected",e.source==="project"),JE(),Xg("ngModel",e.source),zI();}}function je(s,i){if(s&1&&(Is(0,"div",11)(1,"h3"),qC(2,"Storage Location"),pl(),Is(3,"div",31)(4,"span",26),qC(5),pl(),Is(6,"span",27),qC(7),pl()(),Is(8,"p",30),qC(9,"Cannot be changed after creation"),pl()()),s&2){let e=yC();JE(3),Hg("badge-local",e.source==="local")("badge-project",e.source==="project"),JE(2),Zg(e.source==="local"?"\u{1F464}":"\u{1F4E6}"),JE(2),Zg(e.source==="local"?"Local":"Project");}}function qe(s,i){if(s&1){let e=fC();Is(0,"div",12)(1,"label",32)(2,"input",33),Jg("ngModelChange",function(r){If(e);let m=yC();return XC(m.webhookEnabled,r)||(m.webhookEnabled=r),wf(r)}),pl(),UI(),Is(3,"span"),qC(4,"Enable webhook"),pl()(),Is(5,"p",30),qC(6,"Enable webhook to trigger this prompt via HTTP POST"),pl()();}if(s&2){let e=yC();JE(2),Xg("ngModel",e.webhookEnabled),zI();}}function He(s,i){if(s&1){let e=fC();Is(0,"div",13)(1,"div",34)(2,"mat-icon",35),qC(3,"link"),pl(),Is(4,"h4"),qC(5,"Webhook URL"),pl()(),Is(6,"div",36)(7,"p",37),qC(8),pl(),Is(9,"button",38),Ag("click",function(){If(e);let r=yC();return wf(r.copyWebhookUrl())}),Is(10,"mat-icon"),qC(11,"content_copy"),pl(),Is(12,"span"),qC(13,"Copy URL"),pl()()(),Is(14,"p",30),qC(15,"Use this URL to trigger the prompt via HTTP POST"),pl()();}if(s&2){let e=yC();JE(8),Zg(e.getWebhookUrl());}}function Ye(s,i){if(s&1&&(Is(0,"div",14)(1,"mat-icon"),qC(2,"error"),pl(),Is(3,"span"),qC(4),pl()()),s&2){let e=yC();JE(4),Zg(e.errorMessage);}}var S=class s{promptApi=g(d);dialogRef=g(z);configApi=g(W);snackBar=g(Mt);name="";description="";commands=[""];webhookEnabled=false;threadLifetime="";source="local";isSaving=false;errorMessage="";isAdmin=false;isEditMode=false;promptId="";data=g(Ue$1);constructor(){this.isEditMode=this.data.mode==="edit";}ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin=i.groups?.includes("CODAY_ADMIN")??false;},error:i=>{console.error("[PROMPT_FORM] Error loading user config:",i),this.isAdmin=false;}}),this.isEditMode&&this.data.prompt&&(this.promptId=this.data.prompt.id,this.name=this.data.prompt.name,this.description=this.data.prompt.description,this.commands=[...this.data.prompt.commands],this.webhookEnabled=this.data.prompt.webhookEnabled,this.source=this.data.prompt.source);}addCommand(){this.commands.push("");}removeCommand(i){this.commands.length>1&&this.commands.splice(i,1);}trackByIndex(i){return i}normalizeName(){this.name=this.name.replace(/[\s_.,;:!?()[\]{}]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase();}validateForm(){return this.name.trim()?this.description.trim()?this.commands.filter(e=>e.trim()).length===0?(this.errorMessage="At least one command is required",false):true:(this.errorMessage="Description is required",false):(this.errorMessage="Name is required",false)}save(){if(this.errorMessage="",!this.validateForm())return;let i=this.commands.filter(e=>e.trim());if(this.isSaving=true,this.isEditMode&&this.data.prompt){let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled};this.promptApi.updatePrompt(this.data.prompt.id,e).subscribe({next:()=>{this.isSaving=false,this.dialogRef.close(true);},error:t=>{console.error("Error updating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to update prompt",this.isSaving=false;}});}else {let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled,source:this.source};this.promptApi.createPrompt(e).subscribe({next:()=>{this.isSaving=false,this.dialogRef.close(true);},error:t=>{console.error("Error creating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to create prompt",this.isSaving=false;}});}}cancel(){this.dialogRef.close(false);}getWebhookUrl(){return `${window.location.origin}/api/webhooks/${this.promptId}/execute`}copyWebhookUrl(){if(!this.webhookEnabled){this.snackBar.open("Webhook is not enabled","Close",{duration:3e3});return}if(!this.promptId){this.snackBar.open("Prompt must be saved before getting webhook URL","Close",{duration:3e3});return}let i=this.getWebhookUrl();navigator.clipboard.writeText(i).then(()=>{this.snackBar.open("Webhook URL copied to clipboard!","Close",{duration:3e3});}).catch(e=>{console.error("Failed to copy webhook URL:",e),this.snackBar.open("Failed to copy URL","Close",{duration:3e3});});}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=Rw({type:s,selectors:[["app-prompt-form"]],decls:36,vars:11,consts:[["mat-dialog-title",""],[1,"form-container"],["appearance","outline",1,"full-width"],["matInput","","placeholder","my-prompt","required","",3,"ngModelChange","blur","ngModel"],["matInput","","placeholder","What does this prompt do?","rows","3","required","",3,"ngModelChange","ngModel"],[1,"commands-section"],[1,"section-header"],["mat-icon-button","","type","button","title","Add command",3,"click"],[1,"commands-list"],[1,"command-item"],[1,"source-section"],[1,"source-display"],[1,"webhook-section"],[1,"webhook-url-section"],[1,"error-message"],["align","end"],["mat-button","",3,"click","disabled"],["mat-raised-button","","color","primary",3,"click","disabled"],["appearance","outline",1,"command-field"],["matInput","","placeholder","Enter command with placeholders like \\{\\{key\\}\\}","rows","2",3,"ngModelChange","ngModel"],["mat-icon-button","","type","button","title","Remove command",1,"remove-btn",3,"click","disabled"],[1,"source-options"],[1,"source-option"],["type","radio","name","source","value","local",3,"ngModelChange","ngModel"],[1,"source-content"],[1,"source-header"],[1,"source-icon"],[1,"source-label"],[1,"source-description"],["type","radio","name","source","value","project",3,"ngModelChange","ngModel"],[1,"hint"],[1,"source-badge"],[1,"checkbox-label"],["type","checkbox",3,"ngModelChange","ngModel"],[1,"webhook-url-header"],[1,"webhook-icon"],[1,"webhook-url-content"],[1,"url-text"],["mat-raised-button","","color","accent","type","button",3,"click"]],template:function(e,t){e&1&&(Is(0,"h2",0),qC(1),pl(),Is(2,"mat-dialog-content")(3,"div",1)(4,"mat-form-field",2)(5,"mat-label"),qC(6,"Name"),pl(),Is(7,"input",3),Jg("ngModelChange",function(m){return XC(t.name,m)||(t.name=m),m}),Ag("blur",function(){return t.normalizeName()}),pl(),UI(),Is(8,"mat-hint"),qC(9,"A descriptive name (spaces and punctuation will be replaced with hyphens), will be used as command name"),pl()(),Is(10,"mat-form-field",2)(11,"mat-label"),qC(12,"Description"),pl(),Is(13,"textarea",4),Jg("ngModelChange",function(m){return XC(t.description,m)||(t.description=m),m}),pl(),UI(),Is(14,"mat-hint"),qC(15,"Explain the purpose of this prompt, helps for searchability"),pl()(),Is(16,"div",5)(17,"div",6)(18,"h3"),qC(19,"Prompts"),pl(),Is(20,"button",7),Ag("click",function(){return t.addCommand()}),Is(21,"mat-icon"),qC(22,"add"),pl()()(),Is(23,"div",8),iC(24,Ue,10,3,"div",9,rC),pl()(),tC(26,Ne,26,6,"div",10),tC(27,je,10,6,"div",11),tC(28,qe,7,1,"div",12),tC(29,He,16,1,"div",13),tC(30,Ye,5,1,"div",14),pl()(),Is(31,"mat-dialog-actions",15)(32,"button",16),Ag("click",function(){return t.cancel()}),qC(33,"Cancel"),pl(),Is(34,"button",17),Ag("click",function(){return t.save()}),qC(35),pl()()),e&2&&(JE(),Zg(t.isEditMode?"Edit Prompt":"Create Prompt"),JE(6),Xg("ngModel",t.name),zI(),JE(6),Xg("ngModel",t.description),zI(),JE(11),sC(t.commands),JE(2),nC(t.isEditMode?-1:26),JE(),nC(t.isEditMode?27:-1),JE(),nC(t.isAdmin?28:-1),JE(),nC(t.isEditMode&&t.webhookEnabled&&t.isAdmin?29:-1),JE(),nC(t.errorMessage?30:-1),JE(2),Tg("disabled",t.isSaving),JE(2),Tg("disabled",t.isSaving),JE(),vl(" ",t.isSaving?"Saving...":"Save"," "));},dependencies:[Gm,ti,Ye$1,wt$1,mn,Zn,gt,cn,zt,jt,Vt,Nt,hr,pr,Gn,Tn,Sn,nt,ae,le,ce,yt,wt,Xt],styles:[".form-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:0;min-width:500px}@media(max-width:768px){.form-container[_ngcontent-%COMP%]{min-width:auto}}.full-width[_ngcontent-%COMP%]{width:100%}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:.5rem}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.commands-section[_ngcontent-%COMP%] .commands-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .command-field[_ngcontent-%COMP%]{flex:1}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]{margin-top:8px}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.webhook-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:18px;height:18px;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:.95rem}.webhook-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.85rem;color:var(--color-text-secondary)}.webhook-url-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.75rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] .webhook-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;margin-bottom:.5rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] .url-text[_ngcontent-%COMP%]{flex:1;margin:0;padding:.75rem;background:var(--color-bg);border:1px solid var(--color-border);border-radius:4px;font-family:monospace;font-size:.85rem;word-break:break-all;color:var(--color-text)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{white-space:nowrap;display:flex;align-items:center;gap:.5rem}.webhook-url-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary)}.error-message[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:#f443361a;border:1px solid var(--color-error);border-radius:4px;color:var(--color-error)}.error-message[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.error-message[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 1rem;font-size:1rem;font-weight:600}.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{display:flex;gap:1rem;margin-bottom:.75rem}@media(max-width:768px){.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{flex-direction:column}}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:var(--color-bg);border:2px solid var(--color-border);border-radius:8px;cursor:pointer;transition:all .2s ease}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]:hover{border-color:var(--color-primary);background:var(--color-bg-hover)}.source-section[_ngcontent-%COMP%] .source-option.selected[_ngcontent-%COMP%]{border-color:var(--color-primary);background:var(--color-bg-hover);box-shadow:0 0 0 1px var(--color-primary)}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin-top:2px;cursor:pointer}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.25rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-label[_ngcontent-%COMP%]{font-weight:600;font-size:.95rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-description[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.thread-lifetime-disabled[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:#2196f30d;border:1px solid rgba(33,150,243,.2);border-radius:8px;margin-bottom:1rem}.thread-lifetime-disabled[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#2196f3cc;font-size:1.25rem;width:1.25rem;height:1.25rem;margin-top:2px}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;flex:1}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:.95rem;color:var(--color-text)}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{display:block;margin-top:.25rem;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-display[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-display[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:1rem;font-weight:600}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;padding:.5rem 1rem;border-radius:6px;font-size:.9rem;font-weight:500;margin-bottom:.5rem}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.1rem}.source-display[_ngcontent-%COMP%] .source-badge.badge-local[_ngcontent-%COMP%]{background:#2196f31a;color:#2196f3;border:1px solid rgba(33,150,243,.3)}.source-display[_ngcontent-%COMP%] .source-badge.badge-project[_ngcontent-%COMP%]{background:#4caf501a;color:#4caf50;border:1px solid rgba(76,175,80,.3)}.source-display[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}"],changeDetection:1})};var Ge=()=>[],Ke=s=>({id:s});function Je(s,i){if(s&1&&(Is(0,"div",6),qC(1),pl()),s&2){let e=yC();JE(),Zg(e.errorMessage());}}function Qe(s,i){if(s&1){let e=fC();Is(0,"ds-entity-card",8),Ag("selected",function(r){If(e);let m=yC();return wf(m.onEdit(r))}),ml(1,9),Is(2,"button",10),Ag("click",function(r){return r.stopPropagation()}),Is(3,"mat-icon"),qC(4,"more_vert"),pl()(),yl(),pl();}if(s&2){let e=i.$implicit;yC();let t=bC(11);Tg("id",e.id)("name",e.name)("description",e.description)("badges",e.badges??oT(6,Ge)),JE(2),Tg("matMenuTriggerFor",t)("matMenuTriggerData",iT(7,Ke,e.id));}}function Xe(s,i){if(s&1){let e=fC();Is(0,"button",11),Ag("click",function(){If(e);let r=yC().id,m=yC();return wf(m.onToggleWebhook(r))}),Is(1,"mat-icon"),qC(2),pl(),qC(3),pl();}if(s&2){let e=yC().id,t=yC();JE(2),Zg(t.isWebhookEnabled(e)?"link_off":"link"),JE(),vl(" ",t.isWebhookEnabled(e)?"Disable webhook":"Enable webhook"," ");}}function Ze(s,i){if(s&1){let e=fC();Is(0,"button",11),Ag("click",function(){let r=If(e).id,m=yC();return wf(m.onEdit(r))}),Is(1,"mat-icon"),qC(2,"edit"),pl(),qC(3," Edit "),pl(),tC(4,Xe,4,2,"button",12),Is(5,"button",13),Ag("click",function(){let r=If(e).id,m=yC();return wf(m.onDelete(r))}),Is(6,"mat-icon"),qC(7,"delete"),pl(),qC(8," Delete "),pl();}if(s&2){let e=yC();JE(4),nC(e.isAdmin()?4:-1);}}var Le="system",Ie=class s{promptApi=g(d);configApi=g(W);location=g(Sm);dialog=g(Re);prompts=zi([]);isLoading=zi(false);errorMessage=zi(null);showOnlyMine=zi(true);isAdmin=zi(false);currentUsername=zi("");promptItems=yT(()=>{let i=this.prompts(),e=this.currentUsername(),r=this.showOnlyMine()&&e?i.filter(p=>this.isMyPrompt(p)):i,D=[...new Set(r.map(p=>p.createdBy))].sort((p,k)=>p===e&&k!==e?-1:k===e&&p!==e||p===Le?1:k===Le?-1:p.localeCompare(k)),H=[];for(let p of D){let k=p===e?`${p} (you)`:p;for(let F of r.filter(Ae=>Ae.createdBy===p))H.push({id:F.id,name:F.name,description:F.description,badges:this.buildBadges(F),groupKey:p,groupLabel:k});}return H});ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin.set(i.groups?.includes("CODAY_ADMIN")??false),this.currentUsername.set(i.username??"");},error:()=>this.isAdmin.set(false)}),this.loadPrompts();}loadPrompts(){this.isLoading.set(true),this.promptApi.listPrompts().subscribe({next:i=>{this.prompts.set(i.filter(e=>!e.id.startsWith("builtin"))),this.isLoading.set(false);},error:i=>{this.errorMessage.set(i?.error?.error??"Failed to load prompts"),this.isLoading.set(false);}});}onBack(){this.location.back();}onCreate(){this.dialog.open(S,{width:"700px",maxHeight:"90vh",data:{mode:"create"}}).afterClosed().subscribe(e=>{e&&this.loadPrompts();});}onEdit(i){this.promptApi.getPrompt(i).subscribe({next:e=>{this.dialog.open(S,{width:"700px",maxHeight:"90vh",data:{mode:"edit",prompt:e}}).afterClosed().subscribe(r=>{r&&this.loadPrompts();});},error:e=>this.errorMessage.set(e?.error?.error??"Failed to load prompt")});}onDelete(i){confirm("Are you sure you want to delete this prompt?")&&this.promptApi.deletePrompt(i).subscribe({next:()=>this.loadPrompts(),error:e=>this.errorMessage.set(e?.error?.error??"Failed to delete prompt")});}onToggleWebhook(i){let e=this.prompts().find(r=>r.id===i);if(!e)return;(e.webhookEnabled?this.promptApi.disableWebhook(i):this.promptApi.enableWebhook(i)).subscribe({next:()=>this.loadPrompts(),error:r=>this.errorMessage.set(r?.error?.error??"Failed to toggle webhook")});}isWebhookEnabled(i){return this.prompts().find(e=>e.id===i)?.webhookEnabled??false}isMyPrompt(i){let e=t=>t.replace(/[.\s]+/g,"_").toLowerCase();return e(i.createdBy)===e(this.currentUsername())}buildBadges(i){let e=[];return i.source==="local"?e.push({label:"local",variant:"info"}):e.push({label:"project",variant:"success"}),i.webhookEnabled&&e.push({label:"webhook",variant:"warning"}),e}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=Rw({type:s,selectors:[["app-prompt-list"]],decls:13,vars:6,consts:[["promptCard",""],["cardMenu","matMenu"],[1,"prompt-list-page"],["title","Prompts","cardMinWidth","320px","contentMaxWidth","1400px","searchPlaceholder","Filter prompts\u2026","emptyMessage","No prompts found.",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","mat-icon-button","","title","Back",3,"click"],["toolbar-extras","","color","primary",1,"prompt-list__mine-toggle",3,"ngModelChange","ngModel"],[1,"prompt-list__error"],["matMenuContent",""],[3,"selected","id","name","description","badges"],["dsCardActions",""],["mat-icon-button","",3,"click","matMenuTriggerFor","matMenuTriggerData"],["mat-menu-item","",3,"click"],["mat-menu-item",""],["mat-menu-item","",1,"prompt-list__delete-item",3,"click"]],template:function(e,t){if(e&1&&(Is(0,"div",2)(1,"ds-entity-list",3),Ag("createRequested",function(){return t.onCreate()}),Is(2,"button",4),Ag("click",function(){return t.onBack()}),Is(3,"mat-icon"),qC(4,"chevron_left"),pl()(),Is(5,"mat-slide-toggle",5),Ag("ngModelChange",function(m){return t.showOnlyMine.set(m)}),qC(6," Mine "),pl(),UI(),pl(),tC(7,Je,2,1,"div",6),pl(),Dg(8,Qe,5,9,"ng-template",null,0,pT),Is(10,"mat-menu",null,1),Dg(12,Ze,9,1,"ng-template",7),pl()),e&2){let r=bC(9);JE(),Tg("items",t.promptItems())("loading",t.isLoading())("showCreate",true)("itemTemplate",r),JE(4),Tg("ngModel",t.showOnlyMine()),zI(),JE(2),nC(t.errorMessage()?7:-1);}},dependencies:[Wn,ot,it,hr,Gn,yt,wt,ke,se,In,De,Be,ya,En,ti,Zn,cn],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.prompt-list__mine-toggle[_ngcontent-%COMP%]{flex-shrink:0;font-size:.875rem}.prompt-list__delete-item[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.prompt-list__delete-item[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:inherit}.prompt-list__error[_ngcontent-%COMP%]{margin:1rem auto;max-width:900px;padding:.75rem 1rem;background:#dc262614;border:1px solid rgba(220,38,38,.25);border-radius:8px;color:var(--color-error, #ff3b30);font-size:.875rem}"],changeDetection:1})};export{Ie as PromptListComponent};
@@ -1 +1 @@
1
- import {m}from'./chunk-MIRdYHA6.js';import {g,ao as V,G,w as we,d8 as B,H as Hi,b as U,a7 as ga,S as ha,z as z$1,a as P,A as Aw,v as vs,k as Ag,W as WC,j as fl,n as eC,X as XE,a5 as yl,a8 as Zg,t as tC,a9 as dC,o as bg,a3 as HI,q as oC,bo as nC,ac as mC,r as Tg,y as Hg,a6 as $I,x as iC,aa as If,ab as wf}from'./main-SY6UM2GV.js';import {o as z,z as ze,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,Z as Zn,l as Xn,C as Cn,E as En,p as An,q as Ct,V as Vt}from'./chunk-DbP7sgsG.js';import'./chunk-Cdb2CX2Q.js';import'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';var ne=(i,t)=>t.id;function ie(i,t){i&1&&(vs(0,"p",5),WC(1,"Loading\u2026"),fl());}function ae(i,t){i&1&&(vs(0,"span",12),WC(1,"Name is required."),fl());}function le(i,t){if(i&1&&(vs(0,"p",32),WC(1),fl(),vs(2,"span",26),WC(3,"Agent Config cannot be changed after creation."),fl()),i&2){let e=mC(3);XE(),Zg(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function me(i,t){if(i&1&&(vs(0,"option",34),WC(1),fl()),i&2){let e=t.$implicit;Tg("ngValue",e.id),XE(),Zg(e.name);}}function pe(i,t){if(i&1&&(vs(0,"select",33)(1,"option",34),WC(2,"\u2014 None \u2014"),fl(),oC(3,me,2,2,"option",34,ne),fl(),HI(),vs(5,"span",26),WC(6,"Optional. Links this prompt to an agent as a starter. Immutable after creation."),fl()),i&2){let e=mC(3);Tg("formControl",e.agentConfigIdControl),$I(),XE(),Tg("ngValue",null),XE(2),iC(e.availableAgentConfigs());}}function de(i,t){if(i&1&&(vs(0,"div",8)(1,"label",31),WC(2,"Agent Config"),fl(),eC(3,le,4,1)(4,pe,7,2),fl()),i&2){let e=mC(2);XE(3),tC(e.isEditMode()&&e.agentConfigIdControl.value?3:e.isEditMode()?-1:4);}}function ce(i,t){i&1&&(vs(0,"p",19),WC(1,"No parameters defined."),fl());}function se(i,t){i&1&&(vs(0,"span",12),WC(1,"Parameter name is required."),fl());}function _e(i,t){if(i&1){let e=dC();vs(0,"div",20)(1,"div",35)(2,"div",36)(3,"label",37),WC(4,"Name "),vs(5,"span",10),WC(6,"*"),fl()(),bg(7,"input",38),HI(),eC(8,se,2,0,"span",12),fl(),vs(9,"div",36)(10,"label",37),WC(11,"Description"),fl(),bg(12,"input",39),HI(),fl(),vs(13,"div",36)(14,"label",37),WC(15,"Default value"),fl(),bg(16,"input",40),HI(),fl()(),vs(17,"button",41),Ag("click",function(){let m=If(e).$index,d=mC(2);return wf(d.removeParameter(m))}),WC(18," \xD7 "),fl()();}if(i&2){let e=t.$implicit,l=t.$index;Tg("formGroupName",l),XE(3),Tg("for","param-name-"+l),XE(4),Hg("prompt-form__input--invalid",e.controls.name.invalid&&e.controls.name.touched),Tg("id","param-name-"+l),$I(),XE(),tC(e.controls.name.invalid&&e.controls.name.touched?8:-1),XE(2),Tg("for","param-desc-"+l),XE(2),Tg("id","param-desc-"+l),$I(),XE(2),Tg("for","param-default-"+l),XE(2),Tg("id","param-default-"+l),$I();}}function fe(i,t){i&1&&(vs(0,"span",12),WC(1,"Content entry must not be blank."),fl());}function ue(i,t){if(i&1){let e=dC();vs(0,"div",22)(1,"span",42),WC(2),fl(),vs(3,"div",43),bg(4,"textarea",44),HI(),eC(5,fe,2,0,"span",12),fl(),vs(6,"button",45),Ag("click",function(){let m=If(e).$index,d=mC(2);return wf(d.removeContentEntry(m))}),WC(7," \xD7 "),fl()();}if(i&2){let e=t.$implicit,l=t.$index,m=mC(2);XE(2),Zg(l+1),XE(2),Hg("prompt-form__textarea--invalid",e.invalid&&e.touched),Tg("formControlName",l),$I(),XE(),tC(e.invalid&&e.touched?5:-1),XE(),Tg("disabled",m.contentArray.length===1);}}function ge(i,t){if(i&1&&(vs(0,"p",23),WC(1),fl()),i&2){let e=mC(2);XE(),Zg(e.errorMessage());}}function Ce(i,t){i&1&&(vs(0,"span",12),WC(1,"Invalid JSON."),fl());}function xe(i,t){if(i&1){let e=dC();vs(0,"button",46),Ag("click",function(){If(e);let m=mC(2);return wf(m.exportYaml())}),WC(1),fl();}if(i&2){let e=mC(2);Tg("disabled",e.isExporting()),XE(),yl(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function ve(i,t){if(i&1){let e=dC();vs(0,"form",7),Ag("ngSubmit",function(){If(e);let m=mC();return wf(m.submit())}),vs(1,"div",8)(2,"label",9),WC(3,"Name "),vs(4,"span",10),WC(5,"*"),fl()(),bg(6,"input",11),HI(),eC(7,ae,2,0,"span",12),fl(),vs(8,"div",8)(9,"label",13),WC(10,"Description"),fl(),bg(11,"input",14),HI(),fl(),eC(12,de,5,1,"div",8),vs(13,"fieldset",15)(14,"legend",16),WC(15," Parameters "),vs(16,"span",17),WC(17,"Named placeholders used in content"),fl()(),vs(18,"p",18),WC(19," Each parameter must have a name and a default value. Use "),vs(20,"code"),WC(21),fl(),WC(22," in content entries to reference them. "),fl(),eC(23,ce,2,0,"p",19),oC(24,_e,19,10,"div",20,nC),vs(26,"button",21),Ag("click",function(){If(e);let m=mC();return wf(m.addParameter())}),WC(27,"+ Add parameter"),fl()(),vs(28,"fieldset",15)(29,"legend",16),WC(30," Content "),vs(31,"span",10),WC(32,"*"),fl(),vs(33,"span",17),WC(34,"Ordered list of text commands"),fl()(),vs(35,"p",18),WC(36," Each content entry is a command. Use "),vs(37,"code"),WC(38,"@AgentName"),fl(),WC(39," to target an agent, "),vs(40,"code"),WC(41,"/promptName param1 param2"),fl(),WC(42," to call another prompt, and "),vs(43,"code"),WC(44),fl(),WC(45," for parameter placeholders. "),fl(),oC(46,ue,8,6,"div",22,nC),vs(48,"button",21),Ag("click",function(){If(e);let m=mC();return wf(m.addContentEntry())}),WC(49,"+ Add content entry"),fl()(),eC(50,ge,2,1,"p",23),vs(51,"div",8)(52,"label",24),WC(53,"External Metadata"),fl(),bg(54,"textarea",25),HI(),eC(55,Ce,2,0,"span",12),vs(56,"span",26),WC(57,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),fl()(),vs(58,"div",27)(59,"button",28),WC(60),fl(),eC(61,xe,2,2,"button",29),vs(62,"button",30),Ag("click",function(){If(e);let m=mC();return wf(m.cancel())}),WC(63,"Cancel"),fl()()();}if(i&2){let e=mC();Tg("formGroup",e.form),XE(6),Hg("prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),Tg("formControl",e.nameControl),$I(),XE(),tC(e.nameControl.invalid&&e.nameControl.touched?7:-1),XE(4),Tg("formControl",e.descriptionControl),$I(),XE(),tC(e.availableAgentConfigs().length>0?12:-1),XE(),Tg("formArrayName","parameters"),XE(8),Zg(e.paramPlaceholderSyntax),XE(2),tC(e.parametersArray.length===0?23:-1),XE(),iC(e.parametersArray.controls),XE(4),Tg("formArrayName","content"),XE(16),Zg(e.paramPlaceholderSyntax),XE(2),iC(e.contentArray.controls),XE(4),tC(e.errorMessage()?50:-1),XE(4),Tg("formControl",e.externalMetadataJsonControl),$I(),XE(),tC(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?55:-1),XE(4),Tg("disabled",e.form.invalid||e.isSubmitting()),XE(),yl(" ",e.isEditMode()?"Save changes":"Create"," "),XE(),tC(e.isEditMode()?61:-1);}}var re=class i{route=g(V);router=g(G);destroyRef=g(we);promptState=g(m);agentConfigController=g(B);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new z({name:new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(null),agentConfigId:new _t(null),externalMetadataJson:new _t("",{nonNullable:true,validators:[be]}),content:new ze([this.createContentControl()],{validators:[_e$1.required]}),parameters:new ze([])});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}get contentArray(){return this.form.controls.content}get parametersArray(){return this.form.controls.parameters}isEditMode=Hi(false);isSubmitting=Hi(false);isLoading=Hi(false);isExporting=Hi(false);errorMessage=Hi(null);paramPlaceholderSyntax="{{paramName}}";agentConfigs=Hi([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("promptId");t&&(this.isEditMode.set(true),this.loadPrompt(t)),this.isPlatformMode?this.loadPlatformAgentConfigs():this.namespaceId&&this.loadAgentConfigs(this.namespaceId);}loadPrompt(t){this.isLoading.set(true),this.promptState.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingPrompt=e,this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadAgentConfigs(t){this.agentConfigController.listByParentAgentConfig(t).pipe(U(this.destroyRef),ga(()=>ha([]))).subscribe(e=>this.agentConfigs.set(e));}loadPlatformAgentConfigs(){this.agentConfigController.listPlatformAgentsAgentConfig().pipe(U(this.destroyRef),ga(()=>ha([]))).subscribe(t=>this.agentConfigs.set(t));}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId??null),this.contentArray.clear(),(t.content.length>0?t.content:[""]).forEach(l=>this.contentArray.push(this.createContentControl(l))),this.parametersArray.clear(),(t.parameters??[]).forEach(l=>this.parametersArray.push(this.createParameterGroup(l))),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}createContentControl(t=""){return new _t(t,{nonNullable:true,validators:[_e$1.required,_e$1.pattern(/\S/)]})}addContentEntry(){this.contentArray.push(this.createContentControl());}removeContentEntry(t){this.contentArray.length>1&&this.contentArray.removeAt(t);}createParameterGroup(t){return new z({name:new _t(t?.name??"",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(t?.description??null),defaultValue:new _t(t?.defaultValue??"",{nonNullable:true,validators:[_e$1.required]})})}addParameter(){this.parametersArray.push(this.createParameterGroup());}removeParameter(t){this.parametersArray.removeAt(t);}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=z$1(P({},this.existingPrompt??{}),{namespaceId:this.namespaceId,sourceLanguage:this.existingPrompt?.sourceLanguage??"en",name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,content:this.contentArray.controls.map(d=>d.value.trim()),parameters:this.parametersArray.controls.map(d=>({name:d.controls.name.value.trim(),description:d.controls.description.value?.trim()||void 0,defaultValue:d.controls.defaultValue.value.trim()}))});t||(e.agentConfigId=this.agentConfigIdControl.value||null);let l=this.externalMetadataJsonControl.value.trim();e.externalMetadata=l?JSON.parse(l):null;let m=t?this.promptState.update(this.existingPrompt.id,e):this.promptState.create(e);this.errorMessage.set(null),m.pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:d=>{this.isSubmitting.set(false),d.status===409?this.errorMessage.set(`A prompt named "${e.name}" already exists in this scope.`):d.status===400?this.errorMessage.set(d.error?.message??"Invalid prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}exportYaml(){let t=this.existingPrompt?.id;!t||this.isExporting()||(this.isExporting.set(true),this.promptState.exportAsYaml(t).pipe(U(this.destroyRef)).subscribe({next:e=>{let l=new Blob([e],{type:"application/yaml"}),m=URL.createObjectURL(l),d=document.createElement("a");d.href=m,d.download=`${this.existingPrompt?.name??"prompt"}.yaml`,d.click(),URL.revokeObjectURL(m),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","prompts"]):this.router.navigate(["/agentos",this.namespaceId,"prompts"]);}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=Aw({type:i,selectors:[["agentos-prompt-form"]],decls:10,vars:3,consts:[[1,"prompt-form"],[1,"prompt-form__header"],["type","button","title","Back to prompts",1,"prompt-form__back",3,"click"],[1,"prompt-form__back-icon"],[1,"prompt-form__title"],[1,"prompt-form__loading"],[1,"prompt-form__form",3,"formGroup"],[1,"prompt-form__form",3,"ngSubmit","formGroup"],[1,"prompt-form__field"],["for","prompt-name",1,"prompt-form__label"],["aria-hidden","true"],["id","prompt-name","type","text","placeholder","e.g. Summarise meeting notes","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__field-error"],["for","prompt-description",1,"prompt-form__label"],["id","prompt-description","type","text","placeholder","Optional \u2014 short description of this prompt","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__section",3,"formArrayName"],[1,"prompt-form__label"],[1,"prompt-form__label-hint"],[1,"prompt-form__section-hint"],[1,"prompt-form__empty-hint"],[1,"prompt-form__param-row",3,"formGroupName"],["type","button",1,"prompt-form__add-btn",3,"click"],[1,"prompt-form__content-row"],[1,"prompt-form__error"],["for","prompt-external-metadata",1,"prompt-form__label"],["id","prompt-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"prompt-form__textarea","prompt-form__textarea--code",3,"formControl"],[1,"prompt-form__field-hint"],[1,"prompt-form__actions"],["type","submit",1,"prompt-form__btn","prompt-form__btn--primary",3,"disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"disabled"],["type","button",1,"prompt-form__btn",3,"click"],["for","prompt-agent-config",1,"prompt-form__label"],[1,"prompt-form__readonly-value"],["id","prompt-agent-config",1,"prompt-form__select",3,"formControl"],[3,"ngValue"],[1,"prompt-form__param-fields"],[1,"prompt-form__field","prompt-form__field--inline"],[1,"prompt-form__label",3,"for"],["type","text","placeholder","e.g. language","formControlName","name","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","Optional","formControlName","description","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","e.g. English","formControlName","defaultValue","autocomplete","off",1,"prompt-form__input",3,"id"],["type","button","title","Remove this parameter",1,"prompt-form__remove-btn",3,"click"],[1,"prompt-form__content-index"],[1,"prompt-form__content-field"],["rows","4","placeholder","Enter a command\u2026",1,"prompt-form__textarea",3,"formControlName"],["type","button","title","Remove this entry",1,"prompt-form__remove-btn",3,"click","disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"click","disabled"]],template:function(e,l){e&1&&(vs(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return l.cancel()}),vs(3,"span",3),WC(4,"\u2190"),fl(),WC(5),fl(),vs(6,"h1",4),WC(7),fl()(),eC(8,ie,2,0,"p",5)(9,ve,64,18,"form",6),fl()),e&2&&(XE(5),yl(" ",l.isPlatformMode?"Platform prompts":"Prompts"," "),XE(2),Zg(l.isEditMode()?"Edit prompt":"New prompt"),XE(),tC(l.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,Zn,Xn,Cn,En,An,Ct,Vt],styles:[".prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.prompt-form__field--inline[_ngcontent-%COMP%]{flex:1}.prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.prompt-form__label-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);margin-left:.375rem}.prompt-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;cursor:pointer;appearance:auto;transition:border-color .15s ease}.prompt-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;padding:.5rem .875rem;border-radius:0;background:var(--color-bg-hover);border:1px solid var(--color-divider);color:var(--color-text);font-size:.9375rem}.prompt-form__input[_ngcontent-%COMP%], .prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.prompt-form__input[_ngcontent-%COMP%]:focus, .prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__input[_ngcontent-%COMP%]::placeholder, .prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.prompt-form__textarea--code[_ngcontent-%COMP%]{font-family:monospace;font-size:.85rem;resize:vertical}.prompt-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.75rem}.prompt-form__section-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.prompt-form__content-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.prompt-form__content-field[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.25rem}.prompt-form__content-index[_ngcontent-%COMP%]{flex-shrink:0;width:1.5rem;padding-top:.6rem;font-size:.8rem;font-weight:600;color:var(--color-text-secondary);text-align:right;-webkit-user-select:none;user-select:none}.prompt-form__param-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-end;padding:.75rem;border-radius:0;background:var(--color-bg-hover)}.prompt-form__param-fields[_ngcontent-%COMP%]{flex:1;display:flex;gap:.75rem;flex-wrap:wrap}.prompt-form__add-btn[_ngcontent-%COMP%]{align-self:flex-start;padding:.4rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-accent);font-size:.875rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__add-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);border-color:var(--color-accent)}.prompt-form__remove-btn[_ngcontent-%COMP%]{flex-shrink:0;width:1.75rem;height:1.75rem;display:flex;align-items:center;justify-content:center;border-radius:0;border:1px solid transparent;background:transparent;color:var(--color-neutral-500);font-size:1rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}.prompt-form__remove-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:color-mix(in srgb,var(--red) 10%,transparent);color:var(--red);border-color:var(--red)}.prompt-form__remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.prompt-form__error[_ngcontent-%COMP%]{margin:0;padding:.625rem .875rem;border-radius:0;background:color-mix(in srgb,var(--red) 10%,transparent);border:1px solid var(--red);color:var(--red);font-size:.875rem;line-height:1.4}.prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--red);line-height:1.3}.prompt-form__input--invalid[_ngcontent-%COMP%], .prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--red)}.prompt-form__input--invalid[_ngcontent-%COMP%]:focus, .prompt-form__textarea--invalid[_ngcontent-%COMP%]:focus{border-color:var(--red)}.prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.prompt-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.prompt-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};function be(i){let t=i.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}export{re as PromptFormComponent};
1
+ import {m}from'./chunk-Bf1Bttqy.js';import {g,ao as V,G,w as we,d8 as B,z as zi,c as U,a7 as ya,X as br,a as z$1,b as P,h as Rw,I as Is,A as Ag,q as qC,m as pl,t as tC,J as JE,a5 as vl,a8 as Zg,v as nC,a9 as fC,n as bg,a3 as UI,o as iC,bo as rC,ac as yC,T as Tg,H as Hg,a6 as zI,x as sC,aa as If,ab as wf}from'./main-4SCUMPDY.js';import {o as z,z as ze,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,Z as Zn,l as Xn,C as Cn,E as En,p as An,q as Ct,V as Vt}from'./chunk-LgALnta4.js';import'./chunk-BxnUTBZC.js';import'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';var ne=(i,t)=>t.id;function ie(i,t){i&1&&(Is(0,"p",5),qC(1,"Loading\u2026"),pl());}function ae(i,t){i&1&&(Is(0,"span",12),qC(1,"Name is required."),pl());}function le(i,t){if(i&1&&(Is(0,"p",32),qC(1),pl(),Is(2,"span",26),qC(3,"Agent Config cannot be changed after creation."),pl()),i&2){let e=yC(3);JE(),Zg(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function me(i,t){if(i&1&&(Is(0,"option",34),qC(1),pl()),i&2){let e=t.$implicit;Tg("ngValue",e.id),JE(),Zg(e.name);}}function pe(i,t){if(i&1&&(Is(0,"select",33)(1,"option",34),qC(2,"\u2014 None \u2014"),pl(),iC(3,me,2,2,"option",34,ne),pl(),UI(),Is(5,"span",26),qC(6,"Optional. Links this prompt to an agent as a starter. Immutable after creation."),pl()),i&2){let e=yC(3);Tg("formControl",e.agentConfigIdControl),zI(),JE(),Tg("ngValue",null),JE(2),sC(e.availableAgentConfigs());}}function de(i,t){if(i&1&&(Is(0,"div",8)(1,"label",31),qC(2,"Agent Config"),pl(),tC(3,le,4,1)(4,pe,7,2),pl()),i&2){let e=yC(2);JE(3),nC(e.isEditMode()&&e.agentConfigIdControl.value?3:e.isEditMode()?-1:4);}}function ce(i,t){i&1&&(Is(0,"p",19),qC(1,"No parameters defined."),pl());}function se(i,t){i&1&&(Is(0,"span",12),qC(1,"Parameter name is required."),pl());}function _e(i,t){if(i&1){let e=fC();Is(0,"div",20)(1,"div",35)(2,"div",36)(3,"label",37),qC(4,"Name "),Is(5,"span",10),qC(6,"*"),pl()(),bg(7,"input",38),UI(),tC(8,se,2,0,"span",12),pl(),Is(9,"div",36)(10,"label",37),qC(11,"Description"),pl(),bg(12,"input",39),UI(),pl(),Is(13,"div",36)(14,"label",37),qC(15,"Default value"),pl(),bg(16,"input",40),UI(),pl()(),Is(17,"button",41),Ag("click",function(){let m=If(e).$index,d=yC(2);return wf(d.removeParameter(m))}),qC(18," \xD7 "),pl()();}if(i&2){let e=t.$implicit,l=t.$index;Tg("formGroupName",l),JE(3),Tg("for","param-name-"+l),JE(4),Hg("prompt-form__input--invalid",e.controls.name.invalid&&e.controls.name.touched),Tg("id","param-name-"+l),zI(),JE(),nC(e.controls.name.invalid&&e.controls.name.touched?8:-1),JE(2),Tg("for","param-desc-"+l),JE(2),Tg("id","param-desc-"+l),zI(),JE(2),Tg("for","param-default-"+l),JE(2),Tg("id","param-default-"+l),zI();}}function fe(i,t){i&1&&(Is(0,"span",12),qC(1,"Content entry must not be blank."),pl());}function ue(i,t){if(i&1){let e=fC();Is(0,"div",22)(1,"span",42),qC(2),pl(),Is(3,"div",43),bg(4,"textarea",44),UI(),tC(5,fe,2,0,"span",12),pl(),Is(6,"button",45),Ag("click",function(){let m=If(e).$index,d=yC(2);return wf(d.removeContentEntry(m))}),qC(7," \xD7 "),pl()();}if(i&2){let e=t.$implicit,l=t.$index,m=yC(2);JE(2),Zg(l+1),JE(2),Hg("prompt-form__textarea--invalid",e.invalid&&e.touched),Tg("formControlName",l),zI(),JE(),nC(e.invalid&&e.touched?5:-1),JE(),Tg("disabled",m.contentArray.length===1);}}function ge(i,t){if(i&1&&(Is(0,"p",23),qC(1),pl()),i&2){let e=yC(2);JE(),Zg(e.errorMessage());}}function Ce(i,t){i&1&&(Is(0,"span",12),qC(1,"Invalid JSON."),pl());}function xe(i,t){if(i&1){let e=fC();Is(0,"button",46),Ag("click",function(){If(e);let m=yC(2);return wf(m.exportYaml())}),qC(1),pl();}if(i&2){let e=yC(2);Tg("disabled",e.isExporting()),JE(),vl(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function ve(i,t){if(i&1){let e=fC();Is(0,"form",7),Ag("ngSubmit",function(){If(e);let m=yC();return wf(m.submit())}),Is(1,"div",8)(2,"label",9),qC(3,"Name "),Is(4,"span",10),qC(5,"*"),pl()(),bg(6,"input",11),UI(),tC(7,ae,2,0,"span",12),pl(),Is(8,"div",8)(9,"label",13),qC(10,"Description"),pl(),bg(11,"input",14),UI(),pl(),tC(12,de,5,1,"div",8),Is(13,"fieldset",15)(14,"legend",16),qC(15," Parameters "),Is(16,"span",17),qC(17,"Named placeholders used in content"),pl()(),Is(18,"p",18),qC(19," Each parameter must have a name and a default value. Use "),Is(20,"code"),qC(21),pl(),qC(22," in content entries to reference them. "),pl(),tC(23,ce,2,0,"p",19),iC(24,_e,19,10,"div",20,rC),Is(26,"button",21),Ag("click",function(){If(e);let m=yC();return wf(m.addParameter())}),qC(27,"+ Add parameter"),pl()(),Is(28,"fieldset",15)(29,"legend",16),qC(30," Content "),Is(31,"span",10),qC(32,"*"),pl(),Is(33,"span",17),qC(34,"Ordered list of text commands"),pl()(),Is(35,"p",18),qC(36," Each content entry is a command. Use "),Is(37,"code"),qC(38,"@AgentName"),pl(),qC(39," to target an agent, "),Is(40,"code"),qC(41,"/promptName param1 param2"),pl(),qC(42," to call another prompt, and "),Is(43,"code"),qC(44),pl(),qC(45," for parameter placeholders. "),pl(),iC(46,ue,8,6,"div",22,rC),Is(48,"button",21),Ag("click",function(){If(e);let m=yC();return wf(m.addContentEntry())}),qC(49,"+ Add content entry"),pl()(),tC(50,ge,2,1,"p",23),Is(51,"div",8)(52,"label",24),qC(53,"External Metadata"),pl(),bg(54,"textarea",25),UI(),tC(55,Ce,2,0,"span",12),Is(56,"span",26),qC(57,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),pl()(),Is(58,"div",27)(59,"button",28),qC(60),pl(),tC(61,xe,2,2,"button",29),Is(62,"button",30),Ag("click",function(){If(e);let m=yC();return wf(m.cancel())}),qC(63,"Cancel"),pl()()();}if(i&2){let e=yC();Tg("formGroup",e.form),JE(6),Hg("prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),Tg("formControl",e.nameControl),zI(),JE(),nC(e.nameControl.invalid&&e.nameControl.touched?7:-1),JE(4),Tg("formControl",e.descriptionControl),zI(),JE(),nC(e.availableAgentConfigs().length>0?12:-1),JE(),Tg("formArrayName","parameters"),JE(8),Zg(e.paramPlaceholderSyntax),JE(2),nC(e.parametersArray.length===0?23:-1),JE(),sC(e.parametersArray.controls),JE(4),Tg("formArrayName","content"),JE(16),Zg(e.paramPlaceholderSyntax),JE(2),sC(e.contentArray.controls),JE(4),nC(e.errorMessage()?50:-1),JE(4),Tg("formControl",e.externalMetadataJsonControl),zI(),JE(),nC(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?55:-1),JE(4),Tg("disabled",e.form.invalid||e.isSubmitting()),JE(),vl(" ",e.isEditMode()?"Save changes":"Create"," "),JE(),nC(e.isEditMode()?61:-1);}}var re=class i{route=g(V);router=g(G);destroyRef=g(we);promptState=g(m);agentConfigController=g(B);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new z({name:new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(null),agentConfigId:new _t(null),externalMetadataJson:new _t("",{nonNullable:true,validators:[be]}),content:new ze([this.createContentControl()],{validators:[_e$1.required]}),parameters:new ze([])});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}get contentArray(){return this.form.controls.content}get parametersArray(){return this.form.controls.parameters}isEditMode=zi(false);isSubmitting=zi(false);isLoading=zi(false);isExporting=zi(false);errorMessage=zi(null);paramPlaceholderSyntax="{{paramName}}";agentConfigs=zi([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("promptId");t&&(this.isEditMode.set(true),this.loadPrompt(t)),this.isPlatformMode?this.loadPlatformAgentConfigs():this.namespaceId&&this.loadAgentConfigs(this.namespaceId);}loadPrompt(t){this.isLoading.set(true),this.promptState.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingPrompt=e,this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadAgentConfigs(t){this.agentConfigController.listByParentAgentConfig(t).pipe(U(this.destroyRef),ya(()=>br([]))).subscribe(e=>this.agentConfigs.set(e));}loadPlatformAgentConfigs(){this.agentConfigController.listPlatformAgentsAgentConfig().pipe(U(this.destroyRef),ya(()=>br([]))).subscribe(t=>this.agentConfigs.set(t));}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId??null),this.contentArray.clear(),(t.content.length>0?t.content:[""]).forEach(l=>this.contentArray.push(this.createContentControl(l))),this.parametersArray.clear(),(t.parameters??[]).forEach(l=>this.parametersArray.push(this.createParameterGroup(l))),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}createContentControl(t=""){return new _t(t,{nonNullable:true,validators:[_e$1.required,_e$1.pattern(/\S/)]})}addContentEntry(){this.contentArray.push(this.createContentControl());}removeContentEntry(t){this.contentArray.length>1&&this.contentArray.removeAt(t);}createParameterGroup(t){return new z({name:new _t(t?.name??"",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(t?.description??null),defaultValue:new _t(t?.defaultValue??"",{nonNullable:true,validators:[_e$1.required]})})}addParameter(){this.parametersArray.push(this.createParameterGroup());}removeParameter(t){this.parametersArray.removeAt(t);}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=z$1(P({},this.existingPrompt??{}),{namespaceId:this.namespaceId,sourceLanguage:this.existingPrompt?.sourceLanguage??"en",name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,content:this.contentArray.controls.map(d=>d.value.trim()),parameters:this.parametersArray.controls.map(d=>({name:d.controls.name.value.trim(),description:d.controls.description.value?.trim()||void 0,defaultValue:d.controls.defaultValue.value.trim()}))});t||(e.agentConfigId=this.agentConfigIdControl.value||null);let l=this.externalMetadataJsonControl.value.trim();e.externalMetadata=l?JSON.parse(l):null;let m=t?this.promptState.update(this.existingPrompt.id,e):this.promptState.create(e);this.errorMessage.set(null),m.pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:d=>{this.isSubmitting.set(false),d.status===409?this.errorMessage.set(`A prompt named "${e.name}" already exists in this scope.`):d.status===400?this.errorMessage.set(d.error?.message??"Invalid prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}exportYaml(){let t=this.existingPrompt?.id;!t||this.isExporting()||(this.isExporting.set(true),this.promptState.exportAsYaml(t).pipe(U(this.destroyRef)).subscribe({next:e=>{let l=new Blob([e],{type:"application/yaml"}),m=URL.createObjectURL(l),d=document.createElement("a");d.href=m,d.download=`${this.existingPrompt?.name??"prompt"}.yaml`,d.click(),URL.revokeObjectURL(m),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","prompts"]):this.router.navigate(["/agentos",this.namespaceId,"prompts"]);}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=Rw({type:i,selectors:[["agentos-prompt-form"]],decls:10,vars:3,consts:[[1,"prompt-form"],[1,"prompt-form__header"],["type","button","title","Back to prompts",1,"prompt-form__back",3,"click"],[1,"prompt-form__back-icon"],[1,"prompt-form__title"],[1,"prompt-form__loading"],[1,"prompt-form__form",3,"formGroup"],[1,"prompt-form__form",3,"ngSubmit","formGroup"],[1,"prompt-form__field"],["for","prompt-name",1,"prompt-form__label"],["aria-hidden","true"],["id","prompt-name","type","text","placeholder","e.g. Summarise meeting notes","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__field-error"],["for","prompt-description",1,"prompt-form__label"],["id","prompt-description","type","text","placeholder","Optional \u2014 short description of this prompt","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__section",3,"formArrayName"],[1,"prompt-form__label"],[1,"prompt-form__label-hint"],[1,"prompt-form__section-hint"],[1,"prompt-form__empty-hint"],[1,"prompt-form__param-row",3,"formGroupName"],["type","button",1,"prompt-form__add-btn",3,"click"],[1,"prompt-form__content-row"],[1,"prompt-form__error"],["for","prompt-external-metadata",1,"prompt-form__label"],["id","prompt-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"prompt-form__textarea","prompt-form__textarea--code",3,"formControl"],[1,"prompt-form__field-hint"],[1,"prompt-form__actions"],["type","submit",1,"prompt-form__btn","prompt-form__btn--primary",3,"disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"disabled"],["type","button",1,"prompt-form__btn",3,"click"],["for","prompt-agent-config",1,"prompt-form__label"],[1,"prompt-form__readonly-value"],["id","prompt-agent-config",1,"prompt-form__select",3,"formControl"],[3,"ngValue"],[1,"prompt-form__param-fields"],[1,"prompt-form__field","prompt-form__field--inline"],[1,"prompt-form__label",3,"for"],["type","text","placeholder","e.g. language","formControlName","name","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","Optional","formControlName","description","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","e.g. English","formControlName","defaultValue","autocomplete","off",1,"prompt-form__input",3,"id"],["type","button","title","Remove this parameter",1,"prompt-form__remove-btn",3,"click"],[1,"prompt-form__content-index"],[1,"prompt-form__content-field"],["rows","4","placeholder","Enter a command\u2026",1,"prompt-form__textarea",3,"formControlName"],["type","button","title","Remove this entry",1,"prompt-form__remove-btn",3,"click","disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"click","disabled"]],template:function(e,l){e&1&&(Is(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return l.cancel()}),Is(3,"span",3),qC(4,"\u2190"),pl(),qC(5),pl(),Is(6,"h1",4),qC(7),pl()(),tC(8,ie,2,0,"p",5)(9,ve,64,18,"form",6),pl()),e&2&&(JE(5),vl(" ",l.isPlatformMode?"Platform prompts":"Prompts"," "),JE(2),Zg(l.isEditMode()?"Edit prompt":"New prompt"),JE(),nC(l.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,Zn,Xn,Cn,En,An,Ct,Vt],styles:[".prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.prompt-form__field--inline[_ngcontent-%COMP%]{flex:1}.prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.prompt-form__label-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);margin-left:.375rem}.prompt-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;cursor:pointer;appearance:auto;transition:border-color .15s ease}.prompt-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;padding:.5rem .875rem;border-radius:0;background:var(--color-bg-hover);border:1px solid var(--color-divider);color:var(--color-text);font-size:.9375rem}.prompt-form__input[_ngcontent-%COMP%], .prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.prompt-form__input[_ngcontent-%COMP%]:focus, .prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__input[_ngcontent-%COMP%]::placeholder, .prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.prompt-form__textarea--code[_ngcontent-%COMP%]{font-family:monospace;font-size:.85rem;resize:vertical}.prompt-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.75rem}.prompt-form__section-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.prompt-form__content-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.prompt-form__content-field[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.25rem}.prompt-form__content-index[_ngcontent-%COMP%]{flex-shrink:0;width:1.5rem;padding-top:.6rem;font-size:.8rem;font-weight:600;color:var(--color-text-secondary);text-align:right;-webkit-user-select:none;user-select:none}.prompt-form__param-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-end;padding:.75rem;border-radius:0;background:var(--color-bg-hover)}.prompt-form__param-fields[_ngcontent-%COMP%]{flex:1;display:flex;gap:.75rem;flex-wrap:wrap}.prompt-form__add-btn[_ngcontent-%COMP%]{align-self:flex-start;padding:.4rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-accent);font-size:.875rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__add-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);border-color:var(--color-accent)}.prompt-form__remove-btn[_ngcontent-%COMP%]{flex-shrink:0;width:1.75rem;height:1.75rem;display:flex;align-items:center;justify-content:center;border-radius:0;border:1px solid transparent;background:transparent;color:var(--color-neutral-500);font-size:1rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}.prompt-form__remove-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:color-mix(in srgb,var(--red) 10%,transparent);color:var(--red);border-color:var(--red)}.prompt-form__remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.prompt-form__error[_ngcontent-%COMP%]{margin:0;padding:.625rem .875rem;border-radius:0;background:color-mix(in srgb,var(--red) 10%,transparent);border:1px solid var(--red);color:var(--red);font-size:.875rem;line-height:1.4}.prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--red);line-height:1.3}.prompt-form__input--invalid[_ngcontent-%COMP%], .prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--red)}.prompt-form__input--invalid[_ngcontent-%COMP%]:focus, .prompt-form__textarea--invalid[_ngcontent-%COMP%]:focus{border-color:var(--red)}.prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.prompt-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.prompt-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};function be(i){let t=i.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}export{re as PromptFormComponent};
@@ -1 +1 @@
1
- import {g,ao as V,G,w as we,de as M,dd as $,F,a7 as ga,S as ha,H as Hi,m as mT,b as U,z as z$1,a as P,A as Aw,v as vs,k as Ag,W as WC,j as fl,n as eC,X as XE,a8 as Zg,t as tC,a9 as dC,o as bg,a3 as HI,ac as mC,r as Tg,a6 as $I,a5 as yl,q as oC,cH as Xw,x as iC,b0 as Yg,aa as If,ab as wf}from'./main-SY6UM2GV.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,f as fn,A as At,Z as Zn,l as Xn,$ as $t,W as Wt,C as Cn,E as En,p as An}from'./chunk-DbP7sgsG.js';function le(l,t){l&1&&(vs(0,"p",5),WC(1,"Loading\u2026"),fl());}function ae(l,t){if(l&1&&bg(0,"input",11),l&2){let e=mC(2);Tg("value",e.selectedProviderLabel());}}function de(l,t){if(l&1&&(vs(0,"option",43),WC(1),fl()),l&2){let e=t.$implicit;Tg("value",e.id),XE(),Yg("",e.name," (",e.apiType,")");}}function me(l,t){if(l&1&&(vs(0,"select",12)(1,"option",42),WC(2,"Select provider"),fl(),oC(3,de,2,3,"option",43,Xw().trackByProvider,true),fl(),HI()),l&2){let e=mC(2);Tg("formControl",e.aiProviderIdControl),$I(),XE(3),iC(e.providers());}}function ce(l,t){if(l&1){let e=dC();vs(0,"form",7),Ag("ngSubmit",function(){If(e);let u=mC();return wf(u.submit())}),vs(1,"div",8)(2,"label",9),WC(3," Provider "),vs(4,"span",10),WC(5,"*"),fl()(),eC(6,ae,1,1,"input",11)(7,me,5,1,"select",12),fl(),vs(8,"div",8)(9,"label",13),WC(10," API name "),vs(11,"span",10),WC(12,"*"),fl()(),bg(13,"input",14),HI(),fl(),vs(14,"div",8)(15,"label",15),WC(16,"Description"),fl(),bg(17,"input",16),HI(),fl(),vs(18,"div",8)(19,"label",17),WC(20,"Alias"),fl(),bg(21,"input",18),HI(),fl(),vs(22,"div",8)(23,"label",19),WC(24,"Priority"),fl(),bg(25,"input",20),HI(),fl(),vs(26,"div",21)(27,"div",8)(28,"label",22),WC(29,"Temperature"),fl(),bg(30,"input",23),HI(),fl(),vs(31,"div",8)(32,"label",24),WC(33,"Context window"),fl(),bg(34,"input",25),HI(),fl()(),vs(35,"div",8)(36,"label",26),WC(37,"Max completion tokens"),fl(),bg(38,"input",27),HI(),fl(),vs(39,"fieldset",28)(40,"legend",29),WC(41," Pricing "),vs(42,"span",30),WC(43,"(per million tokens \u2014 leave blank to skip cost monitoring)"),fl()(),vs(44,"div",21)(45,"div",8)(46,"label",31),WC(47,"Input"),fl(),bg(48,"input",32),HI(),fl(),vs(49,"div",8)(50,"label",33),WC(51,"Output"),fl(),bg(52,"input",34),HI(),fl()(),vs(53,"div",21)(54,"div",8)(55,"label",35),WC(56,"Cache write"),fl(),bg(57,"input",36),HI(),fl(),vs(58,"div",8)(59,"label",37),WC(60,"Cache read"),fl(),bg(61,"input",38),HI(),fl()()(),vs(62,"div",39)(63,"button",40),WC(64),fl(),vs(65,"button",41),Ag("click",function(){If(e);let u=mC();return wf(u.cancel())}),WC(66,"Cancel"),fl()()();}if(l&2){let e=mC();Tg("formGroup",e.form),XE(6),tC(e.isEditMode()?6:7),XE(7),Tg("formControl",e.apiModelNameControl),$I(),XE(4),Tg("formControl",e.descriptionControl),$I(),XE(4),Tg("formControl",e.aliasControl),$I(),XE(4),Tg("formControl",e.priorityControl),$I(),XE(5),Tg("formControl",e.temperatureControl),$I(),XE(4),Tg("formControl",e.contextWindowControl),$I(),XE(4),Tg("formControl",e.maxCompletionTokensControl),$I(),XE(),Tg("formGroup",e.pricingGroup),XE(9),$I(),XE(4),$I(),XE(5),$I(),XE(4),$I(),XE(2),Tg("disabled",e.form.invalid||e.isSubmitting()),XE(),yl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var re=class l{route=g(V);router=g(G);destroyRef=g(we);aiModelController=g(M);aiProviderController=g($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(ga(()=>ha([]))),{initialValue:[]});form=new z({aiProviderId:new _t("",{nonNullable:true,validators:[_e.required]}),apiModelName:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),alias:new _t("",{nonNullable:true}),priority:new _t(0,{nonNullable:true}),temperature:new _t(null),contextWindow:new _t(null),maxCompletionTokens:new _t(null),pricing:new z({inputMTokens:new _t(null),outputMTokens:new _t(null),cacheWrite:new _t(null),cacheRead:new _t(null)})});get aiProviderIdControl(){return this.form.controls.aiProviderId}get apiModelNameControl(){return this.form.controls.apiModelName}get descriptionControl(){return this.form.controls.description}get aliasControl(){return this.form.controls.alias}get priorityControl(){return this.form.controls.priority}get temperatureControl(){return this.form.controls.temperature}get contextWindowControl(){return this.form.controls.contextWindow}get maxCompletionTokensControl(){return this.form.controls.maxCompletionTokens}get pricingGroup(){return this.form.controls.pricing}isEditMode=Hi(false);isSubmitting=Hi(false);isLoading=Hi(false);selectedProviderLabel=mT(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("modelId");t&&(this.isEditMode.set(true),this.loadModel(t));}loadModel(t){this.isLoading.set(true),this.aiModelController.getByIdAiModel(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingModel=e,this.aiProviderIdControl.setValue(e.aiProviderId),this.aiProviderIdControl.disable(),this.apiModelNameControl.setValue(e.apiModelName),this.descriptionControl.setValue(e.description??null),this.aliasControl.setValue(e.alias??""),this.priorityControl.setValue(e.priority??0),this.temperatureControl.setValue(e.temperature??null),this.contextWindowControl.setValue(e.contextWindow??null),this.maxCompletionTokensControl.setValue(e.maxCompletionTokens??null),this.pricingGroup.setValue({inputMTokens:e.pricing?.inputMTokens??null,outputMTokens:e.pricing?.outputMTokens??null,cacheWrite:e.pricing?.cacheWrite??null,cacheRead:e.pricing?.cacheRead??null}),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.form.getRawValue(),e=t.pricing,u=e.inputMTokens!=null||e.outputMTokens!=null||e.cacheWrite!=null||e.cacheRead!=null?{isEmpty:false,inputMTokens:e.inputMTokens??void 0,outputMTokens:e.outputMTokens??void 0,cacheWrite:e.cacheWrite??void 0,cacheRead:e.cacheRead??void 0}:void 0,k=z$1(P({},this.existingModel??{}),{aiProviderId:t.aiProviderId,namespaceId:this.isPlatformMode?void 0:this.existingModel?.namespaceId??this.namespaceId,apiModelName:t.apiModelName.trim(),description:t.description?.trim()||void 0,alias:t.alias.trim()||void 0,priority:t.priority,temperature:t.temperature??void 0,contextWindow:t.contextWindow??void 0,maxCompletionTokens:t.maxCompletionTokens??void 0,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",k):this.aiModelController.createAiModel(k)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-models"]):this.router.navigate(["/agentos",this.namespaceId,"ai-models"]);}trackByProvider(t,e){return e.id??""}static \u0275fac=function(e){return new(e||l)};static \u0275cmp=Aw({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(vs(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return p.cancel()}),vs(3,"span",3),WC(4,"\u2190"),fl(),WC(5," AI models "),fl(),vs(6,"h1",4),WC(7),fl()(),eC(8,le,2,0,"p",5)(9,ce,67,12,"form",6),fl()),e&2&&(XE(7),Zg(p.isEditMode()?"Edit AI model":"New AI model"),XE(),tC(p.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,fn,At,Zn,Xn,$t,Wt,Cn,En,An],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{re as AiModelFormComponent};
1
+ import {g,ao as V,G,w as we,de as M,dd as $,F,a7 as ya,X as br,z as zi,y as yT,c as U,a as z$1,b as P,h as Rw,I as Is,A as Ag,q as qC,m as pl,t as tC,J as JE,a8 as Zg,v as nC,a9 as fC,n as bg,a3 as UI,ac as yC,T as Tg,a6 as zI,a5 as vl,o as iC,cH as Jw,x as sC,b0 as Yg,aa as If,ab as wf}from'./main-4SCUMPDY.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,f as fn,A as At,Z as Zn,l as Xn,$ as $t,W as Wt,C as Cn,E as En,p as An}from'./chunk-LgALnta4.js';function le(l,t){l&1&&(Is(0,"p",5),qC(1,"Loading\u2026"),pl());}function ae(l,t){if(l&1&&bg(0,"input",11),l&2){let e=yC(2);Tg("value",e.selectedProviderLabel());}}function de(l,t){if(l&1&&(Is(0,"option",43),qC(1),pl()),l&2){let e=t.$implicit;Tg("value",e.id),JE(),Yg("",e.name," (",e.apiType,")");}}function me(l,t){if(l&1&&(Is(0,"select",12)(1,"option",42),qC(2,"Select provider"),pl(),iC(3,de,2,3,"option",43,Jw().trackByProvider,true),pl(),UI()),l&2){let e=yC(2);Tg("formControl",e.aiProviderIdControl),zI(),JE(3),sC(e.providers());}}function ce(l,t){if(l&1){let e=fC();Is(0,"form",7),Ag("ngSubmit",function(){If(e);let u=yC();return wf(u.submit())}),Is(1,"div",8)(2,"label",9),qC(3," Provider "),Is(4,"span",10),qC(5,"*"),pl()(),tC(6,ae,1,1,"input",11)(7,me,5,1,"select",12),pl(),Is(8,"div",8)(9,"label",13),qC(10," API name "),Is(11,"span",10),qC(12,"*"),pl()(),bg(13,"input",14),UI(),pl(),Is(14,"div",8)(15,"label",15),qC(16,"Description"),pl(),bg(17,"input",16),UI(),pl(),Is(18,"div",8)(19,"label",17),qC(20,"Alias"),pl(),bg(21,"input",18),UI(),pl(),Is(22,"div",8)(23,"label",19),qC(24,"Priority"),pl(),bg(25,"input",20),UI(),pl(),Is(26,"div",21)(27,"div",8)(28,"label",22),qC(29,"Temperature"),pl(),bg(30,"input",23),UI(),pl(),Is(31,"div",8)(32,"label",24),qC(33,"Context window"),pl(),bg(34,"input",25),UI(),pl()(),Is(35,"div",8)(36,"label",26),qC(37,"Max completion tokens"),pl(),bg(38,"input",27),UI(),pl(),Is(39,"fieldset",28)(40,"legend",29),qC(41," Pricing "),Is(42,"span",30),qC(43,"(per million tokens \u2014 leave blank to skip cost monitoring)"),pl()(),Is(44,"div",21)(45,"div",8)(46,"label",31),qC(47,"Input"),pl(),bg(48,"input",32),UI(),pl(),Is(49,"div",8)(50,"label",33),qC(51,"Output"),pl(),bg(52,"input",34),UI(),pl()(),Is(53,"div",21)(54,"div",8)(55,"label",35),qC(56,"Cache write"),pl(),bg(57,"input",36),UI(),pl(),Is(58,"div",8)(59,"label",37),qC(60,"Cache read"),pl(),bg(61,"input",38),UI(),pl()()(),Is(62,"div",39)(63,"button",40),qC(64),pl(),Is(65,"button",41),Ag("click",function(){If(e);let u=yC();return wf(u.cancel())}),qC(66,"Cancel"),pl()()();}if(l&2){let e=yC();Tg("formGroup",e.form),JE(6),nC(e.isEditMode()?6:7),JE(7),Tg("formControl",e.apiModelNameControl),zI(),JE(4),Tg("formControl",e.descriptionControl),zI(),JE(4),Tg("formControl",e.aliasControl),zI(),JE(4),Tg("formControl",e.priorityControl),zI(),JE(5),Tg("formControl",e.temperatureControl),zI(),JE(4),Tg("formControl",e.contextWindowControl),zI(),JE(4),Tg("formControl",e.maxCompletionTokensControl),zI(),JE(),Tg("formGroup",e.pricingGroup),JE(9),zI(),JE(4),zI(),JE(5),zI(),JE(4),zI(),JE(2),Tg("disabled",e.form.invalid||e.isSubmitting()),JE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var re=class l{route=g(V);router=g(G);destroyRef=g(we);aiModelController=g(M);aiProviderController=g($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(ya(()=>br([]))),{initialValue:[]});form=new z({aiProviderId:new _t("",{nonNullable:true,validators:[_e.required]}),apiModelName:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),alias:new _t("",{nonNullable:true}),priority:new _t(0,{nonNullable:true}),temperature:new _t(null),contextWindow:new _t(null),maxCompletionTokens:new _t(null),pricing:new z({inputMTokens:new _t(null),outputMTokens:new _t(null),cacheWrite:new _t(null),cacheRead:new _t(null)})});get aiProviderIdControl(){return this.form.controls.aiProviderId}get apiModelNameControl(){return this.form.controls.apiModelName}get descriptionControl(){return this.form.controls.description}get aliasControl(){return this.form.controls.alias}get priorityControl(){return this.form.controls.priority}get temperatureControl(){return this.form.controls.temperature}get contextWindowControl(){return this.form.controls.contextWindow}get maxCompletionTokensControl(){return this.form.controls.maxCompletionTokens}get pricingGroup(){return this.form.controls.pricing}isEditMode=zi(false);isSubmitting=zi(false);isLoading=zi(false);selectedProviderLabel=yT(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("modelId");t&&(this.isEditMode.set(true),this.loadModel(t));}loadModel(t){this.isLoading.set(true),this.aiModelController.getByIdAiModel(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingModel=e,this.aiProviderIdControl.setValue(e.aiProviderId),this.aiProviderIdControl.disable(),this.apiModelNameControl.setValue(e.apiModelName),this.descriptionControl.setValue(e.description??null),this.aliasControl.setValue(e.alias??""),this.priorityControl.setValue(e.priority??0),this.temperatureControl.setValue(e.temperature??null),this.contextWindowControl.setValue(e.contextWindow??null),this.maxCompletionTokensControl.setValue(e.maxCompletionTokens??null),this.pricingGroup.setValue({inputMTokens:e.pricing?.inputMTokens??null,outputMTokens:e.pricing?.outputMTokens??null,cacheWrite:e.pricing?.cacheWrite??null,cacheRead:e.pricing?.cacheRead??null}),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.form.getRawValue(),e=t.pricing,u=e.inputMTokens!=null||e.outputMTokens!=null||e.cacheWrite!=null||e.cacheRead!=null?{isEmpty:false,inputMTokens:e.inputMTokens??void 0,outputMTokens:e.outputMTokens??void 0,cacheWrite:e.cacheWrite??void 0,cacheRead:e.cacheRead??void 0}:void 0,k=z$1(P({},this.existingModel??{}),{aiProviderId:t.aiProviderId,namespaceId:this.isPlatformMode?void 0:this.existingModel?.namespaceId??this.namespaceId,apiModelName:t.apiModelName.trim(),description:t.description?.trim()||void 0,alias:t.alias.trim()||void 0,priority:t.priority,temperature:t.temperature??void 0,contextWindow:t.contextWindow??void 0,maxCompletionTokens:t.maxCompletionTokens??void 0,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",k):this.aiModelController.createAiModel(k)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-models"]):this.router.navigate(["/agentos",this.namespaceId,"ai-models"]);}trackByProvider(t,e){return e.id??""}static \u0275fac=function(e){return new(e||l)};static \u0275cmp=Rw({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(Is(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return p.cancel()}),Is(3,"span",3),qC(4,"\u2190"),pl(),qC(5," AI models "),pl(),Is(6,"h1",4),qC(7),pl()(),tC(8,le,2,0,"p",5)(9,ce,67,12,"form",6),pl()),e&2&&(JE(7),Zg(p.isEditMode()?"Edit AI model":"New AI model"),JE(),nC(p.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,fn,At,Zn,Xn,$t,Wt,Cn,En,An],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{re as AiModelFormComponent};
@@ -1 +1 @@
1
- import {i}from'./chunk-DWsrvadK.js';import {l}from'./chunk-MIRdYHA6.js';import {g,d7 as U,di as pe,aJ as Tr,aD as Ly,bS as ma,a7 as ga,S as ha,u as ue,cE as Rd,bU as Od,Y as x}from'./main-SY6UM2GV.js';var y="none",O="me",N=class f{nsController=g(U);exportService=g(pe);userState=g(l);refresh$=new Tr(void 0);namespaceId$=new Tr(null);vm$=Ly([this.namespaceId$,this.refresh$]).pipe(ma(([e])=>{let n=this.loadPlatformConfigs().pipe(ga(()=>ha([]))),t=this.loadUserConfigs("global").pipe(ga(()=>ha([])));return e?Ly([n,this.loadNamespaceConfigs(e).pipe(ga(()=>ha([]))),this.loadUserConfigs(e).pipe(ga(()=>ha([]))),t]).pipe(ue(([i,r,c,s])=>({platform:i,namespace:r,userOnNs:c,userGlobal:s}))):Ly([n,t]).pipe(ue(([i,r])=>({platform:i,namespace:[],userOnNs:[],userGlobal:r})))}),Rd({bufferSize:1,refCount:true}));setNamespace(e){this.namespaceId$.value!==e&&this.namespaceId$.next(e);}refresh(){this.refresh$.next();}loadPlatformConfigs(){return this.nsController.listIntegrationConfig(y)}loadUserConfigs(e){let n=e==="global"?y:e;return this.nsController.listIntegrationConfig(n,O)}userGlobal$=i(this.refresh$,()=>this.loadUserConfigs("global"),[]);loadNamespaceConfigs(e){return e?this.nsController.listIntegrationConfig(e):ha([])}getById(e,n){return this.nsController.getByIdIntegrationConfig(e)}create(e,n,t){let r=this.userState.currentUser()?.id;if((n==="userOnNs"||n==="userGlobal")&&!r)throw new Error(`Cannot create ${n} config before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(n==="platform"){let s={name:e.name,integrationType:e.integrationType,description:e.description,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(s).pipe(Od(()=>this.refresh()))}if(n==="namespace"){if(!t)throw new Error("Cannot create namespace-scoped config without a namespaceId");let s={name:e.name,integrationType:e.integrationType,description:e.description,namespaceId:t,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(s).pipe(Od(()=>this.refresh()))}if(n==="userOnNs"&&!t)throw new Error("Cannot create userOnNs config without a namespaceId");let c={name:e.name,integrationType:e.integrationType,description:e.description,userId:r,namespaceId:n==="userOnNs"?t:void 0,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(c).pipe(Od(()=>this.refresh()))}update(e,n,t,i){let r={name:n.name,integrationType:n.integrationType,description:n.description,userId:i.userId,namespaceId:i.namespaceId,parameters:n.parameters,authSettingName:n.authSettingName??void 0};return this.nsController.updateIntegrationConfig(e,r).pipe(Od(()=>this.refresh()))}delete(e,n){return this.nsController.deleteIntegrationConfig(e).pipe(Od(()=>this.refresh()))}exportAsYaml(e){return this.exportService.exportAsYaml(e)}static \u0275fac=function(n){return new(n||f)};static \u0275prov=x({token:f,factory:f.\u0275fac,providedIn:"root"})};export{N};
1
+ import {i}from'./chunk-Bsv9CCXL.js';import {l}from'./chunk-Bf1Bttqy.js';import {g,d7 as U,di as pe,aJ as Tr,aD as Ly,bS as va,a7 as ya,X as br,u as ue,cE as Rd,bU as Od,Y as x}from'./main-4SCUMPDY.js';var y="none",O="me",N=class f{nsController=g(U);exportService=g(pe);userState=g(l);refresh$=new Tr(void 0);namespaceId$=new Tr(null);vm$=Ly([this.namespaceId$,this.refresh$]).pipe(va(([e])=>{let n=this.loadPlatformConfigs().pipe(ya(()=>br([]))),t=this.loadUserConfigs("global").pipe(ya(()=>br([])));return e?Ly([n,this.loadNamespaceConfigs(e).pipe(ya(()=>br([]))),this.loadUserConfigs(e).pipe(ya(()=>br([]))),t]).pipe(ue(([i,r,c,s])=>({platform:i,namespace:r,userOnNs:c,userGlobal:s}))):Ly([n,t]).pipe(ue(([i,r])=>({platform:i,namespace:[],userOnNs:[],userGlobal:r})))}),Rd({bufferSize:1,refCount:true}));setNamespace(e){this.namespaceId$.value!==e&&this.namespaceId$.next(e);}refresh(){this.refresh$.next();}loadPlatformConfigs(){return this.nsController.listIntegrationConfig(y)}loadUserConfigs(e){let n=e==="global"?y:e;return this.nsController.listIntegrationConfig(n,O)}userGlobal$=i(this.refresh$,()=>this.loadUserConfigs("global"),[]);loadNamespaceConfigs(e){return e?this.nsController.listIntegrationConfig(e):br([])}getById(e,n){return this.nsController.getByIdIntegrationConfig(e)}create(e,n,t){let r=this.userState.currentUser()?.id;if((n==="userOnNs"||n==="userGlobal")&&!r)throw new Error(`Cannot create ${n} config before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(n==="platform"){let s={name:e.name,integrationType:e.integrationType,description:e.description,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(s).pipe(Od(()=>this.refresh()))}if(n==="namespace"){if(!t)throw new Error("Cannot create namespace-scoped config without a namespaceId");let s={name:e.name,integrationType:e.integrationType,description:e.description,namespaceId:t,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(s).pipe(Od(()=>this.refresh()))}if(n==="userOnNs"&&!t)throw new Error("Cannot create userOnNs config without a namespaceId");let c={name:e.name,integrationType:e.integrationType,description:e.description,userId:r,namespaceId:n==="userOnNs"?t:void 0,parameters:e.parameters,authSettingName:e.authSettingName??void 0};return this.nsController.createIntegrationConfig(c).pipe(Od(()=>this.refresh()))}update(e,n,t,i){let r={name:n.name,integrationType:n.integrationType,description:n.description,userId:i.userId,namespaceId:i.namespaceId,parameters:n.parameters,authSettingName:n.authSettingName??void 0};return this.nsController.updateIntegrationConfig(e,r).pipe(Od(()=>this.refresh()))}delete(e,n){return this.nsController.deleteIntegrationConfig(e).pipe(Od(()=>this.refresh()))}exportAsYaml(e){return this.exportService.exportAsYaml(e)}static \u0275fac=function(n){return new(n||f)};static \u0275prov=x({token:f,factory:f.\u0275fac,providedIn:"root"})};export{N};
@@ -1 +1 @@
1
- import {g,J as dy,S as ha,bU as Od,u as ue,Y as x}from'./main-SY6UM2GV.js';var f=class s{http=g(dy);agentsCache=new Map;getAgents(e){let t=this.agentsCache.get(e);return t?ha(t):this.http.get(`/api/projects/${e}/agents`).pipe(Od(o=>{this.agentsCache.set(e,o);}))}getAgentsAutocomplete(e,t){return this.getAgents(e).pipe(ue(o=>{if(!t)return o;let i=t.toLowerCase(),a=r=>{let n=r.name.toLowerCase();return n.startsWith(i)?0:n.includes(i)?1:2};return o.filter(r=>{let n=r.name.toLowerCase(),h=r.description?.toLowerCase()||"";return n.includes(i)||h.includes(i)}).sort((r,n)=>a(r)-a(n))}))}clearCache(e){this.agentsCache.delete(e);}clearAllCache(){this.agentsCache.clear();}static \u0275fac=function(t){return new(t||s)};static \u0275prov=x({token:s,factory:s.\u0275fac,providedIn:"root"})};export{f};
1
+ import {g,M as dy,X as br,bU as Od,u as ue,Y as x}from'./main-4SCUMPDY.js';var f=class s{http=g(dy);agentsCache=new Map;getAgents(e){let t=this.agentsCache.get(e);return t?br(t):this.http.get(`/api/projects/${e}/agents`).pipe(Od(o=>{this.agentsCache.set(e,o);}))}getAgentsAutocomplete(e,t){return this.getAgents(e).pipe(ue(o=>{if(!t)return o;let i=t.toLowerCase(),a=r=>{let n=r.name.toLowerCase();return n.startsWith(i)?0:n.includes(i)?1:2};return o.filter(r=>{let n=r.name.toLowerCase(),h=r.description?.toLowerCase()||"";return n.includes(i)||h.includes(i)}).sort((r,n)=>a(r)-a(n))}))}clearCache(e){this.agentsCache.delete(e);}clearAllCache(){this.agentsCache.clear();}static \u0275fac=function(t){return new(t||s)};static \u0275prov=x({token:s,factory:s.\u0275fac,providedIn:"root"})};export{f};
@@ -1 +1 @@
1
- import {I}from'./chunk-wlytGgOb.js';import {m}from'./chunk-MIRdYHA6.js';import {g,ao as V$1,G as G$1,w as we,aJ as Tr,H as Hi,bS as ma,Q as By,a7 as ga,S as ha,u as ue,b as U$1,A as Aw,aK as Nb,v as vs,bf as aT,k as Ag,W as WC,j as fl,af as Dg,T as TC,r as Tg,bg as uT,ah as rT,n as eC,ac as mC,t as tC,a9 as dC,aa as If,ab as wf,ag as fT}from'./main-SY6UM2GV.js';import {W as Wn}from'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';import'./chunk-DbP7sgsG.js';import'./chunk-Cdb2CX2Q.js';var U=()=>[];function V(r,t){if(r&1){let o=dC();vs(0,"agentos-prompt-item",4),Ag("deleteRequested",function(n){If(o);let F=mC(2);return wf(F.deletePrompt(n))}),fl();}if(r&2){let o=mC().$implicit,e=mC();Tg("prompt",t)("namespaceId",e.namespaceId)("readOnly",e.isPlatformPrompt(o.id));}}function j(r,t){if(r&1&&eC(0,V,1,3,"agentos-prompt-item",3),r&2){let o,e=t.$implicit,n=mC();tC((o=n.resolvePrompt(e.id))?0:-1,o);}}var G="platform",K="namespace",A=class r{route=g(V$1);router=g(G$1);destroyRef=g(we);promptState=g(m);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Hi(true);allPrompts$=this.refresh$.pipe(ma(()=>(this.isLoading.set(true),By({platform:this.promptState.listPlatform().pipe(ga(()=>ha([]))),namespace:this.promptState.listByNamespace(this.namespaceId)}))));promptItems$=this.allPrompts$.pipe(ue(({platform:t,namespace:o})=>[...t.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:G,groupLabel:"Platform (read-only)"})),...o.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:K,groupLabel:"Namespace"}))]));namespacePromptsById=new Map;platformPromptsById=new Map;constructor(){this.allPrompts$.pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:o})=>{this.platformPromptsById=new Map(t.map(e=>[e.id??"",e])),this.namespacePromptsById=new Map(o.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"prompts","new"]);}deletePrompt(t){this.promptState.delete(t.id??"").pipe(U$1(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolvePrompt(t){return this.platformPromptsById.get(t)??this.namespacePromptsById.get(t)??null}isPlatformPrompt(t){return this.platformPromptsById.has(t)}static \u0275fac=function(o){return new(o||r)};static \u0275cmp=Aw({type:r,selectors:[["agentos-namespace-prompts"]],decls:6,vars:7,consts:[["promptItemTpl",""],["title","Prompts","emptyMessage","No prompts defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","type","button",1,"namespace-prompts__back",3,"click"],[3,"prompt","namespaceId","readOnly"],[3,"deleteRequested","prompt","namespaceId","readOnly"]],template:function(o,e){if(o&1&&(vs(0,"ds-entity-list",1),aT(1,"async"),Ag("createRequested",function(){return e.openCreateForm()}),vs(2,"button",2),Ag("click",function(){return e.goBack()}),WC(3,"\u2190 Namespaces"),fl()(),Dg(4,j,1,1,"ng-template",null,0,fT)),o&2){let n=TC(5);Tg("items",uT(1,4,e.promptItems$)??rT(6,U))("loading",e.isLoading())("showCreate",true)("itemTemplate",n);}},dependencies:[Wn,I,Nb],styles:[".namespace-prompts__back[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.namespace-prompts__back[_ngcontent-%COMP%]:hover{text-decoration:underline}"]})};export{A as NamespacePromptsComponent};
1
+ import {I}from'./chunk-BWqySSd7.js';import {m}from'./chunk-Bf1Bttqy.js';import {g,ao as V$1,G as G$1,w as we,aJ as Tr,z as zi,bS as va,S as By,a7 as ya,X as br,u as ue,c as U$1,h as Rw,aK as xb,I as Is,bf as cT,A as Ag,q as qC,m as pl,af as Dg,r as bC,T as Tg,bg as lT,ah as oT,t as tC,ac as yC,v as nC,a9 as fC,aa as If,ab as wf,ag as pT}from'./main-4SCUMPDY.js';import {W as Wn}from'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';import'./chunk-LgALnta4.js';import'./chunk-BxnUTBZC.js';var U=()=>[];function V(r,t){if(r&1){let o=fC();Is(0,"agentos-prompt-item",4),Ag("deleteRequested",function(n){If(o);let F=yC(2);return wf(F.deletePrompt(n))}),pl();}if(r&2){let o=yC().$implicit,e=yC();Tg("prompt",t)("namespaceId",e.namespaceId)("readOnly",e.isPlatformPrompt(o.id));}}function j(r,t){if(r&1&&tC(0,V,1,3,"agentos-prompt-item",3),r&2){let o,e=t.$implicit,n=yC();nC((o=n.resolvePrompt(e.id))?0:-1,o);}}var G="platform",K="namespace",A=class r{route=g(V$1);router=g(G$1);destroyRef=g(we);promptState=g(m);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=zi(true);allPrompts$=this.refresh$.pipe(va(()=>(this.isLoading.set(true),By({platform:this.promptState.listPlatform().pipe(ya(()=>br([]))),namespace:this.promptState.listByNamespace(this.namespaceId)}))));promptItems$=this.allPrompts$.pipe(ue(({platform:t,namespace:o})=>[...t.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:G,groupLabel:"Platform (read-only)"})),...o.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:K,groupLabel:"Namespace"}))]));namespacePromptsById=new Map;platformPromptsById=new Map;constructor(){this.allPrompts$.pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:o})=>{this.platformPromptsById=new Map(t.map(e=>[e.id??"",e])),this.namespacePromptsById=new Map(o.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"prompts","new"]);}deletePrompt(t){this.promptState.delete(t.id??"").pipe(U$1(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolvePrompt(t){return this.platformPromptsById.get(t)??this.namespacePromptsById.get(t)??null}isPlatformPrompt(t){return this.platformPromptsById.has(t)}static \u0275fac=function(o){return new(o||r)};static \u0275cmp=Rw({type:r,selectors:[["agentos-namespace-prompts"]],decls:6,vars:7,consts:[["promptItemTpl",""],["title","Prompts","emptyMessage","No prompts defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","type","button",1,"namespace-prompts__back",3,"click"],[3,"prompt","namespaceId","readOnly"],[3,"deleteRequested","prompt","namespaceId","readOnly"]],template:function(o,e){if(o&1&&(Is(0,"ds-entity-list",1),cT(1,"async"),Ag("createRequested",function(){return e.openCreateForm()}),Is(2,"button",2),Ag("click",function(){return e.goBack()}),qC(3,"\u2190 Namespaces"),pl()(),Dg(4,j,1,1,"ng-template",null,0,pT)),o&2){let n=bC(5);Tg("items",lT(1,4,e.promptItems$)??oT(6,U))("loading",e.isLoading())("showCreate",true)("itemTemplate",n);}},dependencies:[Wn,I,xb],styles:[".namespace-prompts__back[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.namespace-prompts__back[_ngcontent-%COMP%]:hover{text-decoration:underline}"]})};export{A as NamespacePromptsComponent};
@@ -1 +1 @@
1
- import {B}from'./chunk-MIRdYHA6.js';import {g,G,A as Aw,v as vs,W as WC,j as fl,q as oC,X as XE,x as iC,a9 as dC,k as Ag,r as Tg,aa as If,ac as mC,ab as wf}from'./main-SY6UM2GV.js';import'./chunk-8Uub9JWj.js';import'./chunk-Bd2CH26d.js';import'./chunk-DbP7sgsG.js';import'./chunk-Cdb2CX2Q.js';var M=(a,n)=>n.key;function b(a,n){if(a&1){let e=dC();vs(0,"agentos-action-card",6),Ag("nameClicked",function(){let v=If(e).$implicit,x=mC();return wf(x.navigateTo(v.path))}),fl();}if(a&2){let e=n.$implicit;Tg("name",e.name)("mark",e.mark)("markIsEmoji",true)("description",e.description)("clickable",true);}}var C=class a{router=g(G);sections=[{key:"users",mark:"\u{1F464}",name:"Users & Groups",description:"Manage platform users, their admin rights, and namespace user groups.",path:"/agentos/admin/users"},{key:"agents",mark:"\u{1F916}",name:"Platform agents",description:"Manage agent configs shared across all namespaces.",path:"/agentos/admin/agent-configs"},{key:"integrations",mark:"\u{1F517}",name:"Platform integrations",description:"Manage integration configs shared across all namespaces.",path:"/agentos/admin/integration-configs"},{key:"authSetting",mark:"\u{1F512}",name:"Auth settings",description:"Manage auth settings shared across all namespaces.",path:"/agentos/admin/auth-settings"},{key:"ai-providers",mark:"\u{1F9E0}",name:"Platform AI providers",description:"Manage AI provider configs shared across all namespaces.",path:"/agentos/admin/ai-providers"},{key:"ai-models",mark:"\u2728",name:"Platform AI models",description:"Manage AI model configs shared across all namespaces.",path:"/agentos/admin/ai-models"},{key:"prompts",mark:"\u{1F4C4}",name:"Platform prompts",description:"Manage prompts shared across all namespaces.",path:"/agentos/admin/prompts"},{key:"case-definitions",mark:"\u23F0",name:"Platform case definitions",description:"Manage scheduled case definitions shared across all namespaces.",path:"/agentos/admin/case-definitions"}];navigateTo(n){this.router.navigate([n]);}static \u0275fac=function(e){return new(e||a)};static \u0275cmp=Aw({type:a,selectors:[["agentos-admin-home"]],decls:9,vars:0,consts:[[1,"admin-home"],[1,"admin-home__header"],[1,"admin-home__title"],[1,"admin-home__subtitle"],[1,"admin-home__sections"],[3,"name","mark","markIsEmoji","description","clickable"],[3,"nameClicked","name","mark","markIsEmoji","description","clickable"]],template:function(e,s){e&1&&(vs(0,"div",0)(1,"header",1)(2,"h1",2),WC(3,"Administration"),fl(),vs(4,"p",3),WC(5,"Platform-level settings, visible to super-admins only."),fl()(),vs(6,"nav",4),oC(7,b,1,5,"agentos-action-card",5,M),fl()()),e&2&&(XE(7),iC(s.sections));},dependencies:[B],styles:[".admin-home[_ngcontent-%COMP%]{max-width:860px;margin:0 auto;padding:2rem 1rem;display:flex;flex-direction:column;gap:2rem}.admin-home__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.admin-home__title[_ngcontent-%COMP%]{margin:0;font-size:28px;font-weight:700;color:var(--color-text);font-family:var(--font-heading)}.admin-home__subtitle[_ngcontent-%COMP%]{margin:0;font-size:13px;color:var(--color-neutral-600)}.admin-home__sections[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}"]})};export{C as AdminHomeComponent};
1
+ import {B}from'./chunk-Bf1Bttqy.js';import {g,G,h as Rw,I as Is,q as qC,m as pl,o as iC,J as JE,x as sC,a9 as fC,A as Ag,T as Tg,aa as If,ac as yC,ab as wf}from'./main-4SCUMPDY.js';import'./chunk-BESIk8ll.js';import'./chunk-BSY9MBD-.js';import'./chunk-LgALnta4.js';import'./chunk-BxnUTBZC.js';var M=(a,n)=>n.key;function b(a,n){if(a&1){let e=fC();Is(0,"agentos-action-card",6),Ag("nameClicked",function(){let v=If(e).$implicit,x=yC();return wf(x.navigateTo(v.path))}),pl();}if(a&2){let e=n.$implicit;Tg("name",e.name)("mark",e.mark)("markIsEmoji",true)("description",e.description)("clickable",true);}}var C=class a{router=g(G);sections=[{key:"users",mark:"\u{1F464}",name:"Users & Groups",description:"Manage platform users, their admin rights, and namespace user groups.",path:"/agentos/admin/users"},{key:"agents",mark:"\u{1F916}",name:"Platform agents",description:"Manage agent configs shared across all namespaces.",path:"/agentos/admin/agent-configs"},{key:"integrations",mark:"\u{1F517}",name:"Platform integrations",description:"Manage integration configs shared across all namespaces.",path:"/agentos/admin/integration-configs"},{key:"authSetting",mark:"\u{1F512}",name:"Auth settings",description:"Manage auth settings shared across all namespaces.",path:"/agentos/admin/auth-settings"},{key:"ai-providers",mark:"\u{1F9E0}",name:"Platform AI providers",description:"Manage AI provider configs shared across all namespaces.",path:"/agentos/admin/ai-providers"},{key:"ai-models",mark:"\u2728",name:"Platform AI models",description:"Manage AI model configs shared across all namespaces.",path:"/agentos/admin/ai-models"},{key:"prompts",mark:"\u{1F4C4}",name:"Platform prompts",description:"Manage prompts shared across all namespaces.",path:"/agentos/admin/prompts"},{key:"case-definitions",mark:"\u23F0",name:"Platform case definitions",description:"Manage scheduled case definitions shared across all namespaces.",path:"/agentos/admin/case-definitions"}];navigateTo(n){this.router.navigate([n]);}static \u0275fac=function(e){return new(e||a)};static \u0275cmp=Rw({type:a,selectors:[["agentos-admin-home"]],decls:9,vars:0,consts:[[1,"admin-home"],[1,"admin-home__header"],[1,"admin-home__title"],[1,"admin-home__subtitle"],[1,"admin-home__sections"],[3,"name","mark","markIsEmoji","description","clickable"],[3,"nameClicked","name","mark","markIsEmoji","description","clickable"]],template:function(e,s){e&1&&(Is(0,"div",0)(1,"header",1)(2,"h1",2),qC(3,"Administration"),pl(),Is(4,"p",3),qC(5,"Platform-level settings, visible to super-admins only."),pl()(),Is(6,"nav",4),iC(7,b,1,5,"agentos-action-card",5,M),pl()()),e&2&&(JE(7),sC(s.sections));},dependencies:[B],styles:[".admin-home[_ngcontent-%COMP%]{max-width:860px;margin:0 auto;padding:2rem 1rem;display:flex;flex-direction:column;gap:2rem}.admin-home__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.admin-home__title[_ngcontent-%COMP%]{margin:0;font-size:28px;font-weight:700;color:var(--color-text);font-family:var(--font-heading)}.admin-home__subtitle[_ngcontent-%COMP%]{margin:0;font-size:13px;color:var(--color-neutral-600)}.admin-home__sections[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}"]})};export{C as AdminHomeComponent};
@@ -0,0 +1 @@
1
+ import {g,ao as V,G,d5 as N,w as we,z as zi,c as U$1,a as z$1,b as P,h as Rw,I as Is,A as Ag,q as qC,m as pl,t as tC,J as JE,a8 as Zg,v as nC,a9 as fC,n as bg,a3 as UI,ac as yC,T as Tg,a6 as zI,a5 as vl,aa as If,ab as wf}from'./main-4SCUMPDY.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Y as Ye,f as fn,Z as Zn,l as Xn,$ as $t,C as Cn,E as En}from'./chunk-LgALnta4.js';function U(l,r){l&1&&(Is(0,"p",5),qC(1,"Loading\u2026"),pl());}function H(l,r){if(l&1){let e=fC();Is(0,"form",7),Ag("ngSubmit",function(){If(e);let u=yC();return wf(u.submit())}),Is(1,"div",8)(2,"label",9),qC(3,"Name "),Is(4,"span",10),qC(5,"*"),pl()(),bg(6,"input",11),UI(),pl(),Is(7,"div",8)(8,"label",12),qC(9,"Description"),pl(),bg(10,"textarea",13),UI(),pl(),Is(11,"div",8)(12,"label",14),qC(13,"External ID"),pl(),bg(14,"input",15),UI(),pl(),Is(15,"div",8)(16,"label",16),qC(17,"Default agent"),pl(),bg(18,"input",17),UI(),pl(),Is(19,"div",8)(20,"label",18),qC(21,"Config path"),pl(),bg(22,"input",19),UI(),pl(),Is(23,"div",8)(24,"label",20),qC(25,"Run cost threshold"),pl(),bg(26,"input",21),UI(),Is(27,"span",22),qC(28,"Leave empty to inherit the platform default."),pl()(),Is(29,"div",23)(30,"button",24),qC(31),pl(),Is(32,"button",25),Ag("click",function(){If(e);let u=yC();return wf(u.cancel())}),qC(33,"Cancel"),pl()()();}if(l&2){let e=yC();Tg("formGroup",e.form),JE(6),Tg("formControl",e.nameControl),zI(),JE(4),Tg("formControl",e.descriptionControl),zI(),JE(4),Tg("formControl",e.externalIdControl),zI(),JE(4),Tg("formControl",e.defaultAgentNameControl),zI(),JE(4),Tg("formControl",e.configPathControl),zI(),JE(4),Tg("formControl",e.runCostThresholdControl),zI(),JE(4),Tg("disabled",e.nameControl.invalid||e.isSubmitting()),JE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var q=class l{route=g(V);router=g(G);namespaceController=g(N);destroyRef=g(we);form=new z({name:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t("",{nonNullable:true}),configPath:new _t("",{nonNullable:true}),externalId:new _t("",{nonNullable:true}),defaultAgentName:new _t("",{nonNullable:true}),runCostThreshold:new _t(null)});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get configPathControl(){return this.form.controls.configPath}get externalIdControl(){return this.form.controls.externalId}get defaultAgentNameControl(){return this.form.controls.defaultAgentName}get runCostThresholdControl(){return this.form.controls.runCostThreshold}isEditMode=zi(false);isSubmitting=zi(false);isLoading=zi(false);existingNamespace=null;ngOnInit(){let r=this.route.snapshot.paramMap.get("namespaceId");r&&(this.isEditMode.set(true),this.loadNamespace(r));}loadNamespace(r){this.isLoading.set(true),this.namespaceController.getByIdNamespace(r).pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.existingNamespace=e,this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??""),this.configPathControl.setValue(e.configPath??""),this.externalIdControl.setValue(e.externalId??""),this.defaultAgentNameControl.setValue(e.defaultAgentName??""),this.runCostThresholdControl.setValue(e.runCostThreshold??null),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.nameControl.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let r=z$1(P({},this.existingNamespace),{name:this.nameControl.value.trim(),description:this.descriptionControl.value.trim()||void 0,configPath:this.configPathControl.value.trim()||void 0,externalId:this.externalIdControl.value.trim()||void 0,defaultAgentName:this.defaultAgentNameControl.value.trim()||void 0,runCostThreshold:this.runCostThresholdControl.value??void 0});(this.isEditMode()?this.namespaceController.updateNamespace(this.existingNamespace.id??"",r):this.namespaceController.createNamespace(r)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.router.navigate(["/agentos/namespaces"]);}static \u0275fac=function(e){return new(e||l)};static \u0275cmp=Rw({type:l,selectors:[["agentos-namespace-form"]],decls:10,vars:2,consts:[[1,"namespace-form"],[1,"namespace-form__header"],["type","button","title","Back to namespaces",1,"namespace-form__back",3,"click"],[1,"namespace-form__back-icon"],[1,"namespace-form__title"],[1,"namespace-form__loading"],[1,"namespace-form__form",3,"formGroup"],[1,"namespace-form__form",3,"ngSubmit","formGroup"],[1,"namespace-form__field"],["for","ns-name",1,"namespace-form__label"],["aria-hidden","true"],["id","ns-name","type","text","placeholder","Namespace name","autocomplete","off",1,"namespace-form__input",3,"formControl"],["for","ns-description",1,"namespace-form__label"],["id","ns-description","rows","4","placeholder","Optional description",1,"namespace-form__textarea",3,"formControl"],["for","ns-external-id",1,"namespace-form__label"],["id","ns-external-id","type","text","placeholder","Optional federation ID from an external system","autocomplete","off",1,"namespace-form__input",3,"formControl"],["for","ns-default-agent",1,"namespace-form__label"],["id","ns-default-agent","type","text","placeholder","Logical name of the default agent (e.g. coday)","autocomplete","off",1,"namespace-form__input",3,"formControl"],["for","ns-config-path",1,"namespace-form__label"],["id","ns-config-path","type","text","placeholder","Optional path to base configuration directory","autocomplete","off",1,"namespace-form__input",3,"formControl"],["for","ns-run-cost-threshold",1,"namespace-form__label"],["id","ns-run-cost-threshold","type","number","min","0","step","0.01","placeholder","Optional maximum cost per run (e.g. 0.50)",1,"namespace-form__input",3,"formControl"],[1,"namespace-form__hint"],[1,"namespace-form__actions"],["type","submit",1,"namespace-form__btn","namespace-form__btn--primary",3,"disabled"],["type","button",1,"namespace-form__btn",3,"click"]],template:function(e,p){e&1&&(Is(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return p.cancel()}),Is(3,"span",3),qC(4,"\u2190"),pl(),qC(5," Namespaces "),pl(),Is(6,"h1",4),qC(7),pl()(),tC(8,U,2,0,"p",5)(9,H,34,9,"form",6),pl()),e&2&&(JE(7),Zg(p.isEditMode()?"Edit namespace":"New namespace"),JE(),nC(p.isLoading()?8:9));},dependencies:[ni,Jn,Ye,fn,Zn,Xn,$t,Cn,En],styles:[".namespace-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.namespace-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.namespace-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.namespace-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.namespace-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.namespace-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.namespace-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.namespace-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.namespace-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.namespace-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.namespace-form__input[_ngcontent-%COMP%], .namespace-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.namespace-form__input[_ngcontent-%COMP%]:focus, .namespace-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.namespace-form__input[_ngcontent-%COMP%]::placeholder, .namespace-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.namespace-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:96px;line-height:1.5}.namespace-form__hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.namespace-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.namespace-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.namespace-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.namespace-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.namespace-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.namespace-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{q as NamespaceFormComponent};