@whoz-oss/coday-client 0.191.0 → 0.192.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 (58) hide show
  1. package/browser/{chunk-NW27XB47.js → chunk-2E6MYDFG.js} +1 -1
  2. package/browser/{chunk-VTAI3MOF.js → chunk-3TUBTI3K.js} +1 -1
  3. package/browser/{chunk-QUJXN3NC.js → chunk-4KJQDGDQ.js} +1 -1
  4. package/browser/{chunk-UT7VOSQ7.js → chunk-6LPLMT5G.js} +1 -1
  5. package/browser/{chunk-OONW44HQ.js → chunk-7CSO3M7Q.js} +1 -1
  6. package/browser/chunk-AJAMHOBU.js +1 -0
  7. package/browser/{chunk-HIA7DOSV.js → chunk-BHZ7DCUX.js} +1 -1
  8. package/browser/{chunk-UL3MSBXV.js → chunk-BRQRJTLE.js} +1 -1
  9. package/browser/chunk-BWTU7I6I.js +1 -0
  10. package/browser/chunk-E3YDDL7X.js +1 -0
  11. package/browser/chunk-E7DFLZK7.js +1 -0
  12. package/browser/{chunk-BLT2UGUM.js → chunk-E7XT4AGE.js} +5 -5
  13. package/browser/{chunk-V7RYUISE.js → chunk-ECEWYTGM.js} +1 -1
  14. package/browser/chunk-EYS2HGZ4.js +1 -0
  15. package/browser/chunk-GRJZARL3.js +1 -0
  16. package/browser/chunk-HEBIR2K3.js +1 -0
  17. package/browser/{chunk-H76XRLTE.js → chunk-I6YWE5DW.js} +1 -1
  18. package/browser/{chunk-CPPSTTTC.js → chunk-JRJCV4WT.js} +1 -1
  19. package/browser/{chunk-OSUSTGJD.js → chunk-KTG6TT73.js} +1 -1
  20. package/browser/chunk-KW4N7QC3.js +1 -0
  21. package/browser/{chunk-37Z4RQMS.js → chunk-LJN5BVCL.js} +1 -1
  22. package/browser/chunk-M4B5E7RD.js +1 -0
  23. package/browser/{chunk-IO7Y6AGH.js → chunk-NA7C7FYU.js} +1 -1
  24. package/browser/{chunk-7XZSS2EV.js → chunk-OULUES5R.js} +1 -1
  25. package/browser/chunk-OZXXB3UF.js +1 -0
  26. package/browser/chunk-PIZZDP7D.js +1 -0
  27. package/browser/{chunk-ECF4ASWE.js → chunk-PMFBZ6OG.js} +1 -1
  28. package/browser/{chunk-YHAKQS2P.js → chunk-PW6HGLWK.js} +1 -1
  29. package/browser/chunk-QPBFAKWK.js +1 -0
  30. package/browser/{chunk-RKONB72C.js → chunk-SGCZJMPT.js} +4 -4
  31. package/browser/{chunk-3UWHDPW7.js → chunk-VEHGBGGY.js} +2 -2
  32. package/browser/{chunk-OGI7MX2M.js → chunk-WEEYHBKK.js} +1 -1
  33. package/browser/chunk-WQVPMMUH.js +1 -0
  34. package/browser/{chunk-VDRETD5H.js → chunk-WV7ML4CJ.js} +3 -3
  35. package/browser/{chunk-UVOW2VIJ.js → chunk-XBVYORVG.js} +1 -1
  36. package/browser/chunk-YC254XBK.js +270 -0
  37. package/browser/{chunk-L75REITS.js → chunk-YKWYW7YJ.js} +3 -3
  38. package/browser/{chunk-5BDX24G5.js → chunk-YNF2EAXK.js} +1 -1
  39. package/browser/{chunk-FSOL3ALS.js → chunk-YNYTAOEP.js} +1 -1
  40. package/browser/index.html +2 -2
  41. package/browser/main-GZS32O2T.js +1 -0
  42. package/browser/styles-OTP4QCB4.css +1 -0
  43. package/package.json +1 -1
  44. package/browser/chunk-3USYL5BG.js +0 -1
  45. package/browser/chunk-5DONQZON.js +0 -1
  46. package/browser/chunk-6ID3TABK.js +0 -1
  47. package/browser/chunk-ADN4NBOA.js +0 -1
  48. package/browser/chunk-IYL3P5IQ.js +0 -1
  49. package/browser/chunk-KOR36WEI.js +0 -1
  50. package/browser/chunk-OTANLRGJ.js +0 -1
  51. package/browser/chunk-SEVRZF2U.js +0 -1
  52. package/browser/chunk-SFLR6TA7.js +0 -1
  53. package/browser/chunk-T6BQJAEY.js +0 -1
  54. package/browser/chunk-TDB2ASJ5.js +0 -1
  55. package/browser/chunk-XUO5X2DR.js +0 -1
  56. package/browser/chunk-ZZTT5MET.js +0 -270
  57. package/browser/main-IFKRYXRT.js +0 -1
  58. package/browser/styles-DXY4Y6E7.css +0 -1
