@whoz-oss/coday-client 0.242.0 → 0.244.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 (71) hide show
  1. package/browser/{chunk-JCKKIKVU.js → chunk-4CNY7Z64.js} +1 -1
  2. package/browser/{chunk-NEVEN2BG.js → chunk-4FGWE3EW.js} +1 -1
  3. package/browser/{chunk-HN4TBO7J.js → chunk-5N6DUZII.js} +1 -1
  4. package/browser/{chunk-IN5SVY4U.js → chunk-5OGZHNUE.js} +1 -1
  5. package/browser/{chunk-SDHC7TR2.js → chunk-5WX43L4B.js} +1 -1
  6. package/browser/{chunk-36EOCF7B.js → chunk-5Y2Q6WKL.js} +1 -1
  7. package/browser/{chunk-DFXCCLVG.js → chunk-6BMCL5TR.js} +1 -1
  8. package/browser/{chunk-MZBZJFIH.js → chunk-76HYDFUL.js} +1 -1
  9. package/browser/{chunk-62AZ3TER.js → chunk-7H4TBVB7.js} +1 -1
  10. package/browser/{chunk-P3AFMA53.js → chunk-7O6TY5IW.js} +1 -1
  11. package/browser/{chunk-LU3ZSYWJ.js → chunk-ADEIEQGJ.js} +1 -1
  12. package/browser/{chunk-PXY6PLET.js → chunk-AK746XRX.js} +1 -1
  13. package/browser/{chunk-KKYAHLLD.js → chunk-BWBZLC7A.js} +1 -1
  14. package/browser/{chunk-ZCELWKMZ.js → chunk-CRXIMHRG.js} +3 -3
  15. package/browser/{chunk-GBTVBYVO.js → chunk-CSHG3PLJ.js} +1 -1
  16. package/browser/{chunk-AV3U5ZDG.js → chunk-CU7SABOQ.js} +1 -1
  17. package/browser/{chunk-N6D7DELC.js → chunk-DZ2M3NQD.js} +1 -1
  18. package/browser/{chunk-WH2T6TJR.js → chunk-ECISS7V2.js} +1 -1
  19. package/browser/{chunk-QCC2HSMN.js → chunk-ENRRDIUM.js} +1 -1
  20. package/browser/{chunk-ZS3GOED4.js → chunk-F4ZRQ6MH.js} +1 -1
  21. package/browser/chunk-FA2MVU23.js +1 -0
  22. package/browser/{chunk-GWUHK3IY.js → chunk-GLFQ37PU.js} +1 -1
  23. package/browser/{chunk-KH3XUBG3.js → chunk-GSUU7JSY.js} +1 -1
  24. package/browser/{chunk-6UXZYGDR.js → chunk-H6NBS4JE.js} +1 -1
  25. package/browser/{chunk-FV7MYI7I.js → chunk-I4RHXOIC.js} +1 -1
  26. package/browser/{chunk-KZ2MXYPS.js → chunk-KJJPVCIH.js} +1 -1
  27. package/browser/chunk-KWJJEVAI.js +1 -0
  28. package/browser/{chunk-QA4DQZOM.js → chunk-LHKOA7FX.js} +1 -1
  29. package/browser/{chunk-FOUZFGE6.js → chunk-LUB22VNT.js} +1 -1
  30. package/browser/{chunk-6QIZQ7GE.js → chunk-MFSY4HYK.js} +1 -1
  31. package/browser/{chunk-LYXZJWHW.js → chunk-MIAKSSSF.js} +1 -1
  32. package/browser/{chunk-XFS5RNFU.js → chunk-N2NJQ7DJ.js} +1 -1
  33. package/browser/chunk-NGMAQNX3.js +4 -0
  34. package/browser/{chunk-HY5SN7AG.js → chunk-NNUJIQ6R.js} +1 -1
  35. package/browser/{chunk-TMQGM3DO.js → chunk-NYUYHMIH.js} +1 -1
  36. package/browser/{chunk-JMRUD2BW.js → chunk-ONZVOEJQ.js} +1 -1
  37. package/browser/chunk-P6WNH2KJ.js +1 -0
  38. package/browser/{chunk-VNLBXJU6.js → chunk-QTXEWRHZ.js} +1 -1
  39. package/browser/{chunk-OY6A2XLL.js → chunk-QXBTTCPM.js} +1 -1
  40. package/browser/{chunk-OCX3RQ65.js → chunk-R2NWLPS6.js} +1 -1
  41. package/browser/{chunk-NIV7FMON.js → chunk-RQKLSUW5.js} +1 -1
  42. package/browser/{chunk-UU5QELSX.js → chunk-S5QSZK6N.js} +1 -1
  43. package/browser/{chunk-RGGNQESF.js → chunk-SZM3NJVZ.js} +1 -1
  44. package/browser/{chunk-UAHVURDD.js → chunk-TNSH3NBF.js} +1 -1
  45. package/browser/{chunk-IV7SJSBN.js → chunk-U3AHBQTX.js} +1 -1
  46. package/browser/{chunk-IYEDRCU5.js → chunk-U7ZJFIOR.js} +1 -1
  47. package/browser/{chunk-AFRMVXZZ.js → chunk-UEGZX4MW.js} +1 -1
  48. package/browser/{chunk-D5BPAYOR.js → chunk-UO7SKQEC.js} +1 -1
  49. package/browser/{chunk-BLRBIAYK.js → chunk-UQTA3ACH.js} +1 -1
  50. package/browser/{chunk-35S3IW2A.js → chunk-UWYJO2DN.js} +1 -1
  51. package/browser/{chunk-M5ZWYOBX.js → chunk-VLDPXI7G.js} +1 -1
  52. package/browser/{chunk-MQEDNZF7.js → chunk-VZOBZ3DD.js} +1 -1
  53. package/browser/chunk-W7A7CPWM.js +1 -0
  54. package/browser/{chunk-N2F3TQJA.js → chunk-WMHS3NSI.js} +1 -1
  55. package/browser/{chunk-4T6SALXS.js → chunk-X5ZRXGFA.js} +1 -1
  56. package/browser/{chunk-5IIN2VT5.js → chunk-X73LZ3QV.js} +1 -1
  57. package/browser/{chunk-3MTFWGAR.js → chunk-XAEUGARN.js} +1 -1
  58. package/browser/chunk-XJYEZL5J.js +1 -0
  59. package/browser/{chunk-Y37OZMXI.js → chunk-XZRVHU66.js} +1 -1
  60. package/browser/{chunk-WNYGQVYX.js → chunk-YGBFW4ZS.js} +1 -1
  61. package/browser/{chunk-FELLJOVH.js → chunk-ZQZHBROX.js} +1 -1
  62. package/browser/{chunk-3MREZSO7.js → chunk-ZXQEKBPA.js} +1 -1
  63. package/browser/index.html +1 -1
  64. package/browser/{main-44QZIU3R.js → main-VWHGBAF5.js} +1 -1
  65. package/package.json +1 -1
  66. package/browser/chunk-57XIXFX3.js +0 -1
  67. package/browser/chunk-HSEJNG7W.js +0 -3
  68. package/browser/chunk-LQOQ3VK5.js +0 -1
  69. package/browser/chunk-MH3KTYRA.js +0 -1
  70. package/browser/chunk-QBT6LKOQ.js +0 -1
  71. package/browser/chunk-TET2CIOZ.js +0 -1
