@whoz-oss/coday-client 3.2.1 → 3.3.1
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.
- package/browser/{chunk-DBlPRzsF.js → chunk--fxx5Oa-.js} +1 -1
- package/browser/chunk-2_BBR3ej.js +1 -0
- package/browser/{chunk-B5YwrGx0.js → chunk-8OK_6DuK.js} +1 -1
- package/browser/{chunk-DhA2Ljr1.js → chunk-8Z_HvjaL.js} +1 -1
- package/browser/{chunk-BB-ONbTG.js → chunk-8v01wE3r.js} +1 -1
- package/browser/{chunk-1K5qk_J9.js → chunk-B22dvHxJ.js} +1 -1
- package/browser/{chunk-D_UPkwXx.js → chunk-B7c_faZK.js} +1 -1
- package/browser/{chunk-DIETmX0p.js → chunk-BB4zCw7X.js} +1 -1
- package/browser/{chunk-CsW7EOpv.js → chunk-BCn5ZD_c.js} +1 -1
- package/browser/{chunk-BvuQhvdk.js → chunk-BHJPoh3M.js} +1 -1
- package/browser/{chunk-CC1LKBSv.js → chunk-BOoQVfiw.js} +1 -1
- package/browser/{chunk-C4iG51lq.js → chunk-BPp7UKCF.js} +1 -1
- package/browser/{chunk-CdWuKMws.js → chunk-BR6R4gpW.js} +1 -1
- package/browser/{chunk-CdHCJCQj.js → chunk-BReEzJTt.js} +1 -1
- package/browser/{chunk-CqdkZ3Ch.js → chunk-BTSq1yp8.js} +1 -1
- package/browser/{chunk-7Udlqdai.js → chunk-BU-kFi7p.js} +1 -1
- package/browser/{chunk-DJEvQQHG.js → chunk-BUtf9yKK.js} +1 -1
- package/browser/{chunk-DONjv4Q6.js → chunk-BYZZOwP6.js} +1 -1
- package/browser/{chunk-DKV3GtZ_.js → chunk-BbMMjtpL.js} +1 -1
- package/browser/{chunk-xqqjZWqw.js → chunk-BcqjfPzD.js} +1 -1
- package/browser/{chunk-qF62pyMY.js → chunk-Bgz0YSqs.js} +1 -1
- package/browser/{chunk-mabiXWQO.js → chunk-BhDrA9iN.js} +1 -1
- package/browser/{chunk-BeJEtTi6.js → chunk-Bofelq_e.js} +1 -1
- package/browser/{chunk-Rhpk_xbV.js → chunk-Bu8NHsWv.js} +1 -1
- package/browser/chunk-By8x10iE.js +1 -0
- package/browser/{chunk-DGKCScHp.js → chunk-C39RA_bw.js} +1 -1
- package/browser/{chunk-D1LCrMS_.js → chunk-C8P9SuaA.js} +1 -1
- package/browser/{chunk-DWzvxfzD.js → chunk-CLcLLGWk.js} +1 -1
- package/browser/{chunk-RUHBb69N.js → chunk-CXHlTmz0.js} +1 -1
- package/browser/{chunk-CREQAnHA.js → chunk-CcXOwTvX.js} +1 -1
- package/browser/{chunk-BitsLHDr.js → chunk-CinHjHqk.js} +3 -3
- package/browser/{chunk-Lb5D9bDO.js → chunk-Cix5vmvF.js} +1 -1
- package/browser/{chunk-BylNYuzF.js → chunk-Ck-XMTcy.js} +1 -1
- package/browser/{chunk-DFpVj1mo.js → chunk-Cm0tD0om.js} +1 -1
- package/browser/{chunk-CdpWzKQk.js → chunk-CsChsLgw.js} +1 -1
- package/browser/{chunk-CQkBZ0aV.js → chunk-Cw18oPF0.js} +1 -1
- package/browser/{chunk-CeN-N-Z7.js → chunk-D29_gPoW.js} +1 -1
- package/browser/{chunk-DlrJ4DR-.js → chunk-D2hh5Ex3.js} +1 -1
- package/browser/{chunk-D-W_Ze1F.js → chunk-D3Kj4T8Y.js} +1 -1
- package/browser/{chunk-CQnJEHQ3.js → chunk-D4g4I30m.js} +1 -1
- package/browser/{chunk-OAU818H7.js → chunk-DB8HcHes.js} +1 -1
- package/browser/{chunk-BCbHsiBY.js → chunk-DJBbIbii.js} +1 -1
- package/browser/{chunk-prrANjb6.js → chunk-DS855pzA.js} +1 -1
- package/browser/{chunk-CKnJYwqP.js → chunk-Ddve8eXJ.js} +1 -1
- package/browser/{chunk-q9vkXLSQ.js → chunk-Dg1d1XBn.js} +1 -1
- package/browser/{chunk-CuUiHzl6.js → chunk-Dm2zo81i.js} +1 -1
- package/browser/{chunk-DlEG0pFO.js → chunk-Dr2eg2L_.js} +1 -1
- package/browser/{chunk-DadtttYS.js → chunk-DvXqS7Sb.js} +1 -1
- package/browser/{chunk-BMUpf9LG.js → chunk-DwrSqNJu.js} +1 -1
- package/browser/{chunk-BdgbIoUL.js → chunk-FIgfn9bI.js} +1 -1
- package/browser/{chunk-DERKG0Gj.js → chunk-FQTKLHXY.js} +1 -1
- package/browser/{chunk-BOKjSB45.js → chunk-GHmZXChc.js} +1 -1
- package/browser/chunk-JSqlYB97.js +1 -0
- package/browser/{chunk-DxnXIfN4.js → chunk-K-jE-YGO.js} +1 -1
- package/browser/{chunk-B4dCdFY0.js → chunk-MT0Figq0.js} +1 -1
- package/browser/{chunk-G9lqg2I_.js → chunk-Wl0Mu9Ba.js} +1 -1
- package/browser/{chunk-ADAFVeSv.js → chunk-ciSHZI2F.js} +1 -1
- package/browser/{chunk-Dhbkfl2p.js → chunk-dOYABY0k.js} +1 -1
- package/browser/{chunk-BhpcAaX5.js → chunk-jg8IIJti.js} +1 -1
- package/browser/{chunk-pTH381B1.js → chunk-qRp_60F5.js} +1 -1
- package/browser/{chunk-BQrLrX24.js → chunk-rHrSoLcV.js} +1 -1
- package/browser/{chunk-9N3T6aRI.js → chunk-tYI69pxY.js} +1 -1
- package/browser/{chunk-DF1PsWqw.js → chunk-wTW1YRSg.js} +1 -1
- package/browser/{chunk-ByZe3q2x.js → chunk-xH-xVbwT.js} +1 -1
- package/browser/{chunk-DkLSvor3.js → chunk-yr_6-dSo.js} +1 -1
- package/browser/{chunk-Csom-5tT.js → chunk-zjf6Y2-q.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/{main-CPDUTNNG.js → main-MB7Y2AR2.js} +4 -4
- package/package.json +1 -1
- package/browser/chunk-Ck8o4krA.js +0 -1
- package/browser/chunk-DJrjyHGk.js +0 -1
- package/browser/chunk-Dhu1PBKg.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N as Ne,u as ui$1,a as me,f as fi$1,Y as Yt,V as Ve$1,n as ne}from'./chunk-D1LCrMS_.js';import {g,az as Qt,aQ as As,aY as ks,al as yt$1,A as Aw,o as bg,v as vs,q as oC,k as fl,T as TC,r as Tg,X as XE,x as iC,D as Fg,I as IC,E as wC,j as Gn$1,l as Ag,W as WC,b_ as FC,C as Cg,a8 as Zg,O as Ot,w as we,cJ as yB,ca as mB,H as Hi$1,m as mT,b as U,bz as vC,bA as DC,ad as Vg,y as Hg,aw as pl,b5 as Sg,ax as hl,n as eC,t as tC,cb as gB,cq as vB,cc as Hf,cu as Lg,cv as CC,cd as Sb,af as Dg,an as ce,cK as Id,cL as Nd,bR as ma,S as ha,cI as Rg,b$ as Ng,cM as Rn$1,aK as Do$1,aL as qn$1,bq as sn,bC as ge,aN as wt$1,bD as vt,br as Cl,bK as pe,aR as K,cN as is,a as P,aS as Ut,cO as Bt,bQ as bd,bO as Yy,bt as Ve,c1 as ME,z as z$1,aZ as YT,bH as Eg,b4 as nT,aV as w,bu as kg,aU as U$1,bv as St,aW as D,bw as on,by as Oi$1,bE as X,cP as q,cQ as X$1,ac as mC,a9 as dC,aa as If,ab as wf,a5 as yl,cR as Yt$1,cS as Gp,bL as mr,aO as G,ae as Ot$1,aA as sn$1,bV as Y,cT as pi,cU as yg,aC as Cu,bx as am,cA as on$1,c7 as QT,ah as rT,a4 as rC,c8 as kf,bs as Qn$2,ap as Vy,bW as Pt,bY as X$2,bZ as xt,cV as YI,cC as Ce,a3 as HI,a6 as $I,bn as nC,c2 as kt,bI as dr,a_ as XC,b3 as oT,a$ as Yg,cg as Mg,cW as yr,cX as tt$1,aX as ft$1,cy as Xr,ag as fT}from'./main-CPDUTNNG.js';import {w as wt,j as Yn$1,k as _t$1,n as ni,l as Xn$1,E as En$1,z as ze,Q as Qn$1,e as ei,Y as Ye,f as fn,a as wt$2,A as At,Z as Zn$1,C as Cn}from'./chunk-BhpcAaX5.js';var ii=[[["mat-icon"],["","matMenuItemIcon",""]],"*"],oi=["mat-icon, [matMenuItemIcon]","*"];function ai(n,i){n&1&&(kf(),vs(0,"svg",2),bg(1,"polygon",3),fl());}var ri=["*"];function si(n,i){if(n&1){let e=dC();pl(0,"div",0),Rg("click",function(){If(e);let o=mC();return wf(o.closed.emit("click"))})("animationstart",function(o){If(e);let a=mC();return wf(a._onAnimationStart(o.animationName))})("animationend",function(o){If(e);let a=mC();return wf(a._onAnimationDone(o.animationName))})("animationcancel",function(o){If(e);let a=mC();return wf(a._onAnimationDone(o.animationName))}),pl(1,"div",1),DC(2),hl()();}if(n&2){let e=mC();FC(e._classList),Hg("mat-menu-panel-animations-disabled",e._animationsDisabled)("mat-menu-panel-exit-animation",e._panelAnimationState==="void")("mat-menu-panel-animating",e._isAnimating()),Ng("id",e.panelId),Cg("aria-label",e.ariaLabel||null)("aria-labelledby",e.ariaLabelledby||null)("aria-describedby",e.ariaDescribedby||null);}}var pt=new w("MAT_MENU_PANEL"),Be=(()=>{class n{_elementRef=g(Qt);_document=g(U$1);_focusMonitor=g(St);_parentMenu=g(pt,{optional:true});_changeDetectorRef=g(Cl);role="menuitem";disabled=false;disableRipple=false;_hovered=new ce;_focused=new ce;_highlighted=false;_triggersSubmenu=false;constructor(){g(D).load(on),this._parentMenu?.addItem?.(this);}focus(e,t){this._focusMonitor&&e?this._focusMonitor.focusVia(this._getHostElement(),e,t):this._getHostElement().focus(t),this._focused.next(this);}ngAfterViewInit(){this._focusMonitor&&this._focusMonitor.monitor(this._elementRef,false);}ngOnDestroy(){this._focusMonitor&&this._focusMonitor.stopMonitoring(this._elementRef),this._parentMenu&&this._parentMenu.removeItem&&this._parentMenu.removeItem(this),this._hovered.complete(),this._focused.complete();}_getTabIndex(){return this.disabled?"-1":"0"}_getHostElement(){return this._elementRef.nativeElement}_checkDisabled(e){this.disabled&&(e.preventDefault(),e.stopPropagation());}_handleMouseEnter(){this._hovered.next(this);}getLabel(){let e=this._elementRef.nativeElement.cloneNode(true),t=e.querySelectorAll("mat-icon, .material-icons");for(let o=0;o<t.length;o++)t[o].remove();return e.textContent?.trim()||""}_setHighlighted(e){this._highlighted=e,this._changeDetectorRef.markForCheck();}_setTriggersSubmenu(e){this._triggersSubmenu=e,this._changeDetectorRef.markForCheck();}_hasFocus(){return this._document&&this._document.activeElement===this._getHostElement()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=Aw({type:n,selectors:[["","mat-menu-item",""]],hostAttrs:[1,"mat-mdc-menu-item","mat-focus-indicator"],hostVars:8,hostBindings:function(t,o){t&1&&Ag("click",function(m){return o._checkDisabled(m)})("mouseenter",function(){return o._handleMouseEnter()}),t&2&&(Cg("role",o.role)("tabindex",o._getTabIndex())("aria-disabled",o.disabled)("disabled",o.disabled||null),Hg("mat-mdc-menu-item-highlighted",o._highlighted)("mat-mdc-menu-item-submenu-trigger",o._triggersSubmenu));},inputs:{role:"role",disabled:[2,"disabled","disabled",YT],disableRipple:[2,"disableRipple","disableRipple",YT]},exportAs:["matMenuItem"],ngContentSelectors:oi,decls:5,vars:3,consts:[[1,"mat-mdc-menu-item-text"],["matRipple","",1,"mat-mdc-menu-ripple",3,"matRippleDisabled","matRippleTrigger"],["viewBox","0 0 5 10","focusable","false","aria-hidden","true",1,"mat-mdc-menu-submenu-icon"],["points","0,0 5,5 0,10"]],template:function(t,o){t&1&&(vC(ii),DC(0),vs(1,"span",0),DC(2,1),fl(),bg(3,"div",1),eC(4,ai,2,0,":svg:svg",2)),t&2&&(XE(3),Tg("matRippleDisabled",o.disableRipple||o.disabled)("matRippleTrigger",o._getHostElement()),XE(),tC(o._triggersSubmenu?4:-1));},dependencies:[Oi$1],encapsulation:2})}return n})();var Sn=new w("MatMenuContent"),ya=(()=>{class n{_template=g(dr);_appRef=g(yr);_injector=g(pe);_viewContainerRef=g(mr);_document=g(U$1);_changeDetectorRef=g(Cl);_portal;_outlet;_attached=new ce;attach(e={}){this._portal||(this._portal=new Y(this._template,this._viewContainerRef)),this.detach(),this._outlet||(this._outlet=new tt$1(this._document.createElement("div"),this._appRef,this._injector));let t=this._template.elementRef.nativeElement;t.parentNode.insertBefore(this._outlet.outletElement,t),this._changeDetectorRef.markForCheck(),this._portal.attach(this._outlet,e),this._attached.next();}detach(){this._portal?.isAttached&&this._portal.detach();}ngOnDestroy(){this.detach(),this._outlet?.dispose();}static \u0275fac=function(t){return new(t||n)};static \u0275dir=ks({type:n,selectors:[["ng-template","matMenuContent",""]],features:[nT([{provide:Sn,useExisting:n}])]})}return n})(),li=new w("mat-menu-default-options",{providedIn:"root",factory:()=>({overlapTrigger:false,xPosition:"after",yPosition:"below",backdropClass:"cdk-overlay-transparent-backdrop"})}),mt="_mat-menu-enter",et="_mat-menu-exit",De=(()=>{class n{_elementRef=g(Qt);_changeDetectorRef=g(Cl);_injector=g(pe);_keyManager;_xPosition;_yPosition;_firstItemFocusRef;_exitFallbackTimeout;_animationsDisabled=K();_allItems;_directDescendantItems=new is;_classList={};_panelAnimationState="void";_animationDone=new ce;_isAnimating=Hi$1(false);parentMenu;direction;overlayPanelClass;backdropClass;ariaLabel;ariaLabelledby;ariaDescribedby;get xPosition(){return this._xPosition}set xPosition(e){this._xPosition=e,this.setPositionClasses();}get yPosition(){return this._yPosition}set yPosition(e){this._yPosition=e,this.setPositionClasses();}templateRef;items;lazyContent;overlapTrigger=false;hasBackdrop;get panelClass(){return this._previousPanelClass}set panelClass(e){let t=this._previousPanelClass,o=P({},this._classList);t&&t.length&&t.split(" ").forEach(a=>{o[a]=false;}),this._previousPanelClass=e,e&&e.length&&(e.split(" ").forEach(a=>{o[a]=true;}),this._elementRef.nativeElement.className=""),this._classList=o;}_previousPanelClass="";get classList(){return this.panelClass}set classList(e){this.panelClass=e;}closed=new yt$1;close=this.closed;panelId=g(Ut).getId("mat-menu-panel-");constructor(){let e=g(li);this.overlayPanelClass=e.overlayPanelClass||"",this._xPosition=e.xPosition,this._yPosition=e.yPosition,this.backdropClass=e.backdropClass,this.overlapTrigger=e.overlapTrigger,this.hasBackdrop=e.hasBackdrop;}ngOnInit(){this.setPositionClasses();}ngAfterContentInit(){this._updateDirectDescendants(),this._keyManager=new Bt(this._directDescendantItems).withWrap().withTypeAhead().withHomeAndEnd(),this._keyManager.tabOut.subscribe(()=>this.closed.emit("tab")),this._directDescendantItems.changes.pipe(bd(this._directDescendantItems),ma(e=>Yy(...e.map(t=>t._focused)))).subscribe(e=>this._keyManager.updateActiveItem(e)),this._directDescendantItems.changes.subscribe(e=>{let t=this._keyManager;if(this._panelAnimationState==="enter"&&t.activeItem?._hasFocus()){let o=e.toArray(),a=Math.max(0,Math.min(o.length-1,t.activeItemIndex||0));o[a]&&!o[a].disabled?t.setActiveItem(a):t.setNextItemActive();}});}ngOnDestroy(){this._keyManager?.destroy(),this._directDescendantItems.destroy(),this.closed.complete(),this._firstItemFocusRef?.destroy(),clearTimeout(this._exitFallbackTimeout);}_hovered(){return this._directDescendantItems.changes.pipe(bd(this._directDescendantItems),ma(t=>Yy(...t.map(o=>o._hovered))))}addItem(e){}removeItem(e){}_handleKeydown(e){let t=e.keyCode,o=this._keyManager;switch(t){case 27:Ve(e)||(e.preventDefault(),this.closed.emit("keydown"));break;case 37:this.parentMenu&&this.direction==="ltr"&&this.closed.emit("keydown");break;case 39:this.parentMenu&&this.direction==="rtl"&&this.closed.emit("keydown");break;default:(t===38||t===40)&&o.setFocusOrigin("keyboard"),o.onKeydown(e);return}}focusFirstItem(e="program"){this._firstItemFocusRef?.destroy(),this._firstItemFocusRef=ME(()=>{let t=this._resolvePanel();if(!t||!t.contains(document.activeElement)){let o=this._keyManager;o.setFocusOrigin(e).setFirstItemActive(),!o.activeItem&&t&&t.focus();}},{injector:this._injector});}resetActiveItem(){this._keyManager.setActiveItem(-1);}setElevation(e){}setPositionClasses(e=this.xPosition,t=this.yPosition){this._classList=z$1(P({},this._classList),{"mat-menu-before":e==="before","mat-menu-after":e==="after","mat-menu-above":t==="above","mat-menu-below":t==="below"}),this._changeDetectorRef.markForCheck();}_onAnimationDone(e){let t=e===et;(t||e===mt)&&(t&&(clearTimeout(this._exitFallbackTimeout),this._exitFallbackTimeout=void 0),this._animationDone.next(t?"void":"enter"),this._isAnimating.set(false));}_onAnimationStart(e){(e===mt||e===et)&&this._isAnimating.set(true);}_setIsOpen(e){if(this._panelAnimationState=e?"enter":"void",e){if(this._keyManager.activeItemIndex===0){let t=this._resolvePanel();t&&(t.scrollTop=0);}}else this._animationsDisabled||(this._exitFallbackTimeout=setTimeout(()=>this._onAnimationDone(et),200));this._animationsDisabled&&setTimeout(()=>{this._onAnimationDone(e?mt:et);}),this._changeDetectorRef.markForCheck();}_updateDirectDescendants(){this._allItems.changes.pipe(bd(this._allItems)).subscribe(e=>{this._directDescendantItems.reset(e.filter(t=>t._parentMenu===this)),this._directDescendantItems.notifyOnChanges();});}_resolvePanel(){let e=null;return this._directDescendantItems.length&&(e=this._directDescendantItems.first._getHostElement().closest('[role="menu"]')),e}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=Aw({type:n,selectors:[["mat-menu"]],contentQueries:function(t,o,a){if(t&1&&kg(a,Sn,5)(a,Be,5)(a,Be,4),t&2){let m;IC(m=wC())&&(o.lazyContent=m.first),IC(m=wC())&&(o._allItems=m),IC(m=wC())&&(o.items=m);}},viewQuery:function(t,o){if(t&1&&Fg(dr,5),t&2){let a;IC(a=wC())&&(o.templateRef=a.first);}},hostVars:3,hostBindings:function(t,o){t&2&&Cg("aria-label",null)("aria-labelledby",null)("aria-describedby",null);},inputs:{backdropClass:"backdropClass",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],xPosition:"xPosition",yPosition:"yPosition",overlapTrigger:[2,"overlapTrigger","overlapTrigger",YT],hasBackdrop:[2,"hasBackdrop","hasBackdrop",e=>e==null?null:YT(e)],panelClass:[0,"class","panelClass"],classList:"classList"},outputs:{closed:"closed",close:"close"},exportAs:["matMenu"],features:[nT([{provide:pt,useExisting:n}])],ngContentSelectors:ri,decls:1,vars:0,consts:[["tabindex","-1","role","menu",1,"mat-mdc-menu-panel",3,"click","animationstart","animationend","animationcancel","id"],[1,"mat-mdc-menu-content"]],template:function(t,o){t&1&&(vC(),Eg(0,si,3,12,"ng-template"));},styles:[`mat-menu {
|
|
1
|
+
import {N as Ne,u as ui$1,a as me,f as fi$1,Y as Yt,V as Ve$1,n as ne}from'./chunk-C8P9SuaA.js';import {g,az as Qt,aQ as As,aY as ks,al as yt$1,A as Aw,o as bg,v as vs,q as oC,k as fl,T as TC,r as Tg,X as XE,x as iC,D as Fg,I as IC,E as wC,j as Gn$1,l as Ag,W as WC,b_ as FC,C as Cg,a8 as Zg,O as Ot,w as we,cJ as yB,ca as mB,H as Hi$1,m as mT,b as U,bz as vC,bA as DC,ad as Vg,y as Hg,aw as pl,b5 as Sg,ax as hl,n as eC,t as tC,cb as gB,cq as vB,cc as Hf,cu as Lg,cv as CC,cd as Sb,af as Dg,an as ce,cK as Id,cL as Nd,bR as ma,S as ha,cI as Rg,b$ as Ng,cM as Rn$1,aK as Do$1,aL as qn$1,bq as sn,bC as ge,aN as wt$1,bD as vt,br as Cl,bK as pe,aR as K,cN as is,a as P,aS as Ut,cO as Bt,bQ as bd,bO as Yy,bt as Ve,c1 as ME,z as z$1,aZ as YT,bH as Eg,b4 as nT,aV as w,bu as kg,aU as U$1,bv as St,aW as D,bw as on,by as Oi$1,bE as X,cP as q,cQ as X$1,ac as mC,a9 as dC,aa as If,ab as wf,a5 as yl,cR as Yt$1,cS as Gp,bL as mr,aO as G,ae as Ot$1,aA as sn$1,bV as Y,cT as pi,cU as yg,aC as Cu,bx as am,cA as on$1,c7 as QT,ah as rT,a4 as rC,c8 as kf,bs as Qn$2,ap as Vy,bW as Pt,bY as X$2,bZ as xt,cV as YI,cC as Ce,a3 as HI,a6 as $I,bn as nC,c2 as kt,bI as dr,a_ as XC,b3 as oT,a$ as Yg,cg as Mg,cW as yr,cX as tt$1,aX as ft$1,cy as Xr,ag as fT}from'./main-MB7Y2AR2.js';import {w as wt,j as Yn$1,k as _t$1,n as ni,l as Xn$1,E as En$1,z as ze,Q as Qn$1,e as ei,Y as Ye,f as fn,a as wt$2,A as At,Z as Zn$1,C as Cn}from'./chunk-jg8IIJti.js';var ii=[[["mat-icon"],["","matMenuItemIcon",""]],"*"],oi=["mat-icon, [matMenuItemIcon]","*"];function ai(n,i){n&1&&(kf(),vs(0,"svg",2),bg(1,"polygon",3),fl());}var ri=["*"];function si(n,i){if(n&1){let e=dC();pl(0,"div",0),Rg("click",function(){If(e);let o=mC();return wf(o.closed.emit("click"))})("animationstart",function(o){If(e);let a=mC();return wf(a._onAnimationStart(o.animationName))})("animationend",function(o){If(e);let a=mC();return wf(a._onAnimationDone(o.animationName))})("animationcancel",function(o){If(e);let a=mC();return wf(a._onAnimationDone(o.animationName))}),pl(1,"div",1),DC(2),hl()();}if(n&2){let e=mC();FC(e._classList),Hg("mat-menu-panel-animations-disabled",e._animationsDisabled)("mat-menu-panel-exit-animation",e._panelAnimationState==="void")("mat-menu-panel-animating",e._isAnimating()),Ng("id",e.panelId),Cg("aria-label",e.ariaLabel||null)("aria-labelledby",e.ariaLabelledby||null)("aria-describedby",e.ariaDescribedby||null);}}var pt=new w("MAT_MENU_PANEL"),Be=(()=>{class n{_elementRef=g(Qt);_document=g(U$1);_focusMonitor=g(St);_parentMenu=g(pt,{optional:true});_changeDetectorRef=g(Cl);role="menuitem";disabled=false;disableRipple=false;_hovered=new ce;_focused=new ce;_highlighted=false;_triggersSubmenu=false;constructor(){g(D).load(on),this._parentMenu?.addItem?.(this);}focus(e,t){this._focusMonitor&&e?this._focusMonitor.focusVia(this._getHostElement(),e,t):this._getHostElement().focus(t),this._focused.next(this);}ngAfterViewInit(){this._focusMonitor&&this._focusMonitor.monitor(this._elementRef,false);}ngOnDestroy(){this._focusMonitor&&this._focusMonitor.stopMonitoring(this._elementRef),this._parentMenu&&this._parentMenu.removeItem&&this._parentMenu.removeItem(this),this._hovered.complete(),this._focused.complete();}_getTabIndex(){return this.disabled?"-1":"0"}_getHostElement(){return this._elementRef.nativeElement}_checkDisabled(e){this.disabled&&(e.preventDefault(),e.stopPropagation());}_handleMouseEnter(){this._hovered.next(this);}getLabel(){let e=this._elementRef.nativeElement.cloneNode(true),t=e.querySelectorAll("mat-icon, .material-icons");for(let o=0;o<t.length;o++)t[o].remove();return e.textContent?.trim()||""}_setHighlighted(e){this._highlighted=e,this._changeDetectorRef.markForCheck();}_setTriggersSubmenu(e){this._triggersSubmenu=e,this._changeDetectorRef.markForCheck();}_hasFocus(){return this._document&&this._document.activeElement===this._getHostElement()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=Aw({type:n,selectors:[["","mat-menu-item",""]],hostAttrs:[1,"mat-mdc-menu-item","mat-focus-indicator"],hostVars:8,hostBindings:function(t,o){t&1&&Ag("click",function(m){return o._checkDisabled(m)})("mouseenter",function(){return o._handleMouseEnter()}),t&2&&(Cg("role",o.role)("tabindex",o._getTabIndex())("aria-disabled",o.disabled)("disabled",o.disabled||null),Hg("mat-mdc-menu-item-highlighted",o._highlighted)("mat-mdc-menu-item-submenu-trigger",o._triggersSubmenu));},inputs:{role:"role",disabled:[2,"disabled","disabled",YT],disableRipple:[2,"disableRipple","disableRipple",YT]},exportAs:["matMenuItem"],ngContentSelectors:oi,decls:5,vars:3,consts:[[1,"mat-mdc-menu-item-text"],["matRipple","",1,"mat-mdc-menu-ripple",3,"matRippleDisabled","matRippleTrigger"],["viewBox","0 0 5 10","focusable","false","aria-hidden","true",1,"mat-mdc-menu-submenu-icon"],["points","0,0 5,5 0,10"]],template:function(t,o){t&1&&(vC(ii),DC(0),vs(1,"span",0),DC(2,1),fl(),bg(3,"div",1),eC(4,ai,2,0,":svg:svg",2)),t&2&&(XE(3),Tg("matRippleDisabled",o.disableRipple||o.disabled)("matRippleTrigger",o._getHostElement()),XE(),tC(o._triggersSubmenu?4:-1));},dependencies:[Oi$1],encapsulation:2})}return n})();var Sn=new w("MatMenuContent"),ya=(()=>{class n{_template=g(dr);_appRef=g(yr);_injector=g(pe);_viewContainerRef=g(mr);_document=g(U$1);_changeDetectorRef=g(Cl);_portal;_outlet;_attached=new ce;attach(e={}){this._portal||(this._portal=new Y(this._template,this._viewContainerRef)),this.detach(),this._outlet||(this._outlet=new tt$1(this._document.createElement("div"),this._appRef,this._injector));let t=this._template.elementRef.nativeElement;t.parentNode.insertBefore(this._outlet.outletElement,t),this._changeDetectorRef.markForCheck(),this._portal.attach(this._outlet,e),this._attached.next();}detach(){this._portal?.isAttached&&this._portal.detach();}ngOnDestroy(){this.detach(),this._outlet?.dispose();}static \u0275fac=function(t){return new(t||n)};static \u0275dir=ks({type:n,selectors:[["ng-template","matMenuContent",""]],features:[nT([{provide:Sn,useExisting:n}])]})}return n})(),li=new w("mat-menu-default-options",{providedIn:"root",factory:()=>({overlapTrigger:false,xPosition:"after",yPosition:"below",backdropClass:"cdk-overlay-transparent-backdrop"})}),mt="_mat-menu-enter",et="_mat-menu-exit",De=(()=>{class n{_elementRef=g(Qt);_changeDetectorRef=g(Cl);_injector=g(pe);_keyManager;_xPosition;_yPosition;_firstItemFocusRef;_exitFallbackTimeout;_animationsDisabled=K();_allItems;_directDescendantItems=new is;_classList={};_panelAnimationState="void";_animationDone=new ce;_isAnimating=Hi$1(false);parentMenu;direction;overlayPanelClass;backdropClass;ariaLabel;ariaLabelledby;ariaDescribedby;get xPosition(){return this._xPosition}set xPosition(e){this._xPosition=e,this.setPositionClasses();}get yPosition(){return this._yPosition}set yPosition(e){this._yPosition=e,this.setPositionClasses();}templateRef;items;lazyContent;overlapTrigger=false;hasBackdrop;get panelClass(){return this._previousPanelClass}set panelClass(e){let t=this._previousPanelClass,o=P({},this._classList);t&&t.length&&t.split(" ").forEach(a=>{o[a]=false;}),this._previousPanelClass=e,e&&e.length&&(e.split(" ").forEach(a=>{o[a]=true;}),this._elementRef.nativeElement.className=""),this._classList=o;}_previousPanelClass="";get classList(){return this.panelClass}set classList(e){this.panelClass=e;}closed=new yt$1;close=this.closed;panelId=g(Ut).getId("mat-menu-panel-");constructor(){let e=g(li);this.overlayPanelClass=e.overlayPanelClass||"",this._xPosition=e.xPosition,this._yPosition=e.yPosition,this.backdropClass=e.backdropClass,this.overlapTrigger=e.overlapTrigger,this.hasBackdrop=e.hasBackdrop;}ngOnInit(){this.setPositionClasses();}ngAfterContentInit(){this._updateDirectDescendants(),this._keyManager=new Bt(this._directDescendantItems).withWrap().withTypeAhead().withHomeAndEnd(),this._keyManager.tabOut.subscribe(()=>this.closed.emit("tab")),this._directDescendantItems.changes.pipe(bd(this._directDescendantItems),ma(e=>Yy(...e.map(t=>t._focused)))).subscribe(e=>this._keyManager.updateActiveItem(e)),this._directDescendantItems.changes.subscribe(e=>{let t=this._keyManager;if(this._panelAnimationState==="enter"&&t.activeItem?._hasFocus()){let o=e.toArray(),a=Math.max(0,Math.min(o.length-1,t.activeItemIndex||0));o[a]&&!o[a].disabled?t.setActiveItem(a):t.setNextItemActive();}});}ngOnDestroy(){this._keyManager?.destroy(),this._directDescendantItems.destroy(),this.closed.complete(),this._firstItemFocusRef?.destroy(),clearTimeout(this._exitFallbackTimeout);}_hovered(){return this._directDescendantItems.changes.pipe(bd(this._directDescendantItems),ma(t=>Yy(...t.map(o=>o._hovered))))}addItem(e){}removeItem(e){}_handleKeydown(e){let t=e.keyCode,o=this._keyManager;switch(t){case 27:Ve(e)||(e.preventDefault(),this.closed.emit("keydown"));break;case 37:this.parentMenu&&this.direction==="ltr"&&this.closed.emit("keydown");break;case 39:this.parentMenu&&this.direction==="rtl"&&this.closed.emit("keydown");break;default:(t===38||t===40)&&o.setFocusOrigin("keyboard"),o.onKeydown(e);return}}focusFirstItem(e="program"){this._firstItemFocusRef?.destroy(),this._firstItemFocusRef=ME(()=>{let t=this._resolvePanel();if(!t||!t.contains(document.activeElement)){let o=this._keyManager;o.setFocusOrigin(e).setFirstItemActive(),!o.activeItem&&t&&t.focus();}},{injector:this._injector});}resetActiveItem(){this._keyManager.setActiveItem(-1);}setElevation(e){}setPositionClasses(e=this.xPosition,t=this.yPosition){this._classList=z$1(P({},this._classList),{"mat-menu-before":e==="before","mat-menu-after":e==="after","mat-menu-above":t==="above","mat-menu-below":t==="below"}),this._changeDetectorRef.markForCheck();}_onAnimationDone(e){let t=e===et;(t||e===mt)&&(t&&(clearTimeout(this._exitFallbackTimeout),this._exitFallbackTimeout=void 0),this._animationDone.next(t?"void":"enter"),this._isAnimating.set(false));}_onAnimationStart(e){(e===mt||e===et)&&this._isAnimating.set(true);}_setIsOpen(e){if(this._panelAnimationState=e?"enter":"void",e){if(this._keyManager.activeItemIndex===0){let t=this._resolvePanel();t&&(t.scrollTop=0);}}else this._animationsDisabled||(this._exitFallbackTimeout=setTimeout(()=>this._onAnimationDone(et),200));this._animationsDisabled&&setTimeout(()=>{this._onAnimationDone(e?mt:et);}),this._changeDetectorRef.markForCheck();}_updateDirectDescendants(){this._allItems.changes.pipe(bd(this._allItems)).subscribe(e=>{this._directDescendantItems.reset(e.filter(t=>t._parentMenu===this)),this._directDescendantItems.notifyOnChanges();});}_resolvePanel(){let e=null;return this._directDescendantItems.length&&(e=this._directDescendantItems.first._getHostElement().closest('[role="menu"]')),e}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=Aw({type:n,selectors:[["mat-menu"]],contentQueries:function(t,o,a){if(t&1&&kg(a,Sn,5)(a,Be,5)(a,Be,4),t&2){let m;IC(m=wC())&&(o.lazyContent=m.first),IC(m=wC())&&(o._allItems=m),IC(m=wC())&&(o.items=m);}},viewQuery:function(t,o){if(t&1&&Fg(dr,5),t&2){let a;IC(a=wC())&&(o.templateRef=a.first);}},hostVars:3,hostBindings:function(t,o){t&2&&Cg("aria-label",null)("aria-labelledby",null)("aria-describedby",null);},inputs:{backdropClass:"backdropClass",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],xPosition:"xPosition",yPosition:"yPosition",overlapTrigger:[2,"overlapTrigger","overlapTrigger",YT],hasBackdrop:[2,"hasBackdrop","hasBackdrop",e=>e==null?null:YT(e)],panelClass:[0,"class","panelClass"],classList:"classList"},outputs:{closed:"closed",close:"close"},exportAs:["matMenu"],features:[nT([{provide:pt,useExisting:n}])],ngContentSelectors:ri,decls:1,vars:0,consts:[["tabindex","-1","role","menu",1,"mat-mdc-menu-panel",3,"click","animationstart","animationend","animationcancel","id"],[1,"mat-mdc-menu-content"]],template:function(t,o){t&1&&(vC(),Eg(0,si,3,12,"ng-template"));},styles:[`mat-menu {
|
|
2
2
|
display: none;
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {O}from'./chunk-B4dCdFY0.js';import {v}from'./chunk-DadtttYS.js';import {g,ao as V,G,w as we,H as Hi,F as F$1,db as ue$1,cc as Hf,b as U,A as Aw,v as vs,l as Ag,W as WC,k as fl,n as eC,X as XE,a8 as Zg,t as tC,a9 as dC,q as oC,a4 as rC,a3 as HI,o as bg,bn as nC,ac as mC,r as Tg,a6 as $I,x as iC,a5 as yl,cG as Xw,aa as If,ab as wf}from'./main-CPDUTNNG.js';import'./chunk-BitsLHDr.js';import {o as z,z as ze,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En,p as An,q as Ct,V as Vt}from'./chunk-BhpcAaX5.js';import'./chunk-DJrjyHGk.js';import'./chunk-ADAFVeSv.js';import'./chunk-q9vkXLSQ.js';import'./chunk-D1LCrMS_.js';function ce(a,r){a&1&&(vs(0,"p",5),WC(1,"Loading\u2026"),fl());}function me(a,r){if(a&1&&(vs(0,"label",30),bg(1,"input",31),HI(),vs(2,"span"),WC(3),fl()()),a&2){let e=r.$implicit,l=mC(3);XE(),Tg("formControl",l.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!l.isAdmin()),$I(),XE(2),Zg(e.label);}}function ue(a,r){if(a&1&&(vs(0,"fieldset",8)(1,"legend",24),WC(2,"Port\xE9e de la configuration"),fl(),oC(3,me,4,4,"label",30,Xw().trackByScope,true),fl()),a&2){let e=mC(2);Tg("disabled",e.isEditMode()),XE(3),iC(e.scopeOptions);}}function ve(a,r){if(a&1&&(vs(0,"option",13),WC(1),fl()),a&2){let e=r.$implicit;Tg("value",e),XE(),Zg(e);}}function fe(a,r){if(a&1){let e=dC();vs(0,"div",26),bg(1,"input",32),HI(),bg(2,"input",33),HI(),vs(3,"button",34),Ag("click",function(){let s=If(e).$index,f=mC(2);return wf(f.removeHeader(s))}),WC(4," \xD7 "),fl()();}if(a&2){let e=r.$index;Tg("formGroupName",e),XE(),$I(),XE(),$I();}}function _e(a,r){if(a&1){let e=dC();vs(0,"form",7),Ag("ngSubmit",function(){If(e);let s=mC();return wf(s.submit())}),eC(1,ue,5,1,"fieldset",8),vs(2,"div",9)(3,"label",10),WC(4,"API type "),vs(5,"span",11),WC(6,"*"),fl()(),vs(7,"select",12),oC(8,ve,2,2,"option",13,rC),fl(),HI(),fl(),vs(10,"div",9)(11,"label",14),WC(12,"Name "),vs(13,"span",11),WC(14,"*"),fl()(),bg(15,"input",15),HI(),fl(),vs(16,"div",9)(17,"label",16),WC(18,"Description"),fl(),bg(19,"input",17),HI(),fl(),vs(20,"div",9)(21,"label",18),WC(22,"Base URL"),fl(),bg(23,"input",19),HI(),fl(),vs(24,"div",9)(25,"label",20),WC(26,"API key"),fl(),bg(27,"input",21),HI(),fl(),vs(28,"div",22)(29,"div",23)(30,"span",24),WC(31,"Custom headers"),fl(),vs(32,"button",25),Ag("click",function(){If(e);let s=mC();return wf(s.addHeader())}),WC(33,"+ Add header"),fl()(),oC(34,fe,5,1,"div",26,nC),fl(),vs(36,"div",27)(37,"button",28),WC(38),fl(),vs(39,"button",29),Ag("click",function(){If(e);let s=mC();return wf(s.cancel())}),WC(40,"Cancel"),fl()()();}if(a&2){let e=mC();Tg("formGroup",e.form),XE(),tC(e.isPlatformMode?-1:1),XE(6),Tg("formControl",e.apiTypeControl),$I(),XE(),iC(e.apiTypeOptions),XE(7),Tg("formControl",e.nameControl),$I(),XE(4),Tg("formControl",e.descriptionControl),$I(),XE(4),Tg("formControl",e.baseUrlControl),$I(),XE(4),Tg("formControl",e.apiKeyControl),$I(),XE(),Tg("formArrayName","headers"),XE(6),iC(e.headersArray.controls),XE(3),Tg("disabled",e.form.invalid||e.isSubmitting()),XE(),yl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var ge=new Set(["namespace","userOnNs","userGlobal"]),F=Object.freeze({platform:"Configuration de niveau plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),se=class a{route=g(V);router=g(G);destroyRef=g(we);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Hi(true):F$1(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});apiTypeOptions=Object.values(ue$1);scopeOptions=[{value:"namespace",label:F.namespace},{value:"userOnNs",label:F.userOnNs},{value:"userGlobal",label:F.userGlobal}];form=new z({name:new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(null),apiType:new _t("OpenAI",{nonNullable:true,validators:[_e$1.required]}),baseUrl:new _t("",{nonNullable:true}),apiKey:new _t("",{nonNullable:true}),scope:new _t("namespace",{nonNullable:true}),headers:new ze([],{validators:[]})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get apiTypeControl(){return this.form.controls.apiType}get baseUrlControl(){return this.form.controls.baseUrl}get apiKeyControl(){return this.form.controls.apiKey}get scopeControl(){return this.form.controls.scope}get headersArray(){return this.form.controls.headers}addHeader(){this.headersArray.push(new z({key:new _t("",{nonNullable:true,validators:[_e$1.required]}),value:new _t("",{nonNullable:true})}));}removeHeader(r){this.headersArray.removeAt(r);}isEditMode=Hi(false);isSubmitting=Hi(false);isLoading=Hi(false);existingConfig=null;initialApiKey="";constructor(){this.isPlatformMode||Hf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let r=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,l=r.get("aiProviderId"),s=this.isPlatformMode?"namespace":this.parseScope(e.get("scope"));if(l){this.isEditMode.set(true),this.scopeControl.disable(),this.apiTypeControl.disable(),this.loadConfig(l);return}this.scopeControl.setValue(s);let f=e.get("template");f&&this.hydrateFromTemplate(f);}parseScope(r){return r&&ge.has(r)?r:"namespace"}deriveScopeFromConfig(r){return !r.userId?"namespace":r.namespaceId?"userOnNs":"userGlobal"}loadConfig(r){this.isLoading.set(true),this.state.getById(r).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AiProviderForm] Could not load provider '${r}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(r){this.isLoading.set(true),this.state.getById(r).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.apiTypeControl.setValue(e.apiType),this.baseUrlControl.setValue(e.baseUrl??""),this.apiKeyControl.setValue(""),this.initialApiKey="",this.apiKeyControl.markAsTouched(),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AiProviderForm] Could not hydrate from template ${r}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(r){this.nameControl.setValue(r.name),this.descriptionControl.setValue(r.description??null),this.apiTypeControl.setValue(r.apiType),this.baseUrlControl.setValue(r.baseUrl??"");let e=r.apiKey??"";this.apiKeyControl.setValue(e),this.initialApiKey=e,this.headersArray.clear();for(let[l,s]of Object.entries(r.headers??{}))this.headersArray.push(new z({key:new _t(l,{nonNullable:true,validators:[_e$1.required]}),value:new _t(s,{nonNullable:true})}));}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let r=this.descriptionControl.value?.trim(),e=this.baseUrlControl.value.trim(),l=this.apiKeyControl.value,s=this.isEditMode()&&l===this.initialApiKey?null:l,f=this.headersArray.controls.filter(x=>x.controls.key.value.trim()).map(x=>[x.controls.key.value.trim(),x.controls.value.value]),de=f.length>0?Object.fromEntries(f):null,N={name:this.nameControl.value.trim(),apiType:this.apiTypeControl.value,description:r||null,baseUrl:e||null,apiKey:s,headers:de},T=this.form.getRawValue().scope,pe=this.isPlatformMode?null:this.namespaceId??null;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,N,T,this.existingConfig):this.state.create(N,T,pe)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-providers"]):this.router.navigate(["/agentos",this.namespaceId,"ai-providers"]);}trackByScope(r,e){return e.value}static \u0275fac=function(e){return new(e||a)};static \u0275cmp=Aw({type:a,selectors:[["agentos-ai-provider-form"]],decls:10,vars:2,consts:[[1,"ai-provider-form"],[1,"ai-provider-form__header"],["type","button","title","Back to AI providers",1,"ai-provider-form__back",3,"click"],[1,"ai-provider-form__back-icon"],[1,"ai-provider-form__title"],[1,"ai-provider-form__loading"],[1,"ai-provider-form__form",3,"formGroup"],[1,"ai-provider-form__form",3,"ngSubmit","formGroup"],[1,"ai-provider-form__scope",3,"disabled"],[1,"ai-provider-form__field"],["for","llm-api-type",1,"ai-provider-form__label"],["aria-hidden","true"],["id","llm-api-type",1,"ai-provider-form__select",3,"formControl"],[3,"value"],["for","llm-name",1,"ai-provider-form__label"],["id","llm-name","type","text","placeholder","e.g. OpenAI prod","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-description",1,"ai-provider-form__label"],["id","llm-description","type","text","placeholder","Optional \u2014 short description of this provider","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-base-url",1,"ai-provider-form__label"],["id","llm-base-url","type","url","placeholder","Optional \u2014 leave empty for default endpoint","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-api-key",1,"ai-provider-form__label"],["id","llm-api-key","type","password","placeholder","sk-\u2026","autocomplete","new-password",1,"ai-provider-form__input","ai-provider-form__input--secret",3,"formControl"],[1,"ai-provider-form__headers",3,"formArrayName"],[1,"ai-provider-form__headers-title"],[1,"ai-provider-form__label"],["type","button",1,"ai-provider-form__headers-add",3,"click"],[1,"ai-provider-form__header-row",3,"formGroupName"],[1,"ai-provider-form__actions"],["type","submit",1,"ai-provider-form__btn","ai-provider-form__btn--primary",3,"disabled"],["type","button",1,"ai-provider-form__btn",3,"click"],[1,"ai-provider-form__scope-option"],["type","radio",3,"formControl","value","disabled"],["type","text","placeholder","Header name","formControlName","key","autocomplete","off",1,"ai-provider-form__input"],["type","text","placeholder","Value","formControlName","value","autocomplete","off",1,"ai-provider-form__input"],["type","button","title","Remove header","aria-label","Remove header",1,"ai-provider-form__header-remove",3,"click"]],template:function(e,l){e&1&&(vs(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return l.cancel()}),vs(3,"span",3),WC(4,"\u2190"),fl(),WC(5," AI Providers "),fl(),vs(6,"h1",4),WC(7),fl()(),eC(8,ce,2,0,"p",5)(9,_e,41,10,"form",6),fl()),e&2&&(XE(7),Zg(l.isEditMode()?"Edit AI provider":"New AI provider"),XE(),tC(l.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En,An,Ct,Vt],styles:[".ai-provider-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-provider-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;margin:0}.ai-provider-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.ai-provider-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;font-size:.85rem;color:var(--color-text);cursor:pointer}.ai-provider-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-provider-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-provider-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-provider-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-provider-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-provider-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-provider-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-provider-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-provider-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-provider-form__input[_ngcontent-%COMP%], .ai-provider-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-provider-form__input[_ngcontent-%COMP%]:focus, .ai-provider-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-provider-form__input[_ngcontent-%COMP%]::placeholder, .ai-provider-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-provider-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.ai-provider-form__headers[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-provider-form__headers-title[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between}.ai-provider-form__headers-add[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.8125rem;color:var(--color-accent)}.ai-provider-form__headers-add[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-provider-form__header-row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr auto;gap:.5rem;align-items:center}.ai-provider-form__header-remove[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;background:none;border:1px solid transparent;border-radius:0;cursor:pointer;font-size:1rem;color:var(--color-neutral-500);transition:background .15s ease,color .15s ease,border-color .15s ease;flex-shrink:0}.ai-provider-form__header-remove[_ngcontent-%COMP%]:hover{color:var(--red);background:color-mix(in srgb,var(--red) 10%,transparent);border-color:var(--red)}.ai-provider-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-provider-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-provider-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-provider-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-provider-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-provider-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{se as AiProviderFormComponent};
|
|
1
|
+
import {O}from'./chunk-MT0Figq0.js';import {v}from'./chunk-DvXqS7Sb.js';import {g,ao as V,G,w as we,H as Hi,F as F$1,db as ue$1,cc as Hf,b as U,A as Aw,v as vs,l as Ag,W as WC,k as fl,n as eC,X as XE,a8 as Zg,t as tC,a9 as dC,q as oC,a4 as rC,a3 as HI,o as bg,bn as nC,ac as mC,r as Tg,a6 as $I,x as iC,a5 as yl,cG as Xw,aa as If,ab as wf}from'./main-MB7Y2AR2.js';import'./chunk-CinHjHqk.js';import {o as z,z as ze,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En,p as An,q as Ct,V as Vt}from'./chunk-jg8IIJti.js';import'./chunk-JSqlYB97.js';import'./chunk-ciSHZI2F.js';import'./chunk-Dg1d1XBn.js';import'./chunk-C8P9SuaA.js';function ce(a,r){a&1&&(vs(0,"p",5),WC(1,"Loading\u2026"),fl());}function me(a,r){if(a&1&&(vs(0,"label",30),bg(1,"input",31),HI(),vs(2,"span"),WC(3),fl()()),a&2){let e=r.$implicit,l=mC(3);XE(),Tg("formControl",l.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!l.isAdmin()),$I(),XE(2),Zg(e.label);}}function ue(a,r){if(a&1&&(vs(0,"fieldset",8)(1,"legend",24),WC(2,"Port\xE9e de la configuration"),fl(),oC(3,me,4,4,"label",30,Xw().trackByScope,true),fl()),a&2){let e=mC(2);Tg("disabled",e.isEditMode()),XE(3),iC(e.scopeOptions);}}function ve(a,r){if(a&1&&(vs(0,"option",13),WC(1),fl()),a&2){let e=r.$implicit;Tg("value",e),XE(),Zg(e);}}function fe(a,r){if(a&1){let e=dC();vs(0,"div",26),bg(1,"input",32),HI(),bg(2,"input",33),HI(),vs(3,"button",34),Ag("click",function(){let s=If(e).$index,f=mC(2);return wf(f.removeHeader(s))}),WC(4," \xD7 "),fl()();}if(a&2){let e=r.$index;Tg("formGroupName",e),XE(),$I(),XE(),$I();}}function _e(a,r){if(a&1){let e=dC();vs(0,"form",7),Ag("ngSubmit",function(){If(e);let s=mC();return wf(s.submit())}),eC(1,ue,5,1,"fieldset",8),vs(2,"div",9)(3,"label",10),WC(4,"API type "),vs(5,"span",11),WC(6,"*"),fl()(),vs(7,"select",12),oC(8,ve,2,2,"option",13,rC),fl(),HI(),fl(),vs(10,"div",9)(11,"label",14),WC(12,"Name "),vs(13,"span",11),WC(14,"*"),fl()(),bg(15,"input",15),HI(),fl(),vs(16,"div",9)(17,"label",16),WC(18,"Description"),fl(),bg(19,"input",17),HI(),fl(),vs(20,"div",9)(21,"label",18),WC(22,"Base URL"),fl(),bg(23,"input",19),HI(),fl(),vs(24,"div",9)(25,"label",20),WC(26,"API key"),fl(),bg(27,"input",21),HI(),fl(),vs(28,"div",22)(29,"div",23)(30,"span",24),WC(31,"Custom headers"),fl(),vs(32,"button",25),Ag("click",function(){If(e);let s=mC();return wf(s.addHeader())}),WC(33,"+ Add header"),fl()(),oC(34,fe,5,1,"div",26,nC),fl(),vs(36,"div",27)(37,"button",28),WC(38),fl(),vs(39,"button",29),Ag("click",function(){If(e);let s=mC();return wf(s.cancel())}),WC(40,"Cancel"),fl()()();}if(a&2){let e=mC();Tg("formGroup",e.form),XE(),tC(e.isPlatformMode?-1:1),XE(6),Tg("formControl",e.apiTypeControl),$I(),XE(),iC(e.apiTypeOptions),XE(7),Tg("formControl",e.nameControl),$I(),XE(4),Tg("formControl",e.descriptionControl),$I(),XE(4),Tg("formControl",e.baseUrlControl),$I(),XE(4),Tg("formControl",e.apiKeyControl),$I(),XE(),Tg("formArrayName","headers"),XE(6),iC(e.headersArray.controls),XE(3),Tg("disabled",e.form.invalid||e.isSubmitting()),XE(),yl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var ge=new Set(["namespace","userOnNs","userGlobal"]),F=Object.freeze({platform:"Configuration de niveau plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),se=class a{route=g(V);router=g(G);destroyRef=g(we);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Hi(true):F$1(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});apiTypeOptions=Object.values(ue$1);scopeOptions=[{value:"namespace",label:F.namespace},{value:"userOnNs",label:F.userOnNs},{value:"userGlobal",label:F.userGlobal}];form=new z({name:new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]}),description:new _t(null),apiType:new _t("OpenAI",{nonNullable:true,validators:[_e$1.required]}),baseUrl:new _t("",{nonNullable:true}),apiKey:new _t("",{nonNullable:true}),scope:new _t("namespace",{nonNullable:true}),headers:new ze([],{validators:[]})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get apiTypeControl(){return this.form.controls.apiType}get baseUrlControl(){return this.form.controls.baseUrl}get apiKeyControl(){return this.form.controls.apiKey}get scopeControl(){return this.form.controls.scope}get headersArray(){return this.form.controls.headers}addHeader(){this.headersArray.push(new z({key:new _t("",{nonNullable:true,validators:[_e$1.required]}),value:new _t("",{nonNullable:true})}));}removeHeader(r){this.headersArray.removeAt(r);}isEditMode=Hi(false);isSubmitting=Hi(false);isLoading=Hi(false);existingConfig=null;initialApiKey="";constructor(){this.isPlatformMode||Hf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let r=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,l=r.get("aiProviderId"),s=this.isPlatformMode?"namespace":this.parseScope(e.get("scope"));if(l){this.isEditMode.set(true),this.scopeControl.disable(),this.apiTypeControl.disable(),this.loadConfig(l);return}this.scopeControl.setValue(s);let f=e.get("template");f&&this.hydrateFromTemplate(f);}parseScope(r){return r&&ge.has(r)?r:"namespace"}deriveScopeFromConfig(r){return !r.userId?"namespace":r.namespaceId?"userOnNs":"userGlobal"}loadConfig(r){this.isLoading.set(true),this.state.getById(r).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AiProviderForm] Could not load provider '${r}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(r){this.isLoading.set(true),this.state.getById(r).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.apiTypeControl.setValue(e.apiType),this.baseUrlControl.setValue(e.baseUrl??""),this.apiKeyControl.setValue(""),this.initialApiKey="",this.apiKeyControl.markAsTouched(),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AiProviderForm] Could not hydrate from template ${r}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(r){this.nameControl.setValue(r.name),this.descriptionControl.setValue(r.description??null),this.apiTypeControl.setValue(r.apiType),this.baseUrlControl.setValue(r.baseUrl??"");let e=r.apiKey??"";this.apiKeyControl.setValue(e),this.initialApiKey=e,this.headersArray.clear();for(let[l,s]of Object.entries(r.headers??{}))this.headersArray.push(new z({key:new _t(l,{nonNullable:true,validators:[_e$1.required]}),value:new _t(s,{nonNullable:true})}));}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let r=this.descriptionControl.value?.trim(),e=this.baseUrlControl.value.trim(),l=this.apiKeyControl.value,s=this.isEditMode()&&l===this.initialApiKey?null:l,f=this.headersArray.controls.filter(x=>x.controls.key.value.trim()).map(x=>[x.controls.key.value.trim(),x.controls.value.value]),de=f.length>0?Object.fromEntries(f):null,N={name:this.nameControl.value.trim(),apiType:this.apiTypeControl.value,description:r||null,baseUrl:e||null,apiKey:s,headers:de},T=this.form.getRawValue().scope,pe=this.isPlatformMode?null:this.namespaceId??null;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,N,T,this.existingConfig):this.state.create(N,T,pe)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-providers"]):this.router.navigate(["/agentos",this.namespaceId,"ai-providers"]);}trackByScope(r,e){return e.value}static \u0275fac=function(e){return new(e||a)};static \u0275cmp=Aw({type:a,selectors:[["agentos-ai-provider-form"]],decls:10,vars:2,consts:[[1,"ai-provider-form"],[1,"ai-provider-form__header"],["type","button","title","Back to AI providers",1,"ai-provider-form__back",3,"click"],[1,"ai-provider-form__back-icon"],[1,"ai-provider-form__title"],[1,"ai-provider-form__loading"],[1,"ai-provider-form__form",3,"formGroup"],[1,"ai-provider-form__form",3,"ngSubmit","formGroup"],[1,"ai-provider-form__scope",3,"disabled"],[1,"ai-provider-form__field"],["for","llm-api-type",1,"ai-provider-form__label"],["aria-hidden","true"],["id","llm-api-type",1,"ai-provider-form__select",3,"formControl"],[3,"value"],["for","llm-name",1,"ai-provider-form__label"],["id","llm-name","type","text","placeholder","e.g. OpenAI prod","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-description",1,"ai-provider-form__label"],["id","llm-description","type","text","placeholder","Optional \u2014 short description of this provider","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-base-url",1,"ai-provider-form__label"],["id","llm-base-url","type","url","placeholder","Optional \u2014 leave empty for default endpoint","autocomplete","off",1,"ai-provider-form__input",3,"formControl"],["for","llm-api-key",1,"ai-provider-form__label"],["id","llm-api-key","type","password","placeholder","sk-\u2026","autocomplete","new-password",1,"ai-provider-form__input","ai-provider-form__input--secret",3,"formControl"],[1,"ai-provider-form__headers",3,"formArrayName"],[1,"ai-provider-form__headers-title"],[1,"ai-provider-form__label"],["type","button",1,"ai-provider-form__headers-add",3,"click"],[1,"ai-provider-form__header-row",3,"formGroupName"],[1,"ai-provider-form__actions"],["type","submit",1,"ai-provider-form__btn","ai-provider-form__btn--primary",3,"disabled"],["type","button",1,"ai-provider-form__btn",3,"click"],[1,"ai-provider-form__scope-option"],["type","radio",3,"formControl","value","disabled"],["type","text","placeholder","Header name","formControlName","key","autocomplete","off",1,"ai-provider-form__input"],["type","text","placeholder","Value","formControlName","value","autocomplete","off",1,"ai-provider-form__input"],["type","button","title","Remove header","aria-label","Remove header",1,"ai-provider-form__header-remove",3,"click"]],template:function(e,l){e&1&&(vs(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return l.cancel()}),vs(3,"span",3),WC(4,"\u2190"),fl(),WC(5," AI Providers "),fl(),vs(6,"h1",4),WC(7),fl()(),eC(8,ce,2,0,"p",5)(9,_e,41,10,"form",6),fl()),e&2&&(XE(7),Zg(l.isEditMode()?"Edit AI provider":"New AI provider"),XE(),tC(l.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En,An,Ct,Vt],styles:[".ai-provider-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-provider-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;margin:0}.ai-provider-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.ai-provider-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;font-size:.85rem;color:var(--color-text);cursor:pointer}.ai-provider-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-provider-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-provider-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-provider-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-provider-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-provider-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-provider-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-provider-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-provider-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-provider-form__input[_ngcontent-%COMP%], .ai-provider-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-provider-form__input[_ngcontent-%COMP%]:focus, .ai-provider-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-provider-form__input[_ngcontent-%COMP%]::placeholder, .ai-provider-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-provider-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.ai-provider-form__headers[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-provider-form__headers-title[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between}.ai-provider-form__headers-add[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.8125rem;color:var(--color-accent)}.ai-provider-form__headers-add[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-provider-form__header-row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr auto;gap:.5rem;align-items:center}.ai-provider-form__header-remove[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;background:none;border:1px solid transparent;border-radius:0;cursor:pointer;font-size:1rem;color:var(--color-neutral-500);transition:background .15s ease,color .15s ease,border-color .15s ease;flex-shrink:0}.ai-provider-form__header-remove[_ngcontent-%COMP%]:hover{color:var(--red);background:color-mix(in srgb,var(--red) 10%,transparent);border-color:var(--red)}.ai-provider-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-provider-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-provider-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-provider-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-provider-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-provider-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{se as AiProviderFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {g,bl as Sm,H as Hi,m as mT,cE as Fb,A as Aw,i as hr,j as Gn,v as vs,l as Ag,W as WC,k as fl,a3 as HI,n as eC,X as XE,r as Tg,a6 as $I,t as tC,w as we$1,z as z$1,a as P,Q as By,b as U,Y as x,b0 as An,be as aT,ac as mC,a8 as Zg,bh as lT,cF as dT,q as oC,cG as Xw,o as bg,x as iC,J as dy,cH as Nt,aw as pl,ax as hl,c8 as kf,b5 as Sg,cj as Ff,C as Cg,a5 as yl,a9 as dC,cI as Rg,aa as If,ab as wf,ad as Vg}from'./main-CPDUTNNG.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-BhpcAaX5.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(pl(0,"div",0),WC(1,"No daily data points for this period."),hl());}function Le(o,t){if(o&1&&(kf(),Sg(0,"rect",18)),o&2){let e=mC().$implicit,n=mC(2);Cg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),Sg(0,"rect",19)(1,"rect",20)),o&2){let e=mC().$implicit,n=mC(2);Cg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Cg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=dC();kf(),pl(0,"g",15),Rg("mouseenter",function(i){let d=If(e).$implicit,u=mC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=mC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=mC(2);return wf(i.hideTooltip())}),Sg(1,"rect",16)(2,"rect",17),eC(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),hl();}if(o&2){let e=t.$implicit,n=mC(2);Cg("transform","translate("+e.xGroup+",0)"),XE(),Cg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Cg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),tC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),pl(0,"text",5),WC(1),hl()),o&2){let e=t.$implicit,n=mC(2);Cg("x",e.x)("y",n.yAxis),XE(),Zg(e.label);}}function je(o,t){if(o&1&&(pl(0,"div",24),WC(1),hl(),pl(2,"div",25),WC(3),hl()),o&2){let e=t.$implicit;XE(),Zg(e.label),XE(2),Zg(e.value);}}function ze(o,t){if(o&1&&(pl(0,"div",21)(1,"div",22),WC(2),hl(),pl(3,"div",23),oC(4,je,4,2,null,null,$e),hl()()),o&2){let e=mC(2);Vg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Zg(e.tooltip().data.date),XE(2),iC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(pl(0,"div",8)(1,"span",10),WC(2),hl()()),o&2){let e=mC(2);XE(2),Zg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(pl(0,"div",1),kf(),pl(1,"svg",2),Sg(2,"line",3)(3,"line",3),oC(4,Ye,5,8,":svg:g",4,Ae),oC(6,We,2,3,":svg:text",5,He),hl(),eC(8,ze,6,5,"div",6),Ff(),pl(9,"div",7)(10,"div",8),Sg(11,"span",9),pl(12,"span",10),WC(13,"Cost (per day)"),hl(),pl(14,"span",11),WC(15),hl()(),pl(16,"div",8),Sg(17,"span",12),pl(18,"span",10),WC(19,"Prompt tokens"),hl()(),pl(20,"div",8),Sg(21,"span",13),pl(22,"span",10),WC(23,"Completion tokens"),hl()(),pl(24,"div",8),Sg(25,"span",14),pl(26,"span",10),WC(27,"Tokens missing"),hl()(),pl(28,"div",8)(29,"span",10),WC(30,"Tokens scale"),hl(),pl(31,"span",11),WC(32),hl()(),eC(33,Xe,3,1,"div",8),hl()()),o&2){let e=mC();XE(),Cg("viewBox",e.viewBox),XE(),Cg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Cg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),iC(e.bars()),XE(2),iC(e.axisLabels()),XE(2),tC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),yl("max ",e.maxCostLabel()),XE(17),yl("max ",e.maxTokensLabel()),XE(),tC(e.tokenCoverageLabel()?33:-1);}}var j=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=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{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=mT(()=>{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=mT(()=>"$"+(new Fb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Fb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Hi({visible:false,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,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>z$1(P({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Fb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Fb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{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=mT(()=>{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),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{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=Aw({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&&eC(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&tC(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))}"]})};var X=class o{http=g(dy);getTokenUsage(t){let e=new Nt;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 Nt;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=x({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(we$1);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Hi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Hi({from:this.defaultFrom,to:this.defaultTo});loading=Hi(false);error=Hi(null);aggregation=Hi(null);seriesResponse=Hi(null);series=Hi(null);tokenDataPartial=Hi(false);aggregationByModelId=Hi(null);seriesByModelId=Hi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>z$1(P({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>z$1(P({},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(true),this.error.set(null),By({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(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(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),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=x({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=An({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=An({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(vs(0,"div",23),WC(1," Partial data \u2014 token counts may not cover the full period "),fl());}function Ze(o,t){o&1&&(vs(0,"div",24),WC(1," No token data collected for this period "),fl());}function et(o,t){if(o&1&&(vs(0,"div",19)(1,"div",20)(2,"div",21),WC(3,"Total tokens"),fl(),vs(4,"div",22),WC(5),aT(6,"call"),fl()(),vs(7,"div",20)(8,"div",21),WC(9,"Total calls"),fl(),vs(10,"div",22),WC(11),fl()(),vs(12,"div",20)(13,"div",21),WC(14,"Total cost"),fl(),vs(15,"div",22),WC(16),aT(17,"apply"),fl()()(),eC(18,Qe,2,0,"div",23),eC(19,Ze,2,0,"div",24)),o&2){let e=mC();XE(5),Zg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Zg(e.totalRow().callCount),XE(5),Zg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),tC(e.isPartialPeriod()?18:-1),XE(),tC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(vs(0,"div",16)(1,"div",25),WC(2,"Loading token usage\u2026"),fl()());}function nt(o,t){if(o&1&&(vs(0,"div",17)(1,"div",26),WC(2,"Failed to load"),fl(),vs(3,"div",25),WC(4),fl()()),o&2){let e=mC();XE(4),Zg(e.state.error());}}function ot(o,t){o&1&&(vs(0,"div",16)(1,"div",26),WC(2,"No data"),fl(),vs(3,"div",25),WC(4,"No token usage recorded yet for this period."),fl()());}function at(o,t){if(o&1&&(vs(0,"div",32)(1,"div",29),WC(2),fl(),vs(3,"div",29),WC(4),fl(),vs(5,"div",29),WC(6),fl(),vs(7,"div",30),WC(8),aT(9,"call"),fl(),vs(10,"div",30),WC(11),aT(12,"call"),fl(),vs(13,"div",30),WC(14),aT(15,"call"),fl(),vs(16,"div",30),WC(17),fl(),vs(18,"div",30),WC(19),aT(20,"apply"),fl()()),o&2){let e=t.$implicit,n=mC(2);XE(2),Zg(e.agentName),XE(2),Zg(e.providerName),XE(2),Zg(e.modelId),XE(2),Zg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Zg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Zg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Zg(e.callCount),XE(2),yl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(vs(0,"div",33)(1,"div",29),WC(2),fl(),vs(3,"div",29),WC(4),fl(),vs(5,"div",29),WC(6),fl(),vs(7,"div",30),WC(8),aT(9,"call"),fl(),vs(10,"div",30),WC(11),aT(12,"call"),fl(),vs(13,"div",30),WC(14),aT(15,"call"),fl(),vs(16,"div",30),WC(17),fl(),vs(18,"div",30),WC(19),aT(20,"apply"),fl()()),o&2){let e=mC(2);XE(2),Zg(e.totalRow().agentName),XE(2),Zg(e.totalRow().providerName),XE(2),Zg(e.totalRow().modelId),XE(2),Zg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),yl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Zg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Zg(e.totalRow().callCount),XE(2),yl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(vs(0,"div",18)(1,"section",16)(2,"div",26),WC(3,"Summary"),fl(),vs(4,"div",27)(5,"div",28)(6,"div",29),WC(7,"agentName"),fl(),vs(8,"div",29),WC(9,"providerName"),fl(),vs(10,"div",29),WC(11,"modelId"),fl(),vs(12,"div",30),WC(13,"promptTokens"),fl(),vs(14,"div",30),WC(15,"completionTokens"),fl(),vs(16,"div",30),WC(17,"totalTokens"),fl(),vs(18,"div",30),WC(19,"callCount"),fl(),vs(20,"div",30),WC(21,"cost"),fl()(),vs(22,"div",31),oC(23,at,21,21,"div",32,Xw().trackRow,true),eC(25,it,21,21,"div",33),fl()()(),vs(26,"section",16)(27,"div",26),WC(28,"Daily series"),fl(),bg(29,"app-daily-series-chart",34),fl()()),o&2){let e=mC();XE(23),iC(e.rows()),XE(2),tC(e.totalRow()?25:-1),XE(4),Tg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Sm);state=g(J);view=Hi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});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=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Fb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Fb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=Aw({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&&(vs(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Ag("click",function(){return n.navigateBack()}),vs(4,"mat-icon"),WC(5,"chevron_left"),fl()(),vs(6,"div")(7,"h1",4),WC(8,"Token Usage"),fl(),vs(9,"p",5),WC(10,"Track prompt and completion token usage by agent and model."),fl()()(),vs(11,"div",6)(12,"label",7)(13,"span",8),WC(14,"From"),fl(),vs(15,"div",9)(16,"input",10),Ag("ngModelChange",function(d){return n.onFromChange(d)}),fl(),HI(),vs(17,"button",11),Ag("click",function(){return n.clearFrom()}),WC(18," Clear "),fl()()(),vs(19,"label",7)(20,"span",8),WC(21,"To"),fl(),vs(22,"div",9)(23,"input",10),Ag("ngModelChange",function(d){return n.onToChange(d)}),fl(),HI(),vs(24,"button",11),Ag("click",function(){return n.clearTo()}),WC(25," Clear "),fl()()(),vs(26,"label",7)(27,"span",8),WC(28,"View"),fl(),vs(29,"select",12),Ag("ngModelChange",function(d){return n.view.set(d)}),vs(30,"option",13),WC(31,"By model"),fl(),vs(32,"option",14),WC(33,"By agent"),fl()(),HI(),fl(),vs(34,"button",15),Ag("click",function(){return n.apply()}),WC(35,"Apply"),fl()()(),eC(36,et,20,12),eC(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),fl()),e&2&&(XE(16),Tg("ngModel",n.state.draftFilters().from),$I(),XE(),Tg("disabled",!n.state.draftFilters().from),XE(6),Tg("ngModel",n.state.draftFilters().to),$I(),XE(),Tg("disabled",!n.state.draftFilters().to),XE(5),Tg("ngModel",n.view()),$I(),XE(5),Tg("disabled",n.state.loading()),XE(2),tC(n.totalRow()?36:-1),XE(),tC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,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}"],changeDetection:1})};export{Oe as TokenUsageComponent};
|
|
1
|
+
import {g,bl as Sm,H as Hi,m as mT,cE as Fb,A as Aw,i as hr,j as Gn,v as vs,l as Ag,W as WC,k as fl,a3 as HI,n as eC,X as XE,r as Tg,a6 as $I,t as tC,w as we$1,z as z$1,a as P,Q as By,b as U,Y as x,b0 as An,be as aT,ac as mC,a8 as Zg,bh as lT,cF as dT,q as oC,cG as Xw,o as bg,x as iC,J as dy,cH as Nt,aw as pl,ax as hl,c8 as kf,b5 as Sg,cj as Ff,C as Cg,a5 as yl,a9 as dC,cI as Rg,aa as If,ab as wf,ad as Vg}from'./main-MB7Y2AR2.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-jg8IIJti.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(pl(0,"div",0),WC(1,"No daily data points for this period."),hl());}function Le(o,t){if(o&1&&(kf(),Sg(0,"rect",18)),o&2){let e=mC().$implicit,n=mC(2);Cg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),Sg(0,"rect",19)(1,"rect",20)),o&2){let e=mC().$implicit,n=mC(2);Cg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Cg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=dC();kf(),pl(0,"g",15),Rg("mouseenter",function(i){let d=If(e).$implicit,u=mC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=mC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=mC(2);return wf(i.hideTooltip())}),Sg(1,"rect",16)(2,"rect",17),eC(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),hl();}if(o&2){let e=t.$implicit,n=mC(2);Cg("transform","translate("+e.xGroup+",0)"),XE(),Cg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Cg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),tC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),pl(0,"text",5),WC(1),hl()),o&2){let e=t.$implicit,n=mC(2);Cg("x",e.x)("y",n.yAxis),XE(),Zg(e.label);}}function je(o,t){if(o&1&&(pl(0,"div",24),WC(1),hl(),pl(2,"div",25),WC(3),hl()),o&2){let e=t.$implicit;XE(),Zg(e.label),XE(2),Zg(e.value);}}function ze(o,t){if(o&1&&(pl(0,"div",21)(1,"div",22),WC(2),hl(),pl(3,"div",23),oC(4,je,4,2,null,null,$e),hl()()),o&2){let e=mC(2);Vg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Zg(e.tooltip().data.date),XE(2),iC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(pl(0,"div",8)(1,"span",10),WC(2),hl()()),o&2){let e=mC(2);XE(2),Zg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(pl(0,"div",1),kf(),pl(1,"svg",2),Sg(2,"line",3)(3,"line",3),oC(4,Ye,5,8,":svg:g",4,Ae),oC(6,We,2,3,":svg:text",5,He),hl(),eC(8,ze,6,5,"div",6),Ff(),pl(9,"div",7)(10,"div",8),Sg(11,"span",9),pl(12,"span",10),WC(13,"Cost (per day)"),hl(),pl(14,"span",11),WC(15),hl()(),pl(16,"div",8),Sg(17,"span",12),pl(18,"span",10),WC(19,"Prompt tokens"),hl()(),pl(20,"div",8),Sg(21,"span",13),pl(22,"span",10),WC(23,"Completion tokens"),hl()(),pl(24,"div",8),Sg(25,"span",14),pl(26,"span",10),WC(27,"Tokens missing"),hl()(),pl(28,"div",8)(29,"span",10),WC(30,"Tokens scale"),hl(),pl(31,"span",11),WC(32),hl()(),eC(33,Xe,3,1,"div",8),hl()()),o&2){let e=mC();XE(),Cg("viewBox",e.viewBox),XE(),Cg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Cg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),iC(e.bars()),XE(2),iC(e.axisLabels()),XE(2),tC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),yl("max ",e.maxCostLabel()),XE(17),yl("max ",e.maxTokensLabel()),XE(),tC(e.tokenCoverageLabel()?33:-1);}}var j=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=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{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=mT(()=>{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=mT(()=>"$"+(new Fb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Fb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Hi({visible:false,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,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>z$1(P({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Fb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Fb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{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=mT(()=>{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),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{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=Aw({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&&eC(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&tC(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))}"]})};var X=class o{http=g(dy);getTokenUsage(t){let e=new Nt;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 Nt;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=x({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(we$1);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Hi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Hi({from:this.defaultFrom,to:this.defaultTo});loading=Hi(false);error=Hi(null);aggregation=Hi(null);seriesResponse=Hi(null);series=Hi(null);tokenDataPartial=Hi(false);aggregationByModelId=Hi(null);seriesByModelId=Hi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>z$1(P({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>z$1(P({},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(true),this.error.set(null),By({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(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(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),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=x({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=An({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=An({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(vs(0,"div",23),WC(1," Partial data \u2014 token counts may not cover the full period "),fl());}function Ze(o,t){o&1&&(vs(0,"div",24),WC(1," No token data collected for this period "),fl());}function et(o,t){if(o&1&&(vs(0,"div",19)(1,"div",20)(2,"div",21),WC(3,"Total tokens"),fl(),vs(4,"div",22),WC(5),aT(6,"call"),fl()(),vs(7,"div",20)(8,"div",21),WC(9,"Total calls"),fl(),vs(10,"div",22),WC(11),fl()(),vs(12,"div",20)(13,"div",21),WC(14,"Total cost"),fl(),vs(15,"div",22),WC(16),aT(17,"apply"),fl()()(),eC(18,Qe,2,0,"div",23),eC(19,Ze,2,0,"div",24)),o&2){let e=mC();XE(5),Zg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Zg(e.totalRow().callCount),XE(5),Zg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),tC(e.isPartialPeriod()?18:-1),XE(),tC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(vs(0,"div",16)(1,"div",25),WC(2,"Loading token usage\u2026"),fl()());}function nt(o,t){if(o&1&&(vs(0,"div",17)(1,"div",26),WC(2,"Failed to load"),fl(),vs(3,"div",25),WC(4),fl()()),o&2){let e=mC();XE(4),Zg(e.state.error());}}function ot(o,t){o&1&&(vs(0,"div",16)(1,"div",26),WC(2,"No data"),fl(),vs(3,"div",25),WC(4,"No token usage recorded yet for this period."),fl()());}function at(o,t){if(o&1&&(vs(0,"div",32)(1,"div",29),WC(2),fl(),vs(3,"div",29),WC(4),fl(),vs(5,"div",29),WC(6),fl(),vs(7,"div",30),WC(8),aT(9,"call"),fl(),vs(10,"div",30),WC(11),aT(12,"call"),fl(),vs(13,"div",30),WC(14),aT(15,"call"),fl(),vs(16,"div",30),WC(17),fl(),vs(18,"div",30),WC(19),aT(20,"apply"),fl()()),o&2){let e=t.$implicit,n=mC(2);XE(2),Zg(e.agentName),XE(2),Zg(e.providerName),XE(2),Zg(e.modelId),XE(2),Zg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Zg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Zg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Zg(e.callCount),XE(2),yl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(vs(0,"div",33)(1,"div",29),WC(2),fl(),vs(3,"div",29),WC(4),fl(),vs(5,"div",29),WC(6),fl(),vs(7,"div",30),WC(8),aT(9,"call"),fl(),vs(10,"div",30),WC(11),aT(12,"call"),fl(),vs(13,"div",30),WC(14),aT(15,"call"),fl(),vs(16,"div",30),WC(17),fl(),vs(18,"div",30),WC(19),aT(20,"apply"),fl()()),o&2){let e=mC(2);XE(2),Zg(e.totalRow().agentName),XE(2),Zg(e.totalRow().providerName),XE(2),Zg(e.totalRow().modelId),XE(2),Zg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),yl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Zg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Zg(e.totalRow().callCount),XE(2),yl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(vs(0,"div",18)(1,"section",16)(2,"div",26),WC(3,"Summary"),fl(),vs(4,"div",27)(5,"div",28)(6,"div",29),WC(7,"agentName"),fl(),vs(8,"div",29),WC(9,"providerName"),fl(),vs(10,"div",29),WC(11,"modelId"),fl(),vs(12,"div",30),WC(13,"promptTokens"),fl(),vs(14,"div",30),WC(15,"completionTokens"),fl(),vs(16,"div",30),WC(17,"totalTokens"),fl(),vs(18,"div",30),WC(19,"callCount"),fl(),vs(20,"div",30),WC(21,"cost"),fl()(),vs(22,"div",31),oC(23,at,21,21,"div",32,Xw().trackRow,true),eC(25,it,21,21,"div",33),fl()()(),vs(26,"section",16)(27,"div",26),WC(28,"Daily series"),fl(),bg(29,"app-daily-series-chart",34),fl()()),o&2){let e=mC();XE(23),iC(e.rows()),XE(2),tC(e.totalRow()?25:-1),XE(4),Tg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Sm);state=g(J);view=Hi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});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=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Fb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Fb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=Aw({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&&(vs(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Ag("click",function(){return n.navigateBack()}),vs(4,"mat-icon"),WC(5,"chevron_left"),fl()(),vs(6,"div")(7,"h1",4),WC(8,"Token Usage"),fl(),vs(9,"p",5),WC(10,"Track prompt and completion token usage by agent and model."),fl()()(),vs(11,"div",6)(12,"label",7)(13,"span",8),WC(14,"From"),fl(),vs(15,"div",9)(16,"input",10),Ag("ngModelChange",function(d){return n.onFromChange(d)}),fl(),HI(),vs(17,"button",11),Ag("click",function(){return n.clearFrom()}),WC(18," Clear "),fl()()(),vs(19,"label",7)(20,"span",8),WC(21,"To"),fl(),vs(22,"div",9)(23,"input",10),Ag("ngModelChange",function(d){return n.onToChange(d)}),fl(),HI(),vs(24,"button",11),Ag("click",function(){return n.clearTo()}),WC(25," Clear "),fl()()(),vs(26,"label",7)(27,"span",8),WC(28,"View"),fl(),vs(29,"select",12),Ag("ngModelChange",function(d){return n.view.set(d)}),vs(30,"option",13),WC(31,"By model"),fl(),vs(32,"option",14),WC(33,"By agent"),fl()(),HI(),fl(),vs(34,"button",15),Ag("click",function(){return n.apply()}),WC(35,"Apply"),fl()()(),eC(36,et,20,12),eC(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),fl()),e&2&&(XE(16),Tg("ngModel",n.state.draftFilters().from),$I(),XE(),Tg("disabled",!n.state.draftFilters().from),XE(6),Tg("ngModel",n.state.draftFilters().to),$I(),XE(),Tg("disabled",!n.state.draftFilters().to),XE(5),Tg("ngModel",n.view()),$I(),XE(5),Tg("disabled",n.state.loading()),XE(2),tC(n.totalRow()?36:-1),XE(),tC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,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}"],changeDetection:1})};export{Oe as TokenUsageComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {u}from'./chunk-
|
|
1
|
+
import {u}from'./chunk-CinHjHqk.js';import {g,de as Q,df as T,S as ha,bR as ma,u as ue,a7 as ga,cD as Rd,Y as x}from'./main-MB7Y2AR2.js';var v=class i{userState=g(u);membership=g(Q);currentUser$=T(this.userState.currentUser);cache=new Map;isAdminOfNamespace$(e){if(!e)return ha(false);let t=this.cache.get(e);if(t)return t;let s=this.currentUser$.pipe(ma(a=>a?a.isAdmin?ha(true):this.membership.getMembersNamespaceMembership(e).pipe(ue(d=>d.some(n=>n.id===a.id&&n.role==="ADMIN")),ga(()=>ha(false))):ha(false)),Rd({bufferSize:1,refCount:false}));return this.cache.set(e,s),s}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};export{v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {O}from'./chunk-
|
|
1
|
+
import {O}from'./chunk-D2hh5Ex3.js';import {g,ao as V$1,G as G$1,w as we,d7 as M,aI as Tr,H as Hi,bR as ma,Q as By,a7 as ga,S as ha,u as ue,b as U$1,A as Aw,aJ as Nb,v as vs,be as aT,l as Ag,W as WC,k as fl,af as Dg,T as TC,r as Tg,bf as uT,ah as rT,n as eC,ac as mC,t as tC,a9 as dC,aa as If,ab as wf,ag as fT}from'./main-MB7Y2AR2.js';import {W as Wn}from'./chunk-Dg1d1XBn.js';import'./chunk-C8P9SuaA.js';import'./chunk-jg8IIJti.js';var U=()=>[];function V(i,t){if(i&1){let n=dC();vs(0,"agentos-agent-config-item",4),Ag("deleteRequested",function(o){If(n);let F=mC(2);return wf(F.deleteConfig(o))}),fl();}if(i&2){let n=mC().$implicit,e=mC();Tg("config",t)("namespaceId",e.namespaceId)("readOnly",e.isPlatformConfig(n.id));}}function j(i,t){if(i&1&&eC(0,V,1,3,"agentos-agent-config-item",3),i&2){let n,e=t.$implicit,o=mC();tC((n=o.resolveConfig(e.id))?0:-1,n);}}var G="namespace",K="platform",q=class i{route=g(V$1);router=g(G$1);destroyRef=g(we);agentConfigController=g(M);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Hi(true);allConfigs$=this.refresh$.pipe(ma(()=>(this.isLoading.set(true),By({namespace:this.agentConfigController.listByParentAgentConfig(this.namespaceId),platform:this.agentConfigController.listPlatformAgentsAgentConfig().pipe(ga(()=>ha([])))}))));configItems$=this.allConfigs$.pipe(ue(({namespace:t,platform:n})=>[...n.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:K,groupLabel:"Platform (read-only)"})),...t.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:G,groupLabel:"Namespace"}))]));namespaceConfigsById=new Map;platformConfigsById=new Map;constructor(){this.allConfigs$.pipe(U$1(this.destroyRef)).subscribe({next:({namespace:t,platform:n})=>{this.namespaceConfigsById=new Map(t.map(e=>[e.id??"",e])),this.platformConfigsById=new Map(n.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"agent-configs","new"]);}deleteConfig(t){this.agentConfigController.deleteAgentConfig(t.id??"").pipe(U$1(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolveConfig(t){return this.namespaceConfigsById.get(t)??this.platformConfigsById.get(t)??null}isPlatformConfig(t){return this.platformConfigsById.has(t)}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=Aw({type:i,selectors:[["agentos-namespace-agent-configs"]],decls:6,vars:7,consts:[["agentConfigItemTpl",""],["title","Agent Configs","emptyMessage","No agent configs defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","type","button",1,"namespace-agent-configs__back",3,"click"],[3,"config","namespaceId","readOnly"],[3,"deleteRequested","config","namespaceId","readOnly"]],template:function(n,e){if(n&1&&(vs(0,"ds-entity-list",1),aT(1,"async"),Ag("createRequested",function(){return e.openCreateForm()}),vs(2,"button",2),Ag("click",function(){return e.goBack()}),WC(3," \u2190 Namespaces "),fl()(),Dg(4,j,1,1,"ng-template",null,0,fT)),n&2){let o=TC(5);Tg("items",uT(1,4,e.configItems$)??rT(6,U))("loading",e.isLoading())("showCreate",true)("itemTemplate",o);}},dependencies:[Wn,O,Nb],styles:[".namespace-agent-configs__back[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.namespace-agent-configs__back[_ngcontent-%COMP%]:hover{text-decoration:underline}"]})};export{q as NamespaceAgentConfigsComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {n}from'./chunk-CfgXrte_.js';import {O}from'./chunk-
|
|
1
|
+
import {n}from'./chunk-CfgXrte_.js';import {O}from'./chunk-D29_gPoW.js';import {v}from'./chunk-DvXqS7Sb.js';import {R}from'./chunk-By8x10iE.js';import {g,ao as V,G,w as we,H as Hi,u as ue,b as U$1,bR as ma,S as ha,A as Aw,aJ as Nb,v as vs,be as aT,l as Ag,k as fl,af as Dg,T as TC,r as Tg,bf as uT,ah as rT,n as eC,ac as mC,t as tC,W as WC,X as XE,a8 as Zg,a9 as dC,aa as If,ab as wf,ag as fT}from'./main-MB7Y2AR2.js';import'./chunk-CinHjHqk.js';import {W as Wn,S as Se}from'./chunk-Dg1d1XBn.js';import'./chunk-C8P9SuaA.js';import'./chunk-jg8IIJti.js';import'./chunk-JSqlYB97.js';import'./chunk-ciSHZI2F.js';var W=()=>[];function z(s,e){if(s&1&&(vs(0,"p",3),WC(1),fl()),s&2){let t=mC().$implicit;XE(),Zg(t.name);}}function U(s,e){if(s&1){let t=dC();vs(0,"agentos-auth-setting-item",5),Ag("editRequested",function(){let i=If(t),r=mC(2);return wf(r.onEdit(i))})("deleteRequested",function(){let i=If(t),r=mC(2);return wf(r.onDelete(i))})("duplicateRequested",function(){let i=If(t),r=mC(2);return wf(r.onDuplicate(i))}),fl();}if(s&2){let t=e,n=mC(2);Tg("config",t.config)("scope",t.scope)("readOnly",t.scope==="platform"||t.scope==="namespace"&&!n.isAdmin());}}function X(s,e){if(s&1&&eC(0,z,2,1,"p",3)(1,U,1,3,"agentos-auth-setting-item",4),s&2){let t,n=e.$implicit,i=mC();tC(i.isEmptyPlaceholder(n.id)?0:(t=i.resolve(n.id))?1:-1,t);}}var k=Object.freeze({platform:"Platform (read-only)",namespace:"Auth Settings du namespace",userOnNs:"Mes overrides sur ce namespace",userGlobal:"Mes overrides globaux"}),F="__empty__",j=class s{route=g(V);router=g(G);destroyRef=g(we);state=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isAdmin=Hi(false);listItems$=this.state.vm$.pipe(ue(e=>this.toListItems(e)));isLoading=Hi(true);resolved=new Map;ngOnInit(){this.route.paramMap.pipe(U$1(this.destroyRef)).subscribe(e=>{let t=e.get("namespaceId")??"";t&&t!==this.namespaceId&&(this.namespaceId=t),this.state.setNamespace(t);}),this.route.paramMap.pipe(ue(e=>e.get("namespaceId")??""),ma(e=>e?this.namespaceRole.isAdminOfNamespace$(e):ha(false)),U$1(this.destroyRef)).subscribe(e=>this.isAdmin.set(e)),this.state.vm$.pipe(U$1(this.destroyRef)).subscribe(e=>{this.isLoading.set(false);let t=new Map;e.platform.forEach(n=>{n.id&&t.set(this.itemKey("platform",n.id),{config:n,scope:"platform"});}),e.namespace.forEach(n=>{n.id&&t.set(this.itemKey("namespace",n.id),{config:n,scope:"namespace"});}),e.userOnNs.forEach(n=>{n.id&&t.set(this.itemKey("userOnNs",n.id),{config:n,scope:"userOnNs"});}),e.userGlobal.forEach(n=>{n.id&&t.set(this.itemKey("userGlobal",n.id),{config:n,scope:"userGlobal"});}),this.resolved=t;});}isEmptyPlaceholder(e){return e.startsWith(F)}resolve(e){return this.resolved.get(e)??null}itemKey(e,t){return `${e}:${t}`}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"auth-settings","new"],{queryParams:{scope:n(this.isAdmin())}});}onEdit(e){let t=e.config.id;t&&this.router.navigate(["/agentos",this.namespaceId,"auth-settings",t,"edit"],{queryParams:{scope:e.scope}});}onDelete(e){let t=e.config.id;t&&this.state.delete(t,e.scope).pipe(U$1(this.destroyRef)).subscribe({error:n=>{console.error(`[AuthSettingsAllScopes] Delete failed for ${e.scope}:${t}:`,n);}});}onDuplicate(e){if(!e.config.id)return;let t=e.scope==="platform"||e.scope==="namespace"&&!this.isAdmin()?"userOnNs":e.scope;this.router.navigate(["/agentos",this.namespaceId,"auth-settings","new"],{queryParams:{scope:t,template:e.config.id,templateScope:e.scope}});}toListItems(e){let t=[];return t.push(...this.sectionItems("platform",e.platform)),t.push(...this.sectionItems("namespace",e.namespace)),t.push(...this.sectionItems("userOnNs",e.userOnNs)),t.push(...this.sectionItems("userGlobal",e.userGlobal)),t}sectionItems(e,t){return t.length===0?[{id:`${F}${e}`,name:"Aucun Auth Setting",groupKey:e,groupLabel:k[e]}]:t.filter(n=>!!n.id).map(n=>({id:this.itemKey(e,n.id),name:n.name,description:n.authType,groupKey:e,groupLabel:k[e]}))}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=Aw({type:s,selectors:[["agentos-auth-settings-all-scopes"]],decls:5,vars:7,consts:[["authSettingItemTpl",""],["title","Auth Settings","emptyMessage","No auth settings available.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[1,"auth-settings-all-scopes__empty"],[3,"config","scope","readOnly"],[3,"editRequested","deleteRequested","duplicateRequested","config","scope","readOnly"]],template:function(t,n){if(t&1&&(vs(0,"ds-entity-list",1),aT(1,"async"),Ag("createRequested",function(){return n.openCreateForm()}),vs(2,"ds-icon-button",2),Ag("action",function(){return n.goBack()}),fl()(),Dg(3,X,2,1,"ng-template",null,0,fT)),t&2){let i=TC(4);Tg("items",uT(1,4,n.listItems$)??rT(6,W))("loading",n.isLoading())("showCreate",true)("itemTemplate",i);}},dependencies:[Wn,O,Se,Nb],encapsulation:2})};export{j as AuthSettingsAllScopesComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f}from'./chunk-DGKCScHp.js';import {G as Ge,$,K as Ke,E as Et,y as yt$2}from'./chunk-pTH381B1.js';import {U as Ue$1,x as x$1,i as is}from'./chunk-ADAFVeSv.js';import {al as yt,an as ce,g,ay as O,F,L,az as Qt,U,N,h as he,G,ap as Vy,ae as Ot,aA as sn,av as dt$1,A as Aw,i as hr$1,aB as fr$1,aC as Cu,v as vs,l as Ag,n as eC,k as fl,X as XE,r as Tg,t as tC,D as Fg,I as IC,E as wC,P as P$1,aD as Ly,Y as x,a9 as dC,ai as Jg,aa as If,aj as KC,ab as wf,a3 as HI,y as Hg,ak as Xg,a6 as $I,B as dE,J as dy,S as ha,aE as A,u as ue,a7 as ga,aF as me$1,H as Hi$1,m as mT,z as z$1,a as P$2,aG as z,b as U$1,aH as TS,q as oC,x as iC,aI as Tr$1,aJ as Nb,am as Gm,j as Gn$1,W as WC,aK as Do$1,aL as qn$1,aM as Nn$1,aN as wt$1,aO as G$1,aP as $a,aQ as As,aR as K,aS as Ut,aT as Ue,aU as U$2,aV as w,aW as D,aX as ft$1,aY as ks,aZ as YT,ac as mC,a_ as XC,a$ as Yg,a5 as yl,o as bg,ah as rT,b0 as An,b1 as Ob,b2 as bb,b3 as oT,b4 as nT,aw as pl,b5 as Sg,ax as hl,a8 as Zg,c as ce$1,b6 as u,b7 as B,b8 as T$1,b9 as v,ba as m,bb as R,bc as h,bd as A$1,be as aT,bf as uT,C as Cg,bg as Hy,p as pr$1,bh as lT,bi as aE,bj as yh}from'./main-CPDUTNNG.js';import {s}from'./chunk-DF1PsWqw.js';import {d}from'./chunk-CKnJYwqP.js';import {S as Se$1,P as Pn}from'./chunk-q9vkXLSQ.js';import {u as ui$1,m as mt$1,p as pt$1,Z,V as Ve}from'./chunk-D1LCrMS_.js';import {y as yt$1,w as wt,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-BhpcAaX5.js';var et=class i{sanitizer=g(TS);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=An({name:"highlight",type:i,pure:true})};var fe=class i{http=g(dy);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var _i=["messageInput"],xi=["fileInput"],yi=(i,e)=>e.name;function wi(i,e){i&1&&(vs(0,"div",3),bg(1,"span",8),WC(2," Recording... Click mic to stop "),fl());}function Ti(i,e){i&1&&(vs(0,"div",3),bg(1,"span",9),WC(2," Transcribing... "),fl());}function Si(i,e){if(i&1&&(vs(0,"span",14),WC(1),fl()),i&2){let t=mC().$implicit,n=mC(2);XE(),Zg(" "+(n.getParameterFormat(t)||""));}}function Mi(i,e){if(i&1){let t=dC();vs(0,"div",11),Ag("click",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectedAutocompleteIndex=o)}),vs(1,"div",12),bg(2,"span",13),aT(3,"highlight"),eC(4,Si,2,1,"span",14),fl(),bg(5,"div",15),aT(6,"highlight"),fl();}if(i&2){let t=e.$implicit,n=e.$index,o=mC(2);Hg("selected",n===o.selectedAutocompleteIndex),Cg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),Tg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),tC(o.hasParameterFormat(t)?4:-1),XE(),Tg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Ei(i,e){if(i&1&&(vs(0,"div",4),oC(1,Mi,7,12,"div",10,yi),fl()),i&2){let t=mC();XE(),iC(t.autocompleteItems);}}function Oi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",18),Ag("action",function(){If(t);let o=mC(2);return wf(o.onStopClick())}),fl();}}function Pi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",19),Ag("action",function(){If(t);let o=mC(2);return wf(o.sendMessage())}),fl();}if(i&2){let t=mC(2);Hg("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),Tg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function ki(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",21),Ag("action",function(){If(t);let o=mC(3);return wf(o.triggerFileUpload())}),fl(),vs(1,"input",22,1),Ag("change",function(o){If(t);let r=mC(3);return wf(r.onFileInputChange(o))}),fl();}if(i&2){let t=mC(3);Tg("disabled",t.isDisabled);}}function Ii(i,e){if(i&1){let t=dC();eC(0,ki,3,1),vs(1,"ds-icon-button",20),Ag("action",function(){If(t);let o=mC(2);return wf(o.toggleRecording())}),fl();}if(i&2){let t=mC(2);tC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Hg("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),Tg("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording");}}function Di(i,e){if(i&1&&(vs(0,"div",7),eC(1,Oi,1,0,"ds-icon-button",16),eC(2,Pi,1,6,"ds-icon-button",17),eC(3,Ii,2,6),fl()),i&2){let t=mC();XE(),tC(t.isThinking?1:-1),XE(),tC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),tC(t.isThinking?-1:3);}}var tt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new yt;messageSubmitted=new yt;voiceMessageReady=new yt;voiceRecordingToggled=new yt;heightChanged=new yt;stopRequested=new yt;textareaFocused=new yt;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(fe);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return dt$1(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return dt$1(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
1
|
+
import {f}from'./chunk-C39RA_bw.js';import {G as Ge,$,K as Ke,E as Et,y as yt$2}from'./chunk-qRp_60F5.js';import {U as Ue$1,x as x$1,i as is}from'./chunk-ciSHZI2F.js';import {al as yt,an as ce,g,ay as O,F,L,az as Qt,U,N,h as he,G,ap as Vy,ae as Ot,aA as sn,av as dt$1,A as Aw,i as hr$1,aB as fr$1,aC as Cu,v as vs,l as Ag,n as eC,k as fl,X as XE,r as Tg,t as tC,D as Fg,I as IC,E as wC,P as P$1,aD as Ly,Y as x,a9 as dC,ai as Jg,aa as If,aj as KC,ab as wf,a3 as HI,y as Hg,ak as Xg,a6 as $I,B as dE,J as dy,S as ha,aE as A,u as ue,a7 as ga,aF as me$1,H as Hi$1,m as mT,z as z$1,a as P$2,aG as z,b as U$1,aH as TS,q as oC,x as iC,aI as Tr$1,aJ as Nb,am as Gm,j as Gn$1,W as WC,aK as Do$1,aL as qn$1,aM as Nn$1,aN as wt$1,aO as G$1,aP as $a,aQ as As,aR as K,aS as Ut,aT as Ue,aU as U$2,aV as w,aW as D,aX as ft$1,aY as ks,aZ as YT,ac as mC,a_ as XC,a$ as Yg,a5 as yl,o as bg,ah as rT,b0 as An,b1 as Ob,b2 as bb,b3 as oT,b4 as nT,aw as pl,b5 as Sg,ax as hl,a8 as Zg,c as ce$1,b6 as u,b7 as B,b8 as T$1,b9 as v,ba as m,bb as R,bc as h,bd as A$1,be as aT,bf as uT,C as Cg,bg as Hy,p as pr$1,bh as lT,bi as aE,bj as yh}from'./main-MB7Y2AR2.js';import {s}from'./chunk-wTW1YRSg.js';import {d}from'./chunk-Ddve8eXJ.js';import {S as Se$1,P as Pn}from'./chunk-Dg1d1XBn.js';import {u as ui$1,m as mt$1,p as pt$1,Z,V as Ve}from'./chunk-C8P9SuaA.js';import {y as yt$1,w as wt,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-jg8IIJti.js';var et=class i{sanitizer=g(TS);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=An({name:"highlight",type:i,pure:true})};var fe=class i{http=g(dy);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var _i=["messageInput"],xi=["fileInput"],yi=(i,e)=>e.name;function wi(i,e){i&1&&(vs(0,"div",3),bg(1,"span",8),WC(2," Recording... Click mic to stop "),fl());}function Ti(i,e){i&1&&(vs(0,"div",3),bg(1,"span",9),WC(2," Transcribing... "),fl());}function Si(i,e){if(i&1&&(vs(0,"span",14),WC(1),fl()),i&2){let t=mC().$implicit,n=mC(2);XE(),Zg(" "+(n.getParameterFormat(t)||""));}}function Mi(i,e){if(i&1){let t=dC();vs(0,"div",11),Ag("click",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectedAutocompleteIndex=o)}),vs(1,"div",12),bg(2,"span",13),aT(3,"highlight"),eC(4,Si,2,1,"span",14),fl(),bg(5,"div",15),aT(6,"highlight"),fl();}if(i&2){let t=e.$implicit,n=e.$index,o=mC(2);Hg("selected",n===o.selectedAutocompleteIndex),Cg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),Tg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),tC(o.hasParameterFormat(t)?4:-1),XE(),Tg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Ei(i,e){if(i&1&&(vs(0,"div",4),oC(1,Mi,7,12,"div",10,yi),fl()),i&2){let t=mC();XE(),iC(t.autocompleteItems);}}function Oi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",18),Ag("action",function(){If(t);let o=mC(2);return wf(o.onStopClick())}),fl();}}function Pi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",19),Ag("action",function(){If(t);let o=mC(2);return wf(o.sendMessage())}),fl();}if(i&2){let t=mC(2);Hg("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),Tg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function ki(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",21),Ag("action",function(){If(t);let o=mC(3);return wf(o.triggerFileUpload())}),fl(),vs(1,"input",22,1),Ag("change",function(o){If(t);let r=mC(3);return wf(r.onFileInputChange(o))}),fl();}if(i&2){let t=mC(3);Tg("disabled",t.isDisabled);}}function Ii(i,e){if(i&1){let t=dC();eC(0,ki,3,1),vs(1,"ds-icon-button",20),Ag("action",function(){If(t);let o=mC(2);return wf(o.toggleRecording())}),fl();}if(i&2){let t=mC(2);tC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Hg("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),Tg("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording");}}function Di(i,e){if(i&1&&(vs(0,"div",7),eC(1,Oi,1,0,"ds-icon-button",16),eC(2,Pi,1,6,"ds-icon-button",17),eC(3,Ii,2,6),fl()),i&2){let t=mC();XE(),tC(t.isThinking?1:-1),XE(),tC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),tC(t.isThinking?-1:3);}}var tt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new yt;messageSubmitted=new yt;voiceMessageReady=new yt;voiceRecordingToggled=new yt;heightChanged=new yt;stopRequested=new yt;textareaFocused=new yt;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(fe);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return dt$1(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return dt$1(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
2
2
|
|
|
3
3
|
`),this.sessionHadTranscript=false),this.pendingLineBreaksTimeout=null;},500);}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null);}adjustTextareaHeight(){let e=this.messageInput?.nativeElement;if(!e)return;let t=e.parentElement?.offsetHeight??e.offsetHeight+32;this.heightChanged.emit(t);}getSendButtonShortcut(){return this.useEnterToSend?"Enter":navigator.platform.toLowerCase().includes("mac")?"\u2318+Enter":"Ctrl+Enter"}getSendButtonTooltip(){return this.useEnterToSend?"Send message (Enter) - Shift+Enter for new line":`Send message (${navigator.platform.toLowerCase().includes("mac")?"Cmd+Enter":"Ctrl+Enter"}) - Enter for new line`}getPlaceholder(){return this.isSessionInitializing?"Initializing session...":this.isThinking?this.isStopping?"Stopping...":this.isStarting?"Processing request...":this.currentThinkingPhrase:this.isVoiceMessageMode&&this.isTranscribing?"Uploading...":this.isVoiceMessageMode&&this.isRecording?"Listening...":this.showWelcome?"How can I help you today?":"Type '@' for agents, '/' for commands, or just your message..."}startThinkingAnimation(){this.thinkingPhraseIndex=0,this.currentThinkingPhrase=this.thinkingPhrases[0]??"Thinking...",this.thinkingInterval=window.setInterval(()=>{this.thinkingPhraseIndex<this.thinkingPhrases.length-1&&(this.thinkingPhraseIndex++,this.currentThinkingPhrase=this.thinkingPhrases[this.thinkingPhraseIndex]??"Thinking...");},2e3);}stopThinkingAnimation(){this.thinkingInterval&&(clearInterval(this.thinkingInterval),this.thinkingInterval=null),this.thinkingPhraseIndex=0,this.currentThinkingPhrase="Thinking...";}subscribeToInviteEvents(){this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{e?this.handleInviteEvent(e.invite,e.defaultValue):this.currentInvite="";}));}handleInviteEvent(e,t){this.currentInvite=e,t&&(this.message=t,setTimeout(()=>this.adjustTextareaHeight(),0)),setTimeout(()=>{this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus();},50);}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(e=>{e.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",e.substring(0,50)+"..."),this.restoreMessageContent(e));}));}restoreMessageContent(e){this.message=e,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let t=this.messageInput.nativeElement,n=this.message.length;t.setSelectionRange(n,n);},0)),setTimeout(()=>this.adjustTextareaHeight(),10);}focusTextarea(){let e=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!e,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:e?.disabled,isSessionInitializing:this.isSessionInitializing}),e&&!e.disabled?(e.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available");}checkForAutocomplete(){let e=this.message;if(e.startsWith("@")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showAgentAutocomplete(t);return}if(e.startsWith("/")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showPromptAutocomplete(t);return}this.hideAutocomplete();}showAgentAutocomplete(e){this.autocompleteTrigger="@";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.agentApiService.getAgentsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading agents:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load agents"),this.hideAutocomplete();}}showPromptAutocomplete(e){this.autocompleteTrigger="/";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.promptApiService.getPromptsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading prompts:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load prompts"),this.hideAutocomplete();}}hideAutocomplete(){this.autocompleteVisible=false,this.autocompleteItems=[],this.selectedAutocompleteIndex=0;}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,o=n.parameterFormat;if(console.log(n),o===void 0)this.message=`/${e.name}`;else if(o==="")this.message=`/${e.name} `;else {this.message=`/${e.name} ${o}`;let r=this.message.indexOf('=""');r!==-1&&(t=r+2);}}else this.message=`@${e.name} `;this.hideAutocomplete(),setTimeout(()=>{if(this.messageInput?.nativeElement)if(this.messageInput.nativeElement.focus(),t!==null)this.messageInput.nativeElement.setSelectionRange(t,t);else {let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}},0);}selectAutocompleteItemByClick(e){this.selectedAutocompleteIndex=e,this.selectAutocompleteItem();}getAutocompleteQuery(){return this.message.substring(1).split(" ")[0]??""}getParameterFormat(e){return e.parameterFormat}hasParameterFormat(e){return this.autocompleteTrigger==="/"&&e.parameterFormat!==void 0}scrollSelectedItemIntoView(){setTimeout(()=>{let e=document.querySelector(".autocomplete-popup");if(!e)return;let t=e.querySelector(".autocomplete-item.selected");t&&t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});},0);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=Aw({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&Fg(_i,7)(xi,5),t&2){let o;IC(o=wC())&&(n.messageInput=o.first),IC(o=wC())&&(n.fileInput=o.first);}},hostBindings:function(t,n){t&1&&Ag("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},dE);},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceMessageReady:"voiceMessageReady",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[Cu],decls:8,vars:15,consts:[["messageInput",""],["fileInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"autocomplete-popup"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"actions"],[1,"recording-dot"],[1,"transcribing-dot"],["role","option","tabindex","0",1,"autocomplete-item",3,"selected"],["role","option","tabindex","0",1,"autocomplete-item",3,"click","keydown.enter","keydown.space","mouseenter"],[1,"item-name"],[3,"innerHTML"],[1,"parameter-format"],[1,"item-description",3,"innerHTML"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn"],["icon","send","variant","primary",1,"send-btn",3,"title","disabled","hidden","active"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn",3,"action"],["icon","send","variant","primary",1,"send-btn",3,"action","title","disabled"],["icon","mic",1,"voice-btn",3,"action","variant","disabled","title"],["icon","attach_file","variant","default","title","Upload files (images or documents)",1,"upload-btn",3,"action","disabled"],["type","file","multiple","","accept","image/*,application/pdf,.pdf,.doc,.docx,.txt,.md,.json,.yaml,.yml,.csv,.xml,.html",2,"display","none",3,"change"]],template:function(t,n){if(t&1){let o=dC();vs(0,"div",2),eC(1,wi,3,0,"div",3),eC(2,Ti,3,0,"div",3),eC(3,Ei,3,0,"div",4),vs(4,"div",5)(5,"textarea",6,0),Jg("ngModelChange",function(d){return If(o),KC(n.message,d)||(n.message=d),wf(d)}),Ag("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return If(o),n.isFocused=true,wf(n.textareaFocused.emit())})("blur",function(){return n.isFocused=false}),fl(),HI(),eC(7,Di,4,3,"div",7),fl()();}t&2&&(XE(),tC(!n.isVoiceMessageMode&&n.isRecording?1:-1),XE(),tC(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),XE(),tC(n.autocompleteVisible?3:-1),XE(),Hg("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),XE(),Xg("ngModel",n.message),Tg("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),$I(),XE(2),tC(n.isSessionInitializing?-1:7));},dependencies:[ti$1,Ye,Zn$1,cn,Se$1,et],styles:['@keyframes _ngcontent-%COMP%_gradientBorderShift{0%{background-position:0 0}50%{background-position:100% 0}to{background-position:0 0}}.chat-input-container[_ngcontent-%COMP%]{flex-shrink:0;width:100%;position:relative}.thinking-progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;right:0;height:3px;z-index:1}.thinking-progress[_ngcontent-%COMP%] .mdc-linear-progress__bar-inner{border-top-width:3px}.input-row.grouped-input[_ngcontent-%COMP%]{display:flex;align-items:stretch;background:var(--glass-bg);border-radius:16px;padding:0 .15rem 0 1.25rem;position:relative;transition:border-color .2s,box-shadow .2s,background .3s}.input-row[_ngcontent-%COMP%]{position:relative;background:var(--glass-bg, #1e1e1e)!important;background-clip:padding-box}.input-row[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:-2px;border-radius:inherit;background-size:200% 100%;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;padding:1px;pointer-events:none;z-index:-1;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-error, #ef4444) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-error, #ef4444) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 2s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-listening[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.is-thinking[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-thinking[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-thinking[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.message-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent!important;box-shadow:none;font-size:1rem;padding:1rem 0;color:var(--color-text);resize:none;field-sizing:content;min-height:36px;max-height:70vh;overflow-y:auto;font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;line-height:1.5}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.message-input[_ngcontent-%COMP%]:focus{outline:none;border:none;box-shadow:none}.message-input[_ngcontent-%COMP%]:disabled{background-color:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;opacity:.6}.message-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);transition:opacity .3s ease-in-out}.message-input[_ngcontent-%COMP%]:disabled::placeholder{animation:_ngcontent-%COMP%_thinkingPulsate 2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_thinkingPulsate{0%,to{opacity:.6}50%{opacity:1}}.voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%]{margin:0}.actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.send-btn[_ngcontent-%COMP%]{transition:opacity .4s,margin-left .4s}.send-btn.active[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active) button[_ngcontent-%COMP%]{opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){color:#fff;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-primary, #3b82f6) 20%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 80%,var(--color-primary, #3b82f6) 100%);background-size:300% auto;animation:sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:active:not(:disabled){transform:scale(1.3);box-shadow:0 4px 24px #007aff30}.recording-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-top:.2rem;margin-bottom:.2rem;color:var(--color-error, #ff5555);font-size:.9rem;position:absolute;top:-1.5rem}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:1}50%{opacity:.5}}.autocomplete-popup[_ngcontent-%COMP%]{position:absolute;bottom:100%;left:0;right:0;margin-bottom:.5rem;background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid var(--color-border);max-height:400px;max-width:500px;overflow-y:auto;z-index:100}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]{padding:.75rem 1rem;cursor:pointer;transition:background .2s;border-left:3px solid transparent}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]:hover, .autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{background:var(--color-bg-hover)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{border-left-color:var(--color-primary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-text);margin-bottom:.25rem;font-family:SF Mono,Monaco,Menlo,Cascadia Code,Consolas,monospace;font-size:.95rem}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1));padding:0 2px;border-radius:2px}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] .parameter-format[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-weight:400;opacity:.7}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);line-height:1.3}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1))}@media print{.thinking-progress[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%], .autocomplete-popup[_ngcontent-%COMP%]{display:none!important}}'],changeDetection:1})};var be=class i{unreadCountSubject=new Tr$1(0);unreadCount$=this.unreadCountSubject.asObservable();constructor(){console.log("[UNREAD] Service initialized");}addUnread(){let t=this.unreadCountSubject.value+1;this.unreadCountSubject.next(t),console.log("[UNREAD] Added unread message, total:",t);}markAllAsRead(){this.unreadCountSubject.value>0&&(this.unreadCountSubject.next(0),console.log("[UNREAD] Marked all messages as read"));}getCurrentCount(){return this.unreadCountSubject.value}reset(){this.unreadCountSubject.next(0),console.log("[UNREAD] Counter reset");}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var nt=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=false;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=g(be);project=g(P$1);constructor(){this.initializeTitleUpdates();}initializeTitleUpdates(){Ly([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([e,t])=>{this.updateTitle(e?.name??"...",t);});}updateTitle(e,t){let n;this.isSystemActive?n=`\u23F3${t>0?` (${t}) `:" "}${e}`:t>0?n=`${this.ATTENTION_EMOJI} (${t}) ${e}`:n=e,document.title=n,console.log("[TAB-TITLE] Updated to:",n);}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=true,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=false,this.forceUpdateTitle();},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle();}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=false,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle();}forceUpdateTitle(){let e=this.project.getSelectedProjectId()??"...",t=this.unreadService.getCurrentCount();this.updateTitle(e,t);}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var it=class i{pendingFirstMessage=null;pendingVoiceMessage=null;setPendingFirstMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=e;}consumePendingFirstMessage(){let e=this.pendingFirstMessage;return e?(console.log("[FIRST-MESSAGE-STATE] Consuming pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=null):console.log("[FIRST-MESSAGE-STATE] No pending first message to consume"),e}setPendingVoiceMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending voice message"),this.pendingVoiceMessage=e;}consumePendingVoiceMessage(){let e=this.pendingVoiceMessage;return e&&(console.log("[FIRST-MESSAGE-STATE] Consuming pending voice message"),this.pendingVoiceMessage=null),e}hasPendingFirstMessage(){return this.pendingFirstMessage!==null||this.pendingVoiceMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null),this.pendingVoiceMessage=null;}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ai=(i,e)=>e.label;function Fi(i,e){if(i&1){let t=dC();vs(0,"button",2),Ag("click",function(o){let r=If(t).$implicit,d=mC();return wf(d.executeAction(r,o))}),vs(1,"mat-icon"),WC(2),fl()();}if(i&2){let t=e.$implicit;Cg("title",t.tooltip||t.label),XE(),Cg("aria-label",t.label),XE(),Zg(t.icon);}}var ot=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=Aw({type:i,selectors:[["app-message-context-menu"]],inputs:{actions:"actions"},decls:3,vars:0,consts:[[1,"context-menu-wrapper"],["mat-icon-button",""],["mat-icon-button","",3,"click"]],template:function(t,n){t&1&&(vs(0,"div",0),oC(1,Fi,3,3,"button",1,Ai),fl()),t&2&&(XE(),iC(n.actions));},dependencies:[Gm,Gn$1,wt],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"],changeDetection:1})};var J=class i{renderer;constructor(){this.renderer=new Ue$1,this.configureRenderer();}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),o=e(t);if(n){o=o.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;o=o.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),o=o.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>');}return o};}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return false;if(e.startsWith("//"))return true;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return false}}escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return dt$1(this,null,function*(){let t=yield x$1.parse(e,{renderer:this.renderer,breaks:true,gfm:true});return is.sanitize(t,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ri=i=>({"user-message-wrapper":i});function Hi(i,e){if(i&1&&(vs(0,"div",4)(1,"div",8),WC(2),fl()()),i&2){let t=mC(2);XE(2),yl(" ",t.message.speaker," ");}}function Vi(i,e){if(i&1&&(vs(0,"time",6),WC(1),fl()),i&2){let t=mC(2);XE(),Zg(t.formattedTimestamp);}}function Li(i,e){if(i&1&&(vs(0,"div",7),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC(2);XE(),Tg("actions",t.actions);}}function zi(i,e){if(i&1&&(eC(0,Hi,3,1,"div",4),bg(1,"div",5),eC(2,Vi,2,1,"time",6),eC(3,Li,2,1,"div",7)),i&2){let t=mC();tC(t.shouldShowSpeaker?0:-1),XE(),Tg("innerHTML",t.renderedContent,aE),XE(),tC(t.formattedTimestamp?2:-1),XE(),tC(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1);}}function Ni(i,e){if(i&1&&bg(0,"span",12),i&2){let t=mC(3);Tg("innerHTML",t.renderedContent,aE);}}function $i(i,e){if(i&1&&(vs(0,"span",13),WC(1),fl()),i&2){let t=mC(3);XE(),Zg(t.collapsedErrorText);}}function ji(i,e){i&1&&WC(0," Show less \u25B2 ");}function Ui(i,e){i&1&&WC(0," Show more \u25BC ");}function Bi(i,e){if(i&1){let t=dC();vs(0,"div",10),eC(1,Ni,1,1,"span",12)(2,$i,2,1,"span",13),vs(3,"button",14),Ag("click",function(){If(t);let o=mC(2);return wf(o.toggleErrorExpanded())}),eC(4,ji,1,0)(5,Ui,1,0),fl()();}if(i&2){let t=mC(2);XE(),tC(t.isErrorExpanded()?1:2),XE(3),tC(t.isErrorExpanded()?4:5);}}function Wi(i,e){i&1&&WC(0," \u25B2 ");}function qi(i,e){i&1&&WC(0," \u25BC ");}function Yi(i,e){if(i&1&&(vs(0,"a",17),WC(1,"view"),fl()),i&2){let t=mC(3);Tg("href",t.eventLink,yh);}}function Gi(i,e){if(i&1&&(vs(0,"pre",18),WC(1),fl()),i&2){let t=mC(3);XE(),Zg(t.message.fullContent);}}function Qi(i,e){if(i&1){let t=dC();vs(0,"div",15),bg(1,"span",12),vs(2,"button",16),Ag("click",function(){If(t);let o=mC(2);return wf(o.toggleTechnicalExpanded())}),eC(3,Wi,1,0)(4,qi,1,0),fl(),eC(5,Yi,2,1,"a",17),fl(),eC(6,Gi,2,1,"pre",18);}if(i&2){let t=mC(2);XE(),Tg("innerHTML",t.renderedContent,aE),XE(2),tC(t.isTechnicalExpanded()?3:4),XE(2),tC(t.eventLink?5:-1),XE(),tC(t.isTechnicalExpanded()?6:-1);}}function Xi(i,e){if(i&1&&(vs(0,"a",17),WC(1,"view"),fl()),i&2){let t=mC(3);Tg("href",t.eventLink,yh);}}function Ki(i,e){if(i&1&&(vs(0,"div",11),bg(1,"span",12),eC(2,Xi,2,1,"a",17),fl()),i&2){let t=mC(2);XE(),Tg("innerHTML",t.renderedContent,aE),XE(),tC(t.eventLink?2:-1);}}function Ji(i,e){if(i&1&&eC(0,Bi,6,2,"div",10)(1,Qi,7,4)(2,Ki,3,2,"div",11),i&2){let t=mC();tC(t.message.type==="error"&&t.isLongError?0:t.message.type==="technical"&&t.message.fullContent?1:2);}}function Zi(i,e){if(i&1&&(vs(0,"div",2),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC();XE(),Tg("actions",t.actions);}}function eo(i,e){if(i&1&&(vs(0,"div",3),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC();XE(),Tg("actions",t.actions);}}var Ce=class i{destroy$=new ce;message;canDelete=true;isOtherUser=false;containingThreadId;copyRequested=new yt;deleteRequested=new yt;renderedContent="";shouldHideTechnical=false;shouldHideWarning=false;isErrorExpanded=Hi$1(false);static ERROR_COLLAPSE_LINE_THRESHOLD=5;isTechnicalExpanded=Hi$1(false);sanitizer=g(TS);notificationService=g(s);preferencesService=g(L);projectState=g(P$1);threadState=g(U);markdownService=g(J);get messageClasses(){return {[this.message.role]:true,[this.message.type]:true,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return dt$1(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(Vy(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e;}),this.preferencesService.hideWarningMessages$.pipe(Vy(this.destroy$)).subscribe(e=>{this.shouldHideWarning=e;}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages();})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}get shouldShowSpeaker(){return this.message.role==="user"?this.isOtherUser||this.message.speaker.startsWith("@"):this.message.role==="assistant"}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}datePipe=g(Ob);get formattedTimestamp(){if(this.message.role!=="user"||!this.message.timestamp)return null;let e=new Date().toDateString()===this.message.timestamp.toDateString();return this.datePipe.transform(this.message.timestamp,e?"HH:mm":"dd/MM HH:mm")}get isLongError(){return this.message.type!=="error"?false:this.extractTextContent().split(/\n|\\n/).length>i.ERROR_COLLAPSE_LINE_THRESHOLD}get collapsedErrorText(){return this.extractTextContent().split(/\n|\\n/).slice(0,i.ERROR_COLLAPSE_LINE_THRESHOLD).join(`
|
|
4
4
|
`)+"\u2026"}toggleErrorExpanded(){this.isErrorExpanded.update(e=>!e);}toggleTechnicalExpanded(){this.isTechnicalExpanded.update(e=>!e);}get isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
|