@@ -1,2 +1,2 @@
1
- import{g as Te,h as Fe,i as De,j as Le,k as je,l as xe,m as R}from"./chunk-VDRETD5H.js";import{h as Re}from"./chunk-BUA6GPP7.js";import{c as ye,d as Oe,f as Se,l as Ae,m as we,p as Pe,s as Ce,v as ke}from"./chunk-Z7E7NSDY.js";import{a as Ee}from"./chunk-HZF57OLY.js";import{b as Ie}from"./chunk-5URVSSXV.js";import{A as ve,E as be,I as Me,K as I,c as ue,d as de,e as he,l as me,n as _e,t as ge,u as g,v as fe,x as M,y as f}from"./chunk-EF2BOSEH.js";import{$b as C,A as m,B as O,Cb as te,Db as ie,Fb as oe,G as L,Gb as ne,Hb as se,I as j,Ib as ae,Jb as re,Kb as u,Lb as d,Ma as U,Na as q,Pa as Y,R as x,Rb as le,S as _,Sa as G,Sb as ce,Tc as pe,V as B,Wa as z,Xa as Q,Y as V,Ya as X,Z as N,_ as $,aa as S,bb as Z,ca as r,e as h,ea as W,g as v,h as b,jb as P,ka as A,m as y,oa as p,pa as H,t as F,tc as k,uc as c,va as K,vb as J,wb as ee,y as D,ya as w}from"./chunk-B4RKRLIY.js";var Be=class a{http=r(pe);projectState=r(Ie);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/schedulers`}listSchedulers(){return this.http.get(this.getBaseUrl())}getScheduler(n){return this.http.get(`${this.getBaseUrl()}/${n}`)}createScheduler(n){return this.http.post(this.getBaseUrl(),n)}listSchedulersForProject(n){return this.http.get(`/api/projects/${n}/schedulers`)}enableSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/enable`,{})}disableSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/disable`,{})}runSchedulerNowForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/run-now`,{})}deleteSchedulerForProject(n,e){return this.http.delete(`/api/projects/${n}/schedulers/${e}`)}updateSchedulerForProject(n,e,t){return this.http.put(`/api/projects/${n}/schedulers/${e}`,t)}createSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers`,e)}updateScheduler(n,e){return this.http.put(`${this.getBaseUrl()}/${n}`,e)}deleteScheduler(n){return this.http.delete(`${this.getBaseUrl()}/${n}`)}enableScheduler(n){return this.http.post(`${this.getBaseUrl()}/${n}/enable`,{})}disableScheduler(n){return this.http.post(`${this.getBaseUrl()}/${n}/disable`,{})}runSchedulerNow(n){return this.http.post(`${this.getBaseUrl()}/${n}/run-now`,{})}static \u0275fac=function(e){return new(e||a)};static \u0275prov=N({token:a,factory:a.\u0275fac,providedIn:"root"})};var qe=["panel"],Ye=["*"];function Ge(a,n){if(a&1&&(J(0,"div",1,0),se(2),ee()),a&2){let e=n.id,t=oe();ce(t._classList),le("mat-mdc-autocomplete-visible",t.showPanel)("mat-mdc-autocomplete-hidden",!t.showPanel)("mat-autocomplete-panel-animations-enabled",!t._animationsDisabled)("mat-primary",t._color==="primary")("mat-accent",t._color==="accent")("mat-warn",t._color==="warn"),te("id",t.id),P("aria-label",t.ariaLabel||null)("aria-labelledby",t._getPanelAriaLabelledby(e))}}var E=class{source;option;constructor(n,e){this.source=n,this.option=e}},$e=new S("mat-autocomplete-default-options",{providedIn:"root",factory:()=>({autoActiveFirstOption:!1,autoSelectActiveOption:!1,hideSingleSelectionIndicator:!1,requireSelection:!1,hasBackdrop:!1})}),It=(()=>{class a{_changeDetectorRef=r(k);_elementRef=r(w);_defaults=r($e);_animationsDisabled=I();_activeOptionChanges=h.EMPTY;_keyManager;showPanel=!1;get isOpen(){return this._isOpen&&this.showPanel}_isOpen=!1;_latestOpeningTrigger;_setColor(e){this._color=e,this._changeDetectorRef.markForCheck()}_color;template;panel;options;optionGroups;ariaLabel;ariaLabelledby;displayWith=null;autoActiveFirstOption;autoSelectActiveOption;requireSelection;panelWidth;disableRipple=!1;optionSelected=new p;opened=new p;closed=new p;optionActivated=new p;set classList(e){this._classList=e,this._elementRef.nativeElement.className=""}_classList;get hideSingleSelectionIndicator(){return this._hideSingleSelectionIndicator}set hideSingleSelectionIndicator(e){this._hideSingleSelectionIndicator=e,this._syncParentProperties()}_hideSingleSelectionIndicator;_syncParentProperties(){if(this.options)for(let e of this.options)e._changeDetectorRef.markForCheck()}id=r(ge).getId("mat-autocomplete-");inertGroups;constructor(){let e=r(he);this.inertGroups=e?.SAFARI||!1,this.autoActiveFirstOption=!!this._defaults.autoActiveFirstOption,this.autoSelectActiveOption=!!this._defaults.autoSelectActiveOption,this.requireSelection=!!this._defaults.requireSelection,this._hideSingleSelectionIndicator=this._defaults.hideSingleSelectionIndicator??!1}ngAfterContentInit(){this._keyManager=new fe(this.options).withWrap().skipPredicate(this._skipPredicate),this._activeOptionChanges=this._keyManager.change.subscribe(e=>{this.isOpen&&this.optionActivated.emit({source:this,option:this.options.toArray()[e]||null})}),this._setVisibility()}ngOnDestroy(){this._keyManager?.destroy(),this._activeOptionChanges.unsubscribe()}_setScrollTop(e){this.panel&&(this.panel.nativeElement.scrollTop=e)}_getScrollTop(){return this.panel?this.panel.nativeElement.scrollTop:0}_setVisibility(){this.showPanel=!!this.options?.length,this._changeDetectorRef.markForCheck()}_emitSelectEvent(e){let t=new E(this,e);this.optionSelected.emit(t)}_getPanelAriaLabelledby(e){if(this.ariaLabel)return null;let t=e?e+" ":"";return this.ariaLabelledby?t+this.ariaLabelledby:e}_skipPredicate(){return!1}static \u0275fac=function(t){return new(t||a)};static \u0275cmp=z({type:a,selectors:[["mat-autocomplete"]],contentQueries:function(t,i,o){if(t&1&&ae(o,Le,5)(o,Fe,5),t&2){let s;u(s=d())&&(i.options=s),u(s=d())&&(i.optionGroups=s)}},viewQuery:function(t,i){if(t&1&&re(q,7)(qe,5),t&2){let o;u(o=d())&&(i.template=o.first),u(o=d())&&(i.panel=o.first)}},hostAttrs:[1,"mat-mdc-autocomplete"],inputs:{ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],displayWith:"displayWith",autoActiveFirstOption:[2,"autoActiveFirstOption","autoActiveFirstOption",c],autoSelectActiveOption:[2,"autoSelectActiveOption","autoSelectActiveOption",c],requireSelection:[2,"requireSelection","requireSelection",c],panelWidth:"panelWidth",disableRipple:[2,"disableRipple","disableRipple",c],classList:[0,"class","classList"],hideSingleSelectionIndicator:[2,"hideSingleSelectionIndicator","hideSingleSelectionIndicator",c]},outputs:{optionSelected:"optionSelected",opened:"opened",closed:"closed",optionActivated:"optionActivated"},exportAs:["matAutocomplete"],features:[C([{provide:Te,useExisting:a}])],ngContentSelectors:Ye,decls:1,vars:0,consts:[["panel",""],["role","listbox",1,"mat-mdc-autocomplete-panel","mdc-menu-surface","mdc-menu-surface--open",3,"id"]],template:function(t,i){t&1&&(ne(),Z(0,Ge,3,17,"ng-template"))},styles:[`div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:relative;border-radius:var(--mat-autocomplete-container-shape, var(--mat-sys-corner-extra-small));box-shadow:var(--mat-autocomplete-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12));background-color:var(--mat-autocomplete-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-autocomplete-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden,.cdk-overlay-pane:has(>.mat-mdc-autocomplete-hidden){visibility:hidden;pointer-events:none}@keyframes _mat-autocomplete-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}.mat-autocomplete-panel-animations-enabled{animation:_mat-autocomplete-enter 120ms cubic-bezier(0, 0, 0.2, 1)}mat-autocomplete{display:none}
1
+ import{g as Te,h as Fe,i as De,j as Le,k as je,l as xe,m as R}from"./chunk-WV7ML4CJ.js";import{h as Re}from"./chunk-BUA6GPP7.js";import{c as ye,d as Oe,f as Se,l as Ae,m as we,p as Pe,s as Ce,v as ke}from"./chunk-Z7E7NSDY.js";import{a as Ee}from"./chunk-HZF57OLY.js";import{b as Ie}from"./chunk-5URVSSXV.js";import{A as ve,E as be,I as Me,K as I,c as ue,d as de,e as he,l as me,n as _e,t as ge,u as g,v as fe,x as M,y as f}from"./chunk-EF2BOSEH.js";import{$b as C,A as m,B as O,Cb as te,Db as ie,Fb as oe,G as L,Gb as ne,Hb as se,I as j,Ib as ae,Jb as re,Kb as u,Lb as d,Ma as U,Na as q,Pa as Y,R as x,Rb as le,S as _,Sa as G,Sb as ce,Tc as pe,V as B,Wa as z,Xa as Q,Y as V,Ya as X,Z as N,_ as $,aa as S,bb as Z,ca as r,e as h,ea as W,g as v,h as b,jb as P,ka as A,m as y,oa as p,pa as H,t as F,tc as k,uc as c,va as K,vb as J,wb as ee,y as D,ya as w}from"./chunk-B4RKRLIY.js";var Be=class a{http=r(pe);projectState=r(Ie);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/schedulers`}listSchedulers(){return this.http.get(this.getBaseUrl())}getScheduler(n){return this.http.get(`${this.getBaseUrl()}/${n}`)}createScheduler(n){return this.http.post(this.getBaseUrl(),n)}listSchedulersForProject(n){return this.http.get(`/api/projects/${n}/schedulers`)}enableSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/enable`,{})}disableSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/disable`,{})}runSchedulerNowForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers/${e}/run-now`,{})}deleteSchedulerForProject(n,e){return this.http.delete(`/api/projects/${n}/schedulers/${e}`)}updateSchedulerForProject(n,e,t){return this.http.put(`/api/projects/${n}/schedulers/${e}`,t)}createSchedulerForProject(n,e){return this.http.post(`/api/projects/${n}/schedulers`,e)}updateScheduler(n,e){return this.http.put(`${this.getBaseUrl()}/${n}`,e)}deleteScheduler(n){return this.http.delete(`${this.getBaseUrl()}/${n}`)}enableScheduler(n){return this.http.post(`${this.getBaseUrl()}/${n}/enable`,{})}disableScheduler(n){return this.http.post(`${this.getBaseUrl()}/${n}/disable`,{})}runSchedulerNow(n){return this.http.post(`${this.getBaseUrl()}/${n}/run-now`,{})}static \u0275fac=function(e){return new(e||a)};static \u0275prov=N({token:a,factory:a.\u0275fac,providedIn:"root"})};var qe=["panel"],Ye=["*"];function Ge(a,n){if(a&1&&(J(0,"div",1,0),se(2),ee()),a&2){let e=n.id,t=oe();ce(t._classList),le("mat-mdc-autocomplete-visible",t.showPanel)("mat-mdc-autocomplete-hidden",!t.showPanel)("mat-autocomplete-panel-animations-enabled",!t._animationsDisabled)("mat-primary",t._color==="primary")("mat-accent",t._color==="accent")("mat-warn",t._color==="warn"),te("id",t.id),P("aria-label",t.ariaLabel||null)("aria-labelledby",t._getPanelAriaLabelledby(e))}}var E=class{source;option;constructor(n,e){this.source=n,this.option=e}},$e=new S("mat-autocomplete-default-options",{providedIn:"root",factory:()=>({autoActiveFirstOption:!1,autoSelectActiveOption:!1,hideSingleSelectionIndicator:!1,requireSelection:!1,hasBackdrop:!1})}),It=(()=>{class a{_changeDetectorRef=r(k);_elementRef=r(w);_defaults=r($e);_animationsDisabled=I();_activeOptionChanges=h.EMPTY;_keyManager;showPanel=!1;get isOpen(){return this._isOpen&&this.showPanel}_isOpen=!1;_latestOpeningTrigger;_setColor(e){this._color=e,this._changeDetectorRef.markForCheck()}_color;template;panel;options;optionGroups;ariaLabel;ariaLabelledby;displayWith=null;autoActiveFirstOption;autoSelectActiveOption;requireSelection;panelWidth;disableRipple=!1;optionSelected=new p;opened=new p;closed=new p;optionActivated=new p;set classList(e){this._classList=e,this._elementRef.nativeElement.className=""}_classList;get hideSingleSelectionIndicator(){return this._hideSingleSelectionIndicator}set hideSingleSelectionIndicator(e){this._hideSingleSelectionIndicator=e,this._syncParentProperties()}_hideSingleSelectionIndicator;_syncParentProperties(){if(this.options)for(let e of this.options)e._changeDetectorRef.markForCheck()}id=r(ge).getId("mat-autocomplete-");inertGroups;constructor(){let e=r(he);this.inertGroups=e?.SAFARI||!1,this.autoActiveFirstOption=!!this._defaults.autoActiveFirstOption,this.autoSelectActiveOption=!!this._defaults.autoSelectActiveOption,this.requireSelection=!!this._defaults.requireSelection,this._hideSingleSelectionIndicator=this._defaults.hideSingleSelectionIndicator??!1}ngAfterContentInit(){this._keyManager=new fe(this.options).withWrap().skipPredicate(this._skipPredicate),this._activeOptionChanges=this._keyManager.change.subscribe(e=>{this.isOpen&&this.optionActivated.emit({source:this,option:this.options.toArray()[e]||null})}),this._setVisibility()}ngOnDestroy(){this._keyManager?.destroy(),this._activeOptionChanges.unsubscribe()}_setScrollTop(e){this.panel&&(this.panel.nativeElement.scrollTop=e)}_getScrollTop(){return this.panel?this.panel.nativeElement.scrollTop:0}_setVisibility(){this.showPanel=!!this.options?.length,this._changeDetectorRef.markForCheck()}_emitSelectEvent(e){let t=new E(this,e);this.optionSelected.emit(t)}_getPanelAriaLabelledby(e){if(this.ariaLabel)return null;let t=e?e+" ":"";return this.ariaLabelledby?t+this.ariaLabelledby:e}_skipPredicate(){return!1}static \u0275fac=function(t){return new(t||a)};static \u0275cmp=z({type:a,selectors:[["mat-autocomplete"]],contentQueries:function(t,i,o){if(t&1&&ae(o,Le,5)(o,Fe,5),t&2){let s;u(s=d())&&(i.options=s),u(s=d())&&(i.optionGroups=s)}},viewQuery:function(t,i){if(t&1&&re(q,7)(qe,5),t&2){let o;u(o=d())&&(i.template=o.first),u(o=d())&&(i.panel=o.first)}},hostAttrs:[1,"mat-mdc-autocomplete"],inputs:{ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],displayWith:"displayWith",autoActiveFirstOption:[2,"autoActiveFirstOption","autoActiveFirstOption",c],autoSelectActiveOption:[2,"autoSelectActiveOption","autoSelectActiveOption",c],requireSelection:[2,"requireSelection","requireSelection",c],panelWidth:"panelWidth",disableRipple:[2,"disableRipple","disableRipple",c],classList:[0,"class","classList"],hideSingleSelectionIndicator:[2,"hideSingleSelectionIndicator","hideSingleSelectionIndicator",c]},outputs:{optionSelected:"optionSelected",opened:"opened",closed:"closed",optionActivated:"optionActivated"},exportAs:["matAutocomplete"],features:[C([{provide:Te,useExisting:a}])],ngContentSelectors:Ye,decls:1,vars:0,consts:[["panel",""],["role","listbox",1,"mat-mdc-autocomplete-panel","mdc-menu-surface","mdc-menu-surface--open",3,"id"]],template:function(t,i){t&1&&(ne(),Z(0,Ge,3,17,"ng-template"))},styles:[`div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:relative;border-radius:var(--mat-autocomplete-container-shape, var(--mat-sys-corner-extra-small));box-shadow:var(--mat-autocomplete-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12));background-color:var(--mat-autocomplete-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-autocomplete-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden,.cdk-overlay-pane:has(>.mat-mdc-autocomplete-hidden){visibility:hidden;pointer-events:none}@keyframes _mat-autocomplete-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}.mat-autocomplete-panel-animations-enabled{animation:_mat-autocomplete-enter 120ms cubic-bezier(0, 0, 0.2, 1)}mat-autocomplete{display:none}
2
2
  `],encapsulation:2,changeDetection:0})}return a})();var ze={provide:Ee,useExisting:V(()=>Xe),multi:!0};var Qe=new S("mat-autocomplete-scroll-strategy",{providedIn:"root",factory:()=>{let a=r(A);return()=>Ae(a)}}),Xe=(()=>{class a{_environmentInjector=r(W);_element=r(w);_injector=r(A);_viewContainerRef=r(G);_zone=r(H);_changeDetectorRef=r(k);_dir=r(ve,{optional:!0});_formField=r(Re,{optional:!0,host:!0});_viewportRuler=r(ye);_scrollStrategy=r(Qe);_renderer=r(Y);_animationsDisabled=I();_defaults=r($e,{optional:!0});_overlayRef=null;_portal;_componentDestroyed=!1;_initialized=new b;_keydownSubscription;_outsideClickSubscription;_cleanupWindowBlur;_previousValue=null;_valueOnAttach=null;_valueOnLastKeydown=null;_positionStrategy;_manuallyFloatingLabel=!1;_closingActionsSubscription;_viewportSubscription=h.EMPTY;_breakpointObserver=r(_e);_handsetLandscapeSubscription=h.EMPTY;_canOpenOnNextFocus=!0;_valueBeforeAutoSelection;_pendingAutoselectedOption=null;_closeKeyEventStream=new b;_overlayPanelClass=me(this._defaults?.overlayPanelClass||[]);_windowBlurHandler=()=>{this._canOpenOnNextFocus=this.panelOpen||!this._hasFocus()};_onChange=()=>{};_onTouched=()=>{};autocomplete;position="auto";connectedTo;autocompleteAttribute="off";autocompleteDisabled=!1;constructor(){}_aboveClass="mat-mdc-autocomplete-panel-above";ngAfterViewInit(){this._initialized.next(),this._initialized.complete(),this._cleanupWindowBlur=this._renderer.listen("window","blur",this._windowBlurHandler)}ngOnChanges(e){e.position&&this._positionStrategy&&(this._setStrategyPositions(this._positionStrategy),this.panelOpen&&this._overlayRef.updatePosition())}ngOnDestroy(){this._cleanupWindowBlur?.(),this._handsetLandscapeSubscription.unsubscribe(),this._viewportSubscription.unsubscribe(),this._componentDestroyed=!0,this._destroyPanel(),this._closeKeyEventStream.complete(),this._clearFromModal()}get panelOpen(){return this._overlayAttached&&this.autocomplete.showPanel}_overlayAttached=!1;openPanel(){this._openPanelInternal()}closePanel(){this._resetLabel(),this._overlayAttached&&(this.panelOpen&&this._zone.run(()=>{this.autocomplete.closed.emit()}),this.autocomplete._latestOpeningTrigger===this&&(this.autocomplete._isOpen=!1,this.autocomplete._latestOpeningTrigger=null),this._overlayAttached=!1,this._pendingAutoselectedOption=null,this._overlayRef&&this._overlayRef.hasAttached()&&(this._overlayRef.detach(),this._closingActionsSubscription.unsubscribe()),this._updatePanelState(),this._componentDestroyed||this._changeDetectorRef.detectChanges(),this._trackedModal&&f(this._trackedModal,"aria-owns",this.autocomplete.id))}updatePosition(){this._overlayAttached&&this._overlayRef.updatePosition()}get panelClosingActions(){return m(this.optionSelections,this.autocomplete._keyManager.tabOut.pipe(O(()=>this._overlayAttached)),this._closeKeyEventStream,this._getOutsideClickStream(),this._overlayRef?this._overlayRef.detachments().pipe(O(()=>this._overlayAttached)):y()).pipe(F(e=>e instanceof De?e:null))}optionSelections=D(()=>{let e=this.autocomplete?this.autocomplete.options:null;return e?e.changes.pipe(x(e),_(()=>m(...e.map(t=>t.onSelectionChange)))):this._initialized.pipe(_(()=>this.optionSelections))});get activeOption(){return this.autocomplete&&this.autocomplete._keyManager?this.autocomplete._keyManager.activeItem:null}_getOutsideClickStream(){return new v(e=>{let t=o=>{let s=de(o),l=this._formField?this._formField.getConnectedOverlayOrigin().nativeElement:null,T=this.connectedTo?this.connectedTo.elementRef.nativeElement:null;this._overlayAttached&&s!==this._element.nativeElement&&!this._hasFocus()&&(!l||!l.contains(s))&&(!T||!T.contains(s))&&this._overlayRef&&!this._overlayRef.overlayElement.contains(s)&&e.next(o)},i=[this._renderer.listen("document","click",t),this._renderer.listen("document","auxclick",t),this._renderer.listen("document","touchend",t)];return()=>{i.forEach(o=>o())}})}writeValue(e){Promise.resolve(null).then(()=>this._assignOptionValue(e))}registerOnChange(e){this._onChange=e}registerOnTouched(e){this._onTouched=e}setDisabledState(e){this._element.nativeElement.disabled=e}_handleKeydown(e){let t=e,i=t.keyCode,o=g(t);if(i===27&&!o&&t.preventDefault(),this._valueOnLastKeydown=this._element.nativeElement.value,this.activeOption&&i===13&&this.panelOpen&&!o)this.activeOption._selectViaInteraction(),this._resetActiveItem(),t.preventDefault();else if(this.autocomplete){let s=this.autocomplete._keyManager.activeItem,l=i===38||i===40;i===9||l&&!o&&this.panelOpen?this.autocomplete._keyManager.onKeydown(t):l&&this._canOpen()&&this._openPanelInternal(this._valueOnLastKeydown),(l||this.autocomplete._keyManager.activeItem!==s)&&(this._scrollToOption(this.autocomplete._keyManager.activeItemIndex||0),this.autocomplete.autoSelectActiveOption&&this.activeOption&&(this._pendingAutoselectedOption||(this._valueBeforeAutoSelection=this._valueOnLastKeydown),this._pendingAutoselectedOption=this.activeOption,this._assignOptionValue(this.activeOption.value)))}}_handleInput(e){let t=e.target,i=t.value;if(t.type==="number"&&(i=i==""?null:parseFloat(i)),this._previousValue!==i){if(this._previousValue=i,this._pendingAutoselectedOption=null,(!this.autocomplete||!this.autocomplete.requireSelection)&&this._onChange(i),!i)this._clearPreviousSelectedOption(null,!1);else if(this.panelOpen&&!this.autocomplete.requireSelection){let o=this.autocomplete.options?.find(s=>s.selected);if(o){let s=this._getDisplayValue(o.value);i!==s&&o.deselect(!1)}}if(this._canOpen()&&this._hasFocus()){let o=this._valueOnLastKeydown??this._element.nativeElement.value;this._valueOnLastKeydown=null,this._openPanelInternal(o)}}}_handleFocus(){this._canOpenOnNextFocus?this._canOpen()&&(this._previousValue=this._element.nativeElement.value,this._attachOverlay(this._previousValue),this._floatLabel(!0)):this._canOpenOnNextFocus=!0}_handleClick(){this._canOpen()&&!this.panelOpen&&this._openPanelInternal()}_hasFocus(){return ue()===this._element.nativeElement}_floatLabel(e=!1){this._formField&&this._formField.floatLabel==="auto"&&(e?this._formField._animateAndLockLabel():this._formField.floatLabel="always",this._manuallyFloatingLabel=!0)}_resetLabel(){this._manuallyFloatingLabel&&(this._formField&&(this._formField.floatLabel="auto"),this._manuallyFloatingLabel=!1)}_subscribeToClosingActions(){let e=new v(i=>{U(()=>{i.next()},{injector:this._environmentInjector})}),t=this.autocomplete.options?.changes.pipe(B(()=>this._positionStrategy.reapplyLastPosition()),j(0))??y();return m(e,t).pipe(_(()=>this._zone.run(()=>{let i=this.panelOpen;return this._resetActiveItem(),this._updatePanelState(),this._changeDetectorRef.detectChanges(),this.panelOpen&&this._overlayRef.updatePosition(),i!==this.panelOpen&&(this.panelOpen?this._emitOpened():this.autocomplete.closed.emit()),this.panelClosingActions})),L(1)).subscribe(i=>this._setValueAndClose(i))}_emitOpened(){this.autocomplete.opened.emit()}_destroyPanel(){this._overlayRef&&(this.closePanel(),this._overlayRef.dispose(),this._overlayRef=null)}_getDisplayValue(e){let t=this.autocomplete;return t&&t.displayWith?t.displayWith(e):e}_assignOptionValue(e){let t=this._getDisplayValue(e);e==null&&this._clearPreviousSelectedOption(null,!1),this._updateNativeInputValue(t??"")}_updateNativeInputValue(e){this._formField?this._formField._control.value=e:this._element.nativeElement.value=e,this._previousValue=e}_setValueAndClose(e){let t=this.autocomplete,i=e?e.source:this._pendingAutoselectedOption;i?(this._clearPreviousSelectedOption(i),this._assignOptionValue(i.value),this._onChange(i.value),t._emitSelectEvent(i),this._element.nativeElement.focus()):t.requireSelection&&this._element.nativeElement.value!==this._valueOnAttach&&(this._clearPreviousSelectedOption(null),this._assignOptionValue(null),this._onChange(null)),this.closePanel()}_clearPreviousSelectedOption(e,t){this.autocomplete?.options?.forEach(i=>{i!==e&&i.selected&&i.deselect(t)})}_openPanelInternal(e=this._element.nativeElement.value){if(this._attachOverlay(e),this._floatLabel(),this._trackedModal){let t=this.autocomplete.id;M(this._trackedModal,"aria-owns",t)}}_attachOverlay(e){if(!this.autocomplete)return;let t=this._overlayRef;t?(this._positionStrategy.setOrigin(this._getConnectedElement()),t.updateSize({width:this._getPanelWidth()})):(this._portal=new Se(this.autocomplete.template,this._viewContainerRef,{id:this._formField?.getLabelId()}),t=Ce(this._injector,this._getOverlayConfig()),this._overlayRef=t,this._viewportSubscription=this._viewportRuler.change().subscribe(()=>{this.panelOpen&&t&&t.updateSize({width:this._getPanelWidth()})}),this._handsetLandscapeSubscription=this._breakpointObserver.observe(Me.HandsetLandscape).subscribe(o=>{o.matches?this._positionStrategy.withFlexibleDimensions(!0).withGrowAfterOpen(!0).withViewportMargin(8):this._positionStrategy.withFlexibleDimensions(!1).withGrowAfterOpen(!1).withViewportMargin(0)})),t&&!t.hasAttached()&&(t.attach(this._portal),this._valueOnAttach=e,this._valueOnLastKeydown=null,this._closingActionsSubscription=this._subscribeToClosingActions());let i=this.panelOpen;this.autocomplete._isOpen=this._overlayAttached=!0,this.autocomplete._latestOpeningTrigger=this,this.autocomplete._setColor(this._formField?.color),this._updatePanelState(),this._applyModalPanelOwnership(),this.panelOpen&&i!==this.panelOpen&&this._emitOpened()}_handlePanelKeydown=e=>{(e.keyCode===27&&!g(e)||e.keyCode===38&&g(e,"altKey"))&&(this._pendingAutoselectedOption&&(this._updateNativeInputValue(this._valueBeforeAutoSelection??""),this._pendingAutoselectedOption=null),this._closeKeyEventStream.next(),this._resetActiveItem(),e.stopPropagation(),e.preventDefault())};_updatePanelState(){if(this.autocomplete._setVisibility(),this.panelOpen){let e=this._overlayRef;this._keydownSubscription||(this._keydownSubscription=e.keydownEvents().subscribe(this._handlePanelKeydown)),this._outsideClickSubscription||(this._outsideClickSubscription=e.outsidePointerEvents().subscribe())}else this._keydownSubscription?.unsubscribe(),this._outsideClickSubscription?.unsubscribe(),this._keydownSubscription=this._outsideClickSubscription=void 0}_getOverlayConfig(){return new we({positionStrategy:this._getOverlayPosition(),scrollStrategy:this._scrollStrategy(),width:this._getPanelWidth(),direction:this._dir??void 0,hasBackdrop:this._defaults?.hasBackdrop,backdropClass:this._defaults?.backdropClass||"cdk-overlay-transparent-backdrop",panelClass:this._overlayPanelClass,disableAnimations:this._animationsDisabled})}_getOverlayPosition(){let e=Pe(this._injector,this._getConnectedElement()).withFlexibleDimensions(!1).withPush(!1).withPopoverLocation("inline");return this._setStrategyPositions(e),this._positionStrategy=e,e}_setStrategyPositions(e){let t=[{originX:"start",originY:"bottom",overlayX:"start",overlayY:"top"},{originX:"end",originY:"bottom",overlayX:"end",overlayY:"top"}],i=this._aboveClass,o=[{originX:"start",originY:"top",overlayX:"start",overlayY:"bottom",panelClass:i},{originX:"end",originY:"top",overlayX:"end",overlayY:"bottom",panelClass:i}],s;this.position==="above"?s=o:this.position==="below"?s=t:s=[...t,...o],e.withPositions(s)}_getConnectedElement(){return this.connectedTo?this.connectedTo.elementRef:this._formField?this._formField.getConnectedOverlayOrigin():this._element}_getPanelWidth(){return this.autocomplete.panelWidth||this._getHostWidth()}_getHostWidth(){return this._getConnectedElement().nativeElement.getBoundingClientRect().width}_resetActiveItem(){let e=this.autocomplete;if(e.autoActiveFirstOption){let t=-1;for(let i=0;i<e.options.length;i++)if(!e.options.get(i).disabled){t=i;break}e._keyManager.setActiveItem(t)}else e._keyManager.setActiveItem(-1)}_canOpen(){let e=this._element.nativeElement;return!e.readOnly&&!e.disabled&&!this.autocompleteDisabled}_scrollToOption(e){let t=this.autocomplete,i=je(e,t.options,t.optionGroups);if(e===0&&i===1)t._setScrollTop(0);else if(t.panel){let o=t.options.toArray()[e];if(o){let s=o._getHostElement(),l=xe(s.offsetTop,s.offsetHeight,t._getScrollTop(),t.panel.nativeElement.offsetHeight);t._setScrollTop(l)}}}_trackedModal=null;_applyModalPanelOwnership(){let e=this._element.nativeElement.closest('body > .cdk-overlay-container [aria-modal="true"]');if(!e)return;let t=this.autocomplete.id;this._trackedModal&&f(this._trackedModal,"aria-owns",t),M(e,"aria-owns",t),this._trackedModal=e}_clearFromModal(){if(this._trackedModal){let e=this.autocomplete.id;f(this._trackedModal,"aria-owns",e),this._trackedModal=null}}static \u0275fac=function(t){return new(t||a)};static \u0275dir=X({type:a,selectors:[["input","matAutocomplete",""],["textarea","matAutocomplete",""]],hostAttrs:[1,"mat-mdc-autocomplete-trigger"],hostVars:7,hostBindings:function(t,i){t&1&&ie("focusin",function(){return i._handleFocus()})("blur",function(){return i._onTouched()})("input",function(s){return i._handleInput(s)})("keydown",function(s){return i._handleKeydown(s)})("click",function(){return i._handleClick()}),t&2&&P("autocomplete",i.autocompleteAttribute)("role",i.autocompleteDisabled?null:"combobox")("aria-autocomplete",i.autocompleteDisabled?null:"list")("aria-activedescendant",i.panelOpen&&i.activeOption?i.activeOption.id:null)("aria-expanded",i.autocompleteDisabled?null:i.panelOpen.toString())("aria-controls",i.autocompleteDisabled||!i.panelOpen||i.autocomplete==null?null:i.autocomplete.id)("aria-haspopup",i.autocompleteDisabled?null:"listbox")},inputs:{autocomplete:[0,"matAutocomplete","autocomplete"],position:[0,"matAutocompletePosition","position"],connectedTo:[0,"matAutocompleteConnectedTo","connectedTo"],autocompleteAttribute:[0,"autocomplete","autocompleteAttribute"],autocompleteDisabled:[2,"matAutocompleteDisabled","autocompleteDisabled",c]},exportAs:["matAutocompleteTrigger"],features:[C([ze]),K]})}return a})(),Rt=(()=>{class a{static \u0275fac=function(t){return new(t||a)};static \u0275mod=Q({type:a});static \u0275inj=$({imports:[ke,R,Oe,R,be]})}return a})();export{It as a,Xe as b,Rt as c,Be as d};