@@ -1 +1 @@
1
- import{a as te,b as ie,c as ne}from"./chunk-N2F3TQJA.js";import{a as ee}from"./chunk-KZ2MXYPS.js";import"./chunk-NWFFZ2FW.js";import"./chunk-MQEDNZF7.js";import"./chunk-BLRBIAYK.js";import{a as q,c as B}from"./chunk-6XX7GME4.js";import{a as k,c as T}from"./chunk-VMYKE4ZC.js";import{F as Z,c as L,e as x,g as K,h as G,i as $,l as c,n as H,p as j,s as Y,w as J,x as Q,y as W,z as X}from"./chunk-7OGOI6WM.js";import{Bb as N,Db as v,Fb as d,Ka as l,Sb as R,Tb as s,Ub as A,Vb as I,Wa as E,a as p,b as h,ca as C,ga as V,ha as O,kb as U,lb as m,ma as F,mb as g,mc as z,ob as D,pb as S,qb as b,rb as u,sb as r,ta as f,tb as o,ua as w,ub as _}from"./chunk-CHEXA6RY.js";function re(i,t){i&1&&(r(0,"p",5),s(1,"Loading\u2026"),o())}function ae(i,t){if(i&1&&(r(0,"label",23),_(1,"input",24),r(2,"span"),s(3),o()()),i&2){let e=t.$implicit,n=d(3);l(),u("formControl",n.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!n.isAdmin()),l(2),A(e.label)}}function le(i,t){if(i&1&&(r(0,"fieldset",8)(1,"legend",22),s(2,"Port\xE9e de la configuration"),o(),S(3,ae,4,4,"label",23,U().trackByScope,!0),o()),i&2){let e=d(2);u("disabled",e.isEditMode()),l(3),b(e.scopeOptions)}}function se(i,t){if(i&1&&(r(0,"option",13),s(1),o()),i&2){let e=t.$implicit,n=d(2);u("value",e),l(),A(n.authTypeLabel[e])}}function ce(i,t){i&1&&s(0," Leave a field unchanged to keep the stored credential. ")}function ue(i,t){i&1&&(r(0,"span",11),s(1,"*"),o())}function de(i,t){if(i&1&&_(0,"input",28),i&2){let e=d().$implicit;R("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),u("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off")}}function pe(i,t){if(i&1&&(r(0,"div",9)(1,"label",26),s(2),m(3,ue,2,0,"span",11),o(),m(4,de,1,7,"input",27),o()),i&2){let e,n=t.$implicit,a=d(3);l(),u("for","as-cred-"+n.key),l(),I(" ",n.label," "),l(),g(n.required?3:-1),l(),g((e=a.controlForField(n.key))?4:-1,e)}}function he(i,t){if(i&1&&(r(0,"fieldset",18)(1,"legend",22),s(2,"Credentials"),o(),r(3,"p",25),s(4," Values are stored encrypted and masked on read. "),m(5,ce,1,0),o(),S(6,pe,5,4,"div",9,U().trackByField,!0),o()),i&2){let e=d(2);l(5),g(e.isEditMode()?5:-1),l(),b(e.credentialFields())}}function me(i,t){if(i&1){let e=N();r(0,"form",7),v("ngSubmit",function(){V(e);let a=d();return O(a.submit())}),m(1,le,5,1,"fieldset",8),r(2,"div",9)(3,"label",10),s(4,"Auth type "),r(5,"span",11),s(6,"*"),o()(),r(7,"select",12),S(8,se,2,2,"option",13,D),o()(),r(10,"div",9)(11,"label",14),s(12,"Name "),r(13,"span",11),s(14,"*"),o()(),_(15,"input",15),o(),r(16,"div",9)(17,"label",16),s(18,"Description"),o(),_(19,"input",17),o(),m(20,he,8,1,"fieldset",18),r(21,"div",19)(22,"button",20),s(23),o(),r(24,"button",21),v("click",function(){V(e);let a=d();return O(a.cancel())}),s(25,"Cancel"),o()()()}if(i&2){let e=d();u("formGroup",e.form),l(),g(e.isPlatformMode?-1:1),l(6),u("formControl",e.authTypeControl),l(),b(e.authTypeOptions),l(7),u("formControl",e.nameControl),l(4),u("formControl",e.descriptionControl),l(),g(e.credentialFields().length>0?20:-1),l(2),u("disabled",e.form.invalid||e.isSubmitting()),l(),I(" ",e.isEditMode()?"Save changes":"Create"," ")}}var ge=new Set(["namespace","userOnNs","userGlobal"]),M=Object.freeze({platform:"Plateforme (lecture seule)",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),Ce={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:!0,required:!1}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:!1,required:!1},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:!0,required:!1}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:!0,required:!1}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:!1,required:!1},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:!1,required:!1},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://\u2026/mcp",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}]},oe=class i{route=C(q);router=C(B);destroyRef=C(F);state=C(ne);namespaceRole=C(ee);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?f(!0):T(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:!1});authTypeOptions=te;authTypeLabel=ie;scopeOptions=[{value:"namespace",label:M.namespace},{value:"userOnNs",label:M.userOnNs},{value:"userGlobal",label:M.userGlobal}];nameControl=new c("",{nonNullable:!0,validators:[x.required,x.minLength(1)]});descriptionControl=new c(null);authTypeControl=new c("ApiKeyAuthSetting",{nonNullable:!0,validators:[x.required]});scopeControl=new c("namespace",{nonNullable:!0});form=new $({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new c("",{nonNullable:!0});usernameControl=new c("",{nonNullable:!0});passwordControl=new c("",{nonNullable:!0});tokenControl=new c("",{nonNullable:!0});discoveryUrlControl=new c("",{nonNullable:!0});authorizationUrlControl=new c("",{nonNullable:!0});tokenUrlControl=new c("",{nonNullable:!0});clientIdControl=new c("",{nonNullable:!0});clientSecretControl=new c("",{nonNullable:!0});scopesControl=new c("",{nonNullable:!0});resourceUrlControl=new c("",{nonNullable:!0});selectedAuthType=T(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=z(()=>Ce[this.selectedAuthType()]);isEditMode=f(!1);isSubmitting=f(!1);isLoading=f(!1);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||w(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("authSettingId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let a=this.parseScope(e.get("scope"));this.scopeControl.setValue(a);let y=e.get("template");y&&this.hydrateFromTemplate(y)}parseScope(t){return t&&ge.has(t)?t:"namespace"}deriveScopeFromConfig(t){return!t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(!0),this.state.getById(t).pipe(k(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(t){this.isLoading.set(!0),this.state.getById(t).pipe(k(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case"ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case"BasicAuthAuthSetting":{let e=t,n=e.username??"",a=e.password??"";this.usernameControl.setValue(n),this.passwordControl.setValue(a),this.initialCredentials.username=n,this.initialCredentials.password=a;break}case"BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case"OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("")}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,n=this.authTypeControl.value,a=this.form.getRawValue().scope,y=this.isPlatformMode?null:this.namespaceId??null,P=this.buildTypedPayload(n,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,P,this.existingConfig):this.state.create(P,a,y)).pipe(k(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}buildTypedPayload(t,e,n){let a={name:e,description:n};switch(t){case"ApiKeyAuthSetting":return h(p({},a),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case"BasicAuthAuthSetting":return h(p({},a),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case"BearerTokenAuthSetting":return h(p({},a),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case"OAuthDiscoverableAuthSetting":return h(p({},a),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthCustomAuthSetting":return h(p({},a),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthRegisteredAuthSetting":return h(p({},a),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthMcpDiscoverableAuthSetting":return h(p({},a),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return{apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"])}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","class","type","placeholder","formControl","autocomplete"],[3,"id","type","placeholder","formControl","autocomplete"]],template:function(e,n){e&1&&(r(0,"div",0)(1,"header",1)(2,"button",2),v("click",function(){return n.cancel()}),r(3,"span",3),s(4,"\u2190"),o(),s(5," Auth Settings "),o(),r(6,"h1",4),s(7),o()(),m(8,re,2,0,"p",5)(9,me,26,8,"form",6),o()),e&2&&(l(7),A(n.isEditMode()?"Edit auth setting":"New auth setting"),l(),g(n.isLoading()?8:9))},dependencies:[Z,H,W,X,L,Q,j,K,G,Y,J],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"],changeDetection:0})};export{oe as AuthSettingFormComponent};
1
+ import{a as te,b as ie,c as ne}from"./chunk-WMHS3NSI.js";import{a as ee}from"./chunk-KJJPVCIH.js";import"./chunk-NWFFZ2FW.js";import"./chunk-VZOBZ3DD.js";import"./chunk-UQTA3ACH.js";import{a as q,c as B}from"./chunk-6XX7GME4.js";import{a as k,c as T}from"./chunk-VMYKE4ZC.js";import{F as Z,c as L,e as x,g as K,h as G,i as $,l as c,n as H,p as j,s as Y,w as J,x as Q,y as W,z as X}from"./chunk-7OGOI6WM.js";import{Bb as N,Db as v,Fb as d,Ka as l,Sb as R,Tb as s,Ub as A,Vb as I,Wa as E,a as p,b as h,ca as C,ga as V,ha as O,kb as U,lb as m,ma as F,mb as g,mc as z,ob as D,pb as S,qb as b,rb as u,sb as r,ta as f,tb as o,ua as w,ub as _}from"./chunk-CHEXA6RY.js";function re(i,t){i&1&&(r(0,"p",5),s(1,"Loading\u2026"),o())}function ae(i,t){if(i&1&&(r(0,"label",23),_(1,"input",24),r(2,"span"),s(3),o()()),i&2){let e=t.$implicit,n=d(3);l(),u("formControl",n.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!n.isAdmin()),l(2),A(e.label)}}function le(i,t){if(i&1&&(r(0,"fieldset",8)(1,"legend",22),s(2,"Port\xE9e de la configuration"),o(),S(3,ae,4,4,"label",23,U().trackByScope,!0),o()),i&2){let e=d(2);u("disabled",e.isEditMode()),l(3),b(e.scopeOptions)}}function se(i,t){if(i&1&&(r(0,"option",13),s(1),o()),i&2){let e=t.$implicit,n=d(2);u("value",e),l(),A(n.authTypeLabel[e])}}function ce(i,t){i&1&&s(0," Leave a field unchanged to keep the stored credential. ")}function ue(i,t){i&1&&(r(0,"span",11),s(1,"*"),o())}function de(i,t){if(i&1&&_(0,"input",28),i&2){let e=d().$implicit;R("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),u("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off")}}function pe(i,t){if(i&1&&(r(0,"div",9)(1,"label",26),s(2),m(3,ue,2,0,"span",11),o(),m(4,de,1,7,"input",27),o()),i&2){let e,n=t.$implicit,a=d(3);l(),u("for","as-cred-"+n.key),l(),I(" ",n.label," "),l(),g(n.required?3:-1),l(),g((e=a.controlForField(n.key))?4:-1,e)}}function he(i,t){if(i&1&&(r(0,"fieldset",18)(1,"legend",22),s(2,"Credentials"),o(),r(3,"p",25),s(4," Values are stored encrypted and masked on read. "),m(5,ce,1,0),o(),S(6,pe,5,4,"div",9,U().trackByField,!0),o()),i&2){let e=d(2);l(5),g(e.isEditMode()?5:-1),l(),b(e.credentialFields())}}function me(i,t){if(i&1){let e=N();r(0,"form",7),v("ngSubmit",function(){V(e);let a=d();return O(a.submit())}),m(1,le,5,1,"fieldset",8),r(2,"div",9)(3,"label",10),s(4,"Auth type "),r(5,"span",11),s(6,"*"),o()(),r(7,"select",12),S(8,se,2,2,"option",13,D),o()(),r(10,"div",9)(11,"label",14),s(12,"Name "),r(13,"span",11),s(14,"*"),o()(),_(15,"input",15),o(),r(16,"div",9)(17,"label",16),s(18,"Description"),o(),_(19,"input",17),o(),m(20,he,8,1,"fieldset",18),r(21,"div",19)(22,"button",20),s(23),o(),r(24,"button",21),v("click",function(){V(e);let a=d();return O(a.cancel())}),s(25,"Cancel"),o()()()}if(i&2){let e=d();u("formGroup",e.form),l(),g(e.isPlatformMode?-1:1),l(6),u("formControl",e.authTypeControl),l(),b(e.authTypeOptions),l(7),u("formControl",e.nameControl),l(4),u("formControl",e.descriptionControl),l(),g(e.credentialFields().length>0?20:-1),l(2),u("disabled",e.form.invalid||e.isSubmitting()),l(),I(" ",e.isEditMode()?"Save changes":"Create"," ")}}var ge=new Set(["namespace","userOnNs","userGlobal"]),M=Object.freeze({platform:"Plateforme (lecture seule)",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),Ce={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:!0,required:!1}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:!1,required:!1},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:!0,required:!1}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:!0,required:!1}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:!1,required:!1},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:!1,required:!1},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://\u2026/mcp",secret:!1,required:!1},{key:"clientId",label:"Client ID",placeholder:"",secret:!1,required:!1},{key:"clientSecret",label:"Client secret",placeholder:"",secret:!0,required:!1},{key:"scopes",label:"Scopes",placeholder:"openid profile email",secret:!1,required:!1}]},oe=class i{route=C(q);router=C(B);destroyRef=C(F);state=C(ne);namespaceRole=C(ee);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?f(!0):T(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:!1});authTypeOptions=te;authTypeLabel=ie;scopeOptions=[{value:"namespace",label:M.namespace},{value:"userOnNs",label:M.userOnNs},{value:"userGlobal",label:M.userGlobal}];nameControl=new c("",{nonNullable:!0,validators:[x.required,x.minLength(1)]});descriptionControl=new c(null);authTypeControl=new c("ApiKeyAuthSetting",{nonNullable:!0,validators:[x.required]});scopeControl=new c("namespace",{nonNullable:!0});form=new $({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new c("",{nonNullable:!0});usernameControl=new c("",{nonNullable:!0});passwordControl=new c("",{nonNullable:!0});tokenControl=new c("",{nonNullable:!0});discoveryUrlControl=new c("",{nonNullable:!0});authorizationUrlControl=new c("",{nonNullable:!0});tokenUrlControl=new c("",{nonNullable:!0});clientIdControl=new c("",{nonNullable:!0});clientSecretControl=new c("",{nonNullable:!0});scopesControl=new c("",{nonNullable:!0});resourceUrlControl=new c("",{nonNullable:!0});selectedAuthType=T(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=z(()=>Ce[this.selectedAuthType()]);isEditMode=f(!1);isSubmitting=f(!1);isLoading=f(!1);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||w(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("authSettingId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let a=this.parseScope(e.get("scope"));this.scopeControl.setValue(a);let y=e.get("template");y&&this.hydrateFromTemplate(y)}parseScope(t){return t&&ge.has(t)?t:"namespace"}deriveScopeFromConfig(t){return!t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(!0),this.state.getById(t).pipe(k(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(t){this.isLoading.set(!0),this.state.getById(t).pipe(k(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case"ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case"BasicAuthAuthSetting":{let e=t,n=e.username??"",a=e.password??"";this.usernameControl.setValue(n),this.passwordControl.setValue(a),this.initialCredentials.username=n,this.initialCredentials.password=a;break}case"BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case"OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case"OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("")}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,n=this.authTypeControl.value,a=this.form.getRawValue().scope,y=this.isPlatformMode?null:this.namespaceId??null,P=this.buildTypedPayload(n,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,P,this.existingConfig):this.state.create(P,a,y)).pipe(k(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}buildTypedPayload(t,e,n){let a={name:e,description:n};switch(t){case"ApiKeyAuthSetting":return h(p({},a),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case"BasicAuthAuthSetting":return h(p({},a),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case"BearerTokenAuthSetting":return h(p({},a),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case"OAuthDiscoverableAuthSetting":return h(p({},a),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthCustomAuthSetting":return h(p({},a),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthRegisteredAuthSetting":return h(p({},a),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case"OAuthMcpDiscoverableAuthSetting":return h(p({},a),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return{apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"])}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","class","type","placeholder","formControl","autocomplete"],[3,"id","type","placeholder","formControl","autocomplete"]],template:function(e,n){e&1&&(r(0,"div",0)(1,"header",1)(2,"button",2),v("click",function(){return n.cancel()}),r(3,"span",3),s(4,"\u2190"),o(),s(5," Auth Settings "),o(),r(6,"h1",4),s(7),o()(),m(8,re,2,0,"p",5)(9,me,26,8,"form",6),o()),e&2&&(l(7),A(n.isEditMode()?"Edit auth setting":"New auth setting"),l(),g(n.isLoading()?8:9))},dependencies:[Z,H,W,X,L,Q,j,K,G,Y,J],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"],changeDetection:0})};export{oe as AuthSettingFormComponent};
@@ -1 +1 @@
1
- import{a as L}from"./chunk-KHMEGI4Z.js";import{b as z}from"./chunk-BLRBIAYK.js";import"./chunk-TSYL5EEO.js";import{a as T,c as A,d as D}from"./chunk-6XX7GME4.js";import{a as N}from"./chunk-VMYKE4ZC.js";import{Bb as b,Db as f,Fb as l,Ga as M,Ka as r,Rb as u,Tb as a,Ub as p,Vb as h,Wa as I,ca as _,fc as O,ga as C,gc as w,ha as x,jb as v,lb as d,ma as P,mb as s,pb as S,qb as E,rb as y,sb as i,ta as m,tb as t,ub as k}from"./chunk-CHEXA6RY.js";var F=(n,o)=>o.name;function B(n,o){n&1&&(i(0,"p",6),a(1,"Loading\u2026"),t())}function $(n,o){n&1&&(i(0,"p",7),a(1,"Failed to load agent definition."),t())}function j(n,o){if(n&1&&(i(0,"dt",12),a(1,"User context"),t(),i(2,"dd",14),a(3),t()),n&2){let e=l();r(3),p(e.userId)}}function H(n,o){if(n&1&&(i(0,"pre",21),a(1),t()),n&2){let e=l(2);r(),p(e.systemPrompt)}}function J(n,o){if(n&1){let e=b();i(0,"section",9)(1,"button",19),f("click",function(){C(e);let g=l(2);return x(g.toggleSystemPrompt())}),i(2,"h2",10),a(3,"System Prompt"),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,H,2,1,"pre",21),t()}if(n&2){let e=l(2);r(),v("aria-expanded",!e.systemPromptCollapsed()),r(3),u("agent-config-inspect__chevron--open",!e.systemPromptCollapsed()),r(2),s(e.systemPromptCollapsed()?-1:6)}}function U(n,o){if(n&1&&(i(0,"pre",21),a(1),t()),n&2){let e=l(2);r(),p(e.instructions)}}function G(n,o){if(n&1){let e=b();i(0,"section",9)(1,"button",19),f("click",function(){C(e);let g=l(2);return x(g.toggleInstructions())}),i(2,"h2",10),a(3,"Instructions"),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,U,2,1,"pre",21),t()}if(n&2){let e=l(2);r(),v("aria-expanded",!e.instructionsCollapsed()),r(3),u("agent-config-inspect__chevron--open",!e.instructionsCollapsed()),r(2),s(e.instructionsCollapsed()?-1:6)}}function q(n,o){n&1&&(i(0,"p",17),a(1,"No tools available for this agent."),t())}function K(n,o){if(n&1&&(k(0,"div",26),O(1,"agentosMarkdown")),n&2){let e=l(2).$implicit;y("innerHTML",w(1,1,e.description),M)}}function Q(n,o){if(n&1&&(i(0,"div",25),d(1,K,2,3,"div",26),i(2,"pre",27),a(3),t()()),n&2){let e=l().$implicit,c=l(3);r(),s(e.description?1:-1),r(2),p(c.formatSchema(e.inputSchema))}}function W(n,o){if(n&1){let e=b();i(0,"li",22)(1,"button",23),f("click",function(){let g=C(e).$implicit,V=l(3);return x(V.toggleTool(g))}),i(2,"span",24),a(3),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,Q,4,2,"div",25),t()}if(n&2){let e=o.$implicit,c=l(3);r(),v("aria-expanded",c.isToolExpanded(e)),r(2),p(e.name),r(),u("agent-config-inspect__chevron--open",c.isToolExpanded(e)),r(2),s(c.isToolExpanded(e)?6:-1)}}function X(n,o){if(n&1&&(i(0,"ul",18),S(1,W,7,5,"li",22,F),t()),n&2){let e=l();r(),E(e.tools)}}function Y(n,o){if(n&1&&(i(0,"div",8)(1,"section",9)(2,"h2",10),a(3,"General"),t(),i(4,"dl",11)(5,"dt",12),a(6,"Name"),t(),i(7,"dd",13),a(8),t(),i(9,"dt",12),a(10,"Resolved model"),t(),i(11,"dd",14),a(12),t(),i(13,"dt",12),a(14,"Provider"),t(),i(15,"dd",13),a(16),t(),i(17,"dt",12),a(18,"Advanced execution"),t(),i(19,"dd",13)(20,"span",15),a(21),t()(),d(22,j,4,1),t()(),d(23,J,7,4,"section",9),d(24,G,7,4,"section",9),i(25,"section",9)(26,"h2",10),a(27," Tools "),i(28,"span",16),a(29),t()(),d(30,q,2,0,"p",17)(31,X,3,0,"ul",18),t()()),n&2){let e=o;r(8),p(e.name),r(4),p(e.resolvedModelApiName),r(4),p(e.resolvedProviderName),r(4),u("agent-config-inspect__badge--active",e.advancedExecution),r(),h(" ",e.advancedExecution?"Enabled":"Disabled"," "),r(),s(e.userId?22:-1),r(),s(e.systemPrompt?23:-1),r(),s(e.instructions?24:-1),r(5),h("(",e.tools.length,")"),r(),s(e.tools.length===0?30:31)}}var R=class n{route=_(T);router=_(A);destroyRef=_(P);agentConfigController=_(z);namespaceId=this.route.snapshot.params.namespaceId;agentConfigId=this.route.snapshot.params.agentConfigId;isPlatformMode=!this.namespaceId;isLoading=m(!0);hasError=m(!1);definition=m(null);expandedTools=m(new Set);systemPromptCollapsed=m(!0);instructionsCollapsed=m(!0);ngOnInit(){this.agentConfigController.getDefinitionAgentConfig(this.agentConfigId).pipe(N(this.destroyRef)).subscribe({next:o=>{this.definition.set(o),this.isLoading.set(!1)},error:()=>{this.hasError.set(!0),this.isLoading.set(!1)}})}toggleTool(o){this.expandedTools.update(e=>{let c=new Set(e);return c.has(o.name)?c.delete(o.name):c.add(o.name),c})}isToolExpanded(o){return this.expandedTools().has(o.name)}toggleSystemPrompt(){this.systemPromptCollapsed.update(o=>!o)}toggleInstructions(){this.instructionsCollapsed.update(o=>!o)}formatSchema(o){try{return JSON.stringify(JSON.parse(o),null,2)}catch(e){return o}}editRoute(){return this.isPlatformMode?["/agentos","admin","agent-configs",this.agentConfigId,"edit"]:["/agentos",this.namespaceId,"agent-configs",this.agentConfigId,"edit"]}back(){this.isPlatformMode?this.router.navigate(["/agentos","admin","agent-configs"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"])}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=I({type:n,selectors:[["agentos-agent-config-inspect"]],decls:13,vars:2,consts:[[1,"agent-config-inspect"],[1,"agent-config-inspect__header"],["type","button","title","Back to agent configs",1,"agent-config-inspect__back",3,"click"],[1,"agent-config-inspect__back-icon"],[1,"agent-config-inspect__title"],[1,"agent-config-inspect__sibling-link",3,"routerLink"],[1,"agent-config-inspect__loading"],[1,"agent-config-inspect__error"],[1,"agent-config-inspect__content"],[1,"agent-config-inspect__section"],[1,"agent-config-inspect__section-title"],[1,"agent-config-inspect__dl"],[1,"agent-config-inspect__dt"],[1,"agent-config-inspect__dd"],[1,"agent-config-inspect__dd","agent-config-inspect__dd--mono"],[1,"agent-config-inspect__badge"],[1,"agent-config-inspect__count"],[1,"agent-config-inspect__empty"],[1,"agent-config-inspect__tools"],["type","button",1,"agent-config-inspect__collapsible",3,"click"],[1,"agent-config-inspect__chevron"],[1,"agent-config-inspect__instructions"],[1,"agent-config-inspect__tool"],["type","button",1,"agent-config-inspect__tool-header",3,"click"],[1,"agent-config-inspect__tool-name"],[1,"agent-config-inspect__tool-body"],[1,"agent-config-inspect__tool-description",3,"innerHTML"],[1,"agent-config-inspect__schema"]],template:function(e,c){if(e&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),f("click",function(){return c.back()}),i(3,"span",3),a(4,"\u2190"),t(),a(5," Agent Configs "),t(),i(6,"h1",4),a(7,"Agent definition"),t(),i(8,"a",5),a(9,"Edit config \u2192"),t()(),d(10,B,2,0,"p",6)(11,$,2,0,"p",7)(12,Y,32,11,"div",8),t()),e&2){let g;r(8),y("routerLink",c.editRoute()),r(2),s(c.isLoading()?10:c.hasError()?11:(g=c.definition())?12:-1,g)}},dependencies:[D,L],styles:[".agent-config-inspect[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.agent-config-inspect__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.agent-config-inspect__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-primary, #007aff);font-family:inherit}.agent-config-inspect__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-inspect__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.agent-config-inspect__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.agent-config-inspect__sibling-link[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-primary, #007aff);text-decoration:none}.agent-config-inspect__sibling-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-inspect__loading[_ngcontent-%COMP%], .agent-config-inspect__error[_ngcontent-%COMP%], .agent-config-inspect__empty[_ngcontent-%COMP%]{margin:0;font-size:.9rem;color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__error[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.agent-config-inspect__content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem}.agent-config-inspect__section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem;padding:1.25rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:10px}.agent-config-inspect__section-title[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;font-weight:600;color:var(--color-text, #1d1d1f)}.agent-config-inspect__count[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;margin-left:.25rem}.agent-config-inspect__dl[_ngcontent-%COMP%]{display:grid;grid-template-columns:max-content 1fr;gap:.5rem 1.25rem;margin:0}.agent-config-inspect__dt[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);align-self:center}.agent-config-inspect__dd[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;color:var(--color-text, #1d1d1f);align-self:center;word-break:break-word}.agent-config-inspect__dd--mono[_ngcontent-%COMP%]{font-family:monospace;font-size:.875rem}.agent-config-inspect__badge[_ngcontent-%COMP%]{display:inline-block;padding:.2em .6em;border-radius:4px;font-size:.75rem;font-weight:500;background:var(--color-surface-muted, rgba(0, 0, 0, .06));color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__badge--active[_ngcontent-%COMP%]{background:var(--color-success-bg, #e3f5e1);color:var(--color-success, #34c759)}.agent-config-inspect__collapsible[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:.5rem;width:100%;background:none;border:none;padding:0;cursor:pointer;font-family:inherit;text-align:left}.agent-config-inspect__chevron[_ngcontent-%COMP%]{font-size:.7rem;color:var(--color-text-secondary, #6e6e73);transition:transform .15s ease;flex-shrink:0}.agent-config-inspect__chevron--open[_ngcontent-%COMP%]{transform:rotate(180deg)}.agent-config-inspect__instructions[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;border-radius:6px;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.875rem;font-family:inherit;color:var(--color-text, #1d1d1f);white-space:pre-wrap;word-break:break-word;line-height:1.6;max-height:400px;overflow-y:auto}.agent-config-inspect__tools[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.5rem}.agent-config-inspect__tool[_ngcontent-%COMP%]{border:1px solid var(--color-border, rgba(0, 0, 0, .08));border-radius:6px;overflow:hidden}.agent-config-inspect__tool-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:.75rem;width:100%;padding:.75rem 1rem;background:none;border:none;cursor:pointer;font-family:inherit;text-align:left;transition:background .1s ease}.agent-config-inspect__tool-header[_ngcontent-%COMP%]:hover{background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.agent-config-inspect__tool-name[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-config-inspect__tool-body[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;padding:0 1rem .75rem;border-top:1px solid var(--color-border, rgba(0, 0, 0, .08))}.agent-config-inspect__tool-description[_ngcontent-%COMP%]{margin:0;padding-top:.75rem;font-size:.8125rem;line-height:1.5;color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__tool-description[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 .25rem}.agent-config-inspect__tool-description[_ngcontent-%COMP%] p[_ngcontent-%COMP%]:last-child{margin-bottom:0}.agent-config-inspect__tool-description[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{font-family:monospace;font-size:.8em;background:var(--color-surface-muted, rgba(0, 0, 0, .06));padding:.1em .3em;border-radius:3px}.agent-config-inspect__schema[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.8125rem;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:pre;overflow-x:auto;line-height:1.5;max-height:360px;overflow-y:auto}"],changeDetection:0})};export{R as AgentConfigInspectComponent};
1
+ import{a as L}from"./chunk-KHMEGI4Z.js";import{b as z}from"./chunk-UQTA3ACH.js";import"./chunk-TSYL5EEO.js";import{a as T,c as A,d as D}from"./chunk-6XX7GME4.js";import{a as N}from"./chunk-VMYKE4ZC.js";import{Bb as b,Db as f,Fb as l,Ga as M,Ka as r,Rb as u,Tb as a,Ub as p,Vb as h,Wa as I,ca as _,fc as O,ga as C,gc as w,ha as x,jb as v,lb as d,ma as P,mb as s,pb as S,qb as E,rb as y,sb as i,ta as m,tb as t,ub as k}from"./chunk-CHEXA6RY.js";var F=(n,o)=>o.name;function B(n,o){n&1&&(i(0,"p",6),a(1,"Loading\u2026"),t())}function $(n,o){n&1&&(i(0,"p",7),a(1,"Failed to load agent definition."),t())}function j(n,o){if(n&1&&(i(0,"dt",12),a(1,"User context"),t(),i(2,"dd",14),a(3),t()),n&2){let e=l();r(3),p(e.userId)}}function H(n,o){if(n&1&&(i(0,"pre",21),a(1),t()),n&2){let e=l(2);r(),p(e.systemPrompt)}}function J(n,o){if(n&1){let e=b();i(0,"section",9)(1,"button",19),f("click",function(){C(e);let g=l(2);return x(g.toggleSystemPrompt())}),i(2,"h2",10),a(3,"System Prompt"),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,H,2,1,"pre",21),t()}if(n&2){let e=l(2);r(),v("aria-expanded",!e.systemPromptCollapsed()),r(3),u("agent-config-inspect__chevron--open",!e.systemPromptCollapsed()),r(2),s(e.systemPromptCollapsed()?-1:6)}}function U(n,o){if(n&1&&(i(0,"pre",21),a(1),t()),n&2){let e=l(2);r(),p(e.instructions)}}function G(n,o){if(n&1){let e=b();i(0,"section",9)(1,"button",19),f("click",function(){C(e);let g=l(2);return x(g.toggleInstructions())}),i(2,"h2",10),a(3,"Instructions"),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,U,2,1,"pre",21),t()}if(n&2){let e=l(2);r(),v("aria-expanded",!e.instructionsCollapsed()),r(3),u("agent-config-inspect__chevron--open",!e.instructionsCollapsed()),r(2),s(e.instructionsCollapsed()?-1:6)}}function q(n,o){n&1&&(i(0,"p",17),a(1,"No tools available for this agent."),t())}function K(n,o){if(n&1&&(k(0,"div",26),O(1,"agentosMarkdown")),n&2){let e=l(2).$implicit;y("innerHTML",w(1,1,e.description),M)}}function Q(n,o){if(n&1&&(i(0,"div",25),d(1,K,2,3,"div",26),i(2,"pre",27),a(3),t()()),n&2){let e=l().$implicit,c=l(3);r(),s(e.description?1:-1),r(2),p(c.formatSchema(e.inputSchema))}}function W(n,o){if(n&1){let e=b();i(0,"li",22)(1,"button",23),f("click",function(){let g=C(e).$implicit,V=l(3);return x(V.toggleTool(g))}),i(2,"span",24),a(3),t(),i(4,"span",20),a(5," \u25BC "),t()(),d(6,Q,4,2,"div",25),t()}if(n&2){let e=o.$implicit,c=l(3);r(),v("aria-expanded",c.isToolExpanded(e)),r(2),p(e.name),r(),u("agent-config-inspect__chevron--open",c.isToolExpanded(e)),r(2),s(c.isToolExpanded(e)?6:-1)}}function X(n,o){if(n&1&&(i(0,"ul",18),S(1,W,7,5,"li",22,F),t()),n&2){let e=l();r(),E(e.tools)}}function Y(n,o){if(n&1&&(i(0,"div",8)(1,"section",9)(2,"h2",10),a(3,"General"),t(),i(4,"dl",11)(5,"dt",12),a(6,"Name"),t(),i(7,"dd",13),a(8),t(),i(9,"dt",12),a(10,"Resolved model"),t(),i(11,"dd",14),a(12),t(),i(13,"dt",12),a(14,"Provider"),t(),i(15,"dd",13),a(16),t(),i(17,"dt",12),a(18,"Advanced execution"),t(),i(19,"dd",13)(20,"span",15),a(21),t()(),d(22,j,4,1),t()(),d(23,J,7,4,"section",9),d(24,G,7,4,"section",9),i(25,"section",9)(26,"h2",10),a(27," Tools "),i(28,"span",16),a(29),t()(),d(30,q,2,0,"p",17)(31,X,3,0,"ul",18),t()()),n&2){let e=o;r(8),p(e.name),r(4),p(e.resolvedModelApiName),r(4),p(e.resolvedProviderName),r(4),u("agent-config-inspect__badge--active",e.advancedExecution),r(),h(" ",e.advancedExecution?"Enabled":"Disabled"," "),r(),s(e.userId?22:-1),r(),s(e.systemPrompt?23:-1),r(),s(e.instructions?24:-1),r(5),h("(",e.tools.length,")"),r(),s(e.tools.length===0?30:31)}}var R=class n{route=_(T);router=_(A);destroyRef=_(P);agentConfigController=_(z);namespaceId=this.route.snapshot.params.namespaceId;agentConfigId=this.route.snapshot.params.agentConfigId;isPlatformMode=!this.namespaceId;isLoading=m(!0);hasError=m(!1);definition=m(null);expandedTools=m(new Set);systemPromptCollapsed=m(!0);instructionsCollapsed=m(!0);ngOnInit(){this.agentConfigController.getDefinitionAgentConfig(this.agentConfigId).pipe(N(this.destroyRef)).subscribe({next:o=>{this.definition.set(o),this.isLoading.set(!1)},error:()=>{this.hasError.set(!0),this.isLoading.set(!1)}})}toggleTool(o){this.expandedTools.update(e=>{let c=new Set(e);return c.has(o.name)?c.delete(o.name):c.add(o.name),c})}isToolExpanded(o){return this.expandedTools().has(o.name)}toggleSystemPrompt(){this.systemPromptCollapsed.update(o=>!o)}toggleInstructions(){this.instructionsCollapsed.update(o=>!o)}formatSchema(o){try{return JSON.stringify(JSON.parse(o),null,2)}catch(e){return o}}editRoute(){return this.isPlatformMode?["/agentos","admin","agent-configs",this.agentConfigId,"edit"]:["/agentos",this.namespaceId,"agent-configs",this.agentConfigId,"edit"]}back(){this.isPlatformMode?this.router.navigate(["/agentos","admin","agent-configs"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"])}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=I({type:n,selectors:[["agentos-agent-config-inspect"]],decls:13,vars:2,consts:[[1,"agent-config-inspect"],[1,"agent-config-inspect__header"],["type","button","title","Back to agent configs",1,"agent-config-inspect__back",3,"click"],[1,"agent-config-inspect__back-icon"],[1,"agent-config-inspect__title"],[1,"agent-config-inspect__sibling-link",3,"routerLink"],[1,"agent-config-inspect__loading"],[1,"agent-config-inspect__error"],[1,"agent-config-inspect__content"],[1,"agent-config-inspect__section"],[1,"agent-config-inspect__section-title"],[1,"agent-config-inspect__dl"],[1,"agent-config-inspect__dt"],[1,"agent-config-inspect__dd"],[1,"agent-config-inspect__dd","agent-config-inspect__dd--mono"],[1,"agent-config-inspect__badge"],[1,"agent-config-inspect__count"],[1,"agent-config-inspect__empty"],[1,"agent-config-inspect__tools"],["type","button",1,"agent-config-inspect__collapsible",3,"click"],[1,"agent-config-inspect__chevron"],[1,"agent-config-inspect__instructions"],[1,"agent-config-inspect__tool"],["type","button",1,"agent-config-inspect__tool-header",3,"click"],[1,"agent-config-inspect__tool-name"],[1,"agent-config-inspect__tool-body"],[1,"agent-config-inspect__tool-description",3,"innerHTML"],[1,"agent-config-inspect__schema"]],template:function(e,c){if(e&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),f("click",function(){return c.back()}),i(3,"span",3),a(4,"\u2190"),t(),a(5," Agent Configs "),t(),i(6,"h1",4),a(7,"Agent definition"),t(),i(8,"a",5),a(9,"Edit config \u2192"),t()(),d(10,B,2,0,"p",6)(11,$,2,0,"p",7)(12,Y,32,11,"div",8),t()),e&2){let g;r(8),y("routerLink",c.editRoute()),r(2),s(c.isLoading()?10:c.hasError()?11:(g=c.definition())?12:-1,g)}},dependencies:[D,L],styles:[".agent-config-inspect[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.agent-config-inspect__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.agent-config-inspect__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-primary, #007aff);font-family:inherit}.agent-config-inspect__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-inspect__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.agent-config-inspect__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.agent-config-inspect__sibling-link[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-primary, #007aff);text-decoration:none}.agent-config-inspect__sibling-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-inspect__loading[_ngcontent-%COMP%], .agent-config-inspect__error[_ngcontent-%COMP%], .agent-config-inspect__empty[_ngcontent-%COMP%]{margin:0;font-size:.9rem;color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__error[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.agent-config-inspect__content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem}.agent-config-inspect__section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem;padding:1.25rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:10px}.agent-config-inspect__section-title[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;font-weight:600;color:var(--color-text, #1d1d1f)}.agent-config-inspect__count[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;margin-left:.25rem}.agent-config-inspect__dl[_ngcontent-%COMP%]{display:grid;grid-template-columns:max-content 1fr;gap:.5rem 1.25rem;margin:0}.agent-config-inspect__dt[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);align-self:center}.agent-config-inspect__dd[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;color:var(--color-text, #1d1d1f);align-self:center;word-break:break-word}.agent-config-inspect__dd--mono[_ngcontent-%COMP%]{font-family:monospace;font-size:.875rem}.agent-config-inspect__badge[_ngcontent-%COMP%]{display:inline-block;padding:.2em .6em;border-radius:4px;font-size:.75rem;font-weight:500;background:var(--color-surface-muted, rgba(0, 0, 0, .06));color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__badge--active[_ngcontent-%COMP%]{background:var(--color-success-bg, #e3f5e1);color:var(--color-success, #34c759)}.agent-config-inspect__collapsible[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:.5rem;width:100%;background:none;border:none;padding:0;cursor:pointer;font-family:inherit;text-align:left}.agent-config-inspect__chevron[_ngcontent-%COMP%]{font-size:.7rem;color:var(--color-text-secondary, #6e6e73);transition:transform .15s ease;flex-shrink:0}.agent-config-inspect__chevron--open[_ngcontent-%COMP%]{transform:rotate(180deg)}.agent-config-inspect__instructions[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;border-radius:6px;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.875rem;font-family:inherit;color:var(--color-text, #1d1d1f);white-space:pre-wrap;word-break:break-word;line-height:1.6;max-height:400px;overflow-y:auto}.agent-config-inspect__tools[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.5rem}.agent-config-inspect__tool[_ngcontent-%COMP%]{border:1px solid var(--color-border, rgba(0, 0, 0, .08));border-radius:6px;overflow:hidden}.agent-config-inspect__tool-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:.75rem;width:100%;padding:.75rem 1rem;background:none;border:none;cursor:pointer;font-family:inherit;text-align:left;transition:background .1s ease}.agent-config-inspect__tool-header[_ngcontent-%COMP%]:hover{background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.agent-config-inspect__tool-name[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-config-inspect__tool-body[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;padding:0 1rem .75rem;border-top:1px solid var(--color-border, rgba(0, 0, 0, .08))}.agent-config-inspect__tool-description[_ngcontent-%COMP%]{margin:0;padding-top:.75rem;font-size:.8125rem;line-height:1.5;color:var(--color-text-secondary, #6e6e73)}.agent-config-inspect__tool-description[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 .25rem}.agent-config-inspect__tool-description[_ngcontent-%COMP%] p[_ngcontent-%COMP%]:last-child{margin-bottom:0}.agent-config-inspect__tool-description[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{font-family:monospace;font-size:.8em;background:var(--color-surface-muted, rgba(0, 0, 0, .06));padding:.1em .3em;border-radius:3px}.agent-config-inspect__schema[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.8125rem;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:pre;overflow-x:auto;line-height:1.5;max-height:360px;overflow-y:auto}"],changeDetection:0})};export{R as AgentConfigInspectComponent};
@@ -1 +1 @@
1
- import{b as o,k as i,p as l}from"./chunk-BLRBIAYK.js";import{Z as a,ca as t,z as n}from"./chunk-CHEXA6RY.js";var m=class s{controller=t(l);agentConfigController=t(o);namespacePermissions=t(i);listByNamespace(e){return this.controller.findByNamespaceIdUserGroup(e)}loadFormData(e){return n({namespaceAgents:this.agentConfigController.listByParentAgentConfig(e,!1),platformAgents:this.agentConfigController.listPlatformAgentsAgentConfig(!1),groups:this.listByNamespace(e),users:this.namespacePermissions.listNamespaceUsers(e)})}loadExistingGroup(e){return n({group:this.getById(e),members:this.getMembers(e)})}getById(e){return this.controller.getByIdUserGroup(e)}getMembers(e){return this.controller.getMembersUserGroup(e)}create(e){return this.controller.createUserGroup({namespaceId:e.namespaceId,name:e.name,agentIds:e.agentIds,userExternalIdsToAdd:e.memberExternalIdsToAdd,adminExternalIds:e.adminExternalIds})}update(e,r){return this.controller.updateUserGroup(e,{name:r.name,agentIds:r.agentIds,userExternalIdsToAdd:r.memberExternalIdsToAdd,userExternalIdsToRemove:r.memberExternalIdsToRemove,adminExternalIds:r.adminExternalIds})}delete(e){return this.controller.deleteUserGroup(e)}static \u0275fac=function(r){return new(r||s)};static \u0275prov=a({token:s,factory:s.\u0275fac,providedIn:"root"})};export{m as a};
1
+ import{b as o,k as i,p as l}from"./chunk-UQTA3ACH.js";import{Z as a,ca as t,z as n}from"./chunk-CHEXA6RY.js";var m=class s{controller=t(l);agentConfigController=t(o);namespacePermissions=t(i);listByNamespace(e){return this.controller.findByNamespaceIdUserGroup(e)}loadFormData(e){return n({namespaceAgents:this.agentConfigController.listByParentAgentConfig(e,!1),platformAgents:this.agentConfigController.listPlatformAgentsAgentConfig(!1),groups:this.listByNamespace(e),users:this.namespacePermissions.listNamespaceUsers(e)})}loadExistingGroup(e){return n({group:this.getById(e),members:this.getMembers(e)})}getById(e){return this.controller.getByIdUserGroup(e)}getMembers(e){return this.controller.getMembersUserGroup(e)}create(e){return this.controller.createUserGroup({namespaceId:e.namespaceId,name:e.name,agentIds:e.agentIds,userExternalIdsToAdd:e.memberExternalIdsToAdd,adminExternalIds:e.adminExternalIds})}update(e,r){return this.controller.updateUserGroup(e,{name:r.name,agentIds:r.agentIds,userExternalIdsToAdd:r.memberExternalIdsToAdd,userExternalIdsToRemove:r.memberExternalIdsToRemove,adminExternalIds:r.adminExternalIds})}delete(e){return this.controller.deleteUserGroup(e)}static \u0275fac=function(r){return new(r||s)};static \u0275prov=a({token:s,factory:s.\u0275fac,providedIn:"root"})};export{m as a};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-LU3ZSYWJ.js";import{a as te}from"./chunk-KZ2MXYPS.js";import"./chunk-NWFFZ2FW.js";import"./chunk-MQEDNZF7.js";import{e as B,i as G}from"./chunk-BLRBIAYK.js";import{a as D,c as L}from"./chunk-6XX7GME4.js";import{v as Z}from"./chunk-VNO76B3S.js";import"./chunk-E6T6QLQT.js";import"./chunk-SPV5SLNS.js";import{a as u,c as O}from"./chunk-VMYKE4ZC.js";import"./chunk-AS2L77JV.js";import{F as X,c as z,e as P,g as $,h as j,i as q,l as _,n as U,p as W,s as J,w as Y,x as H,y as K,z as Q}from"./chunk-7OGOI6WM.js";import"./chunk-G5RWG2GK.js";import{Bb as M,Db as f,Fb as p,Ka as a,Tb as l,Ub as C,Vb as N,Wa as V,ca as d,ga as h,ha as b,kb as k,lb as v,m as F,ma as T,mb as y,mc as R,ob as A,pb as x,qb as S,rb as c,sb as i,ta as g,tb as o,ua as w,ub as I}from"./chunk-CHEXA6RY.js";function ie(r,t){r&1&&(i(0,"p",5),l(1,"Loading\u2026"),o())}function re(r,t){if(r&1&&(i(0,"label",10),I(1,"input",29),i(2,"span"),l(3),o()()),r&2){let e=t.$implicit,n=p(2);a(),c("value",e.value)("formControl",n.scopeControl)("disabled",e.value==="namespace"&&!n.isAdmin()),a(2),C(e.label)}}function ae(r,t){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let e=t.$implicit;c("value",e.type),a(),C(e.displayName)}}function le(r,t){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let e=t.$implicit;c("value",e),a(),C(e)}}function se(r,t){if(r&1){let e=M();i(0,"div",24)(1,"ds-json-schema-form",30),f("valueChange",function(s){h(e);let m=p(2);return b(m.onParamsChange(s))}),o()()}if(r&2){let e=p(2);a(),c("schema",t)("value",e.initialParams())}}function ce(r,t){if(r&1){let e=M();i(0,"button",31),f("click",function(){h(e);let s=p(2);return b(s.exportYaml())}),l(1),o()}if(r&2){let e=p(2);c("disabled",e.isExporting()),a(),N(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ")}}function me(r,t){if(r&1){let e=M();i(0,"form",7),f("ngSubmit",function(){h(e);let s=p();return b(s.submit())}),i(1,"fieldset",8)(2,"legend",9),l(3,"Scope"),o(),x(4,re,4,4,"label",10,k().trackByScope,!0),o(),i(6,"div",11)(7,"label",12),l(8,"Type "),i(9,"span",13),l(10,"*"),o()(),i(11,"select",14)(12,"option",15),l(13,"Select type"),o(),x(14,ae,2,2,"option",16,k().trackByType,!0),o()(),i(16,"div",11)(17,"label",17),l(18,"Name "),i(19,"span",13),l(20,"*"),o()(),I(21,"input",18),o(),i(22,"div",11)(23,"label",19),l(24,"Description"),o(),I(25,"textarea",20),o(),i(26,"div",11)(27,"label",21),l(28,"Auth Setting"),o(),i(29,"select",22)(30,"option",23),l(31,"None"),o(),x(32,le,2,2,"option",16,A),o()(),v(34,se,2,2,"div",24),i(35,"div",25)(36,"button",26),l(37),o(),v(38,ce,2,2,"button",27),i(39,"button",28),f("click",function(){h(e);let s=p();return b(s.cancel())}),l(40,"Cancel"),o()()()}if(r&2){let e,n=p();c("formGroup",n.form),a(),c("disabled",n.isEditMode()),a(3),S(n.scopeOptions),a(7),c("formControl",n.typeControl),a(3),S(n.integrationTypes()),a(7),c("formControl",n.nameControl),a(4),c("formControl",n.descriptionControl),a(4),c("formControl",n.authSettingNameControl),a(),c("ngValue",null),a(2),S(n.availableAuthSettings()),a(2),y((e=n.schema())?34:-1,e),a(2),c("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),a(),N(" ",n.isEditMode()?"Save changes":"Create"," "),a(),y(n.isEditMode()?38:-1)}}var pe=new Set(["platform","namespace","userOnNs","userGlobal"]),E=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ne=class r{route=d(D);router=d(L);destroyRef=d(T);state=d(ee);integrationTypeController=d(G);authSettingController=d(B);namespaceRole=d(te);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=O(this.isPlatformMode?F(!0):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new q({name:new _("",{nonNullable:!0,validators:[P.required,P.minLength(1)]}),description:new _(null),type:new _("",{nonNullable:!0,validators:[P.required]}),scope:new _("namespace",{nonNullable:!0})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=g(!1);isSubmitting=g(!1);isLoading=g(!1);isExporting=g(!1);scopeOptions=[{value:"platform",label:E.platform},{value:"namespace",label:E.namespace},{value:"userOnNs",label:E.userOnNs},{value:"userGlobal",label:E.userGlobal}];authSettingNameControl=new _(null);availableAuthSettings=g([]);paramsValue=g(null);initialParams=g(null);integrationTypes=O(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=O(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=R(()=>{let t=this.selectedType();return t?this.integrationTypes().find(n=>n.type===t)?.configSchema??null:null});existingConfig=null;constructor(){w(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("integrationId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let s=this.parseScope(e.get("scope"));this.scopeControl.setValue(s),this.loadAuthSettingsForScope(s),this.scopeControl.valueChanges.pipe(u(this.destroyRef)).subscribe(oe=>{this.loadAuthSettingsForScope(oe)});let m=e.get("template");m&&this.hydrateFromTemplate(m)}parseScope(t){return t&&pe.has(t)?t:"namespace"}deriveScopeFromConfig(t){return!t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(!0),this.state.getById(t).pipe(u(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e;let n=this.deriveScopeFromConfig(e);this.scopeControl.setValue(n),this.applyConfigToForm(e),this.loadAuthSettingsForScope(n),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[IntegrationForm] Could not load config '${t}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(t){this.isLoading.set(!0),this.state.getById(t).pipe(u(this.destroyRef)).subscribe({next:e=>{this.applyConfigToForm(e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:e=>{console.warn(`[IntegrationForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.typeControl.setValue(t.integrationType),this.initialParams.set(t.parameters),this.paramsValue.set(t.parameters),this.authSettingNameControl.setValue(t.authSettingName??null)}loadAuthSettingsForScope(t){let e;switch(t){case"platform":e=this.authSettingController.listAuthSetting();break;case"namespace":e=this.authSettingController.listAuthSetting(this.namespaceId);break;case"userOnNs":e=this.authSettingController.listAuthSetting(this.namespaceId,"me");break;case"userGlobal":e=this.authSettingController.listAuthSetting("none","me");break}e.pipe(u(this.destroyRef)).subscribe({next:n=>{let s=n.map(m=>m.name).filter(Boolean);this.availableAuthSettings.set([...new Set(s)])},error:()=>this.availableAuthSettings.set([])})}onParamsChange(t){this.paramsValue.set(t)}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let t=this.descriptionControl.value?.trim(),e={name:this.nameControl.value.trim(),description:t||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,e,n,this.existingConfig):this.state.create(e,n,this.namespaceId??null)).pipe(u(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(!0),this.state.exportAsYaml(t).pipe(u(this.destroyRef)).subscribe({next:e=>{let n=new Blob([e],{type:"application/yaml"}),s=URL.createObjectURL(n),m=document.createElement("a");m.href=s,m.download=`${this.existingConfig?.name??"integration"}.yaml`,m.click(),URL.revokeObjectURL(s),this.isExporting.set(!1)},error:()=>this.isExporting.set(!1)}))}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"])}trackByType(t,e){return e.type}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=V({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],["for","integration-auth-setting",1,"integration-form__label"],["id","integration-auth-setting",1,"integration-form__select",3,"formControl"],[3,"ngValue"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"click","disabled"]],template:function(e,n){e&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),f("click",function(){return n.cancel()}),i(3,"span",3),l(4,"\u2190"),o(),l(5," Integrations "),o(),i(6,"h1",4),l(7),o()(),v(8,ie,2,0,"p",5)(9,me,41,11,"form",6),o()),e&2&&(a(7),C(n.isEditMode()?"Edit integration":"New integration"),a(),y(n.isLoading()?8:9))},dependencies:[X,U,K,Q,z,H,W,$,j,J,Y,Z],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-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)}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-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}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface)}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-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}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.integration-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.integration-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"],changeDetection:0})};export{ne as IntegrationFormComponent};
1
+ import{a as ee}from"./chunk-ADEIEQGJ.js";import{a as te}from"./chunk-KJJPVCIH.js";import"./chunk-NWFFZ2FW.js";import"./chunk-VZOBZ3DD.js";import{e as B,i as G}from"./chunk-UQTA3ACH.js";import{a as D,c as L}from"./chunk-6XX7GME4.js";import{v as Z}from"./chunk-VNO76B3S.js";import"./chunk-E6T6QLQT.js";import"./chunk-SPV5SLNS.js";import{a as u,c as O}from"./chunk-VMYKE4ZC.js";import"./chunk-AS2L77JV.js";import{F as X,c as z,e as P,g as $,h as j,i as q,l as _,n as U,p as W,s as J,w as Y,x as H,y as K,z as Q}from"./chunk-7OGOI6WM.js";import"./chunk-G5RWG2GK.js";import{Bb as M,Db as f,Fb as p,Ka as a,Tb as l,Ub as C,Vb as N,Wa as V,ca as d,ga as h,ha as b,kb as k,lb as v,m as F,ma as T,mb as y,mc as R,ob as A,pb as x,qb as S,rb as c,sb as i,ta as g,tb as o,ua as w,ub as I}from"./chunk-CHEXA6RY.js";function ie(r,t){r&1&&(i(0,"p",5),l(1,"Loading\u2026"),o())}function re(r,t){if(r&1&&(i(0,"label",10),I(1,"input",29),i(2,"span"),l(3),o()()),r&2){let e=t.$implicit,n=p(2);a(),c("value",e.value)("formControl",n.scopeControl)("disabled",e.value==="namespace"&&!n.isAdmin()),a(2),C(e.label)}}function ae(r,t){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let e=t.$implicit;c("value",e.type),a(),C(e.displayName)}}function le(r,t){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let e=t.$implicit;c("value",e),a(),C(e)}}function se(r,t){if(r&1){let e=M();i(0,"div",24)(1,"ds-json-schema-form",30),f("valueChange",function(s){h(e);let m=p(2);return b(m.onParamsChange(s))}),o()()}if(r&2){let e=p(2);a(),c("schema",t)("value",e.initialParams())}}function ce(r,t){if(r&1){let e=M();i(0,"button",31),f("click",function(){h(e);let s=p(2);return b(s.exportYaml())}),l(1),o()}if(r&2){let e=p(2);c("disabled",e.isExporting()),a(),N(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ")}}function me(r,t){if(r&1){let e=M();i(0,"form",7),f("ngSubmit",function(){h(e);let s=p();return b(s.submit())}),i(1,"fieldset",8)(2,"legend",9),l(3,"Scope"),o(),x(4,re,4,4,"label",10,k().trackByScope,!0),o(),i(6,"div",11)(7,"label",12),l(8,"Type "),i(9,"span",13),l(10,"*"),o()(),i(11,"select",14)(12,"option",15),l(13,"Select type"),o(),x(14,ae,2,2,"option",16,k().trackByType,!0),o()(),i(16,"div",11)(17,"label",17),l(18,"Name "),i(19,"span",13),l(20,"*"),o()(),I(21,"input",18),o(),i(22,"div",11)(23,"label",19),l(24,"Description"),o(),I(25,"textarea",20),o(),i(26,"div",11)(27,"label",21),l(28,"Auth Setting"),o(),i(29,"select",22)(30,"option",23),l(31,"None"),o(),x(32,le,2,2,"option",16,A),o()(),v(34,se,2,2,"div",24),i(35,"div",25)(36,"button",26),l(37),o(),v(38,ce,2,2,"button",27),i(39,"button",28),f("click",function(){h(e);let s=p();return b(s.cancel())}),l(40,"Cancel"),o()()()}if(r&2){let e,n=p();c("formGroup",n.form),a(),c("disabled",n.isEditMode()),a(3),S(n.scopeOptions),a(7),c("formControl",n.typeControl),a(3),S(n.integrationTypes()),a(7),c("formControl",n.nameControl),a(4),c("formControl",n.descriptionControl),a(4),c("formControl",n.authSettingNameControl),a(),c("ngValue",null),a(2),S(n.availableAuthSettings()),a(2),y((e=n.schema())?34:-1,e),a(2),c("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),a(),N(" ",n.isEditMode()?"Save changes":"Create"," "),a(),y(n.isEditMode()?38:-1)}}var pe=new Set(["platform","namespace","userOnNs","userGlobal"]),E=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ne=class r{route=d(D);router=d(L);destroyRef=d(T);state=d(ee);integrationTypeController=d(G);authSettingController=d(B);namespaceRole=d(te);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=O(this.isPlatformMode?F(!0):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new q({name:new _("",{nonNullable:!0,validators:[P.required,P.minLength(1)]}),description:new _(null),type:new _("",{nonNullable:!0,validators:[P.required]}),scope:new _("namespace",{nonNullable:!0})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=g(!1);isSubmitting=g(!1);isLoading=g(!1);isExporting=g(!1);scopeOptions=[{value:"platform",label:E.platform},{value:"namespace",label:E.namespace},{value:"userOnNs",label:E.userOnNs},{value:"userGlobal",label:E.userGlobal}];authSettingNameControl=new _(null);availableAuthSettings=g([]);paramsValue=g(null);initialParams=g(null);integrationTypes=O(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=O(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=R(()=>{let t=this.selectedType();return t?this.integrationTypes().find(n=>n.type===t)?.configSchema??null:null});existingConfig=null;constructor(){w(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("integrationId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let s=this.parseScope(e.get("scope"));this.scopeControl.setValue(s),this.loadAuthSettingsForScope(s),this.scopeControl.valueChanges.pipe(u(this.destroyRef)).subscribe(oe=>{this.loadAuthSettingsForScope(oe)});let m=e.get("template");m&&this.hydrateFromTemplate(m)}parseScope(t){return t&&pe.has(t)?t:"namespace"}deriveScopeFromConfig(t){return!t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(!0),this.state.getById(t).pipe(u(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e;let n=this.deriveScopeFromConfig(e);this.scopeControl.setValue(n),this.applyConfigToForm(e),this.loadAuthSettingsForScope(n),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[IntegrationForm] Could not load config '${t}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(t){this.isLoading.set(!0),this.state.getById(t).pipe(u(this.destroyRef)).subscribe({next:e=>{this.applyConfigToForm(e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:e=>{console.warn(`[IntegrationForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.typeControl.setValue(t.integrationType),this.initialParams.set(t.parameters),this.paramsValue.set(t.parameters),this.authSettingNameControl.setValue(t.authSettingName??null)}loadAuthSettingsForScope(t){let e;switch(t){case"platform":e=this.authSettingController.listAuthSetting();break;case"namespace":e=this.authSettingController.listAuthSetting(this.namespaceId);break;case"userOnNs":e=this.authSettingController.listAuthSetting(this.namespaceId,"me");break;case"userGlobal":e=this.authSettingController.listAuthSetting("none","me");break}e.pipe(u(this.destroyRef)).subscribe({next:n=>{let s=n.map(m=>m.name).filter(Boolean);this.availableAuthSettings.set([...new Set(s)])},error:()=>this.availableAuthSettings.set([])})}onParamsChange(t){this.paramsValue.set(t)}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let t=this.descriptionControl.value?.trim(),e={name:this.nameControl.value.trim(),description:t||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,e,n,this.existingConfig):this.state.create(e,n,this.namespaceId??null)).pipe(u(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(!0),this.state.exportAsYaml(t).pipe(u(this.destroyRef)).subscribe({next:e=>{let n=new Blob([e],{type:"application/yaml"}),s=URL.createObjectURL(n),m=document.createElement("a");m.href=s,m.download=`${this.existingConfig?.name??"integration"}.yaml`,m.click(),URL.revokeObjectURL(s),this.isExporting.set(!1)},error:()=>this.isExporting.set(!1)}))}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"])}trackByType(t,e){return e.type}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=V({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],["for","integration-auth-setting",1,"integration-form__label"],["id","integration-auth-setting",1,"integration-form__select",3,"formControl"],[3,"ngValue"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"click","disabled"]],template:function(e,n){e&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),f("click",function(){return n.cancel()}),i(3,"span",3),l(4,"\u2190"),o(),l(5," Integrations "),o(),i(6,"h1",4),l(7),o()(),v(8,ie,2,0,"p",5)(9,me,41,11,"form",6),o()),e&2&&(a(7),C(n.isEditMode()?"Edit integration":"New integration"),a(),y(n.isLoading()?8:9))},dependencies:[X,U,K,Q,z,H,W,$,j,J,Y,Z],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-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)}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-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}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface)}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-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}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.integration-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.integration-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"],changeDetection:0})};export{ne as IntegrationFormComponent};
@@ -1 +1 @@
1
- import{a as re,b as ie,c as V}from"./chunk-I2ONTIJI.js";import{a as oe}from"./chunk-HSEJNG7W.js";import{a as Q,b as X,f as ne}from"./chunk-AFRMVXZZ.js";import{a as G,b as C,c as B,h as Z,s as ee,x as te}from"./chunk-ZCELWKMZ.js";import{c as K}from"./chunk-6XX7GME4.js";import"./chunk-J4UAEXFM.js";import"./chunk-GTCP3EYX.js";import"./chunk-E6T6QLQT.js";import"./chunk-BTOJ27OO.js";import"./chunk-SPV5SLNS.js";import{a as _,c as f}from"./chunk-VMYKE4ZC.js";import{a as H,b as W}from"./chunk-AS2L77JV.js";import"./chunk-7OGOI6WM.js";import{a as Y,b as M}from"./chunk-TASSC2XX.js";import{Q as U,S as J}from"./chunk-G5RWG2GK.js";import{Bb as S,Db as h,Fb as l,Ka as p,Rb as j,T as L,Tb as c,Ub as k,Vb as z,Wa as N,Z as w,ca as d,ga as u,h as A,ha as g,jb as E,lb as b,ma as $,mb as y,mc as v,pb as x,qb as T,rb as P,sb as a,t as I,ta as O,tb as s,ub as D}from"./chunk-CHEXA6RY.js";var R=class n{threadState=d(C);codayService=d(ne);threadList=f(this.threadState.threadList$,{initialValue:[]});selectedThread=f(this.threadState.selectedThread$,{initialValue:null});isThinking=f(this.codayService.isThinking$,{initialValue:!1});inviteEvent=f(this.codayService.currentInviteEvent$.pipe(I(t=>t?.invite===Z?null:t)),{initialValue:null});tasks=v(()=>{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=V[i.status]-V[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<ie?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=d(M);threadState=d(C);destroy$=new A;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(L(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=te(i);if(!m)return;m instanceof ee&&(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=w({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&&D(0,"mat-spinner",6)}function me(n,t){n&1&&(a(0,"mat-icon"),c(1,"add"),s())}function ue(n,t){if(n&1&&(a(0,"span",16),c(1),s()),n&2){let e=l().$implicit,r=l();p(),k(r.filterCounts()[e.key])}}function ge(n,t){if(n&1){let e=S();a(0,"button",15),h("click",function(){let o=u(e).$implicit,i=l();return g(i.setFilter(o.key))}),a(1,"mat-icon",10),c(2),s(),a(3,"span"),c(4),s(),b(5,ue,2,1,"span",16),s()}if(n&2){let e=t.$implicit,r=l();j("active",r.activeFilter()===e.key),E("aria-selected",r.activeFilter()===e.key),p(2),k(e.icon),p(2),k(e.label),p(),y(r.filterCounts()[e.key]>0?5:-1)}}function _e(n,t){n&1&&(a(0,"div",12),D(1,"mat-spinner",17),a(2,"p"),c(3,"Loading tasks\u2026"),s()())}function fe(n,t){if(n&1){let e=S();a(0,"p"),c(1,"No tasks yet. Start your first one!"),s(),a(2,"button",19),h("click",function(){u(e);let o=l(2);return g(o.createTask())}),a(3,"mat-icon"),c(4,"add"),s(),c(5," New Task "),s()}}function he(n,t){n&1&&(a(0,"p"),c(1,"No tasks in this category."),s())}function ke(n,t){if(n&1&&(a(0,"div",13)(1,"mat-icon",18),c(2,"rocket_launch"),s(),b(3,fe,6,0)(4,he,2,0,"p"),s()),n&2){let e=l();p(3),y(e.activeFilter()==="all"?3:4)}}function ve(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(3);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(3);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(3);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(3);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(3);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function Ce(n,t){if(n&1&&(a(0,"section",20)(1,"h2",21)(2,"mat-icon",22),c(3),s(),c(4),a(5,"span",23),c(6),s()(),a(7,"div",14),x(8,ve,1,1,"app-task-card",24,le),s()()),n&2){let e=t.$implicit;p(3),k(e.icon),p(),z(" ",e.label," "),p(2),k(e.tasks.length),p(2),T(e.tasks)}}function be(n,t){if(n&1&&x(0,Ce,10,3,"section",20,de),n&2){let e=l();T(e.taskGroups())}}function ye(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(2);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(2);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(2);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(2);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(2);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function xe(n,t){if(n&1&&(a(0,"div",14),x(1,ye,1,1,"app-task-card",24,le),s()),n&2){let e=l();p(),T(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=d(K);projectState=d(M);threadState=d(C);threadApi=d(G);taskStatus=d(R);userService=d(B);projectApi=d(Y);destroyRef=d($);_projectEventStream=d(F);filters=Te;activeFilter=O("all");starredOnly=O(!1);isCreating=O(!1);isLoadingList=f(this.threadState.isLoadingThreadList$,{initialValue:!1});username=f(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=v(()=>{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=v(()=>{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=v(()=>{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(_(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(!0),this.threadApi.createThread().pipe(_(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(!1),this.router.navigate(["project",t,"thread",e.thread.id])},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(!1)}}))}onStopRequested(t){this.threadApi.stopThread(t).pipe(_(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)})}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(_(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(_(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(_(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(_(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=N({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&&(a(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),c(6,"rocket_launch"),s(),c(7," Task Control "),s(),a(8,"button",5),h("click",function(){return r.createTask()}),b(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),c(11," New Task "),s()(),a(12,"nav",7),x(13,ge,6,6,"button",8,ce),a(15,"button",9),h("click",function(){return r.toggleStarredFilter()}),a(16,"mat-icon",10),c(17,"star"),s(),a(18,"span"),c(19,"Starred"),s()()()(),a(20,"main",11),b(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),s()()()),e&2&&(p(8),P("disabled",r.isCreating()),p(),y(r.isCreating()?9:10),p(4),T(r.filters),p(2),j("active",r.starredOnly()),E("aria-checked",r.starredOnly()),p(6),y(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24))},dependencies:[re,oe,W,H,J,U,X,Q],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}"],changeDetection:0})};export{se as TaskControlComponent};
1
+ import{a as re,b as ie,c as V}from"./chunk-I2ONTIJI.js";import{a as oe}from"./chunk-NGMAQNX3.js";import{a as Q,b as X,f as ne}from"./chunk-UEGZX4MW.js";import{a as G,b as C,c as B,h as Z,s as ee,y as te}from"./chunk-CRXIMHRG.js";import{c as K}from"./chunk-6XX7GME4.js";import"./chunk-J4UAEXFM.js";import"./chunk-GTCP3EYX.js";import"./chunk-E6T6QLQT.js";import"./chunk-BTOJ27OO.js";import"./chunk-SPV5SLNS.js";import{a as _,c as f}from"./chunk-VMYKE4ZC.js";import{a as H,b as W}from"./chunk-AS2L77JV.js";import"./chunk-7OGOI6WM.js";import{a as Y,b as M}from"./chunk-TASSC2XX.js";import{Q as U,S as J}from"./chunk-G5RWG2GK.js";import{Bb as S,Db as h,Fb as l,Ka as p,Rb as j,T as L,Tb as c,Ub as k,Vb as z,Wa as N,Z as w,ca as d,ga as u,h as A,ha as g,jb as E,lb as b,ma as $,mb as y,mc as v,pb as x,qb as T,rb as P,sb as a,t as I,ta as O,tb as s,ub as D}from"./chunk-CHEXA6RY.js";var R=class n{threadState=d(C);codayService=d(ne);threadList=f(this.threadState.threadList$,{initialValue:[]});selectedThread=f(this.threadState.selectedThread$,{initialValue:null});isThinking=f(this.codayService.isThinking$,{initialValue:!1});inviteEvent=f(this.codayService.currentInviteEvent$.pipe(I(t=>t?.invite===Z?null:t)),{initialValue:null});tasks=v(()=>{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=V[i.status]-V[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<ie?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=d(M);threadState=d(C);destroy$=new A;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(L(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=te(i);if(!m)return;m instanceof ee&&(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=w({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&&D(0,"mat-spinner",6)}function me(n,t){n&1&&(a(0,"mat-icon"),c(1,"add"),s())}function ue(n,t){if(n&1&&(a(0,"span",16),c(1),s()),n&2){let e=l().$implicit,r=l();p(),k(r.filterCounts()[e.key])}}function ge(n,t){if(n&1){let e=S();a(0,"button",15),h("click",function(){let o=u(e).$implicit,i=l();return g(i.setFilter(o.key))}),a(1,"mat-icon",10),c(2),s(),a(3,"span"),c(4),s(),b(5,ue,2,1,"span",16),s()}if(n&2){let e=t.$implicit,r=l();j("active",r.activeFilter()===e.key),E("aria-selected",r.activeFilter()===e.key),p(2),k(e.icon),p(2),k(e.label),p(),y(r.filterCounts()[e.key]>0?5:-1)}}function _e(n,t){n&1&&(a(0,"div",12),D(1,"mat-spinner",17),a(2,"p"),c(3,"Loading tasks\u2026"),s()())}function fe(n,t){if(n&1){let e=S();a(0,"p"),c(1,"No tasks yet. Start your first one!"),s(),a(2,"button",19),h("click",function(){u(e);let o=l(2);return g(o.createTask())}),a(3,"mat-icon"),c(4,"add"),s(),c(5," New Task "),s()}}function he(n,t){n&1&&(a(0,"p"),c(1,"No tasks in this category."),s())}function ke(n,t){if(n&1&&(a(0,"div",13)(1,"mat-icon",18),c(2,"rocket_launch"),s(),b(3,fe,6,0)(4,he,2,0,"p"),s()),n&2){let e=l();p(3),y(e.activeFilter()==="all"?3:4)}}function ve(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(3);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(3);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(3);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(3);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(3);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function Ce(n,t){if(n&1&&(a(0,"section",20)(1,"h2",21)(2,"mat-icon",22),c(3),s(),c(4),a(5,"span",23),c(6),s()(),a(7,"div",14),x(8,ve,1,1,"app-task-card",24,le),s()()),n&2){let e=t.$implicit;p(3),k(e.icon),p(),z(" ",e.label," "),p(2),k(e.tasks.length),p(2),T(e.tasks)}}function be(n,t){if(n&1&&x(0,Ce,10,3,"section",20,de),n&2){let e=l();T(e.taskGroups())}}function ye(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(2);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(2);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(2);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(2);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(2);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function xe(n,t){if(n&1&&(a(0,"div",14),x(1,ye,1,1,"app-task-card",24,le),s()),n&2){let e=l();p(),T(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=d(K);projectState=d(M);threadState=d(C);threadApi=d(G);taskStatus=d(R);userService=d(B);projectApi=d(Y);destroyRef=d($);_projectEventStream=d(F);filters=Te;activeFilter=O("all");starredOnly=O(!1);isCreating=O(!1);isLoadingList=f(this.threadState.isLoadingThreadList$,{initialValue:!1});username=f(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=v(()=>{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=v(()=>{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=v(()=>{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(_(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(!0),this.threadApi.createThread().pipe(_(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(!1),this.router.navigate(["project",t,"thread",e.thread.id])},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(!1)}}))}onStopRequested(t){this.threadApi.stopThread(t).pipe(_(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)})}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(_(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(_(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(_(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(_(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=N({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&&(a(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),c(6,"rocket_launch"),s(),c(7," Task Control "),s(),a(8,"button",5),h("click",function(){return r.createTask()}),b(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),c(11," New Task "),s()(),a(12,"nav",7),x(13,ge,6,6,"button",8,ce),a(15,"button",9),h("click",function(){return r.toggleStarredFilter()}),a(16,"mat-icon",10),c(17,"star"),s(),a(18,"span"),c(19,"Starred"),s()()()(),a(20,"main",11),b(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),s()()()),e&2&&(p(8),P("disabled",r.isCreating()),p(),y(r.isCreating()?9:10),p(4),T(r.filters),p(2),j("active",r.starredOnly()),E("aria-checked",r.starredOnly()),p(6),y(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24))},dependencies:[re,oe,W,H,J,U,X,Q],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}"],changeDetection:0})};export{se as TaskControlComponent};
@@ -1 +1 @@
1
- import{c as u}from"./chunk-5IIN2VT5.js";import{a as i,c as m}from"./chunk-6XX7GME4.js";import{Db as c,Wa as n,ca as t,rb as o,sb as r,tb as p}from"./chunk-CHEXA6RY.js";var d=class s{route=t(i);router=t(m);namespaceId=this.route.snapshot.params.namespaceId;goBack(){this.router.navigate(["/agentos","namespaces"])}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=n({type:s,selectors:[["agentos-namespace-user-groups"]],decls:1,vars:1,consts:[["backLabel","Namespaces",3,"backRequested","namespaceId"]],template:function(e,a){e&1&&(r(0,"agentos-user-group-list",0),c("backRequested",function(){return a.goBack()}),p()),e&2&&o("namespaceId",a.namespaceId)},dependencies:[u],encapsulation:2,changeDetection:0})};export{d as a};
1
+ import{c as u}from"./chunk-X73LZ3QV.js";import{a as i,c as m}from"./chunk-6XX7GME4.js";import{Db as c,Wa as n,ca as t,rb as o,sb as r,tb as p}from"./chunk-CHEXA6RY.js";var d=class s{route=t(i);router=t(m);namespaceId=this.route.snapshot.params.namespaceId;goBack(){this.router.navigate(["/agentos","namespaces"])}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=n({type:s,selectors:[["agentos-namespace-user-groups"]],decls:1,vars:1,consts:[["backLabel","Namespaces",3,"backRequested","namespaceId"]],template:function(e,a){e&1&&(r(0,"agentos-user-group-list",0),c("backRequested",function(){return a.goBack()}),p()),e&2&&o("namespaceId",a.namespaceId)},dependencies:[u],encapsulation:2,changeDetection:0})};export{d as a};
@@ -1 +1 @@
1
- import{a as E}from"./chunk-HSEJNG7W.js";import{c as S,d as _,f as u,g as C}from"./chunk-QVW2GZXC.js";import{a as q,b as U,c as Y,d as Q}from"./chunk-OCX3RQ65.js";import"./chunk-EAVXJ7QN.js";import{f as I}from"./chunk-AFRMVXZZ.js";import"./chunk-TSYL5EEO.js";import"./chunk-N6D7DELC.js";import{a as L,d as b}from"./chunk-ZCELWKMZ.js";import"./chunk-YJOXSEUO.js";import"./chunk-GIIRKWUO.js";import{a as $,c as H}from"./chunk-6XX7GME4.js";import"./chunk-2PWIGCN2.js";import"./chunk-SKBEA6VH.js";import"./chunk-J4UAEXFM.js";import"./chunk-GTCP3EYX.js";import"./chunk-VNO76B3S.js";import"./chunk-E6T6QLQT.js";import"./chunk-BTOJ27OO.js";import"./chunk-SPV5SLNS.js";import"./chunk-VMYKE4ZC.js";import"./chunk-AS2L77JV.js";import"./chunk-7OGOI6WM.js";import"./chunk-TASSC2XX.js";import"./chunk-G5RWG2GK.js";import{B as x,Bb as M,Db as y,Fb as s,Jb as W,Ka as m,Kb as O,Lb as P,N as A,T as p,Tb as G,Ub as z,Wa as v,Z as F,ca as a,d as k,ga as c,h as f,ha as d,lb as V,mb as j,rb as w,sb as h,tb as g,ub as R,vb as D,wb as B}from"./chunk-CHEXA6RY.js";var T=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,i){t&1&&(D(0,"h1",0),G(1),B()),t&2&&(m(),z(i.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var N=class o{destroy$=new f;isSetup=!1;codayService=a(I);preferencesService=a(b);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),i=e.createGain();t.connect(i),i.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),i.gain.setValueAtTime(.1,e.currentTime),i.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let n=e.createOscillator(),r=e.createGain();n.connect(r),r.connect(e.destination);let l=e.currentTime+.11;n.frequency.setValueAtTime(950,l),r.gain.setValueAtTime(.1,l),r.gain.exponentialRampToValueAtTime(.01,l+.09),n.start(l),n.stop(l+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return k(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||o)};static \u0275prov=F({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=["inputSection"];function ee(o,e){if(o&1){let t=M();h(0,"app-thread",4),y("chatFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())})("drawerStateChange",function(n){c(t);let r=s();return d(r.onDrawerStateChange(n))}),g()}if(o&2){let t=s();w("projectName",t.projectName)("threadId",t.threadId)}}function te(o,e){if(o&1){let t=M();h(0,"div",5),R(1,"app-welcome-message"),g(),h(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),y("messageSubmitted",function(n){c(t);let r=s();return d(r.onMessageSubmitted(n))})("voiceMessageReady",function(n){c(t);let r=s();return d(r.onVoiceMessageReady(n))})("voiceRecordingToggled",function(n){c(t);let r=s();return d(r.onVoiceToggled(n))})("heightChanged",function(n){c(t);let r=s();return d(r.onInputHeightChanged(n))})("textareaFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())}),g()()()()}if(o&2){let t=s();m(6),w("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var K=class o{destroy$=new f;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=a(I);titleService=a(U);preferencesService=a(b);route=a($);router=a(H);threadApiService=a(L);agentNotificationService=a(N);firstMessageState=a(Y);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(p(this.destroy$)).subscribe(e=>{let t=e.projectName,i=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:i,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=i,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-main"]],viewQuery:function(t,i){if(t&1&&W(Z,5)(E,5),t&2){let n;O(n=P())&&(i.inputSection=n.first),O(n=P())&&(i.sidenav=n.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,i){t&1&&(h(0,"app-sidenav",1)(1,"div",2),y("mousedown",function(){return i.onChatFocusedOnMobile()})("touchstart",function(){return i.onChatFocusedOnMobile()}),V(2,ee,1,2,"app-thread",3)(3,te,7,5),g()()),t&2&&(w("drawerOpen",i.isDrawerOpen),m(2),j(i.threadId?2:3))},dependencies:[q,Q,T,E],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[S("slideIn",[C(":enter",[u({transform:"translateY(100%)",opacity:0}),_("300ms ease-out",u({transform:"translateY(0)",opacity:1}))]),C(":leave",[_("200ms ease-in",u({transform:"translateY(100%)",opacity:0}))])])]}})};export{K as MainAppComponent};
1
+ import{a as E}from"./chunk-NGMAQNX3.js";import{c as S,d as _,f as u,g as C}from"./chunk-QVW2GZXC.js";import{a as q,b as U,c as Y,d as Q}from"./chunk-R2NWLPS6.js";import"./chunk-EAVXJ7QN.js";import{f as I}from"./chunk-UEGZX4MW.js";import"./chunk-TSYL5EEO.js";import"./chunk-DZ2M3NQD.js";import{a as L,d as b}from"./chunk-CRXIMHRG.js";import"./chunk-YJOXSEUO.js";import"./chunk-GIIRKWUO.js";import{a as $,c as H}from"./chunk-6XX7GME4.js";import"./chunk-2PWIGCN2.js";import"./chunk-SKBEA6VH.js";import"./chunk-J4UAEXFM.js";import"./chunk-GTCP3EYX.js";import"./chunk-VNO76B3S.js";import"./chunk-E6T6QLQT.js";import"./chunk-BTOJ27OO.js";import"./chunk-SPV5SLNS.js";import"./chunk-VMYKE4ZC.js";import"./chunk-AS2L77JV.js";import"./chunk-7OGOI6WM.js";import"./chunk-TASSC2XX.js";import"./chunk-G5RWG2GK.js";import{B as x,Bb as M,Db as y,Fb as s,Jb as W,Ka as m,Kb as O,Lb as P,N as A,T as p,Tb as G,Ub as z,Wa as v,Z as F,ca as a,d as k,ga as c,h as f,ha as d,lb as V,mb as j,rb as w,sb as h,tb as g,ub as R,vb as D,wb as B}from"./chunk-CHEXA6RY.js";var T=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,i){t&1&&(D(0,"h1",0),G(1),B()),t&2&&(m(),z(i.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var N=class o{destroy$=new f;isSetup=!1;codayService=a(I);preferencesService=a(b);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),i=e.createGain();t.connect(i),i.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),i.gain.setValueAtTime(.1,e.currentTime),i.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let n=e.createOscillator(),r=e.createGain();n.connect(r),r.connect(e.destination);let l=e.currentTime+.11;n.frequency.setValueAtTime(950,l),r.gain.setValueAtTime(.1,l),r.gain.exponentialRampToValueAtTime(.01,l+.09),n.start(l),n.stop(l+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return k(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||o)};static \u0275prov=F({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=["inputSection"];function ee(o,e){if(o&1){let t=M();h(0,"app-thread",4),y("chatFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())})("drawerStateChange",function(n){c(t);let r=s();return d(r.onDrawerStateChange(n))}),g()}if(o&2){let t=s();w("projectName",t.projectName)("threadId",t.threadId)}}function te(o,e){if(o&1){let t=M();h(0,"div",5),R(1,"app-welcome-message"),g(),h(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),y("messageSubmitted",function(n){c(t);let r=s();return d(r.onMessageSubmitted(n))})("voiceMessageReady",function(n){c(t);let r=s();return d(r.onVoiceMessageReady(n))})("voiceRecordingToggled",function(n){c(t);let r=s();return d(r.onVoiceToggled(n))})("heightChanged",function(n){c(t);let r=s();return d(r.onInputHeightChanged(n))})("textareaFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())}),g()()()()}if(o&2){let t=s();m(6),w("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var K=class o{destroy$=new f;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=a(I);titleService=a(U);preferencesService=a(b);route=a($);router=a(H);threadApiService=a(L);agentNotificationService=a(N);firstMessageState=a(Y);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(p(this.destroy$)).subscribe(e=>{let t=e.projectName,i=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:i,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=i,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-main"]],viewQuery:function(t,i){if(t&1&&W(Z,5)(E,5),t&2){let n;O(n=P())&&(i.inputSection=n.first),O(n=P())&&(i.sidenav=n.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,i){t&1&&(h(0,"app-sidenav",1)(1,"div",2),y("mousedown",function(){return i.onChatFocusedOnMobile()})("touchstart",function(){return i.onChatFocusedOnMobile()}),V(2,ee,1,2,"app-thread",3)(3,te,7,5),g()()),t&2&&(w("drawerOpen",i.isDrawerOpen),m(2),j(i.threadId?2:3))},dependencies:[q,Q,T,E],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[S("slideIn",[C(":enter",[u({transform:"translateY(100%)",opacity:0}),_("300ms ease-out",u({transform:"translateY(0)",opacity:1}))]),C(":leave",[_("200ms ease-in",u({transform:"translateY(100%)",opacity:0}))])])]}})};export{K as MainAppComponent};
@@ -1 +1 @@
1
- import{A as O,x as w}from"./chunk-BLRBIAYK.js";import{c as D}from"./chunk-6XX7GME4.js";import{A as k,s as E}from"./chunk-VNO76B3S.js";import{Bb as v,Db as g,Fb as l,Ka as d,Rb as y,Tb as s,Ub as b,Vb as C,Wa as M,ca as P,ga as h,ha as f,lb as c,mb as m,pc as x,qc as u,rb as I,sb as r,ta as S,tb as o}from"./chunk-CHEXA6RY.js";function L(n,t){if(n&1&&(r(0,"span",5),s(1),o()),n&2){let e=l();d(),b(e.definition().description)}}function q(n,t){if(n&1&&(r(0,"span",7),s(1),o()),n&2){let e=l();d(),C("Next: ",e.nextRunLabel)}}function U(n,t){if(n&1&&(r(0,"span",8),s(1),o()),n&2){let e=l();d(),C("Last run: ",e.lastRunLabel)}}function $(n,t){if(n&1){let e=v();r(0,"span",12),s(1,"Delete?"),o(),r(2,"ds-icon-button",13),g("action",function(){h(e);let a=l(2);return f(a.onDeleteConfirmed())}),o(),r(3,"ds-icon-button",14),g("action",function(){h(e);let a=l(2);return f(a.onDeleteCancelled())}),o()}}function N(n,t){if(n&1){let e=v();r(0,"ds-kebab-menu",15),g("itemSelected",function(a){h(e);let p=l(2);return f(p.onMenuAction(a))}),o()}if(n&2){let e=l(2);I("items",e.menuItems)}}function V(n,t){if(n&1&&(r(0,"div",10),c(1,$,4,0)(2,N,1,1,"ds-kebab-menu",11),o()),n&2){let e=l();y("scheduled-prompt-item__actions--confirming",e.pendingDelete()),d(),m(e.pendingDelete()?1:2)}}var R=class n{router=P(D);definition=u.required();namespaceId=u(void 0);platformMode=u(!1);readOnly=u(!1);enableRequested=x();disableRequested=x();deleteRequested=x();pendingDelete=S(!1);get scheduleLabel(){let{recurrence:t}=this.definition(),e=t.unit,i=t.timeUtc,a=e===w.WEEK?"week":"month",p=e===w.WEEK&&t.days?.length?` (${t.days.map(_=>O[_]??_).join(", ")})`:"";return`Every ${a}${p} at ${i} UTC`}formatInstant(t){if(!t)return null;let e=new Date(t),i=e.getUTCDate(),a=e.toLocaleString("en-GB",{month:"short",timeZone:"UTC"}),p=e.getUTCFullYear(),_=String(e.getUTCHours()).padStart(2,"0"),T=String(e.getUTCMinutes()).padStart(2,"0");return`${i} ${a} ${p} at ${_}:${T} UTC`}get nextRunLabel(){return this.formatInstant(this.definition().nextRunAt)}get lastRunLabel(){return this.formatInstant(this.definition().lastRunAt)}get menuItems(){let t=this.definition();return[{key:"edit",label:"Edit scheduled prompt",icon:"edit"},{key:"toggle",label:t.enabled?"Disable":"Enable",icon:t.enabled?"toggle_on":"toggle_off"},{key:"delete",label:"Delete scheduled prompt",icon:"delete",variant:"danger"}]}onMenuAction(t){let e=this.definition();switch(t){case"edit":this.platformMode()?this.router.navigate(["/agentos","admin","scheduled-prompts",e.id,"edit"]):this.router.navigate(["/agentos",this.namespaceId(),"scheduled-prompts",e.id,"edit"]);break;case"toggle":e.enabled?this.disableRequested.emit(e):this.enableRequested.emit(e);break;case"delete":this.pendingDelete.set(!0);break}}onDeleteConfirmed(){this.pendingDelete.set(!1),this.deleteRequested.emit(this.definition())}onDeleteCancelled(){this.pendingDelete.set(!1)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=M({type:n,selectors:[["agentos-scheduled-prompt-item"]],inputs:{definition:[1,"definition"],namespaceId:[1,"namespaceId"],platformMode:[1,"platformMode"],readOnly:[1,"readOnly"]},outputs:{enableRequested:"enableRequested",disableRequested:"disableRequested",deleteRequested:"deleteRequested"},decls:13,vars:11,consts:[["role","listitem",1,"scheduled-prompt-item"],[1,"scheduled-prompt-item__body"],[1,"scheduled-prompt-item__header"],[1,"scheduled-prompt-item__name"],[1,"scheduled-prompt-item__status"],[1,"scheduled-prompt-item__description"],[1,"scheduled-prompt-item__schedule"],[1,"scheduled-prompt-item__next-run"],[1,"scheduled-prompt-item__last-run"],[1,"scheduled-prompt-item__actions",3,"scheduled-prompt-item__actions--confirming"],[1,"scheduled-prompt-item__actions"],[3,"items"],[1,"scheduled-prompt-item__confirm-label"],["icon","check","variant","danger","title","Confirm deletion",3,"action"],["icon","close","title","Cancel deletion",3,"action"],[3,"itemSelected","items"]],template:function(e,i){e&1&&(r(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),s(4),o(),r(5,"span",4),s(6),o()(),c(7,L,2,1,"span",5),r(8,"span",6),s(9),o(),c(10,q,2,1,"span",7),c(11,U,2,1,"span",8),o(),c(12,V,3,3,"div",9),o()),e&2&&(d(4),b(i.definition().name),d(),y("scheduled-prompt-item__status--enabled",i.definition().enabled)("scheduled-prompt-item__status--disabled",!i.definition().enabled),d(),C(" ",i.definition().enabled?"Enabled":"Disabled"," "),d(),m(i.definition().description?7:-1),d(2),b(i.scheduleLabel),d(),m(i.nextRunLabel?10:-1),d(),m(i.lastRunLabel?11:-1),d(),m(i.readOnly()?-1:12))},dependencies:[k,E],styles:[".scheduled-prompt-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem 1rem;border-radius:10px;border:1px solid var(--color-border, rgba(0, 0, 0, .08));background:var(--glass-bg, rgba(255, 255, 255, .72));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px));transition:background .15s ease,border-color .15s ease}.scheduled-prompt-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-color:var(--color-primary, #007aff)}.scheduled-prompt-item__body[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.2rem;min-width:0}.scheduled-prompt-item__header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;min-width:0}.scheduled-prompt-item__name[_ngcontent-%COMP%]{font-size:.95rem;font-weight:500;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}.scheduled-prompt-item__status[_ngcontent-%COMP%]{font-size:.7rem;font-weight:600;padding:.15rem .5rem;border-radius:999px;white-space:nowrap;flex-shrink:0;text-transform:uppercase;letter-spacing:.04em}.scheduled-prompt-item__status--enabled[_ngcontent-%COMP%]{background:var(--color-success-bg, rgba(52, 199, 89, .12));color:var(--color-success, #34c759)}.scheduled-prompt-item__status--disabled[_ngcontent-%COMP%]{background:var(--color-warning-bg, rgba(255, 159, 10, .12));color:var(--color-warning, #ff9f0a)}.scheduled-prompt-item__description[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__schedule[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);font-family:monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__next-run[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__last-run[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary, #6e6e73);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__actions[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;gap:.125rem;opacity:0;transition:opacity .15s ease}.scheduled-prompt-item[_ngcontent-%COMP%]:hover .scheduled-prompt-item__actions[_ngcontent-%COMP%], .scheduled-prompt-item[_ngcontent-%COMP%]:focus-within .scheduled-prompt-item__actions[_ngcontent-%COMP%]{opacity:1}.scheduled-prompt-item__actions--confirming[_ngcontent-%COMP%]{opacity:1}.scheduled-prompt-item__confirm-label[_ngcontent-%COMP%]{font-size:.8rem;font-weight:500;color:var(--color-error, #ff3b30);margin-right:.25rem;white-space:nowrap}"],changeDetection:0})};export{R as a};
1
+ import{B as O,y as w}from"./chunk-UQTA3ACH.js";import{c as D}from"./chunk-6XX7GME4.js";import{A as k,s as E}from"./chunk-VNO76B3S.js";import{Bb as v,Db as g,Fb as l,Ka as d,Rb as y,Tb as s,Ub as b,Vb as C,Wa as M,ca as P,ga as h,ha as f,lb as c,mb as m,pc as x,qc as u,rb as I,sb as r,ta as S,tb as o}from"./chunk-CHEXA6RY.js";function L(n,t){if(n&1&&(r(0,"span",5),s(1),o()),n&2){let e=l();d(),b(e.definition().description)}}function q(n,t){if(n&1&&(r(0,"span",7),s(1),o()),n&2){let e=l();d(),C("Next: ",e.nextRunLabel)}}function U(n,t){if(n&1&&(r(0,"span",8),s(1),o()),n&2){let e=l();d(),C("Last run: ",e.lastRunLabel)}}function $(n,t){if(n&1){let e=v();r(0,"span",12),s(1,"Delete?"),o(),r(2,"ds-icon-button",13),g("action",function(){h(e);let a=l(2);return f(a.onDeleteConfirmed())}),o(),r(3,"ds-icon-button",14),g("action",function(){h(e);let a=l(2);return f(a.onDeleteCancelled())}),o()}}function N(n,t){if(n&1){let e=v();r(0,"ds-kebab-menu",15),g("itemSelected",function(a){h(e);let p=l(2);return f(p.onMenuAction(a))}),o()}if(n&2){let e=l(2);I("items",e.menuItems)}}function V(n,t){if(n&1&&(r(0,"div",10),c(1,$,4,0)(2,N,1,1,"ds-kebab-menu",11),o()),n&2){let e=l();y("scheduled-prompt-item__actions--confirming",e.pendingDelete()),d(),m(e.pendingDelete()?1:2)}}var R=class n{router=P(D);definition=u.required();namespaceId=u(void 0);platformMode=u(!1);readOnly=u(!1);enableRequested=x();disableRequested=x();deleteRequested=x();pendingDelete=S(!1);get scheduleLabel(){let{recurrence:t}=this.definition(),e=t.unit,i=t.timeUtc,a=e===w.WEEK?"week":"month",p=e===w.WEEK&&t.days?.length?` (${t.days.map(_=>O[_]??_).join(", ")})`:"";return`Every ${a}${p} at ${i} UTC`}formatInstant(t){if(!t)return null;let e=new Date(t),i=e.getUTCDate(),a=e.toLocaleString("en-GB",{month:"short",timeZone:"UTC"}),p=e.getUTCFullYear(),_=String(e.getUTCHours()).padStart(2,"0"),T=String(e.getUTCMinutes()).padStart(2,"0");return`${i} ${a} ${p} at ${_}:${T} UTC`}get nextRunLabel(){return this.formatInstant(this.definition().nextRunAt)}get lastRunLabel(){return this.formatInstant(this.definition().lastRunAt)}get menuItems(){let t=this.definition();return[{key:"edit",label:"Edit scheduled prompt",icon:"edit"},{key:"toggle",label:t.enabled?"Disable":"Enable",icon:t.enabled?"toggle_on":"toggle_off"},{key:"delete",label:"Delete scheduled prompt",icon:"delete",variant:"danger"}]}onMenuAction(t){let e=this.definition();switch(t){case"edit":this.platformMode()?this.router.navigate(["/agentos","admin","scheduled-prompts",e.id,"edit"]):this.router.navigate(["/agentos",this.namespaceId(),"scheduled-prompts",e.id,"edit"]);break;case"toggle":e.enabled?this.disableRequested.emit(e):this.enableRequested.emit(e);break;case"delete":this.pendingDelete.set(!0);break}}onDeleteConfirmed(){this.pendingDelete.set(!1),this.deleteRequested.emit(this.definition())}onDeleteCancelled(){this.pendingDelete.set(!1)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=M({type:n,selectors:[["agentos-scheduled-prompt-item"]],inputs:{definition:[1,"definition"],namespaceId:[1,"namespaceId"],platformMode:[1,"platformMode"],readOnly:[1,"readOnly"]},outputs:{enableRequested:"enableRequested",disableRequested:"disableRequested",deleteRequested:"deleteRequested"},decls:13,vars:11,consts:[["role","listitem",1,"scheduled-prompt-item"],[1,"scheduled-prompt-item__body"],[1,"scheduled-prompt-item__header"],[1,"scheduled-prompt-item__name"],[1,"scheduled-prompt-item__status"],[1,"scheduled-prompt-item__description"],[1,"scheduled-prompt-item__schedule"],[1,"scheduled-prompt-item__next-run"],[1,"scheduled-prompt-item__last-run"],[1,"scheduled-prompt-item__actions",3,"scheduled-prompt-item__actions--confirming"],[1,"scheduled-prompt-item__actions"],[3,"items"],[1,"scheduled-prompt-item__confirm-label"],["icon","check","variant","danger","title","Confirm deletion",3,"action"],["icon","close","title","Cancel deletion",3,"action"],[3,"itemSelected","items"]],template:function(e,i){e&1&&(r(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),s(4),o(),r(5,"span",4),s(6),o()(),c(7,L,2,1,"span",5),r(8,"span",6),s(9),o(),c(10,q,2,1,"span",7),c(11,U,2,1,"span",8),o(),c(12,V,3,3,"div",9),o()),e&2&&(d(4),b(i.definition().name),d(),y("scheduled-prompt-item__status--enabled",i.definition().enabled)("scheduled-prompt-item__status--disabled",!i.definition().enabled),d(),C(" ",i.definition().enabled?"Enabled":"Disabled"," "),d(),m(i.definition().description?7:-1),d(2),b(i.scheduleLabel),d(),m(i.nextRunLabel?10:-1),d(),m(i.lastRunLabel?11:-1),d(),m(i.readOnly()?-1:12))},dependencies:[k,E],styles:[".scheduled-prompt-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem 1rem;border-radius:10px;border:1px solid var(--color-border, rgba(0, 0, 0, .08));background:var(--glass-bg, rgba(255, 255, 255, .72));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px));transition:background .15s ease,border-color .15s ease}.scheduled-prompt-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-color:var(--color-primary, #007aff)}.scheduled-prompt-item__body[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.2rem;min-width:0}.scheduled-prompt-item__header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;min-width:0}.scheduled-prompt-item__name[_ngcontent-%COMP%]{font-size:.95rem;font-weight:500;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}.scheduled-prompt-item__status[_ngcontent-%COMP%]{font-size:.7rem;font-weight:600;padding:.15rem .5rem;border-radius:999px;white-space:nowrap;flex-shrink:0;text-transform:uppercase;letter-spacing:.04em}.scheduled-prompt-item__status--enabled[_ngcontent-%COMP%]{background:var(--color-success-bg, rgba(52, 199, 89, .12));color:var(--color-success, #34c759)}.scheduled-prompt-item__status--disabled[_ngcontent-%COMP%]{background:var(--color-warning-bg, rgba(255, 159, 10, .12));color:var(--color-warning, #ff9f0a)}.scheduled-prompt-item__description[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__schedule[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);font-family:monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__next-run[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text, #1d1d1f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__last-run[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary, #6e6e73);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scheduled-prompt-item__actions[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;gap:.125rem;opacity:0;transition:opacity .15s ease}.scheduled-prompt-item[_ngcontent-%COMP%]:hover .scheduled-prompt-item__actions[_ngcontent-%COMP%], .scheduled-prompt-item[_ngcontent-%COMP%]:focus-within .scheduled-prompt-item__actions[_ngcontent-%COMP%]{opacity:1}.scheduled-prompt-item__actions--confirming[_ngcontent-%COMP%]{opacity:1}.scheduled-prompt-item__confirm-label[_ngcontent-%COMP%]{font-size:.8rem;font-weight:500;color:var(--color-error, #ff3b30);margin-right:.25rem;white-space:nowrap}"],changeDetection:0})};export{R as a};
@@ -1 +1 @@
1
- import{a as J,c as Q}from"./chunk-5IIN2VT5.js";import{a as H}from"./chunk-6UXZYGDR.js";import{j as G,k as V}from"./chunk-BLRBIAYK.js";import{a as q,c as I}from"./chunk-6XX7GME4.js";import{A as W,o as j,s as K,z as $}from"./chunk-VNO76B3S.js";import{a as T,b as F,c as z}from"./chunk-VMYKE4ZC.js";import{Bb as C,D as P,Db as m,Fb as l,Ka as d,Pb as O,Rb as D,S as R,Tb as u,Ub as A,Wa as v,ab as E,ca as c,ga as g,ha as _,jb as N,jc as L,lb as b,m as S,ma as w,mb as f,mc as U,pc as x,qc as h,rb as p,sb as o,t as B,ta as y,tb as r}from"./chunk-CHEXA6RY.js";function ee(s,t){if(s&1&&(o(0,"span",3),u(1),r()),s&2){let e=l();d(),A(e.subtitle)}}var M=class s{user=h.required();editRequested=x();deleteRequested=x();menuItems=[{key:"edit",label:"Edit user",icon:"edit"},{key:"delete",label:"Delete user",icon:"delete",variant:"danger"}];get displayName(){let{firstname:t,lastname:e,email:n}=this.user();return[t,e].filter(Boolean).join(" ")||n||"\u2014"}get subtitle(){return this.user().email??this.user().externalId??""}onMenuAction(t){switch(t){case"edit":this.editRequested.emit(this.user());break;case"delete":confirm(`Delete user "${this.displayName}"?`)&&this.deleteRequested.emit(this.user());break}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-user-item"]],inputs:{user:[1,"user"]},outputs:{editRequested:"editRequested",deleteRequested:"deleteRequested"},decls:7,vars:3,consts:[["role","listitem","dsBlueprint","",1,"user-item"],[1,"user-item__body"],[1,"user-item__name"],[1,"user-item__subtitle"],[1,"user-item__actions"],[3,"itemSelected","items"]],template:function(e,n){e&1&&(o(0,"div",0)(1,"div",1)(2,"span",2),u(3),r(),b(4,ee,2,1,"span",3),r(),o(5,"div",4)(6,"ds-kebab-menu",5),m("itemSelected",function(a){return n.onMenuAction(a)}),r()()()),e&2&&(d(3),A(n.displayName),d(),f(n.subtitle?4:-1),d(2),p("items",n.menuItems))},dependencies:[j,W],styles:[".user-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;width:100%;padding:14px 16px;position:relative;border-radius:0;border:1px solid var(--color-divider);background:var(--color-bg);box-shadow:var(--shadow-sm);box-sizing:border-box;overflow:visible;transition:border-color .15s ease}.user-item[_ngcontent-%COMP%]:hover{border-color:var(--color-accent)}.user-item__body[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.user-item__name[_ngcontent-%COMP%]{font-size:15px;font-weight:600;color:var(--color-text);line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-item__subtitle[_ngcontent-%COMP%]{font-size:13px;color:var(--color-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-item__actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .15s ease}.user-item[_ngcontent-%COMP%]:hover .user-item__actions[_ngcontent-%COMP%], .user-item[_ngcontent-%COMP%]:focus-within .user-item__actions[_ngcontent-%COMP%]{opacity:1}"],changeDetection:0})};function te(s,t){if(s&1){let e=C();o(0,"agentos-namespace-select",4),m("valueChange",function(i){g(e);let a=l();return _(a.onNamespaceChange(i))}),r()}if(s&2){let e=l();p("namespaces",t)("value",e.selectedNamespaceId())("includeAllOption",!0)}}function ne(s,t){if(s&1){let e=C();o(0,"ds-icon-button",5),m("action",function(){g(e);let i=l();return _(i.goBack())}),r()}}function se(s,t){if(s&1){let e=C();o(0,"agentos-user-item",7),m("editRequested",function(i){g(e);let a=l(2);return _(a.navigateToEdit(i))})("deleteRequested",function(i){g(e);let a=l(2);return _(a.deleteUser(i))}),r()}s&2&&p("user",t)}function ie(s,t){if(s&1&&b(0,se,1,1,"agentos-user-item",6),s&2){let e,n=t.$implicit,i=l();f((e=i.resolveUser(n.id))?0:-1,e)}}var k=class s{router=c(I);destroyRef=c(w);userAdminState=c(H);namespacePermissions=c(V);showBackButton=h(!0);namespaces=h(void 0);selectedNamespaceId=h(null);hideTitle=h(!1);namespaceFilterChange=x();isLoading=this.userAdminState.isLoading;namespaceUserIds=z(F(this.selectedNamespaceId).pipe(R(t=>t?this.namespacePermissions.listNamespaceUsers(t).pipe(B(e=>new Set(e.map(n=>n.id))),P(e=>(console.error("[UserList] Failed to load namespace users",e),S(null)))):S(null))),{initialValue:null});userItems=U(()=>{let t=this.namespaceUserIds();return this.userAdminState.users().filter(e=>t===null||t.has(e.id??"")).map(e=>({id:e.id??"",name:[e.firstname,e.lastname].filter(Boolean).join(" ")||e.email||"\u2014",description:e.email}))});get usersById(){return new Map(this.userAdminState.users().map(t=>[t.id??"",t]))}ngOnInit(){this.userAdminState.loadAll().pipe(T(this.destroyRef)).subscribe()}onNamespaceChange(t){this.namespaceFilterChange.emit(t)}goBack(){this.router.navigate(["/agentos","admin"])}navigateToCreate(){this.router.navigate(["/agentos/admin/users/new"])}navigateToEdit(t){this.router.navigate(["/agentos/admin/users",t.id??"","edit"])}deleteUser(t){this.userAdminState.deleteUser(t.id??"").pipe(T(this.destroyRef)).subscribe()}resolveUser(t){return this.usersById.get(t)??null}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-user-list"]],inputs:{showBackButton:[1,"showBackButton"],namespaces:[1,"namespaces"],selectedNamespaceId:[1,"selectedNamespaceId"],hideTitle:[1,"hideTitle"]},outputs:{namespaceFilterChange:"namespaceFilterChange"},decls:5,vars:5,consts:[["userItemTpl",""],["title","Users","emptyMessage","No users found.","cardMinWidth","320px",3,"createRequested","hideTitle","items","showCreate","itemTemplate"],["toolbar-start","",3,"namespaces","value","includeAllOption"],["toolbar-start","","icon","arrow_back","title","Back"],["toolbar-start","",3,"valueChange","namespaces","value","includeAllOption"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"user"],[3,"editRequested","deleteRequested","user"]],template:function(e,n){if(e&1&&(o(0,"ds-entity-list",1),m("createRequested",function(){return n.navigateToCreate()}),b(1,te,1,3,"agentos-namespace-select",2)(2,ne,1,0,"ds-icon-button",3),r(),E(3,ie,1,1,"ng-template",null,0,L)),e&2){let i,a=O(4);p("hideTitle",n.hideTitle())("items",n.userItems())("showCreate",!0)("itemTemplate",a),d(),f((i=n.namespaces())?1:n.showBackButton()?2:-1,i)}},dependencies:[$,M,K,J],encapsulation:2,changeDetection:0})};function re(s,t){if(s&1){let e=C();o(0,"agentos-user-list",9),m("namespaceFilterChange",function(i){g(e);let a=l();return _(a.onUsersNamespaceChange(i))}),r()}if(s&2){let e=l();p("showBackButton",!1)("hideTitle",!0)("namespaces",e.namespaces())("selectedNamespaceId",e.usersNamespaceFilter())}}function oe(s,t){s&1&&(o(0,"p",10),u(1,"No namespaces yet. Create one before managing groups."),r())}function ae(s,t){if(s&1){let e=C();o(0,"agentos-user-group-list",12),m("namespaceChange",function(i){g(e);let a=l(2);return _(a.onGroupsNamespaceChange(i))}),r()}if(s&2){let e=l(2);p("namespaceId",t)("hideTitle",!0)("namespaces",e.namespaces())("returnTo",e.returnTo())}}function le(s,t){if(s&1&&b(0,oe,2,0,"p",10)(1,ae,1,4,"agentos-user-group-list",11),s&2){let e,n=l();f(n.namespaces().length===0?0:(e=n.groupsNamespaceId())?1:-1,e)}}var Z=class s{router=c(I);route=c(q);destroyRef=c(w);namespaceController=c(G);activeTab=y(this.route.snapshot.queryParamMap.get("tab")==="groups"?"groups":"users");namespaces=y([]);usersNamespaceFilter=y(null);groupsNamespaceId=y(null);returnTo=U(()=>{let t=this.groupsNamespaceId();return t?`/agentos/admin/users?tab=groups&ns=${t}`:"/agentos/admin/users?tab=groups"});constructor(){let t=this.route.snapshot.queryParamMap.get("ns");this.namespaceController.listAllNamespace().pipe(T(this.destroyRef)).subscribe(e=>{let n=e.filter(a=>a.role!=="MEMBER");this.namespaces.set(n);let i=t&&n.some(a=>a.id===t)?t:n[0]?.id??null;this.groupsNamespaceId.set(i)})}setTab(t){this.activeTab.set(t)}onUsersNamespaceChange(t){this.usersNamespaceFilter.set(t)}onGroupsNamespaceChange(t){this.groupsNamespaceId.set(t)}goBack(){this.router.navigate(["/agentos","admin"])}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-admin-users-groups"]],decls:14,vars:8,consts:[[1,"admin-users-groups"],[1,"admin-users-groups__header"],["type","button",1,"admin-users-groups__back",3,"click"],[1,"admin-users-groups__title"],["role","tablist","aria-label","Users and Groups",1,"admin-users-groups__tabs"],["id","admin-tab-users","type","button","role","tab","aria-controls","admin-users-groups-panel",1,"admin-users-groups__tab",3,"click"],["id","admin-tab-groups","type","button","role","tab","aria-controls","admin-users-groups-panel",1,"admin-users-groups__tab",3,"click"],["id","admin-users-groups-panel","role","tabpanel","tabindex","0",1,"admin-users-groups__panel"],[3,"showBackButton","hideTitle","namespaces","selectedNamespaceId"],[3,"namespaceFilterChange","showBackButton","hideTitle","namespaces","selectedNamespaceId"],[1,"admin-users-groups__empty"],[3,"namespaceId","hideTitle","namespaces","returnTo"],[3,"namespaceChange","namespaceId","hideTitle","namespaces","returnTo"]],template:function(e,n){e&1&&(o(0,"div",0)(1,"header",1)(2,"button",2),m("click",function(){return n.goBack()}),u(3,"\u2190 Admin"),r(),o(4,"h1",3),u(5,"Users & Groups"),r()(),o(6,"div",4)(7,"button",5),m("click",function(){return n.setTab("users")}),u(8," Users "),r(),o(9,"button",6),m("click",function(){return n.setTab("groups")}),u(10," Groups "),r()(),o(11,"div",7),b(12,re,1,4,"agentos-user-list",8)(13,le,2,1),r()()),e&2&&(d(7),D("admin-users-groups__tab--active",n.activeTab()==="users"),N("aria-selected",n.activeTab()==="users"),d(2),D("admin-users-groups__tab--active",n.activeTab()==="groups"),N("aria-selected",n.activeTab()==="groups"),d(2),N("aria-labelledby",n.activeTab()==="users"?"admin-tab-users":"admin-tab-groups"),d(),f(n.activeTab()==="users"?12:13))},dependencies:[k,Q],styles:[".admin-users-groups[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:1.5rem 1rem 0;--entity-list-toolbar-max-width: 900px}.admin-users-groups__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-width:900px;margin:0 auto;width:100%}.admin-users-groups__back[_ngcontent-%COMP%]{align-self:flex-start;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.admin-users-groups__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.admin-users-groups__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.admin-users-groups__tabs[_ngcontent-%COMP%]{display:inline-flex;gap:.25rem;padding:.25rem;border-radius:10px;background:var(--color-surface-hover, rgba(0, 0, 0, .05));border:1px solid var(--color-border, rgba(0, 0, 0, .08));max-width:900px;margin:0 auto;width:fit-content;align-self:center}.admin-users-groups__tab[_ngcontent-%COMP%]{padding:.4rem 1.25rem;border-radius:8px;border:none;background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.9rem;font-family:inherit;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.admin-users-groups__tab[_ngcontent-%COMP%]:hover{color:var(--color-text, #1d1d1f)}.admin-users-groups__tab--active[_ngcontent-%COMP%]{background:var(--color-bg-surface, #fff);color:var(--color-text, #1d1d1f);box-shadow:0 1px 2px #00000014}.admin-users-groups__empty[_ngcontent-%COMP%]{max-width:900px;margin:1rem auto;width:100%;color:var(--color-text-secondary, #6e6e73);font-size:.9rem}"],changeDetection:0})};export{M as a,k as b,Z as c};
1
+ import{a as J,c as Q}from"./chunk-X73LZ3QV.js";import{a as H}from"./chunk-H6NBS4JE.js";import{j as G,k as V}from"./chunk-UQTA3ACH.js";import{a as q,c as I}from"./chunk-6XX7GME4.js";import{A as W,o as j,s as K,z as $}from"./chunk-VNO76B3S.js";import{a as T,b as F,c as z}from"./chunk-VMYKE4ZC.js";import{Bb as C,D as P,Db as m,Fb as l,Ka as d,Pb as O,Rb as D,S as R,Tb as u,Ub as A,Wa as v,ab as E,ca as c,ga as g,ha as _,jb as N,jc as L,lb as b,m as S,ma as w,mb as f,mc as U,pc as x,qc as h,rb as p,sb as o,t as B,ta as y,tb as r}from"./chunk-CHEXA6RY.js";function ee(s,t){if(s&1&&(o(0,"span",3),u(1),r()),s&2){let e=l();d(),A(e.subtitle)}}var M=class s{user=h.required();editRequested=x();deleteRequested=x();menuItems=[{key:"edit",label:"Edit user",icon:"edit"},{key:"delete",label:"Delete user",icon:"delete",variant:"danger"}];get displayName(){let{firstname:t,lastname:e,email:n}=this.user();return[t,e].filter(Boolean).join(" ")||n||"\u2014"}get subtitle(){return this.user().email??this.user().externalId??""}onMenuAction(t){switch(t){case"edit":this.editRequested.emit(this.user());break;case"delete":confirm(`Delete user "${this.displayName}"?`)&&this.deleteRequested.emit(this.user());break}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-user-item"]],inputs:{user:[1,"user"]},outputs:{editRequested:"editRequested",deleteRequested:"deleteRequested"},decls:7,vars:3,consts:[["role","listitem","dsBlueprint","",1,"user-item"],[1,"user-item__body"],[1,"user-item__name"],[1,"user-item__subtitle"],[1,"user-item__actions"],[3,"itemSelected","items"]],template:function(e,n){e&1&&(o(0,"div",0)(1,"div",1)(2,"span",2),u(3),r(),b(4,ee,2,1,"span",3),r(),o(5,"div",4)(6,"ds-kebab-menu",5),m("itemSelected",function(a){return n.onMenuAction(a)}),r()()()),e&2&&(d(3),A(n.displayName),d(),f(n.subtitle?4:-1),d(2),p("items",n.menuItems))},dependencies:[j,W],styles:[".user-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;width:100%;padding:14px 16px;position:relative;border-radius:0;border:1px solid var(--color-divider);background:var(--color-bg);box-shadow:var(--shadow-sm);box-sizing:border-box;overflow:visible;transition:border-color .15s ease}.user-item[_ngcontent-%COMP%]:hover{border-color:var(--color-accent)}.user-item__body[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.user-item__name[_ngcontent-%COMP%]{font-size:15px;font-weight:600;color:var(--color-text);line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-item__subtitle[_ngcontent-%COMP%]{font-size:13px;color:var(--color-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-item__actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .15s ease}.user-item[_ngcontent-%COMP%]:hover .user-item__actions[_ngcontent-%COMP%], .user-item[_ngcontent-%COMP%]:focus-within .user-item__actions[_ngcontent-%COMP%]{opacity:1}"],changeDetection:0})};function te(s,t){if(s&1){let e=C();o(0,"agentos-namespace-select",4),m("valueChange",function(i){g(e);let a=l();return _(a.onNamespaceChange(i))}),r()}if(s&2){let e=l();p("namespaces",t)("value",e.selectedNamespaceId())("includeAllOption",!0)}}function ne(s,t){if(s&1){let e=C();o(0,"ds-icon-button",5),m("action",function(){g(e);let i=l();return _(i.goBack())}),r()}}function se(s,t){if(s&1){let e=C();o(0,"agentos-user-item",7),m("editRequested",function(i){g(e);let a=l(2);return _(a.navigateToEdit(i))})("deleteRequested",function(i){g(e);let a=l(2);return _(a.deleteUser(i))}),r()}s&2&&p("user",t)}function ie(s,t){if(s&1&&b(0,se,1,1,"agentos-user-item",6),s&2){let e,n=t.$implicit,i=l();f((e=i.resolveUser(n.id))?0:-1,e)}}var k=class s{router=c(I);destroyRef=c(w);userAdminState=c(H);namespacePermissions=c(V);showBackButton=h(!0);namespaces=h(void 0);selectedNamespaceId=h(null);hideTitle=h(!1);namespaceFilterChange=x();isLoading=this.userAdminState.isLoading;namespaceUserIds=z(F(this.selectedNamespaceId).pipe(R(t=>t?this.namespacePermissions.listNamespaceUsers(t).pipe(B(e=>new Set(e.map(n=>n.id))),P(e=>(console.error("[UserList] Failed to load namespace users",e),S(null)))):S(null))),{initialValue:null});userItems=U(()=>{let t=this.namespaceUserIds();return this.userAdminState.users().filter(e=>t===null||t.has(e.id??"")).map(e=>({id:e.id??"",name:[e.firstname,e.lastname].filter(Boolean).join(" ")||e.email||"\u2014",description:e.email}))});get usersById(){return new Map(this.userAdminState.users().map(t=>[t.id??"",t]))}ngOnInit(){this.userAdminState.loadAll().pipe(T(this.destroyRef)).subscribe()}onNamespaceChange(t){this.namespaceFilterChange.emit(t)}goBack(){this.router.navigate(["/agentos","admin"])}navigateToCreate(){this.router.navigate(["/agentos/admin/users/new"])}navigateToEdit(t){this.router.navigate(["/agentos/admin/users",t.id??"","edit"])}deleteUser(t){this.userAdminState.deleteUser(t.id??"").pipe(T(this.destroyRef)).subscribe()}resolveUser(t){return this.usersById.get(t)??null}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-user-list"]],inputs:{showBackButton:[1,"showBackButton"],namespaces:[1,"namespaces"],selectedNamespaceId:[1,"selectedNamespaceId"],hideTitle:[1,"hideTitle"]},outputs:{namespaceFilterChange:"namespaceFilterChange"},decls:5,vars:5,consts:[["userItemTpl",""],["title","Users","emptyMessage","No users found.","cardMinWidth","320px",3,"createRequested","hideTitle","items","showCreate","itemTemplate"],["toolbar-start","",3,"namespaces","value","includeAllOption"],["toolbar-start","","icon","arrow_back","title","Back"],["toolbar-start","",3,"valueChange","namespaces","value","includeAllOption"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"user"],[3,"editRequested","deleteRequested","user"]],template:function(e,n){if(e&1&&(o(0,"ds-entity-list",1),m("createRequested",function(){return n.navigateToCreate()}),b(1,te,1,3,"agentos-namespace-select",2)(2,ne,1,0,"ds-icon-button",3),r(),E(3,ie,1,1,"ng-template",null,0,L)),e&2){let i,a=O(4);p("hideTitle",n.hideTitle())("items",n.userItems())("showCreate",!0)("itemTemplate",a),d(),f((i=n.namespaces())?1:n.showBackButton()?2:-1,i)}},dependencies:[$,M,K,J],encapsulation:2,changeDetection:0})};function re(s,t){if(s&1){let e=C();o(0,"agentos-user-list",9),m("namespaceFilterChange",function(i){g(e);let a=l();return _(a.onUsersNamespaceChange(i))}),r()}if(s&2){let e=l();p("showBackButton",!1)("hideTitle",!0)("namespaces",e.namespaces())("selectedNamespaceId",e.usersNamespaceFilter())}}function oe(s,t){s&1&&(o(0,"p",10),u(1,"No namespaces yet. Create one before managing groups."),r())}function ae(s,t){if(s&1){let e=C();o(0,"agentos-user-group-list",12),m("namespaceChange",function(i){g(e);let a=l(2);return _(a.onGroupsNamespaceChange(i))}),r()}if(s&2){let e=l(2);p("namespaceId",t)("hideTitle",!0)("namespaces",e.namespaces())("returnTo",e.returnTo())}}function le(s,t){if(s&1&&b(0,oe,2,0,"p",10)(1,ae,1,4,"agentos-user-group-list",11),s&2){let e,n=l();f(n.namespaces().length===0?0:(e=n.groupsNamespaceId())?1:-1,e)}}var Z=class s{router=c(I);route=c(q);destroyRef=c(w);namespaceController=c(G);activeTab=y(this.route.snapshot.queryParamMap.get("tab")==="groups"?"groups":"users");namespaces=y([]);usersNamespaceFilter=y(null);groupsNamespaceId=y(null);returnTo=U(()=>{let t=this.groupsNamespaceId();return t?`/agentos/admin/users?tab=groups&ns=${t}`:"/agentos/admin/users?tab=groups"});constructor(){let t=this.route.snapshot.queryParamMap.get("ns");this.namespaceController.listAllNamespace().pipe(T(this.destroyRef)).subscribe(e=>{let n=e.filter(a=>a.role!=="MEMBER");this.namespaces.set(n);let i=t&&n.some(a=>a.id===t)?t:n[0]?.id??null;this.groupsNamespaceId.set(i)})}setTab(t){this.activeTab.set(t)}onUsersNamespaceChange(t){this.usersNamespaceFilter.set(t)}onGroupsNamespaceChange(t){this.groupsNamespaceId.set(t)}goBack(){this.router.navigate(["/agentos","admin"])}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=v({type:s,selectors:[["agentos-admin-users-groups"]],decls:14,vars:8,consts:[[1,"admin-users-groups"],[1,"admin-users-groups__header"],["type","button",1,"admin-users-groups__back",3,"click"],[1,"admin-users-groups__title"],["role","tablist","aria-label","Users and Groups",1,"admin-users-groups__tabs"],["id","admin-tab-users","type","button","role","tab","aria-controls","admin-users-groups-panel",1,"admin-users-groups__tab",3,"click"],["id","admin-tab-groups","type","button","role","tab","aria-controls","admin-users-groups-panel",1,"admin-users-groups__tab",3,"click"],["id","admin-users-groups-panel","role","tabpanel","tabindex","0",1,"admin-users-groups__panel"],[3,"showBackButton","hideTitle","namespaces","selectedNamespaceId"],[3,"namespaceFilterChange","showBackButton","hideTitle","namespaces","selectedNamespaceId"],[1,"admin-users-groups__empty"],[3,"namespaceId","hideTitle","namespaces","returnTo"],[3,"namespaceChange","namespaceId","hideTitle","namespaces","returnTo"]],template:function(e,n){e&1&&(o(0,"div",0)(1,"header",1)(2,"button",2),m("click",function(){return n.goBack()}),u(3,"\u2190 Admin"),r(),o(4,"h1",3),u(5,"Users & Groups"),r()(),o(6,"div",4)(7,"button",5),m("click",function(){return n.setTab("users")}),u(8," Users "),r(),o(9,"button",6),m("click",function(){return n.setTab("groups")}),u(10," Groups "),r()(),o(11,"div",7),b(12,re,1,4,"agentos-user-list",8)(13,le,2,1),r()()),e&2&&(d(7),D("admin-users-groups__tab--active",n.activeTab()==="users"),N("aria-selected",n.activeTab()==="users"),d(2),D("admin-users-groups__tab--active",n.activeTab()==="groups"),N("aria-selected",n.activeTab()==="groups"),d(2),N("aria-labelledby",n.activeTab()==="users"?"admin-tab-users":"admin-tab-groups"),d(),f(n.activeTab()==="users"?12:13))},dependencies:[k,Q],styles:[".admin-users-groups[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:1.5rem 1rem 0;--entity-list-toolbar-max-width: 900px}.admin-users-groups__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-width:900px;margin:0 auto;width:100%}.admin-users-groups__back[_ngcontent-%COMP%]{align-self:flex-start;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.admin-users-groups__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.admin-users-groups__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.admin-users-groups__tabs[_ngcontent-%COMP%]{display:inline-flex;gap:.25rem;padding:.25rem;border-radius:10px;background:var(--color-surface-hover, rgba(0, 0, 0, .05));border:1px solid var(--color-border, rgba(0, 0, 0, .08));max-width:900px;margin:0 auto;width:fit-content;align-self:center}.admin-users-groups__tab[_ngcontent-%COMP%]{padding:.4rem 1.25rem;border-radius:8px;border:none;background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.9rem;font-family:inherit;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.admin-users-groups__tab[_ngcontent-%COMP%]:hover{color:var(--color-text, #1d1d1f)}.admin-users-groups__tab--active[_ngcontent-%COMP%]{background:var(--color-bg-surface, #fff);color:var(--color-text, #1d1d1f);box-shadow:0 1px 2px #00000014}.admin-users-groups__empty[_ngcontent-%COMP%]{max-width:900px;margin:1rem auto;width:100%;color:var(--color-text-secondary, #6e6e73);font-size:.9rem}"],changeDetection:0})};export{M as a,k as b,Z as c};