@@ -1 +1 @@
1
- import{a as E}from"./chunk-3UWHDPW7.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-BLT2UGUM.js";import"./chunk-MUX7LGIM.js";import{g as I}from"./chunk-RKONB72C.js";import"./chunk-FPNEFWYN.js";import"./chunk-CPPSTTTC.js";import{a as L,w as b}from"./chunk-ZZTT5MET.js";import"./chunk-SLBKHVIO.js";import"./chunk-XYYLNQXO.js";import{b as $,d as H}from"./chunk-4GVABYH4.js";import"./chunk-CBYR4M6L.js";import"./chunk-MOG6OBSN.js";import"./chunk-YNZD2HBV.js";import"./chunk-VDRETD5H.js";import"./chunk-BUA6GPP7.js";import"./chunk-V363EHJE.js";import"./chunk-6CNI4FAD.js";import"./chunk-Z7E7NSDY.js";import"./chunk-ZEMOOOQR.js";import"./chunk-HZF57OLY.js";import"./chunk-5URVSSXV.js";import"./chunk-EF2BOSEH.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-B4RKRLIY.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-VEHGBGGY.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-E7XT4AGE.js";import"./chunk-MUX7LGIM.js";import{g as I}from"./chunk-SGCZJMPT.js";import"./chunk-FPNEFWYN.js";import"./chunk-JRJCV4WT.js";import{a as L,d as b}from"./chunk-YC254XBK.js";import"./chunk-SLBKHVIO.js";import"./chunk-XYYLNQXO.js";import{b as $,d as H}from"./chunk-4GVABYH4.js";import"./chunk-CBYR4M6L.js";import"./chunk-MOG6OBSN.js";import"./chunk-YNZD2HBV.js";import"./chunk-WV7ML4CJ.js";import"./chunk-BUA6GPP7.js";import"./chunk-6CNI4FAD.js";import"./chunk-Z7E7NSDY.js";import"./chunk-V363EHJE.js";import"./chunk-ZEMOOOQR.js";import"./chunk-HZF57OLY.js";import"./chunk-5URVSSXV.js";import"./chunk-EF2BOSEH.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-B4RKRLIY.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 ke}from"./chunk-V363EHJE.js";import{a as _e,b as he}from"./chunk-ZEMOOOQR.js";import{E as Te,c as fe,g as be,m as ve,x as ye,y as xe,z as Ce}from"./chunk-HZF57OLY.js";import{O as ge,S as ue}from"./chunk-EF2BOSEH.js";import{Bb as se,Db as P,Dc as ce,Eb as de,Fb as g,Ka as s,Kc as D,Qb as me,Sc as Z,Tb as a,Tc as pe,Ub as m,Vb as E,Wa as L,Z as H,Za as Q,a as R,b as A,ca as M,dc as x,fc as w,ga as $,gc as G,ha as V,ia as O,ja as ae,jb as b,kb as re,kc as p,lb as v,ma as ie,mb as y,pb as I,qb as N,rb as S,sb as r,ta as h,tb as l,ub as le,vb as c,wb as _,xb as T,z as oe}from"./chunk-B4RKRLIY.js";var Fe=(o,t)=>t.date,Re=(o,t)=>t.x,Ae=(o,t)=>t.label;function He(o,t){o&1&&(c(0,"div",0),a(1,"No daily data points for this period."),_())}function $e(o,t){if(o&1&&(O(),T(0,"rect",18)),o&2){let e=g().$implicit,n=g(2);b("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH)}}function Ve(o,t){if(o&1&&(O(),T(0,"rect",19)(1,"rect",20)),o&2){let e=g().$implicit,n=g(2);b("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),s(),b("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0)}}function Le(o,t){if(o&1){let e=se();O(),c(0,"g",15),de("mouseenter",function(i){let d=$(e).$implicit,u=g(2);return V(u.showTooltip(i,d.point))})("mousemove",function(i){let d=$(e).$implicit,u=g(2);return V(u.showTooltip(i,d.point))})("mouseleave",function(){$(e);let i=g(2);return V(i.hideTooltip())}),T(1,"rect",16)(2,"rect",17),v(3,$e,1,4,":svg:rect",18)(4,Ve,2,8),_()}if(o&2){let e=t.$implicit,n=g(2);b("transform","translate("+e.xGroup+",0)"),s(),b("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),s(),b("y",n.yBase-e.costH)("width",e.w)("height",e.costH),s(),y(e.tokensStubH!==null?3:4)}}function Ge(o,t){if(o&1&&(O(),c(0,"text",5),a(1),_()),o&2){let e=t.$implicit,n=g(2);b("x",e.x)("y",n.yAxis),s(),m(e.label)}}function Ye(o,t){if(o&1&&(c(0,"div",24),a(1),_(),c(2,"div",25),a(3),_()),o&2){let e=t.$implicit;s(),m(e.label),s(2),m(e.value)}}function We(o,t){if(o&1&&(c(0,"div",21)(1,"div",22),a(2),_(),c(3,"div",23),I(4,Ye,4,2,null,null,Ae),_()()),o&2){let e=g(2);me("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),s(2),m(e.tooltip().data.date),s(2),N(e.tooltipLines())}}function je(o,t){if(o&1&&(c(0,"div",8)(1,"span",10),a(2),_()()),o&2){let e=g(2);s(2),m(e.tokenCoverageLabel())}}function ze(o,t){if(o&1&&(c(0,"div",1),O(),c(1,"svg",2),T(2,"line",3)(3,"line",3),I(4,Le,5,8,":svg:g",4,Fe),I(6,Ge,2,3,":svg:text",5,Re),_(),v(8,We,6,5,"div",6),ae(),c(9,"div",7)(10,"div",8),T(11,"span",9),c(12,"span",10),a(13,"Cost (per day)"),_(),c(14,"span",11),a(15),_()(),c(16,"div",8),T(17,"span",12),c(18,"span",10),a(19,"Prompt tokens"),_()(),c(20,"div",8),T(21,"span",13),c(22,"span",10),a(23,"Completion tokens"),_()(),c(24,"div",8),T(25,"span",14),c(26,"span",10),a(27,"Tokens missing"),_()(),c(28,"div",8)(29,"span",10),a(30,"Tokens scale"),_(),c(31,"span",11),a(32),_()(),v(33,je,3,1,"div",8),_()()),o&2){let e=g();s(),b("viewBox",e.viewBox),s(),b("y1",e.yTop)("x2",720)("y2",e.yTop),s(),b("y1",e.yBase)("x2",720)("y2",e.yBase),s(),N(e.bars()),s(2),N(e.axisLabels()),s(2),y(e.tooltip().visible&&e.tooltip().data?8:-1),s(7),E("max ",e.maxCostLabel()),s(17),E("max ",e.maxTokensLabel()),s(),y(e.tokenCoverageLabel()?33:-1)}}var Y=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=p(()=>(this.points??[]).filter(t=>!!t.date));maxCost=p(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=p(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=p(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=p(()=>"$"+(new D("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=p(()=>new D("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=h({visible:!1,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return{date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ee=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:!0,x:F,y:ee,data:this.toTooltipData(e)})}hideTooltip(){this.tooltip.update(t=>A(R({},t),{visible:!1}))}formatTokens(t){return t===null?"\u2014":new D("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return"$"+(new D("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=p(()=>{let t=this.tooltip(),e=t.data;return!t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=p(()=>{let t=this.safePoints(),e=t.length;if(e===0)return[];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ee=(C.cost??0)/f*this.innerH,te=C.promptTokens,ne=C.completionTokens,K=te!==null||ne!==null,Oe=te??0,Ie=ne??0,Ne=K?Oe/k*this.innerH:null,Ue=K?Ie/k*this.innerH:null;return{date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ee,xTokens:F+u+this.barGap,promptH:Ne,completionH:Ue,tokensStubH:K?null:U}})});axisLabels=p(()=>{let t=this.safePoints(),e=t.length;if(e===0)return[];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return{x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=L({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&v(0,He,2,0,"div",0)(1,ze,34,11,"div",1),e&2&&y(n.safePoints().length===0?0:1)},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"],changeDetection:0})};var j=class o{http=M(pe);getTokenUsage(t){let e=new Z;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new Z;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=H({token:o,factory:o.\u0275fac,providedIn:"root"})};function Me(o){return`${o}`.padStart(2,"0")}function Se(o){return`${o.getUTCFullYear()}-${Me(o.getUTCMonth()+1)}-${Me(o.getUTCDate())}`}function Xe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Je(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var z=class o{api=M(j);destroyRef=M(ie);defaultFrom=Se(Xe());defaultTo=Se(Je());draftFilters=h({from:this.defaultFrom,to:this.defaultTo});appliedFilters=h({from:this.defaultFrom,to:this.defaultTo});loading=h(!1);error=h(null);aggregation=h(null);seriesResponse=h(null);series=h(null);tokenDataPartial=h(!1);aggregationByModelId=h(null);seriesByModelId=h(null);init(){this.reload()}setDraftFrom(t){this.draftFilters.update(e=>A(R({},e),{from:t}))}setDraftTo(t){this.draftFilters.update(e=>A(R({},e),{to:t}))}clearDraftFrom(){this.setDraftFrom(null)}clearDraftTo(){this.setDraftTo(null)}apply(){this.appliedFilters.set(this.draftFilters()),this.reload()}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0})}return[...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0})}return[...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(!0),this.error.set(null),oe({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(ke(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(!1)},error:n=>{this.loading.set(!1),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(!1),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage")}})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=H({token:o,factory:o.\u0275fac,providedIn:"root"})};var X=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},Pe=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:X,set:X,deleteProperty:X,has:X}),J=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(Pe,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=Q({name:"call",type:o,pure:!0})},q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(Pe,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=Q({name:"apply",type:o,pure:!0})};function qe(o,t){o&1&&(r(0,"div",23),a(1," Partial data \u2014 token counts may not cover the full period "),l())}function Ke(o,t){o&1&&(r(0,"div",24),a(1," No token data collected for this period "),l())}function Qe(o,t){if(o&1&&(r(0,"div",19)(1,"div",20)(2,"div",21),a(3,"Total tokens"),l(),r(4,"div",22),a(5),x(6,"call"),l()(),r(7,"div",20)(8,"div",21),a(9,"Total calls"),l(),r(10,"div",22),a(11),l()(),r(12,"div",20)(13,"div",21),a(14,"Total cost"),l(),r(15,"div",22),a(16),x(17,"apply"),l()()(),v(18,qe,2,0,"div",23),v(19,Ke,2,0,"div",24)),o&2){let e=g();s(5),m(w(6,5,e.totalRow().totalTokens,e.formatTokenValue)),s(6),m(e.totalRow().callCount),s(5),m(G(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),s(2),y(e.isPartialPeriod()?18:-1),s(),y(e.isMissingPeriod()?19:-1)}}function Ze(o,t){o&1&&(r(0,"div",16)(1,"div",25),a(2,"Loading token usage\u2026"),l()())}function et(o,t){if(o&1&&(r(0,"div",17)(1,"div",26),a(2,"Failed to load"),l(),r(3,"div",25),a(4),l()()),o&2){let e=g();s(4),m(e.state.error())}}function tt(o,t){o&1&&(r(0,"div",16)(1,"div",26),a(2,"No data"),l(),r(3,"div",25),a(4,"No token usage recorded yet for this period."),l()())}function nt(o,t){if(o&1&&(r(0,"div",32)(1,"div",29),a(2),l(),r(3,"div",29),a(4),l(),r(5,"div",29),a(6),l(),r(7,"div",30),a(8),x(9,"call"),l(),r(10,"div",30),a(11),x(12,"call"),l(),r(13,"div",30),a(14),x(15,"call"),l(),r(16,"div",30),a(17),l(),r(18,"div",30),a(19),x(20,"apply"),l()()),o&2){let e=t.$implicit,n=g(2);s(2),m(e.agentName),s(2),m(e.providerName),s(2),m(e.modelId),s(2),m(w(9,8,e.promptTokens,n.formatTokenValue)),s(3),m(w(12,11,e.completionTokens,n.formatTokenValue)),s(3),m(w(15,14,e.totalTokens,n.formatTokenValue)),s(3),m(e.callCount),s(2),E(" ",G(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ")}}function ot(o,t){if(o&1&&(r(0,"div",33)(1,"div",29),a(2),l(),r(3,"div",29),a(4),l(),r(5,"div",29),a(6),l(),r(7,"div",30),a(8),x(9,"call"),l(),r(10,"div",30),a(11),x(12,"call"),l(),r(13,"div",30),a(14),x(15,"call"),l(),r(16,"div",30),a(17),l(),r(18,"div",30),a(19),x(20,"apply"),l()()),o&2){let e=g(2);s(2),m(e.totalRow().agentName),s(2),m(e.totalRow().providerName),s(2),m(e.totalRow().modelId),s(2),m(w(9,8,e.totalRow().promptTokens,e.formatTokenValue)),s(3),E(" ",w(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),s(3),m(w(15,14,e.totalRow().totalTokens,e.formatTokenValue)),s(3),m(e.totalRow().callCount),s(2),E(" ",G(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ")}}function at(o,t){if(o&1&&(r(0,"div",18)(1,"section",16)(2,"div",26),a(3,"Summary"),l(),r(4,"div",27)(5,"div",28)(6,"div",29),a(7,"agentName"),l(),r(8,"div",29),a(9,"providerName"),l(),r(10,"div",29),a(11,"modelId"),l(),r(12,"div",30),a(13,"promptTokens"),l(),r(14,"div",30),a(15,"completionTokens"),l(),r(16,"div",30),a(17,"totalTokens"),l(),r(18,"div",30),a(19,"callCount"),l(),r(20,"div",30),a(21,"cost"),l()(),r(22,"div",31),I(23,nt,21,21,"div",32,re().trackRow,!0),v(25,ot,21,21,"div",33),l()()(),r(26,"section",16)(27,"div",26),a(28,"Daily series"),l(),le(29,"app-daily-series-chart",34),l()()),o&2){let e=g();s(23),N(e.rows()),s(2),y(e.totalRow()?25:-1),s(4),S("points",e.chartPoints())}}var we="\u2014",De=class o{location=M(ce);state=M(z);view=h("byModel");rowsByAgent=p(()=>this.state.aggregation()?.models??[]);totalRow=p(()=>this.state.aggregation()?.total??null);rowsByModel=p(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=p(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=p(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=p(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=p(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=p(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:!1});ngOnInit(){this.state.init()}onFromChange(t){this.state.setDraftFrom(t||null)}onToChange(t){this.state.setDraftTo(t||null)}clearFrom(){this.state.clearDraftFrom()}clearTo(){this.state.clearDraftTo()}apply(){this.state.apply()}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else{let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0)}}return[...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return`${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=p(()=>{if(this.state.loading())return!1;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):!1});isPartialPeriod=p(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back()}formatTokenValue(t){return t===null?we:new D("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?we:"$"+(new D("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=L({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(r(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),P("click",function(){return n.navigateBack()}),r(4,"mat-icon"),a(5,"chevron_left"),l()(),r(6,"div")(7,"h1",4),a(8,"Token Usage"),l(),r(9,"p",5),a(10,"Track prompt and completion token usage by agent and model."),l()()(),r(11,"div",6)(12,"label",7)(13,"span",8),a(14,"From"),l(),r(15,"div",9)(16,"input",10),P("ngModelChange",function(d){return n.onFromChange(d)}),l(),r(17,"button",11),P("click",function(){return n.clearFrom()}),a(18," Clear "),l()()(),r(19,"label",7)(20,"span",8),a(21,"To"),l(),r(22,"div",9)(23,"input",10),P("ngModelChange",function(d){return n.onToChange(d)}),l(),r(24,"button",11),P("click",function(){return n.clearTo()}),a(25," Clear "),l()()(),r(26,"label",7)(27,"span",8),a(28,"View"),l(),r(29,"select",12),P("ngModelChange",function(d){return n.view.set(d)}),r(30,"option",13),a(31,"By model"),l(),r(32,"option",14),a(33,"By agent"),l()()(),r(34,"button",15),P("click",function(){return n.apply()}),a(35,"Apply"),l()()(),v(36,Qe,20,12),v(37,Ze,3,0,"div",16)(38,et,5,1,"div",17)(39,tt,5,0,"div",16)(40,at,30,2,"div",18),l()),e&2&&(s(16),S("ngModel",n.state.draftFilters().from),s(),S("disabled",!n.state.draftFilters().from),s(6),S("ngModel",n.state.draftFilters().to),s(),S("disabled",!n.state.draftFilters().to),s(5),S("ngModel",n.view()),s(5),S("disabled",n.state.loading()),s(2),y(n.totalRow()?36:-1),s(),y(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40))},dependencies:[Te,xe,Ce,fe,ye,be,ve,Y,ue,ge,he,_e,J,q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"]})};export{De as TokenUsageComponent};
1
+ import{a as _e}from"./chunk-V363EHJE.js";import{a as he,b as fe}from"./chunk-ZEMOOOQR.js";import{E as ke,c as be,g as ve,m as ye,x as xe,y as Ce,z as Te}from"./chunk-HZF57OLY.js";import{O as ge,S as ue}from"./chunk-EF2BOSEH.js";import{Bb as se,Db as P,Dc as ce,Eb as de,Fb as g,Ka as s,Kc as D,Qb as me,Sc as Z,Tb as a,Tc as pe,Ub as m,Vb as E,Wa as L,Z as H,Za as Q,a as R,b as A,ca as M,dc as x,fc as w,ga as $,gc as G,ha as V,ia as O,ja as ae,jb as b,kb as re,kc as p,lb as v,ma as ie,mb as y,pb as I,qb as N,rb as S,sb as r,ta as h,tb as l,ub as le,vb as c,wb as _,xb as T,z as oe}from"./chunk-B4RKRLIY.js";var Fe=(o,t)=>t.date,Re=(o,t)=>t.x,Ae=(o,t)=>t.label;function He(o,t){o&1&&(c(0,"div",0),a(1,"No daily data points for this period."),_())}function $e(o,t){if(o&1&&(O(),T(0,"rect",18)),o&2){let e=g().$implicit,n=g(2);b("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH)}}function Ve(o,t){if(o&1&&(O(),T(0,"rect",19)(1,"rect",20)),o&2){let e=g().$implicit,n=g(2);b("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),s(),b("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0)}}function Le(o,t){if(o&1){let e=se();O(),c(0,"g",15),de("mouseenter",function(i){let d=$(e).$implicit,u=g(2);return V(u.showTooltip(i,d.point))})("mousemove",function(i){let d=$(e).$implicit,u=g(2);return V(u.showTooltip(i,d.point))})("mouseleave",function(){$(e);let i=g(2);return V(i.hideTooltip())}),T(1,"rect",16)(2,"rect",17),v(3,$e,1,4,":svg:rect",18)(4,Ve,2,8),_()}if(o&2){let e=t.$implicit,n=g(2);b("transform","translate("+e.xGroup+",0)"),s(),b("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),s(),b("y",n.yBase-e.costH)("width",e.w)("height",e.costH),s(),y(e.tokensStubH!==null?3:4)}}function Ge(o,t){if(o&1&&(O(),c(0,"text",5),a(1),_()),o&2){let e=t.$implicit,n=g(2);b("x",e.x)("y",n.yAxis),s(),m(e.label)}}function Ye(o,t){if(o&1&&(c(0,"div",24),a(1),_(),c(2,"div",25),a(3),_()),o&2){let e=t.$implicit;s(),m(e.label),s(2),m(e.value)}}function We(o,t){if(o&1&&(c(0,"div",21)(1,"div",22),a(2),_(),c(3,"div",23),I(4,Ye,4,2,null,null,Ae),_()()),o&2){let e=g(2);me("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),s(2),m(e.tooltip().data.date),s(2),N(e.tooltipLines())}}function je(o,t){if(o&1&&(c(0,"div",8)(1,"span",10),a(2),_()()),o&2){let e=g(2);s(2),m(e.tokenCoverageLabel())}}function ze(o,t){if(o&1&&(c(0,"div",1),O(),c(1,"svg",2),T(2,"line",3)(3,"line",3),I(4,Le,5,8,":svg:g",4,Fe),I(6,Ge,2,3,":svg:text",5,Re),_(),v(8,We,6,5,"div",6),ae(),c(9,"div",7)(10,"div",8),T(11,"span",9),c(12,"span",10),a(13,"Cost (per day)"),_(),c(14,"span",11),a(15),_()(),c(16,"div",8),T(17,"span",12),c(18,"span",10),a(19,"Prompt tokens"),_()(),c(20,"div",8),T(21,"span",13),c(22,"span",10),a(23,"Completion tokens"),_()(),c(24,"div",8),T(25,"span",14),c(26,"span",10),a(27,"Tokens missing"),_()(),c(28,"div",8)(29,"span",10),a(30,"Tokens scale"),_(),c(31,"span",11),a(32),_()(),v(33,je,3,1,"div",8),_()()),o&2){let e=g();s(),b("viewBox",e.viewBox),s(),b("y1",e.yTop)("x2",720)("y2",e.yTop),s(),b("y1",e.yBase)("x2",720)("y2",e.yBase),s(),N(e.bars()),s(2),N(e.axisLabels()),s(2),y(e.tooltip().visible&&e.tooltip().data?8:-1),s(7),E("max ",e.maxCostLabel()),s(17),E("max ",e.maxTokensLabel()),s(),y(e.tokenCoverageLabel()?33:-1)}}var Y=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=p(()=>(this.points??[]).filter(t=>!!t.date));maxCost=p(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=p(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=p(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=p(()=>"$"+(new D("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=p(()=>new D("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=h({visible:!1,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return{date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ee=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:!0,x:F,y:ee,data:this.toTooltipData(e)})}hideTooltip(){this.tooltip.update(t=>A(R({},t),{visible:!1}))}formatTokens(t){return t===null?"\u2014":new D("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return"$"+(new D("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=p(()=>{let t=this.tooltip(),e=t.data;return!t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=p(()=>{let t=this.safePoints(),e=t.length;if(e===0)return[];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ee=(C.cost??0)/f*this.innerH,te=C.promptTokens,ne=C.completionTokens,K=te!==null||ne!==null,Oe=te??0,Ie=ne??0,Ne=K?Oe/k*this.innerH:null,Ue=K?Ie/k*this.innerH:null;return{date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ee,xTokens:F+u+this.barGap,promptH:Ne,completionH:Ue,tokensStubH:K?null:U}})});axisLabels=p(()=>{let t=this.safePoints(),e=t.length;if(e===0)return[];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return{x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=L({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&v(0,He,2,0,"div",0)(1,ze,34,11,"div",1),e&2&&y(n.safePoints().length===0?0:1)},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"],changeDetection:0})};var j=class o{http=M(pe);getTokenUsage(t){let e=new Z;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new Z;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=H({token:o,factory:o.\u0275fac,providedIn:"root"})};function Me(o){return`${o}`.padStart(2,"0")}function Se(o){return`${o.getUTCFullYear()}-${Me(o.getUTCMonth()+1)}-${Me(o.getUTCDate())}`}function Xe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Je(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var z=class o{api=M(j);destroyRef=M(ie);defaultFrom=Se(Xe());defaultTo=Se(Je());draftFilters=h({from:this.defaultFrom,to:this.defaultTo});appliedFilters=h({from:this.defaultFrom,to:this.defaultTo});loading=h(!1);error=h(null);aggregation=h(null);seriesResponse=h(null);series=h(null);tokenDataPartial=h(!1);aggregationByModelId=h(null);seriesByModelId=h(null);init(){this.reload()}setDraftFrom(t){this.draftFilters.update(e=>A(R({},e),{from:t}))}setDraftTo(t){this.draftFilters.update(e=>A(R({},e),{to:t}))}clearDraftFrom(){this.setDraftFrom(null)}clearDraftTo(){this.setDraftTo(null)}apply(){this.appliedFilters.set(this.draftFilters()),this.reload()}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0})}return[...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0})}return[...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(!0),this.error.set(null),oe({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(_e(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(!1)},error:n=>{this.loading.set(!1),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(!1),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage")}})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=H({token:o,factory:o.\u0275fac,providedIn:"root"})};var X=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},Pe=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:X,set:X,deleteProperty:X,has:X}),J=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(Pe,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=Q({name:"call",type:o,pure:!0})},q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(Pe,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=Q({name:"apply",type:o,pure:!0})};function qe(o,t){o&1&&(r(0,"div",23),a(1," Partial data \u2014 token counts may not cover the full period "),l())}function Ke(o,t){o&1&&(r(0,"div",24),a(1," No token data collected for this period "),l())}function Qe(o,t){if(o&1&&(r(0,"div",19)(1,"div",20)(2,"div",21),a(3,"Total tokens"),l(),r(4,"div",22),a(5),x(6,"call"),l()(),r(7,"div",20)(8,"div",21),a(9,"Total calls"),l(),r(10,"div",22),a(11),l()(),r(12,"div",20)(13,"div",21),a(14,"Total cost"),l(),r(15,"div",22),a(16),x(17,"apply"),l()()(),v(18,qe,2,0,"div",23),v(19,Ke,2,0,"div",24)),o&2){let e=g();s(5),m(w(6,5,e.totalRow().totalTokens,e.formatTokenValue)),s(6),m(e.totalRow().callCount),s(5),m(G(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),s(2),y(e.isPartialPeriod()?18:-1),s(),y(e.isMissingPeriod()?19:-1)}}function Ze(o,t){o&1&&(r(0,"div",16)(1,"div",25),a(2,"Loading token usage\u2026"),l()())}function et(o,t){if(o&1&&(r(0,"div",17)(1,"div",26),a(2,"Failed to load"),l(),r(3,"div",25),a(4),l()()),o&2){let e=g();s(4),m(e.state.error())}}function tt(o,t){o&1&&(r(0,"div",16)(1,"div",26),a(2,"No data"),l(),r(3,"div",25),a(4,"No token usage recorded yet for this period."),l()())}function nt(o,t){if(o&1&&(r(0,"div",32)(1,"div",29),a(2),l(),r(3,"div",29),a(4),l(),r(5,"div",29),a(6),l(),r(7,"div",30),a(8),x(9,"call"),l(),r(10,"div",30),a(11),x(12,"call"),l(),r(13,"div",30),a(14),x(15,"call"),l(),r(16,"div",30),a(17),l(),r(18,"div",30),a(19),x(20,"apply"),l()()),o&2){let e=t.$implicit,n=g(2);s(2),m(e.agentName),s(2),m(e.providerName),s(2),m(e.modelId),s(2),m(w(9,8,e.promptTokens,n.formatTokenValue)),s(3),m(w(12,11,e.completionTokens,n.formatTokenValue)),s(3),m(w(15,14,e.totalTokens,n.formatTokenValue)),s(3),m(e.callCount),s(2),E(" ",G(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ")}}function ot(o,t){if(o&1&&(r(0,"div",33)(1,"div",29),a(2),l(),r(3,"div",29),a(4),l(),r(5,"div",29),a(6),l(),r(7,"div",30),a(8),x(9,"call"),l(),r(10,"div",30),a(11),x(12,"call"),l(),r(13,"div",30),a(14),x(15,"call"),l(),r(16,"div",30),a(17),l(),r(18,"div",30),a(19),x(20,"apply"),l()()),o&2){let e=g(2);s(2),m(e.totalRow().agentName),s(2),m(e.totalRow().providerName),s(2),m(e.totalRow().modelId),s(2),m(w(9,8,e.totalRow().promptTokens,e.formatTokenValue)),s(3),E(" ",w(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),s(3),m(w(15,14,e.totalRow().totalTokens,e.formatTokenValue)),s(3),m(e.totalRow().callCount),s(2),E(" ",G(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ")}}function at(o,t){if(o&1&&(r(0,"div",18)(1,"section",16)(2,"div",26),a(3,"Summary"),l(),r(4,"div",27)(5,"div",28)(6,"div",29),a(7,"agentName"),l(),r(8,"div",29),a(9,"providerName"),l(),r(10,"div",29),a(11,"modelId"),l(),r(12,"div",30),a(13,"promptTokens"),l(),r(14,"div",30),a(15,"completionTokens"),l(),r(16,"div",30),a(17,"totalTokens"),l(),r(18,"div",30),a(19,"callCount"),l(),r(20,"div",30),a(21,"cost"),l()(),r(22,"div",31),I(23,nt,21,21,"div",32,re().trackRow,!0),v(25,ot,21,21,"div",33),l()()(),r(26,"section",16)(27,"div",26),a(28,"Daily series"),l(),le(29,"app-daily-series-chart",34),l()()),o&2){let e=g();s(23),N(e.rows()),s(2),y(e.totalRow()?25:-1),s(4),S("points",e.chartPoints())}}var we="\u2014",De=class o{location=M(ce);state=M(z);view=h("byModel");rowsByAgent=p(()=>this.state.aggregation()?.models??[]);totalRow=p(()=>this.state.aggregation()?.total??null);rowsByModel=p(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=p(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=p(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=p(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=p(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=p(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:!1});ngOnInit(){this.state.init()}onFromChange(t){this.state.setDraftFrom(t||null)}onToChange(t){this.state.setDraftTo(t||null)}clearFrom(){this.state.clearDraftFrom()}clearTo(){this.state.clearDraftTo()}apply(){this.state.apply()}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else{let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0)}}return[...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return`${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=p(()=>{if(this.state.loading())return!1;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):!1});isPartialPeriod=p(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back()}formatTokenValue(t){return t===null?we:new D("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?we:"$"+(new D("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=L({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(r(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),P("click",function(){return n.navigateBack()}),r(4,"mat-icon"),a(5,"chevron_left"),l()(),r(6,"div")(7,"h1",4),a(8,"Token Usage"),l(),r(9,"p",5),a(10,"Track prompt and completion token usage by agent and model."),l()()(),r(11,"div",6)(12,"label",7)(13,"span",8),a(14,"From"),l(),r(15,"div",9)(16,"input",10),P("ngModelChange",function(d){return n.onFromChange(d)}),l(),r(17,"button",11),P("click",function(){return n.clearFrom()}),a(18," Clear "),l()()(),r(19,"label",7)(20,"span",8),a(21,"To"),l(),r(22,"div",9)(23,"input",10),P("ngModelChange",function(d){return n.onToChange(d)}),l(),r(24,"button",11),P("click",function(){return n.clearTo()}),a(25," Clear "),l()()(),r(26,"label",7)(27,"span",8),a(28,"View"),l(),r(29,"select",12),P("ngModelChange",function(d){return n.view.set(d)}),r(30,"option",13),a(31,"By model"),l(),r(32,"option",14),a(33,"By agent"),l()()(),r(34,"button",15),P("click",function(){return n.apply()}),a(35,"Apply"),l()()(),v(36,Qe,20,12),v(37,Ze,3,0,"div",16)(38,et,5,1,"div",17)(39,tt,5,0,"div",16)(40,at,30,2,"div",18),l()),e&2&&(s(16),S("ngModel",n.state.draftFilters().from),s(),S("disabled",!n.state.draftFilters().from),s(6),S("ngModel",n.state.draftFilters().to),s(),S("disabled",!n.state.draftFilters().to),s(5),S("ngModel",n.view()),s(5),S("disabled",n.state.loading()),s(2),y(n.totalRow()?36:-1),s(),y(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40))},dependencies:[ke,Ce,Te,be,xe,ve,ye,Y,ue,ge,fe,he,J,q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"]})};export{De as TokenUsageComponent};
@@ -1 +1 @@
1
- import{b as me,c as le}from"./chunk-CBYR4M6L.js";import{a as R}from"./chunk-MOG6OBSN.js";import{a as Oe,b as ke,c as z}from"./chunk-YNZD2HBV.js";import{a as de,b as pe,c as ge,d as ue,e as _e,s as Ee,t as Se,u as Fe}from"./chunk-VDRETD5H.js";import{c as he,d as be,i as Ce,j as fe,m as ye,n as we}from"./chunk-BUA6GPP7.js";import"./chunk-V363EHJE.js";import{a as te,b as ne,d as oe,e as ie,f as re,g as ae,h as se}from"./chunk-6CNI4FAD.js";import"./chunk-Z7E7NSDY.js";import{a as L,b as A}from"./chunk-ZEMOOOQR.js";import{C as ve,E as B,b as Me,c as Pe,g as W,m as V,p as xe}from"./chunk-HZF57OLY.js";import"./chunk-5URVSSXV.js";import{O as D,Q as ce,S as I}from"./chunk-EF2BOSEH.js";import{Bb as f,Db as d,Dc as $,Fb as l,Ka as c,Lc as ee,Pb as N,Rb as T,Tb as a,Ub as M,Vb as O,Wa as F,Xb as x,Yb as v,Zb as y,ab as U,ac as J,bc as Q,ca as _,ga as g,ha as u,hc as X,kc as Z,lb as h,mb as b,nb as q,pb as H,qb as Y,rb as C,sb as n,ta as P,tb as o,yb as G,zb as K}from"./chunk-B4RKRLIY.js";function Re(s,i){if(s&1){let e=f();n(0,"div",9)(1,"mat-form-field",18)(2,"mat-label"),a(3),o(),n(4,"textarea",19),y("ngModelChange",function(r){let m=g(e).$index,E=l();return v(E.commands[m],r)||(E.commands[m]=r),u(r)}),o(),n(5,"mat-hint"),a(6,"Use placeholder for dynamic values"),o()(),n(7,"button",20),d("click",function(){let r=g(e).$index,m=l();return u(m.removeCommand(r))}),n(8,"mat-icon"),a(9,"delete"),o()()()}if(s&2){let e=i.$index,t=l();c(3),O("Prompt ",e+1),c(),x("ngModel",t.commands[e]),c(3),C("disabled",t.commands.length===1)}}function ze(s,i){if(s&1){let e=f();n(0,"div",10)(1,"h3"),a(2,"Save to"),o(),n(3,"div",21)(4,"label",22)(5,"input",23),y("ngModelChange",function(r){g(e);let m=l();return v(m.source,r)||(m.source=r),u(r)}),o(),n(6,"div",24)(7,"div",25)(8,"span",26),a(9,"\u{1F464}"),o(),n(10,"span",27),a(11,"Local"),o()(),n(12,"p",28),a(13,"Personal prompt in ~/.coday/... (not committed)"),o()()(),n(14,"label",22)(15,"input",29),y("ngModelChange",function(r){g(e);let m=l();return v(m.source,r)||(m.source=r),u(r)}),o(),n(16,"div",24)(17,"div",25)(18,"span",26),a(19,"\u{1F4E6}"),o(),n(20,"span",27),a(21,"Project"),o()(),n(22,"p",28),a(23,"Shared prompt in ./prompts/ (committable)"),o()()()(),n(24,"p",30),a(25,"Storage location is permanent and cannot be changed after creation"),o()()}if(s&2){let e=l();c(4),T("selected",e.source==="local"),c(),x("ngModel",e.source),c(9),T("selected",e.source==="project"),c(),x("ngModel",e.source)}}function Ue(s,i){if(s&1&&(n(0,"div",11)(1,"h3"),a(2,"Storage Location"),o(),n(3,"div",31)(4,"span",26),a(5),o(),n(6,"span",27),a(7),o()(),n(8,"p",30),a(9,"Cannot be changed after creation"),o()()),s&2){let e=l();c(3),T("badge-local",e.source==="local")("badge-project",e.source==="project"),c(2),M(e.source==="local"?"\u{1F464}":"\u{1F4E6}"),c(2),M(e.source==="local"?"Local":"Project")}}function Ne(s,i){if(s&1){let e=f();n(0,"div",12)(1,"label",32)(2,"input",33),y("ngModelChange",function(r){g(e);let m=l();return v(m.webhookEnabled,r)||(m.webhookEnabled=r),u(r)}),o(),n(3,"span"),a(4,"Enable webhook"),o()(),n(5,"p",30),a(6,"Enable webhook to trigger this prompt via HTTP POST"),o()()}if(s&2){let e=l();c(2),x("ngModel",e.webhookEnabled)}}function je(s,i){if(s&1){let e=f();n(0,"div",13)(1,"div",34)(2,"mat-icon",35),a(3,"link"),o(),n(4,"h4"),a(5,"Webhook URL"),o()(),n(6,"div",36)(7,"p",37),a(8),o(),n(9,"button",38),d("click",function(){g(e);let r=l();return u(r.copyWebhookUrl())}),n(10,"mat-icon"),a(11,"content_copy"),o(),n(12,"span"),a(13,"Copy URL"),o()()(),n(14,"p",30),a(15,"Use this URL to trigger the prompt via HTTP POST"),o()()}if(s&2){let e=l();c(8),M(e.getWebhookUrl())}}function qe(s,i){if(s&1&&(n(0,"div",14)(1,"mat-icon"),a(2,"error"),o(),n(3,"span"),a(4),o()()),s&2){let e=l();c(4),M(e.errorMessage)}}var k=class s{promptApi=_(R);dialogRef=_(te);configApi=_(z);snackBar=_(me);name="";description="";commands=[""];webhookEnabled=!1;threadLifetime="";source="local";isSaving=!1;errorMessage="";isAdmin=!1;isEditMode=!1;promptId="";data=_(ne);constructor(){this.isEditMode=this.data.mode==="edit"}ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin=i.groups?.includes("CODAY_ADMIN")??!1},error:i=>{console.error("[PROMPT_FORM] Error loading user config:",i),this.isAdmin=!1}}),this.isEditMode&&this.data.prompt&&(this.promptId=this.data.prompt.id,this.name=this.data.prompt.name,this.description=this.data.prompt.description,this.commands=[...this.data.prompt.commands],this.webhookEnabled=this.data.prompt.webhookEnabled,this.source=this.data.prompt.source)}addCommand(){this.commands.push("")}removeCommand(i){this.commands.length>1&&this.commands.splice(i,1)}trackByIndex(i){return i}normalizeName(){this.name=this.name.replace(/[\s_.,;:!?()[\]{}]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}validateForm(){return this.name.trim()?this.description.trim()?this.commands.filter(e=>e.trim()).length===0?(this.errorMessage="At least one command is required",!1):!0:(this.errorMessage="Description is required",!1):(this.errorMessage="Name is required",!1)}save(){if(this.errorMessage="",!this.validateForm())return;let i=this.commands.filter(e=>e.trim());if(this.isSaving=!0,this.isEditMode&&this.data.prompt){let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled};this.promptApi.updatePrompt(this.data.prompt.id,e).subscribe({next:()=>{this.isSaving=!1,this.dialogRef.close(!0)},error:t=>{console.error("Error updating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to update prompt",this.isSaving=!1}})}else{let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled,source:this.source};this.promptApi.createPrompt(e).subscribe({next:()=>{this.isSaving=!1,this.dialogRef.close(!0)},error:t=>{console.error("Error creating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to create prompt",this.isSaving=!1}})}}cancel(){this.dialogRef.close(!1)}getWebhookUrl(){return`${window.location.origin}/api/webhooks/${this.promptId}/execute`}copyWebhookUrl(){if(!this.webhookEnabled){this.snackBar.open("Webhook is not enabled","Close",{duration:3e3});return}if(!this.promptId){this.snackBar.open("Prompt must be saved before getting webhook URL","Close",{duration:3e3});return}let i=this.getWebhookUrl();navigator.clipboard.writeText(i).then(()=>{this.snackBar.open("Webhook URL copied to clipboard!","Close",{duration:3e3})}).catch(e=>{console.error("Failed to copy webhook URL:",e),this.snackBar.open("Failed to copy URL","Close",{duration:3e3})})}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=F({type:s,selectors:[["app-prompt-form"]],decls:36,vars:11,consts:[["mat-dialog-title",""],[1,"form-container"],["appearance","outline",1,"full-width"],["matInput","","placeholder","my-prompt","required","",3,"ngModelChange","blur","ngModel"],["matInput","","placeholder","What does this prompt do?","rows","3","required","",3,"ngModelChange","ngModel"],[1,"commands-section"],[1,"section-header"],["mat-icon-button","","type","button","title","Add command",3,"click"],[1,"commands-list"],[1,"command-item"],[1,"source-section"],[1,"source-display"],[1,"webhook-section"],[1,"webhook-url-section"],[1,"error-message"],["align","end"],["mat-button","",3,"click","disabled"],["mat-raised-button","","color","primary",3,"click","disabled"],["appearance","outline",1,"command-field"],["matInput","","placeholder","Enter command with placeholders like \\{\\{key\\}\\}","rows","2",3,"ngModelChange","ngModel"],["mat-icon-button","","type","button","title","Remove command",1,"remove-btn",3,"click","disabled"],[1,"source-options"],[1,"source-option"],["type","radio","name","source","value","local",3,"ngModelChange","ngModel"],[1,"source-content"],[1,"source-header"],[1,"source-icon"],[1,"source-label"],[1,"source-description"],["type","radio","name","source","value","project",3,"ngModelChange","ngModel"],[1,"hint"],[1,"source-badge"],[1,"checkbox-label"],["type","checkbox",3,"ngModelChange","ngModel"],[1,"webhook-url-header"],[1,"webhook-icon"],[1,"webhook-url-content"],[1,"url-text"],["mat-raised-button","","color","accent","type","button",3,"click"]],template:function(e,t){e&1&&(n(0,"h2",0),a(1),o(),n(2,"mat-dialog-content")(3,"div",1)(4,"mat-form-field",2)(5,"mat-label"),a(6,"Name"),o(),n(7,"input",3),y("ngModelChange",function(m){return v(t.name,m)||(t.name=m),m}),d("blur",function(){return t.normalizeName()}),o(),n(8,"mat-hint"),a(9,"A descriptive name (spaces and punctuation will be replaced with hyphens), will be used as command name"),o()(),n(10,"mat-form-field",2)(11,"mat-label"),a(12,"Description"),o(),n(13,"textarea",4),y("ngModelChange",function(m){return v(t.description,m)||(t.description=m),m}),o(),n(14,"mat-hint"),a(15,"Explain the purpose of this prompt, helps for searchability"),o()(),n(16,"div",5)(17,"div",6)(18,"h3"),a(19,"Prompts"),o(),n(20,"button",7),d("click",function(){return t.addCommand()}),n(21,"mat-icon"),a(22,"add"),o()()(),n(23,"div",8),H(24,Re,10,3,"div",9,q),o()(),h(26,ze,26,6,"div",10),h(27,Ue,10,6,"div",11),h(28,Ne,7,1,"div",12),h(29,je,16,1,"div",13),h(30,qe,5,1,"div",14),o()(),n(31,"mat-dialog-actions",15)(32,"button",16),d("click",function(){return t.cancel()}),a(33,"Cancel"),o(),n(34,"button",17),d("click",function(){return t.save()}),a(35),o()()),e&2&&(c(),M(t.isEditMode?"Edit Prompt":"Create Prompt"),c(6),x("ngModel",t.name),c(6),x("ngModel",t.description),c(11),Y(t.commands),c(2),b(t.isEditMode?-1:26),c(),b(t.isEditMode?27:-1),c(),b(t.isAdmin?28:-1),c(),b(t.isEditMode&&t.webhookEnabled&&t.isAdmin?29:-1),c(),b(t.errorMessage?30:-1),c(2),C("disabled",t.isSaving),c(2),C("disabled",t.isSaving),c(),O(" ",t.isSaving?"Saving...":"Save"," "))},dependencies:[ee,B,Pe,Me,xe,W,ve,V,se,ie,ae,re,I,ce,D,we,ye,Ce,he,be,fe,A,L,le],styles:[".form-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:0;min-width:500px}@media(max-width:768px){.form-container[_ngcontent-%COMP%]{min-width:auto}}.full-width[_ngcontent-%COMP%]{width:100%}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:.5rem}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.commands-section[_ngcontent-%COMP%] .commands-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .command-field[_ngcontent-%COMP%]{flex:1}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]{margin-top:8px}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.webhook-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:18px;height:18px;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:.95rem}.webhook-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.85rem;color:var(--color-text-secondary)}.webhook-url-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.75rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] .webhook-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;margin-bottom:.5rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] .url-text[_ngcontent-%COMP%]{flex:1;margin:0;padding:.75rem;background:var(--color-bg);border:1px solid var(--color-border);border-radius:4px;font-family:monospace;font-size:.85rem;word-break:break-all;color:var(--color-text)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{white-space:nowrap;display:flex;align-items:center;gap:.5rem}.webhook-url-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary)}.error-message[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:#f443361a;border:1px solid var(--color-error);border-radius:4px;color:var(--color-error)}.error-message[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.error-message[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 1rem;font-size:1rem;font-weight:600}.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{display:flex;gap:1rem;margin-bottom:.75rem}@media(max-width:768px){.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{flex-direction:column}}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:var(--color-bg);border:2px solid var(--color-border);border-radius:8px;cursor:pointer;transition:all .2s ease}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]:hover{border-color:var(--color-primary);background:var(--color-bg-hover)}.source-section[_ngcontent-%COMP%] .source-option.selected[_ngcontent-%COMP%]{border-color:var(--color-primary);background:var(--color-bg-hover);box-shadow:0 0 0 1px var(--color-primary)}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin-top:2px;cursor:pointer}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.25rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-label[_ngcontent-%COMP%]{font-weight:600;font-size:.95rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-description[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.thread-lifetime-disabled[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:#2196f30d;border:1px solid rgba(33,150,243,.2);border-radius:8px;margin-bottom:1rem}.thread-lifetime-disabled[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#2196f3cc;font-size:1.25rem;width:1.25rem;height:1.25rem;margin-top:2px}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;flex:1}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:.95rem;color:var(--color-text)}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{display:block;margin-top:.25rem;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-display[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-display[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:1rem;font-weight:600}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;padding:.5rem 1rem;border-radius:6px;font-size:.9rem;font-weight:500;margin-bottom:.5rem}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.1rem}.source-display[_ngcontent-%COMP%] .source-badge.badge-local[_ngcontent-%COMP%]{background:#2196f31a;color:#2196f3;border:1px solid rgba(33,150,243,.3)}.source-display[_ngcontent-%COMP%] .source-badge.badge-project[_ngcontent-%COMP%]{background:#4caf501a;color:#4caf50;border:1px solid rgba(76,175,80,.3)}.source-display[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}"]})};var He=()=>[],Ye=s=>({id:s});function Ge(s,i){if(s&1&&(n(0,"div",6),a(1),o()),s&2){let e=l();c(),M(e.errorMessage())}}function Ke(s,i){if(s&1){let e=f();n(0,"ds-entity-card",8),d("selected",function(r){g(e);let m=l();return u(m.onEdit(r))}),G(1,9),n(2,"button",10),d("click",function(r){return r.stopPropagation()}),n(3,"mat-icon"),a(4,"more_vert"),o()(),K(),o()}if(s&2){let e=i.$implicit;l();let t=N(11);C("id",e.id)("name",e.name)("description",e.description)("badges",e.badges??J(6,He)),c(2),C("matMenuTriggerFor",t)("matMenuTriggerData",Q(7,Ye,e.id))}}function Je(s,i){if(s&1){let e=f();n(0,"button",11),d("click",function(){g(e);let r=l().id,m=l();return u(m.onToggleWebhook(r))}),n(1,"mat-icon"),a(2),o(),a(3),o()}if(s&2){let e=l().id,t=l();c(2),M(t.isWebhookEnabled(e)?"link_off":"link"),c(),O(" ",t.isWebhookEnabled(e)?"Disable webhook":"Enable webhook"," ")}}function Qe(s,i){if(s&1){let e=f();n(0,"button",11),d("click",function(){let r=g(e).id,m=l();return u(m.onEdit(r))}),n(1,"mat-icon"),a(2,"edit"),o(),a(3," Edit "),o(),h(4,Je,4,2,"button",12),n(5,"button",13),d("click",function(){let r=g(e).id,m=l();return u(m.onDelete(r))}),n(6,"mat-icon"),a(7,"delete"),o(),a(8," Delete "),o()}if(s&2){let e=l();c(4),b(e.isAdmin()?4:-1)}}var Te="system",De=class s{promptApi=_(R);configApi=_(z);location=_($);dialog=_(oe);prompts=P([]);isLoading=P(!1);errorMessage=P(null);showOnlyMine=P(!0);isAdmin=P(!1);currentUsername=P("");promptItems=Z(()=>{let i=this.prompts(),e=this.currentUsername(),r=this.showOnlyMine()&&e?i.filter(p=>this.isMyPrompt(p)):i,E=[...new Set(r.map(p=>p.createdBy))].sort((p,w)=>p===e&&w!==e?-1:w===e&&p!==e||p===Te?1:w===Te?-1:p.localeCompare(w)),j=[];for(let p of E){let w=p===e?`${p} (you)`:p;for(let S of r.filter(Ie=>Ie.createdBy===p))j.push({id:S.id,name:S.name,description:S.description,badges:this.buildBadges(S),groupKey:p,groupLabel:w})}return j});ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin.set(i.groups?.includes("CODAY_ADMIN")??!1),this.currentUsername.set(i.username??"")},error:()=>this.isAdmin.set(!1)}),this.loadPrompts()}loadPrompts(){this.isLoading.set(!0),this.promptApi.listPrompts().subscribe({next:i=>{this.prompts.set(i.filter(e=>!e.id.startsWith("builtin"))),this.isLoading.set(!1)},error:i=>{this.errorMessage.set(i?.error?.error??"Failed to load prompts"),this.isLoading.set(!1)}})}onBack(){this.location.back()}onCreate(){this.dialog.open(k,{width:"700px",maxHeight:"90vh",data:{mode:"create"}}).afterClosed().subscribe(e=>{e&&this.loadPrompts()})}onEdit(i){this.promptApi.getPrompt(i).subscribe({next:e=>{this.dialog.open(k,{width:"700px",maxHeight:"90vh",data:{mode:"edit",prompt:e}}).afterClosed().subscribe(r=>{r&&this.loadPrompts()})},error:e=>this.errorMessage.set(e?.error?.error??"Failed to load prompt")})}onDelete(i){confirm("Are you sure you want to delete this prompt?")&&this.promptApi.deletePrompt(i).subscribe({next:()=>this.loadPrompts(),error:e=>this.errorMessage.set(e?.error?.error??"Failed to delete prompt")})}onToggleWebhook(i){let e=this.prompts().find(r=>r.id===i);if(!e)return;(e.webhookEnabled?this.promptApi.disableWebhook(i):this.promptApi.enableWebhook(i)).subscribe({next:()=>this.loadPrompts(),error:r=>this.errorMessage.set(r?.error?.error??"Failed to toggle webhook")})}isWebhookEnabled(i){return this.prompts().find(e=>e.id===i)?.webhookEnabled??!1}isMyPrompt(i){let e=t=>t.replace(/[.\s]+/g,"_").toLowerCase();return e(i.createdBy)===e(this.currentUsername())}buildBadges(i){let e=[];return i.source==="local"?e.push({label:"local",variant:"info"}):e.push({label:"project",variant:"success"}),i.webhookEnabled&&e.push({label:"webhook",variant:"warning"}),e}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=F({type:s,selectors:[["app-prompt-list"]],decls:13,vars:5,consts:[["promptCard",""],["cardMenu","matMenu"],[1,"prompt-list-page"],["title","Prompts","cardMinWidth","320px","contentMaxWidth","1400px","searchPlaceholder","Filter prompts\u2026","emptyMessage","No prompts found.",3,"createRequested","items","showCreate","itemTemplate"],["toolbar-start","","mat-icon-button","","title","Back",3,"click"],["toolbar-extras","","color","primary",1,"prompt-list__mine-toggle",3,"ngModelChange","ngModel"],[1,"prompt-list__error"],["matMenuContent",""],[3,"selected","id","name","description","badges"],["dsCardActions",""],["mat-icon-button","",3,"click","matMenuTriggerFor","matMenuTriggerData"],["mat-menu-item","",3,"click"],["mat-menu-item",""],["mat-menu-item","",1,"prompt-list__delete-item",3,"click"]],template:function(e,t){if(e&1&&(n(0,"div",2)(1,"ds-entity-list",3),d("createRequested",function(){return t.onCreate()}),n(2,"button",4),d("click",function(){return t.onBack()}),n(3,"mat-icon"),a(4,"chevron_left"),o()(),n(5,"mat-slide-toggle",5),d("ngModelChange",function(m){return t.showOnlyMine.set(m)}),a(6," Mine "),o()(),h(7,Ge,2,1,"div",6),o(),U(8,Ke,5,9,"ng-template",null,0,X),n(10,"mat-menu",null,1),U(12,Qe,9,1,"ng-template",7),o()),e&2){let r=N(9);c(),C("items",t.promptItems())("showCreate",!0)("itemTemplate",r),c(4),C("ngModel",t.showOnlyMine()),c(2),b(t.errorMessage()?7:-1)}},dependencies:[Fe,Se,Ee,I,D,A,L,ke,Oe,_e,ge,de,pe,ue,B,W,V],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.prompt-list__mine-toggle[_ngcontent-%COMP%]{flex-shrink:0;font-size:.875rem}.prompt-list__delete-item[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.prompt-list__delete-item[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:inherit}.prompt-list__error[_ngcontent-%COMP%]{margin:1rem auto;max-width:900px;padding:.75rem 1rem;background:#dc262614;border:1px solid rgba(220,38,38,.25);border-radius:8px;color:var(--color-error, #ff3b30);font-size:.875rem}"]})};export{De as PromptListComponent};
1
+ import{b as me,c as le}from"./chunk-CBYR4M6L.js";import{a as R}from"./chunk-MOG6OBSN.js";import{a as Oe,b as ke,c as z}from"./chunk-YNZD2HBV.js";import{a as de,b as pe,c as ge,d as ue,e as _e,s as Ee,t as Se,u as Fe}from"./chunk-WV7ML4CJ.js";import{c as he,d as be,i as Ce,j as fe,m as ye,n as we}from"./chunk-BUA6GPP7.js";import{a as te,b as ne,d as oe,e as ie,f as re,g as ae,h as se}from"./chunk-6CNI4FAD.js";import"./chunk-Z7E7NSDY.js";import"./chunk-V363EHJE.js";import{a as L,b as A}from"./chunk-ZEMOOOQR.js";import{C as ve,E as B,b as Me,c as Pe,g as W,m as V,p as xe}from"./chunk-HZF57OLY.js";import"./chunk-5URVSSXV.js";import{O as D,Q as ce,S as I}from"./chunk-EF2BOSEH.js";import{Bb as f,Db as d,Dc as $,Fb as l,Ka as c,Lc as ee,Pb as N,Rb as T,Tb as a,Ub as M,Vb as O,Wa as F,Xb as x,Yb as v,Zb as y,ab as U,ac as J,bc as Q,ca as _,ga as g,ha as u,hc as X,kc as Z,lb as h,mb as b,nb as q,pb as H,qb as Y,rb as C,sb as n,ta as P,tb as o,yb as G,zb as K}from"./chunk-B4RKRLIY.js";function Re(s,i){if(s&1){let e=f();n(0,"div",9)(1,"mat-form-field",18)(2,"mat-label"),a(3),o(),n(4,"textarea",19),y("ngModelChange",function(r){let m=g(e).$index,E=l();return v(E.commands[m],r)||(E.commands[m]=r),u(r)}),o(),n(5,"mat-hint"),a(6,"Use placeholder for dynamic values"),o()(),n(7,"button",20),d("click",function(){let r=g(e).$index,m=l();return u(m.removeCommand(r))}),n(8,"mat-icon"),a(9,"delete"),o()()()}if(s&2){let e=i.$index,t=l();c(3),O("Prompt ",e+1),c(),x("ngModel",t.commands[e]),c(3),C("disabled",t.commands.length===1)}}function ze(s,i){if(s&1){let e=f();n(0,"div",10)(1,"h3"),a(2,"Save to"),o(),n(3,"div",21)(4,"label",22)(5,"input",23),y("ngModelChange",function(r){g(e);let m=l();return v(m.source,r)||(m.source=r),u(r)}),o(),n(6,"div",24)(7,"div",25)(8,"span",26),a(9,"\u{1F464}"),o(),n(10,"span",27),a(11,"Local"),o()(),n(12,"p",28),a(13,"Personal prompt in ~/.coday/... (not committed)"),o()()(),n(14,"label",22)(15,"input",29),y("ngModelChange",function(r){g(e);let m=l();return v(m.source,r)||(m.source=r),u(r)}),o(),n(16,"div",24)(17,"div",25)(18,"span",26),a(19,"\u{1F4E6}"),o(),n(20,"span",27),a(21,"Project"),o()(),n(22,"p",28),a(23,"Shared prompt in ./prompts/ (committable)"),o()()()(),n(24,"p",30),a(25,"Storage location is permanent and cannot be changed after creation"),o()()}if(s&2){let e=l();c(4),T("selected",e.source==="local"),c(),x("ngModel",e.source),c(9),T("selected",e.source==="project"),c(),x("ngModel",e.source)}}function Ue(s,i){if(s&1&&(n(0,"div",11)(1,"h3"),a(2,"Storage Location"),o(),n(3,"div",31)(4,"span",26),a(5),o(),n(6,"span",27),a(7),o()(),n(8,"p",30),a(9,"Cannot be changed after creation"),o()()),s&2){let e=l();c(3),T("badge-local",e.source==="local")("badge-project",e.source==="project"),c(2),M(e.source==="local"?"\u{1F464}":"\u{1F4E6}"),c(2),M(e.source==="local"?"Local":"Project")}}function Ne(s,i){if(s&1){let e=f();n(0,"div",12)(1,"label",32)(2,"input",33),y("ngModelChange",function(r){g(e);let m=l();return v(m.webhookEnabled,r)||(m.webhookEnabled=r),u(r)}),o(),n(3,"span"),a(4,"Enable webhook"),o()(),n(5,"p",30),a(6,"Enable webhook to trigger this prompt via HTTP POST"),o()()}if(s&2){let e=l();c(2),x("ngModel",e.webhookEnabled)}}function je(s,i){if(s&1){let e=f();n(0,"div",13)(1,"div",34)(2,"mat-icon",35),a(3,"link"),o(),n(4,"h4"),a(5,"Webhook URL"),o()(),n(6,"div",36)(7,"p",37),a(8),o(),n(9,"button",38),d("click",function(){g(e);let r=l();return u(r.copyWebhookUrl())}),n(10,"mat-icon"),a(11,"content_copy"),o(),n(12,"span"),a(13,"Copy URL"),o()()(),n(14,"p",30),a(15,"Use this URL to trigger the prompt via HTTP POST"),o()()}if(s&2){let e=l();c(8),M(e.getWebhookUrl())}}function qe(s,i){if(s&1&&(n(0,"div",14)(1,"mat-icon"),a(2,"error"),o(),n(3,"span"),a(4),o()()),s&2){let e=l();c(4),M(e.errorMessage)}}var k=class s{promptApi=_(R);dialogRef=_(te);configApi=_(z);snackBar=_(me);name="";description="";commands=[""];webhookEnabled=!1;threadLifetime="";source="local";isSaving=!1;errorMessage="";isAdmin=!1;isEditMode=!1;promptId="";data=_(ne);constructor(){this.isEditMode=this.data.mode==="edit"}ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin=i.groups?.includes("CODAY_ADMIN")??!1},error:i=>{console.error("[PROMPT_FORM] Error loading user config:",i),this.isAdmin=!1}}),this.isEditMode&&this.data.prompt&&(this.promptId=this.data.prompt.id,this.name=this.data.prompt.name,this.description=this.data.prompt.description,this.commands=[...this.data.prompt.commands],this.webhookEnabled=this.data.prompt.webhookEnabled,this.source=this.data.prompt.source)}addCommand(){this.commands.push("")}removeCommand(i){this.commands.length>1&&this.commands.splice(i,1)}trackByIndex(i){return i}normalizeName(){this.name=this.name.replace(/[\s_.,;:!?()[\]{}]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}validateForm(){return this.name.trim()?this.description.trim()?this.commands.filter(e=>e.trim()).length===0?(this.errorMessage="At least one command is required",!1):!0:(this.errorMessage="Description is required",!1):(this.errorMessage="Name is required",!1)}save(){if(this.errorMessage="",!this.validateForm())return;let i=this.commands.filter(e=>e.trim());if(this.isSaving=!0,this.isEditMode&&this.data.prompt){let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled};this.promptApi.updatePrompt(this.data.prompt.id,e).subscribe({next:()=>{this.isSaving=!1,this.dialogRef.close(!0)},error:t=>{console.error("Error updating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to update prompt",this.isSaving=!1}})}else{let e={name:this.name.trim(),description:this.description.trim(),commands:i,webhookEnabled:this.webhookEnabled,source:this.source};this.promptApi.createPrompt(e).subscribe({next:()=>{this.isSaving=!1,this.dialogRef.close(!0)},error:t=>{console.error("Error creating prompt:",t),this.errorMessage=t?.error?.error||t?.message||"Failed to create prompt",this.isSaving=!1}})}}cancel(){this.dialogRef.close(!1)}getWebhookUrl(){return`${window.location.origin}/api/webhooks/${this.promptId}/execute`}copyWebhookUrl(){if(!this.webhookEnabled){this.snackBar.open("Webhook is not enabled","Close",{duration:3e3});return}if(!this.promptId){this.snackBar.open("Prompt must be saved before getting webhook URL","Close",{duration:3e3});return}let i=this.getWebhookUrl();navigator.clipboard.writeText(i).then(()=>{this.snackBar.open("Webhook URL copied to clipboard!","Close",{duration:3e3})}).catch(e=>{console.error("Failed to copy webhook URL:",e),this.snackBar.open("Failed to copy URL","Close",{duration:3e3})})}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=F({type:s,selectors:[["app-prompt-form"]],decls:36,vars:11,consts:[["mat-dialog-title",""],[1,"form-container"],["appearance","outline",1,"full-width"],["matInput","","placeholder","my-prompt","required","",3,"ngModelChange","blur","ngModel"],["matInput","","placeholder","What does this prompt do?","rows","3","required","",3,"ngModelChange","ngModel"],[1,"commands-section"],[1,"section-header"],["mat-icon-button","","type","button","title","Add command",3,"click"],[1,"commands-list"],[1,"command-item"],[1,"source-section"],[1,"source-display"],[1,"webhook-section"],[1,"webhook-url-section"],[1,"error-message"],["align","end"],["mat-button","",3,"click","disabled"],["mat-raised-button","","color","primary",3,"click","disabled"],["appearance","outline",1,"command-field"],["matInput","","placeholder","Enter command with placeholders like \\{\\{key\\}\\}","rows","2",3,"ngModelChange","ngModel"],["mat-icon-button","","type","button","title","Remove command",1,"remove-btn",3,"click","disabled"],[1,"source-options"],[1,"source-option"],["type","radio","name","source","value","local",3,"ngModelChange","ngModel"],[1,"source-content"],[1,"source-header"],[1,"source-icon"],[1,"source-label"],[1,"source-description"],["type","radio","name","source","value","project",3,"ngModelChange","ngModel"],[1,"hint"],[1,"source-badge"],[1,"checkbox-label"],["type","checkbox",3,"ngModelChange","ngModel"],[1,"webhook-url-header"],[1,"webhook-icon"],[1,"webhook-url-content"],[1,"url-text"],["mat-raised-button","","color","accent","type","button",3,"click"]],template:function(e,t){e&1&&(n(0,"h2",0),a(1),o(),n(2,"mat-dialog-content")(3,"div",1)(4,"mat-form-field",2)(5,"mat-label"),a(6,"Name"),o(),n(7,"input",3),y("ngModelChange",function(m){return v(t.name,m)||(t.name=m),m}),d("blur",function(){return t.normalizeName()}),o(),n(8,"mat-hint"),a(9,"A descriptive name (spaces and punctuation will be replaced with hyphens), will be used as command name"),o()(),n(10,"mat-form-field",2)(11,"mat-label"),a(12,"Description"),o(),n(13,"textarea",4),y("ngModelChange",function(m){return v(t.description,m)||(t.description=m),m}),o(),n(14,"mat-hint"),a(15,"Explain the purpose of this prompt, helps for searchability"),o()(),n(16,"div",5)(17,"div",6)(18,"h3"),a(19,"Prompts"),o(),n(20,"button",7),d("click",function(){return t.addCommand()}),n(21,"mat-icon"),a(22,"add"),o()()(),n(23,"div",8),H(24,Re,10,3,"div",9,q),o()(),h(26,ze,26,6,"div",10),h(27,Ue,10,6,"div",11),h(28,Ne,7,1,"div",12),h(29,je,16,1,"div",13),h(30,qe,5,1,"div",14),o()(),n(31,"mat-dialog-actions",15)(32,"button",16),d("click",function(){return t.cancel()}),a(33,"Cancel"),o(),n(34,"button",17),d("click",function(){return t.save()}),a(35),o()()),e&2&&(c(),M(t.isEditMode?"Edit Prompt":"Create Prompt"),c(6),x("ngModel",t.name),c(6),x("ngModel",t.description),c(11),Y(t.commands),c(2),b(t.isEditMode?-1:26),c(),b(t.isEditMode?27:-1),c(),b(t.isAdmin?28:-1),c(),b(t.isEditMode&&t.webhookEnabled&&t.isAdmin?29:-1),c(),b(t.errorMessage?30:-1),c(2),C("disabled",t.isSaving),c(2),C("disabled",t.isSaving),c(),O(" ",t.isSaving?"Saving...":"Save"," "))},dependencies:[ee,B,Pe,Me,xe,W,ve,V,se,ie,ae,re,I,ce,D,we,ye,Ce,he,be,fe,A,L,le],styles:[".form-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;padding:0;min-width:500px}@media(max-width:768px){.form-container[_ngcontent-%COMP%]{min-width:auto}}.full-width[_ngcontent-%COMP%]{width:100%}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:.5rem}.commands-section[_ngcontent-%COMP%] .section-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.commands-section[_ngcontent-%COMP%] .commands-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .command-field[_ngcontent-%COMP%]{flex:1}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]{margin-top:8px}.commands-section[_ngcontent-%COMP%] .command-item[_ngcontent-%COMP%] .remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.webhook-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:18px;height:18px;cursor:pointer}.webhook-section[_ngcontent-%COMP%] .checkbox-label[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:.95rem}.webhook-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.85rem;color:var(--color-text-secondary)}.webhook-url-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.75rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] .webhook-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-header[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{margin:0;font-size:1rem;font-weight:600}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;margin-bottom:.5rem}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] .url-text[_ngcontent-%COMP%]{flex:1;margin:0;padding:.75rem;background:var(--color-bg);border:1px solid var(--color-border);border-radius:4px;font-family:monospace;font-size:.85rem;word-break:break-all;color:var(--color-text)}.webhook-url-section[_ngcontent-%COMP%] .webhook-url-content[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{white-space:nowrap;display:flex;align-items:center;gap:.5rem}.webhook-url-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary)}.error-message[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:#f443361a;border:1px solid var(--color-error);border-radius:4px;color:var(--color-error)}.error-message[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.error-message[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 1rem;font-size:1rem;font-weight:600}.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{display:flex;gap:1rem;margin-bottom:.75rem}@media(max-width:768px){.source-section[_ngcontent-%COMP%] .source-options[_ngcontent-%COMP%]{flex-direction:column}}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:var(--color-bg);border:2px solid var(--color-border);border-radius:8px;cursor:pointer;transition:all .2s ease}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%]:hover{border-color:var(--color-primary);background:var(--color-bg-hover)}.source-section[_ngcontent-%COMP%] .source-option.selected[_ngcontent-%COMP%]{border-color:var(--color-primary);background:var(--color-bg-hover);box-shadow:0 0 0 1px var(--color-primary)}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin-top:2px;cursor:pointer}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%]{flex:1}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.25rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-header[_ngcontent-%COMP%] .source-label[_ngcontent-%COMP%]{font-weight:600;font-size:.95rem}.source-section[_ngcontent-%COMP%] .source-option[_ngcontent-%COMP%] .source-content[_ngcontent-%COMP%] .source-description[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-section[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.thread-lifetime-disabled[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem;padding:1rem;background:#2196f30d;border:1px solid rgba(33,150,243,.2);border-radius:8px;margin-bottom:1rem}.thread-lifetime-disabled[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#2196f3cc;font-size:1.25rem;width:1.25rem;height:1.25rem;margin-top:2px}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;flex:1}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:.95rem;color:var(--color-text)}.thread-lifetime-disabled[_ngcontent-%COMP%] p[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{display:block;margin-top:.25rem;font-size:.85rem;color:var(--color-text-secondary);line-height:1.4}.source-display[_ngcontent-%COMP%]{padding:1rem;background:var(--color-surface);border-radius:8px;border:1px solid var(--color-border)}.source-display[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:1rem;font-weight:600}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;padding:.5rem 1rem;border-radius:6px;font-size:.9rem;font-weight:500;margin-bottom:.5rem}.source-display[_ngcontent-%COMP%] .source-badge[_ngcontent-%COMP%] .source-icon[_ngcontent-%COMP%]{font-size:1.1rem}.source-display[_ngcontent-%COMP%] .source-badge.badge-local[_ngcontent-%COMP%]{background:#2196f31a;color:#2196f3;border:1px solid rgba(33,150,243,.3)}.source-display[_ngcontent-%COMP%] .source-badge.badge-project[_ngcontent-%COMP%]{background:#4caf501a;color:#4caf50;border:1px solid rgba(76,175,80,.3)}.source-display[_ngcontent-%COMP%] .hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}"]})};var He=()=>[],Ye=s=>({id:s});function Ge(s,i){if(s&1&&(n(0,"div",6),a(1),o()),s&2){let e=l();c(),M(e.errorMessage())}}function Ke(s,i){if(s&1){let e=f();n(0,"ds-entity-card",8),d("selected",function(r){g(e);let m=l();return u(m.onEdit(r))}),G(1,9),n(2,"button",10),d("click",function(r){return r.stopPropagation()}),n(3,"mat-icon"),a(4,"more_vert"),o()(),K(),o()}if(s&2){let e=i.$implicit;l();let t=N(11);C("id",e.id)("name",e.name)("description",e.description)("badges",e.badges??J(6,He)),c(2),C("matMenuTriggerFor",t)("matMenuTriggerData",Q(7,Ye,e.id))}}function Je(s,i){if(s&1){let e=f();n(0,"button",11),d("click",function(){g(e);let r=l().id,m=l();return u(m.onToggleWebhook(r))}),n(1,"mat-icon"),a(2),o(),a(3),o()}if(s&2){let e=l().id,t=l();c(2),M(t.isWebhookEnabled(e)?"link_off":"link"),c(),O(" ",t.isWebhookEnabled(e)?"Disable webhook":"Enable webhook"," ")}}function Qe(s,i){if(s&1){let e=f();n(0,"button",11),d("click",function(){let r=g(e).id,m=l();return u(m.onEdit(r))}),n(1,"mat-icon"),a(2,"edit"),o(),a(3," Edit "),o(),h(4,Je,4,2,"button",12),n(5,"button",13),d("click",function(){let r=g(e).id,m=l();return u(m.onDelete(r))}),n(6,"mat-icon"),a(7,"delete"),o(),a(8," Delete "),o()}if(s&2){let e=l();c(4),b(e.isAdmin()?4:-1)}}var Te="system",De=class s{promptApi=_(R);configApi=_(z);location=_($);dialog=_(oe);prompts=P([]);isLoading=P(!1);errorMessage=P(null);showOnlyMine=P(!0);isAdmin=P(!1);currentUsername=P("");promptItems=Z(()=>{let i=this.prompts(),e=this.currentUsername(),r=this.showOnlyMine()&&e?i.filter(p=>this.isMyPrompt(p)):i,E=[...new Set(r.map(p=>p.createdBy))].sort((p,w)=>p===e&&w!==e?-1:w===e&&p!==e||p===Te?1:w===Te?-1:p.localeCompare(w)),j=[];for(let p of E){let w=p===e?`${p} (you)`:p;for(let S of r.filter(Ie=>Ie.createdBy===p))j.push({id:S.id,name:S.name,description:S.description,badges:this.buildBadges(S),groupKey:p,groupLabel:w})}return j});ngOnInit(){this.configApi.getUserConfig().subscribe({next:i=>{this.isAdmin.set(i.groups?.includes("CODAY_ADMIN")??!1),this.currentUsername.set(i.username??"")},error:()=>this.isAdmin.set(!1)}),this.loadPrompts()}loadPrompts(){this.isLoading.set(!0),this.promptApi.listPrompts().subscribe({next:i=>{this.prompts.set(i.filter(e=>!e.id.startsWith("builtin"))),this.isLoading.set(!1)},error:i=>{this.errorMessage.set(i?.error?.error??"Failed to load prompts"),this.isLoading.set(!1)}})}onBack(){this.location.back()}onCreate(){this.dialog.open(k,{width:"700px",maxHeight:"90vh",data:{mode:"create"}}).afterClosed().subscribe(e=>{e&&this.loadPrompts()})}onEdit(i){this.promptApi.getPrompt(i).subscribe({next:e=>{this.dialog.open(k,{width:"700px",maxHeight:"90vh",data:{mode:"edit",prompt:e}}).afterClosed().subscribe(r=>{r&&this.loadPrompts()})},error:e=>this.errorMessage.set(e?.error?.error??"Failed to load prompt")})}onDelete(i){confirm("Are you sure you want to delete this prompt?")&&this.promptApi.deletePrompt(i).subscribe({next:()=>this.loadPrompts(),error:e=>this.errorMessage.set(e?.error?.error??"Failed to delete prompt")})}onToggleWebhook(i){let e=this.prompts().find(r=>r.id===i);if(!e)return;(e.webhookEnabled?this.promptApi.disableWebhook(i):this.promptApi.enableWebhook(i)).subscribe({next:()=>this.loadPrompts(),error:r=>this.errorMessage.set(r?.error?.error??"Failed to toggle webhook")})}isWebhookEnabled(i){return this.prompts().find(e=>e.id===i)?.webhookEnabled??!1}isMyPrompt(i){let e=t=>t.replace(/[.\s]+/g,"_").toLowerCase();return e(i.createdBy)===e(this.currentUsername())}buildBadges(i){let e=[];return i.source==="local"?e.push({label:"local",variant:"info"}):e.push({label:"project",variant:"success"}),i.webhookEnabled&&e.push({label:"webhook",variant:"warning"}),e}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=F({type:s,selectors:[["app-prompt-list"]],decls:13,vars:5,consts:[["promptCard",""],["cardMenu","matMenu"],[1,"prompt-list-page"],["title","Prompts","cardMinWidth","320px","contentMaxWidth","1400px","searchPlaceholder","Filter prompts\u2026","emptyMessage","No prompts found.",3,"createRequested","items","showCreate","itemTemplate"],["toolbar-start","","mat-icon-button","","title","Back",3,"click"],["toolbar-extras","","color","primary",1,"prompt-list__mine-toggle",3,"ngModelChange","ngModel"],[1,"prompt-list__error"],["matMenuContent",""],[3,"selected","id","name","description","badges"],["dsCardActions",""],["mat-icon-button","",3,"click","matMenuTriggerFor","matMenuTriggerData"],["mat-menu-item","",3,"click"],["mat-menu-item",""],["mat-menu-item","",1,"prompt-list__delete-item",3,"click"]],template:function(e,t){if(e&1&&(n(0,"div",2)(1,"ds-entity-list",3),d("createRequested",function(){return t.onCreate()}),n(2,"button",4),d("click",function(){return t.onBack()}),n(3,"mat-icon"),a(4,"chevron_left"),o()(),n(5,"mat-slide-toggle",5),d("ngModelChange",function(m){return t.showOnlyMine.set(m)}),a(6," Mine "),o()(),h(7,Ge,2,1,"div",6),o(),U(8,Ke,5,9,"ng-template",null,0,X),n(10,"mat-menu",null,1),U(12,Qe,9,1,"ng-template",7),o()),e&2){let r=N(9);c(),C("items",t.promptItems())("showCreate",!0)("itemTemplate",r),c(4),C("ngModel",t.showOnlyMine()),c(2),b(t.errorMessage()?7:-1)}},dependencies:[Fe,Se,Ee,I,D,A,L,ke,Oe,_e,ge,de,pe,ue,B,W,V],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.prompt-list__mine-toggle[_ngcontent-%COMP%]{flex-shrink:0;font-size:.875rem}.prompt-list__delete-item[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.prompt-list__delete-item[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:inherit}.prompt-list__error[_ngcontent-%COMP%]{margin:1rem auto;max-width:900px;padding:.75rem 1rem;background:#dc262614;border:1px solid rgba(220,38,38,.25);border-radius:8px;color:var(--color-error, #ff3b30);font-size:.875rem}"]})};export{De as PromptListComponent};