@whoz-oss/coday-client 0.121.2 → 0.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/3rdpartylicenses.txt +2 -2
  2. package/browser/chunk-5NUGIKIB.js +1 -0
  3. package/browser/chunk-5OMZQ4OZ.js +1 -0
  4. package/browser/chunk-6KXNYOC4.js +1 -0
  5. package/browser/{chunk-FCCT54AP.js → chunk-6Z6SJ4Y2.js} +1 -1
  6. package/browser/{chunk-VUV5JL5J.js → chunk-7QG3AKRT.js} +1 -1
  7. package/browser/chunk-7XMHOWLT.js +1 -0
  8. package/browser/{chunk-MJEQQZDO.js → chunk-AKBSVQGQ.js} +1 -1
  9. package/browser/{chunk-JPWWZVYZ.js → chunk-AVD3CUGR.js} +1 -1
  10. package/browser/chunk-B4OTLKPN.js +1 -0
  11. package/browser/chunk-BYYYYB67.js +1 -0
  12. package/browser/chunk-CR4XXAY3.js +1 -0
  13. package/browser/{chunk-UMDZZGIC.js → chunk-DE3P5WR7.js} +1 -1
  14. package/browser/{chunk-UXXLDXN3.js → chunk-DSN23Y6D.js} +1 -1
  15. package/browser/chunk-DWEXNFR7.js +1 -0
  16. package/browser/chunk-EH7TPIXS.js +1 -0
  17. package/browser/chunk-GHOFO7YQ.js +1 -0
  18. package/browser/chunk-HAWWBYDG.js +1 -0
  19. package/browser/{chunk-GT5UFSUE.js → chunk-HIRSL5MY.js} +1 -1
  20. package/browser/chunk-HK2BLNG3.js +1 -0
  21. package/browser/chunk-HLLG2DDM.js +1 -0
  22. package/browser/{chunk-PKKHLHXJ.js → chunk-HVJQKHJC.js} +1 -1
  23. package/browser/chunk-I3QA4WXI.js +1 -0
  24. package/browser/{chunk-5CTKRMM2.js → chunk-IYJZ4CSD.js} +1 -1
  25. package/browser/{chunk-UGVRFJHC.js → chunk-IZRO2LMH.js} +1 -1
  26. package/browser/{chunk-VNGIXNER.js → chunk-JBAZQRNW.js} +1 -1
  27. package/browser/chunk-JQSINAMU.js +1 -0
  28. package/browser/chunk-L66AMHS4.js +13 -0
  29. package/browser/chunk-LEUHLZHG.js +1 -0
  30. package/browser/chunk-LPT4NEYN.js +1 -0
  31. package/browser/chunk-OGOX2BYJ.js +1 -0
  32. package/browser/{chunk-TE3JOGRA.js → chunk-P36TOKXO.js} +1 -1
  33. package/browser/chunk-PDZ2DBT6.js +1 -0
  34. package/browser/{chunk-4LFZBXC3.js → chunk-PWW4FOUT.js} +1 -1
  35. package/browser/{chunk-3TOJSAQM.js → chunk-Q56XXDIJ.js} +1 -1
  36. package/browser/{chunk-S5LR3GBS.js → chunk-RHMP25CV.js} +1 -1
  37. package/browser/chunk-RIKUGKVO.js +1 -0
  38. package/browser/{chunk-DJBCK5D7.js → chunk-RUEXWAWX.js} +2 -2
  39. package/browser/{chunk-P5TSPSCB.js → chunk-UGL3W65S.js} +1 -1
  40. package/browser/{chunk-5UOZGBZ2.js → chunk-VCDX36SM.js} +1 -1
  41. package/browser/{chunk-NO2ODJHX.js → chunk-VEOXUX7X.js} +1 -1
  42. package/browser/{chunk-KYPMYRHP.js → chunk-VU7RWHPC.js} +1 -1
  43. package/browser/{chunk-7RF7FEOC.js → chunk-W4XTZNHN.js} +1 -1
  44. package/browser/chunk-XL52MS6C.js +1 -0
  45. package/browser/{chunk-OMLFSDJ5.js → chunk-XNWPPTWL.js} +1 -1
  46. package/browser/chunk-Y3EGCKL7.js +1 -0
  47. package/browser/{chunk-PWN5O4WY.js → chunk-Y73HWDY3.js} +1 -1
  48. package/browser/{chunk-2DE3OXG3.js → chunk-ZK67B6NL.js} +1 -1
  49. package/browser/index.html +1 -1
  50. package/browser/main-RALP5G7L.js +359 -0
  51. package/package.json +1 -1
  52. package/browser/chunk-4FGPNBI3.js +0 -1
  53. package/browser/chunk-4OMSGXSL.js +0 -1
  54. package/browser/chunk-ELXKRVE4.js +0 -1
  55. package/browser/chunk-FPUSD6J7.js +0 -1
  56. package/browser/chunk-G5XS2TEE.js +0 -1
  57. package/browser/chunk-JW6LSUP2.js +0 -1
  58. package/browser/chunk-LVEC3TBP.js +0 -1
  59. package/browser/chunk-OK747ZMT.js +0 -1
  60. package/browser/chunk-R35XCYRZ.js +0 -1
  61. package/browser/chunk-R5SZYFB2.js +0 -1
  62. package/browser/chunk-W4VYO3E2.js +0 -1
  63. package/browser/chunk-WQDJM4TR.js +0 -1
  64. package/browser/chunk-XPK5V34V.js +0 -1
  65. package/browser/chunk-YDXVLOQW.js +0 -11
  66. package/browser/chunk-Z7DC3UIO.js +0 -1
  67. package/browser/main-4CSREW6D.js +0 -361
@@ -0,0 +1,359 @@
1
+ import{a as Vl,b as zl}from"./chunk-RHMP25CV.js";import{a as Hl,b as Ul,c as Bl}from"./chunk-IYJZ4CSD.js";import{a as $l}from"./chunk-6Z6SJ4Y2.js";import{a as gl,b as fl}from"./chunk-VCDX36SM.js";import{a as Er,b as Mr,c as _l,d as Pr,e as kr,f as bl,g as Or}from"./chunk-VEOXUX7X.js";import{a as Ar,b as _e}from"./chunk-Q56XXDIJ.js";import{k as vl}from"./chunk-VU7RWHPC.js";import{$ as jl,B as El,D as Dl,P as Rl,Q as Dr,R as Nl,Y as Fl,_ as Ll,t as yl,u as Cl,v as Sl,w as xl,x as Tl,y as wl,z as Ir}from"./chunk-L66AMHS4.js";import{a as rt,b as Me}from"./chunk-JBAZQRNW.js";import{F as ul,G as hl,L as ze,N as mn,P as ei,Q as wr,R as qe,S as ae,T as Te,i as al,j as sl,m as ll,o as cl,r as dl,s as pl,y as ml}from"./chunk-HVJQKHJC.js";import{B as Il,C as st,c as ht,g as ot,m as at,p as Ml,q as Pl,v as kl,w as Ol,x as Al}from"./chunk-ZK67B6NL.js";import{b as Tr,c as il,d as Nt,e as rl,f as ol}from"./chunk-Y73HWDY3.js";import{$ as gr,$b as Ks,A as De,Aa as na,Ab as v,Ac as Sr,Bc as xr,C as sn,Cb as h,Cc as Zs,Db as Ws,Dc as sa,Ea as mt,Eb as Gs,F as hr,Fa as En,Fc as nt,Ga as zs,Gb as tt,H as Xo,Ha as p,Hb as je,Ia as $s,Ib as Ve,Ic as el,J as Rs,Jc as tl,L as Jo,La as Hs,Ma as Us,Mb as Pn,N as Ns,Nb as yt,Nc as it,Ob as J,Oc as nl,P as Zo,Pb as oa,Q as ea,Qb as u,Qc as Rt,R as z,Rb as F,Sb as Oe,T as ut,Ta as N,Tb as Jn,U as ne,Ua as Jt,Ub as Z,Va as Bs,Vb as ee,Wa as qs,Wb as te,X as U,Xb as Ys,Y as Xt,Yb as Qs,Za as cn,Zb as _r,_ as Fs,_b as br,a as G,aa as f,ac as Ri,b as he,bc as Xs,c as As,ca as Ls,cb as ia,cc as aa,d as H,ec as Zn,fa as x,g as ur,ga as T,gb as Re,h as ce,ha as ta,hc as Ct,i as q,ia as js,ib as C,jb as S,ka as fr,kc as vr,la as Kn,m as Tn,mb as Ce,n as Qn,na as ie,nb as Se,nc as Js,oa as Xn,ob as w,pb as l,pc as yr,q as Ko,qb as c,qc as Cr,r as Is,ra as Vs,rb as R,s as Le,sa as et,sb as dn,t as wn,ta as Di,tb as pn,ua as Dt,ub as ra,wa as ln,xb as Mn,y as Ds,yb as O}from"./chunk-RUEXWAWX.js";var W=(function(i){return i[i.State=0]="State",i[i.Transition=1]="Transition",i[i.Sequence=2]="Sequence",i[i.Group=3]="Group",i[i.Animate=4]="Animate",i[i.Keyframes=5]="Keyframes",i[i.Style=6]="Style",i[i.Trigger=7]="Trigger",i[i.Reference=8]="Reference",i[i.AnimateChild=9]="AnimateChild",i[i.AnimateRef=10]="AnimateRef",i[i.Query=11]="Query",i[i.Stagger=12]="Stagger",i})(W||{}),gt="*";function la(i,e){return{type:W.Trigger,name:i,definitions:e,options:{}}}function Rr(i,e=null){return{type:W.Animate,styles:e,timings:i}}function ql(i,e=null){return{type:W.Sequence,steps:i,options:e}}function un(i){return{type:W.Style,styles:i,offset:null}}function Nr(i,e,t=null){return{type:W.Transition,expr:i,animation:e,options:t}}var Ft=class{_onDoneFns=[];_onStartFns=[];_onDestroyFns=[];_originalOnDoneFns=[];_originalOnStartFns=[];_started=!1;_destroyed=!1;_finished=!1;_position=0;parentPlayer=null;totalTime;constructor(e=0,t=0){this.totalTime=e+t}_onFinish(){this._finished||(this._finished=!0,this._onDoneFns.forEach(e=>e()),this._onDoneFns=[])}onStart(e){this._originalOnStartFns.push(e),this._onStartFns.push(e)}onDone(e){this._originalOnDoneFns.push(e),this._onDoneFns.push(e)}onDestroy(e){this._onDestroyFns.push(e)}hasStarted(){return this._started}init(){}play(){this.hasStarted()||(this._onStart(),this.triggerMicrotask()),this._started=!0}triggerMicrotask(){queueMicrotask(()=>this._onFinish())}_onStart(){this._onStartFns.forEach(e=>e()),this._onStartFns=[]}pause(){}restart(){}finish(){this._onFinish()}destroy(){this._destroyed||(this._destroyed=!0,this.hasStarted()||this._onStart(),this.finish(),this._onDestroyFns.forEach(e=>e()),this._onDestroyFns=[])}reset(){this._started=!1,this._finished=!1,this._onStartFns=this._originalOnStartFns,this._onDoneFns=this._originalOnDoneFns}setPosition(e){this._position=this.totalTime?e*this.totalTime:1}getPosition(){return this.totalTime?this._position/this.totalTime:1}triggerCallback(e){let t=e=="start"?this._onStartFns:this._onDoneFns;t.forEach(n=>n()),t.length=0}},kn=class{_onDoneFns=[];_onStartFns=[];_finished=!1;_started=!1;_destroyed=!1;_onDestroyFns=[];parentPlayer=null;totalTime=0;players;constructor(e){this.players=e;let t=0,n=0,r=0,o=this.players.length;o==0?queueMicrotask(()=>this._onFinish()):this.players.forEach(a=>{a.onDone(()=>{++t==o&&this._onFinish()}),a.onDestroy(()=>{++n==o&&this._onDestroy()}),a.onStart(()=>{++r==o&&this._onStart()})}),this.totalTime=this.players.reduce((a,s)=>Math.max(a,s.totalTime),0)}_onFinish(){this._finished||(this._finished=!0,this._onDoneFns.forEach(e=>e()),this._onDoneFns=[])}init(){this.players.forEach(e=>e.init())}onStart(e){this._onStartFns.push(e)}_onStart(){this.hasStarted()||(this._started=!0,this._onStartFns.forEach(e=>e()),this._onStartFns=[])}onDone(e){this._onDoneFns.push(e)}onDestroy(e){this._onDestroyFns.push(e)}hasStarted(){return this._started}play(){this.parentPlayer||this.init(),this._onStart(),this.players.forEach(e=>e.play())}pause(){this.players.forEach(e=>e.pause())}restart(){this.players.forEach(e=>e.restart())}finish(){this._onFinish(),this.players.forEach(e=>e.finish())}destroy(){this._onDestroy()}_onDestroy(){this._destroyed||(this._destroyed=!0,this._onFinish(),this.players.forEach(e=>e.destroy()),this._onDestroyFns.forEach(e=>e()),this._onDestroyFns=[])}reset(){this.players.forEach(e=>e.reset()),this._destroyed=!1,this._finished=!1,this._started=!1}setPosition(e){let t=e*this.totalTime;this.players.forEach(n=>{let r=n.totalTime?Math.min(1,t/n.totalTime):1;n.setPosition(r)})}getPosition(){let e=this.players.reduce((t,n)=>t===null||n.totalTime>t.totalTime?n:t,null);return e!=null?e.getPosition():0}beforeDestroy(){this.players.forEach(e=>{e.beforeDestroy&&e.beforeDestroy()})}triggerCallback(e){let t=e=="start"?this._onStartFns:this._onDoneFns;t.forEach(n=>n()),t.length=0}},ti="!";function Wl(i){return new ne(3e3,!1)}function fp(){return new ne(3100,!1)}function _p(){return new ne(3101,!1)}function bp(i){return new ne(3001,!1)}function vp(i){return new ne(3003,!1)}function yp(i){return new ne(3004,!1)}function Yl(i,e){return new ne(3005,!1)}function Ql(){return new ne(3006,!1)}function Kl(){return new ne(3007,!1)}function Xl(i,e){return new ne(3008,!1)}function Jl(i){return new ne(3002,!1)}function Zl(i,e,t,n,r){return new ne(3010,!1)}function ec(){return new ne(3011,!1)}function tc(){return new ne(3012,!1)}function nc(){return new ne(3200,!1)}function ic(){return new ne(3202,!1)}function rc(){return new ne(3013,!1)}function oc(i){return new ne(3014,!1)}function ac(i){return new ne(3015,!1)}function sc(i){return new ne(3016,!1)}function lc(i,e){return new ne(3404,!1)}function Cp(i){return new ne(3502,!1)}function cc(i){return new ne(3503,!1)}function dc(){return new ne(3300,!1)}function pc(i){return new ne(3504,!1)}function mc(i){return new ne(3301,!1)}function uc(i,e){return new ne(3302,!1)}function hc(i){return new ne(3303,!1)}function gc(i,e){return new ne(3400,!1)}function fc(i){return new ne(3401,!1)}function _c(i){return new ne(3402,!1)}function bc(i,e){return new ne(3505,!1)}function Zt(i){switch(i.length){case 0:return new Ft;case 1:return i[0];default:return new kn(i)}}function ma(i,e,t=new Map,n=new Map){let r=[],o=[],a=-1,s=null;if(e.forEach(d=>{let m=d.get("offset"),_=m==a,b=_&&s||new Map;d.forEach((y,P)=>{let E=P,k=y;if(P!=="offset")switch(E=i.normalizePropertyName(E,r),k){case ti:k=t.get(P);break;case gt:k=n.get(P);break;default:k=i.normalizeStyleValue(P,E,k,r);break}b.set(E,k)}),_||o.push(b),s=b,a=m}),r.length)throw Cp(r);return o}function Fr(i,e,t,n){switch(e){case"start":i.onStart(()=>n(t&&ca(t,"start",i)));break;case"done":i.onDone(()=>n(t&&ca(t,"done",i)));break;case"destroy":i.onDestroy(()=>n(t&&ca(t,"destroy",i)));break}}function ca(i,e,t){let n=t.totalTime,r=!!t.disabled,o=Lr(i.element,i.triggerName,i.fromState,i.toState,e||i.phaseName,n??i.totalTime,r),a=i._data;return a!=null&&(o._data=a),o}function Lr(i,e,t,n,r="",o=0,a){return{element:i,triggerName:e,fromState:t,toState:n,phaseName:r,totalTime:o,disabled:!!a}}function lt(i,e,t){let n=i.get(e);return n||i.set(e,n=t),n}function ua(i){let e=i.indexOf(":"),t=i.substring(1,e),n=i.slice(e+1);return[t,n]}var Sp=typeof document>"u"?null:document.documentElement;function jr(i){let e=i.parentNode||i.host||null;return e===Sp?null:e}function xp(i){return i.substring(1,6)=="ebkit"}var On=null,Gl=!1;function vc(i){On||(On=Tp()||{},Gl=On.style?"WebkitAppearance"in On.style:!1);let e=!0;return On.style&&!xp(i)&&(e=i in On.style,!e&&Gl&&(e="Webkit"+i.charAt(0).toUpperCase()+i.slice(1)in On.style)),e}function Tp(){return typeof document<"u"?document.body:null}function ha(i,e){for(;e;){if(e===i)return!0;e=jr(e)}return!1}function ga(i,e,t){if(t)return Array.from(i.querySelectorAll(e));let n=i.querySelector(e);return n?[n]:[]}var wp=1e3,fa="{{",Ep="}}",_a="ng-enter",Vr="ng-leave",Ni="ng-trigger",Fi=".ng-trigger",ba="ng-animating",zr=".ng-animating";function Lt(i){if(typeof i=="number")return i;let e=i.match(/^(-?[\.\d]+)(m?s)/);return!e||e.length<2?0:da(parseFloat(e[1]),e[2])}function da(i,e){return e==="s"?i*wp:i}function Li(i,e,t){return i.hasOwnProperty("duration")?i:Pp(i,e,t)}var Mp=/^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;function Pp(i,e,t){let n,r=0,o="";if(typeof i=="string"){let a=i.match(Mp);if(a===null)return e.push(Wl(i)),{duration:0,delay:0,easing:""};n=da(parseFloat(a[1]),a[2]);let s=a[3];s!=null&&(r=da(parseFloat(s),a[4]));let d=a[5];d&&(o=d)}else n=i;if(!t){let a=!1,s=e.length;n<0&&(e.push(fp()),a=!0),r<0&&(e.push(_p()),a=!0),a&&e.splice(s,0,Wl(i))}return{duration:n,delay:r,easing:o}}function yc(i){return i.length?i[0]instanceof Map?i:i.map(e=>new Map(Object.entries(e))):[]}function St(i,e,t){e.forEach((n,r)=>{let o=$r(r);t&&!t.has(r)&&t.set(r,i.style[o]),i.style[o]=n})}function hn(i,e){e.forEach((t,n)=>{let r=$r(n);i.style[r]=""})}function ni(i){return Array.isArray(i)?i.length==1?i[0]:ql(i):i}function Cc(i,e,t){let n=e.params||{},r=va(i);r.length&&r.forEach(o=>{n.hasOwnProperty(o)||t.push(bp(o))})}var pa=new RegExp(`${fa}\\s*(.+?)\\s*${Ep}`,"g");function va(i){let e=[];if(typeof i=="string"){let t;for(;t=pa.exec(i);)e.push(t[1]);pa.lastIndex=0}return e}function ii(i,e,t){let n=`${i}`,r=n.replace(pa,(o,a)=>{let s=e[a];return s==null&&(t.push(vp(a)),s=""),s.toString()});return r==n?i:r}var kp=/-+([a-z0-9])/g;function $r(i){return i.replace(kp,(...e)=>e[1].toUpperCase())}function Sc(i,e){return i===0||e===0}function xc(i,e,t){if(t.size&&e.length){let n=e[0],r=[];if(t.forEach((o,a)=>{n.has(a)||r.push(a),n.set(a,o)}),r.length)for(let o=1;o<e.length;o++){let a=e[o];r.forEach(s=>a.set(s,Hr(i,s)))}}return e}function ct(i,e,t){switch(e.type){case W.Trigger:return i.visitTrigger(e,t);case W.State:return i.visitState(e,t);case W.Transition:return i.visitTransition(e,t);case W.Sequence:return i.visitSequence(e,t);case W.Group:return i.visitGroup(e,t);case W.Animate:return i.visitAnimate(e,t);case W.Keyframes:return i.visitKeyframes(e,t);case W.Style:return i.visitStyle(e,t);case W.Reference:return i.visitReference(e,t);case W.AnimateChild:return i.visitAnimateChild(e,t);case W.AnimateRef:return i.visitAnimateRef(e,t);case W.Query:return i.visitQuery(e,t);case W.Stagger:return i.visitStagger(e,t);default:throw yp(e.type)}}function Hr(i,e){return window.getComputedStyle(i)[e]}var Fa=(()=>{class i{validateStyleProperty(t){return vc(t)}containsElement(t,n){return ha(t,n)}getParentElement(t){return jr(t)}query(t,n,r){return ga(t,n,r)}computeStyle(t,n,r){return r||""}animate(t,n,r,o,a,s=[],d){return new Ft(r,o)}static \u0275fac=function(n){return new(n||i)};static \u0275prov=U({token:i,factory:i.\u0275fac})}return i})(),In=class{static NOOP=new Fa},Dn=class{};var Op=new Set(["width","height","minWidth","minHeight","maxWidth","maxHeight","left","top","bottom","right","fontSize","outlineWidth","outlineOffset","paddingTop","paddingLeft","paddingBottom","paddingRight","marginTop","marginLeft","marginBottom","marginRight","borderRadius","borderWidth","borderTopWidth","borderLeftWidth","borderRightWidth","borderBottomWidth","textIndent","perspective"]),Gr=class extends Dn{normalizePropertyName(e,t){return $r(e)}normalizeStyleValue(e,t,n,r){let o="",a=n.toString().trim();if(Op.has(t)&&n!==0&&n!=="0")if(typeof n=="number")o="px";else{let s=n.match(/^[+-]?[\d\.]+([a-z]*)$/);s&&s[1].length==0&&r.push(Yl(e,n))}return a+o}};var Yr="*";function Ap(i,e){let t=[];return typeof i=="string"?i.split(/\s*,\s*/).forEach(n=>Ip(n,t,e)):t.push(i),t}function Ip(i,e,t){if(i[0]==":"){let d=Dp(i,t);if(typeof d=="function"){e.push(d);return}i=d}let n=i.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);if(n==null||n.length<4)return t.push(ac(i)),e;let r=n[1],o=n[2],a=n[3];e.push(Tc(r,a));let s=r==Yr&&a==Yr;o[0]=="<"&&!s&&e.push(Tc(a,r))}function Dp(i,e){switch(i){case":enter":return"void => *";case":leave":return"* => void";case":increment":return(t,n)=>parseFloat(n)>parseFloat(t);case":decrement":return(t,n)=>parseFloat(n)<parseFloat(t);default:return e.push(sc(i)),"* => *"}}var Ur=new Set(["true","1"]),Br=new Set(["false","0"]);function Tc(i,e){let t=Ur.has(i)||Br.has(i),n=Ur.has(e)||Br.has(e);return(r,o)=>{let a=i==Yr||i==r,s=e==Yr||e==o;return!a&&t&&typeof r=="boolean"&&(a=r?Ur.has(i):Br.has(i)),!s&&n&&typeof o=="boolean"&&(s=o?Ur.has(e):Br.has(e)),a&&s}}var Rc=":self",Rp=new RegExp(`s*${Rc}s*,?`,"g");function Nc(i,e,t,n){return new wa(i).build(e,t,n)}var wc="",wa=class{_driver;constructor(e){this._driver=e}build(e,t,n){let r=new Ea(t);return this._resetContextStyleTimingState(r),ct(this,ni(e),r)}_resetContextStyleTimingState(e){e.currentQuerySelector=wc,e.collectedStyles=new Map,e.collectedStyles.set(wc,new Map),e.currentTime=0}visitTrigger(e,t){let n=t.queryCount=0,r=t.depCount=0,o=[],a=[];return e.name.charAt(0)=="@"&&t.errors.push(Ql()),e.definitions.forEach(s=>{if(this._resetContextStyleTimingState(t),s.type==W.State){let d=s,m=d.name;m.toString().split(/\s*,\s*/).forEach(_=>{d.name=_,o.push(this.visitState(d,t))}),d.name=m}else if(s.type==W.Transition){let d=this.visitTransition(s,t);n+=d.queryCount,r+=d.depCount,a.push(d)}else t.errors.push(Kl())}),{type:W.Trigger,name:e.name,states:o,transitions:a,queryCount:n,depCount:r,options:null}}visitState(e,t){let n=this.visitStyle(e.styles,t),r=e.options&&e.options.params||null;if(n.containsDynamicStyles){let o=new Set,a=r||{};n.styles.forEach(s=>{s instanceof Map&&s.forEach(d=>{va(d).forEach(m=>{a.hasOwnProperty(m)||o.add(m)})})}),o.size&&t.errors.push(Xl(e.name,[...o.values()]))}return{type:W.State,name:e.name,style:n,options:r?{params:r}:null}}visitTransition(e,t){t.queryCount=0,t.depCount=0;let n=ct(this,ni(e.animation),t),r=Ap(e.expr,t.errors);return{type:W.Transition,matchers:r,animation:n,queryCount:t.queryCount,depCount:t.depCount,options:An(e.options)}}visitSequence(e,t){return{type:W.Sequence,steps:e.steps.map(n=>ct(this,n,t)),options:An(e.options)}}visitGroup(e,t){let n=t.currentTime,r=0,o=e.steps.map(a=>{t.currentTime=n;let s=ct(this,a,t);return r=Math.max(r,t.currentTime),s});return t.currentTime=r,{type:W.Group,steps:o,options:An(e.options)}}visitAnimate(e,t){let n=jp(e.timings,t.errors);t.currentAnimateTimings=n;let r,o=e.styles?e.styles:un({});if(o.type==W.Keyframes)r=this.visitKeyframes(o,t);else{let a=e.styles,s=!1;if(!a){s=!0;let m={};n.easing&&(m.easing=n.easing),a=un(m)}t.currentTime+=n.duration+n.delay;let d=this.visitStyle(a,t);d.isEmptyStep=s,r=d}return t.currentAnimateTimings=null,{type:W.Animate,timings:n,style:r,options:null}}visitStyle(e,t){let n=this._makeStyleAst(e,t);return this._validateStyleAst(n,t),n}_makeStyleAst(e,t){let n=[],r=Array.isArray(e.styles)?e.styles:[e.styles];for(let s of r)typeof s=="string"?s===gt?n.push(s):t.errors.push(Jl(s)):n.push(new Map(Object.entries(s)));let o=!1,a=null;return n.forEach(s=>{if(s instanceof Map&&(s.has("easing")&&(a=s.get("easing"),s.delete("easing")),!o)){for(let d of s.values())if(d.toString().indexOf(fa)>=0){o=!0;break}}}),{type:W.Style,styles:n,easing:a,offset:e.offset,containsDynamicStyles:o,options:null}}_validateStyleAst(e,t){let n=t.currentAnimateTimings,r=t.currentTime,o=t.currentTime;n&&o>0&&(o-=n.duration+n.delay),e.styles.forEach(a=>{typeof a!="string"&&a.forEach((s,d)=>{let m=t.collectedStyles.get(t.currentQuerySelector),_=m.get(d),b=!0;_&&(o!=r&&o>=_.startTime&&r<=_.endTime&&(t.errors.push(Zl(d,_.startTime,_.endTime,o,r)),b=!1),o=_.startTime),b&&m.set(d,{startTime:o,endTime:r}),t.options&&Cc(s,t.options,t.errors)})})}visitKeyframes(e,t){let n={type:W.Keyframes,styles:[],options:null};if(!t.currentAnimateTimings)return t.errors.push(ec()),n;let r=1,o=0,a=[],s=!1,d=!1,m=0,_=e.steps.map(pe=>{let D=this._makeStyleAst(pe,t),K=D.offset!=null?D.offset:Lp(D.styles),B=0;return K!=null&&(o++,B=D.offset=K),d=d||B<0||B>1,s=s||B<m,m=B,a.push(B),D});d&&t.errors.push(tc()),s&&t.errors.push(nc());let b=e.steps.length,y=0;o>0&&o<b?t.errors.push(ic()):o==0&&(y=r/(b-1));let P=b-1,E=t.currentTime,k=t.currentAnimateTimings,Q=k.duration;return _.forEach((pe,D)=>{let K=y>0?D==P?1:y*D:a[D],B=K*Q;t.currentTime=E+k.delay+B,k.duration=B,this._validateStyleAst(pe,t),pe.offset=K,n.styles.push(pe)}),n}visitReference(e,t){return{type:W.Reference,animation:ct(this,ni(e.animation),t),options:An(e.options)}}visitAnimateChild(e,t){return t.depCount++,{type:W.AnimateChild,options:An(e.options)}}visitAnimateRef(e,t){return{type:W.AnimateRef,animation:this.visitReference(e.animation,t),options:An(e.options)}}visitQuery(e,t){let n=t.currentQuerySelector,r=e.options||{};t.queryCount++,t.currentQuery=e;let[o,a]=Np(e.selector);t.currentQuerySelector=n.length?n+" "+o:o,lt(t.collectedStyles,t.currentQuerySelector,new Map);let s=ct(this,ni(e.animation),t);return t.currentQuery=null,t.currentQuerySelector=n,{type:W.Query,selector:o,limit:r.limit||0,optional:!!r.optional,includeSelf:a,animation:s,originalSelector:e.selector,options:An(e.options)}}visitStagger(e,t){t.currentQuery||t.errors.push(rc());let n=e.timings==="full"?{duration:0,delay:0,easing:"full"}:Li(e.timings,t.errors,!0);return{type:W.Stagger,animation:ct(this,ni(e.animation),t),timings:n,options:null}}};function Np(i){let e=!!i.split(/\s*,\s*/).find(t=>t==Rc);return e&&(i=i.replace(Rp,"")),i=i.replace(/@\*/g,Fi).replace(/@\w+/g,t=>Fi+"-"+t.slice(1)).replace(/:animating/g,zr),[i,e]}function Fp(i){return i?G({},i):null}var Ea=class{errors;queryCount=0;depCount=0;currentTransition=null;currentQuery=null;currentQuerySelector=null;currentAnimateTimings=null;currentTime=0;collectedStyles=new Map;options=null;unsupportedCSSPropertiesFound=new Set;constructor(e){this.errors=e}};function Lp(i){if(typeof i=="string")return null;let e=null;if(Array.isArray(i))i.forEach(t=>{if(t instanceof Map&&t.has("offset")){let n=t;e=parseFloat(n.get("offset")),n.delete("offset")}});else if(i instanceof Map&&i.has("offset")){let t=i;e=parseFloat(t.get("offset")),t.delete("offset")}return e}function jp(i,e){if(i.hasOwnProperty("duration"))return i;if(typeof i=="number"){let o=Li(i,e).duration;return ya(o,0,"")}let t=i;if(t.split(/\s+/).some(o=>o.charAt(0)=="{"&&o.charAt(1)=="{")){let o=ya(0,0,"");return o.dynamic=!0,o.strValue=t,o}let r=Li(t,e);return ya(r.duration,r.delay,r.easing)}function An(i){return i?(i=G({},i),i.params&&(i.params=Fp(i.params))):i={},i}function ya(i,e,t){return{duration:i,delay:e,easing:t}}function La(i,e,t,n,r,o,a=null,s=!1){return{type:1,element:i,keyframes:e,preStyleProps:t,postStyleProps:n,duration:r,delay:o,totalTime:r+o,easing:a,subTimeline:s}}var Vi=class{_map=new Map;get(e){return this._map.get(e)||[]}append(e,t){let n=this._map.get(e);n||this._map.set(e,n=[]),n.push(...t)}has(e){return this._map.has(e)}clear(){this._map.clear()}},Vp=1,zp=":enter",$p=new RegExp(zp,"g"),Hp=":leave",Up=new RegExp(Hp,"g");function Fc(i,e,t,n,r,o=new Map,a=new Map,s,d,m=[]){return new Ma().buildKeyframes(i,e,t,n,r,o,a,s,d,m)}var Ma=class{buildKeyframes(e,t,n,r,o,a,s,d,m,_=[]){m=m||new Vi;let b=new Pa(e,t,m,r,o,_,[]);b.options=d;let y=d.delay?Lt(d.delay):0;b.currentTimeline.delayNextStep(y),b.currentTimeline.setStyles([a],null,b.errors,d),ct(this,n,b);let P=b.timelines.filter(E=>E.containsAnimation());if(P.length&&s.size){let E;for(let k=P.length-1;k>=0;k--){let Q=P[k];if(Q.element===t){E=Q;break}}E&&!E.allowOnlyTimelineStyles()&&E.setStyles([s],null,b.errors,d)}return P.length?P.map(E=>E.buildKeyframes()):[La(t,[],[],[],0,y,"",!1)]}visitTrigger(e,t){}visitState(e,t){}visitTransition(e,t){}visitAnimateChild(e,t){let n=t.subInstructions.get(t.element);if(n){let r=t.createSubContext(e.options),o=t.currentTimeline.currentTime,a=this._visitSubInstructions(n,r,r.options);o!=a&&t.transformIntoNewTimeline(a)}t.previousNode=e}visitAnimateRef(e,t){let n=t.createSubContext(e.options);n.transformIntoNewTimeline(),this._applyAnimationRefDelays([e.options,e.animation.options],t,n),this.visitReference(e.animation,n),t.transformIntoNewTimeline(n.currentTimeline.currentTime),t.previousNode=e}_applyAnimationRefDelays(e,t,n){for(let r of e){let o=r?.delay;if(o){let a=typeof o=="number"?o:Lt(ii(o,r?.params??{},t.errors));n.delayNextStep(a)}}}_visitSubInstructions(e,t,n){let o=t.currentTimeline.currentTime,a=n.duration!=null?Lt(n.duration):null,s=n.delay!=null?Lt(n.delay):null;return a!==0&&e.forEach(d=>{let m=t.appendInstructionToTimeline(d,a,s);o=Math.max(o,m.duration+m.delay)}),o}visitReference(e,t){t.updateOptions(e.options,!0),ct(this,e.animation,t),t.previousNode=e}visitSequence(e,t){let n=t.subContextCount,r=t,o=e.options;if(o&&(o.params||o.delay)&&(r=t.createSubContext(o),r.transformIntoNewTimeline(),o.delay!=null)){r.previousNode.type==W.Style&&(r.currentTimeline.snapshotCurrentStyles(),r.previousNode=Qr);let a=Lt(o.delay);r.delayNextStep(a)}e.steps.length&&(e.steps.forEach(a=>ct(this,a,r)),r.currentTimeline.applyStylesToKeyframe(),r.subContextCount>n&&r.transformIntoNewTimeline()),t.previousNode=e}visitGroup(e,t){let n=[],r=t.currentTimeline.currentTime,o=e.options&&e.options.delay?Lt(e.options.delay):0;e.steps.forEach(a=>{let s=t.createSubContext(e.options);o&&s.delayNextStep(o),ct(this,a,s),r=Math.max(r,s.currentTimeline.currentTime),n.push(s.currentTimeline)}),n.forEach(a=>t.currentTimeline.mergeTimelineCollectedStyles(a)),t.transformIntoNewTimeline(r),t.previousNode=e}_visitTiming(e,t){if(e.dynamic){let n=e.strValue,r=t.params?ii(n,t.params,t.errors):n;return Li(r,t.errors)}else return{duration:e.duration,delay:e.delay,easing:e.easing}}visitAnimate(e,t){let n=t.currentAnimateTimings=this._visitTiming(e.timings,t),r=t.currentTimeline;n.delay&&(t.incrementTime(n.delay),r.snapshotCurrentStyles());let o=e.style;o.type==W.Keyframes?this.visitKeyframes(o,t):(t.incrementTime(n.duration),this.visitStyle(o,t),r.applyStylesToKeyframe()),t.currentAnimateTimings=null,t.previousNode=e}visitStyle(e,t){let n=t.currentTimeline,r=t.currentAnimateTimings;!r&&n.hasCurrentStyleProperties()&&n.forwardFrame();let o=r&&r.easing||e.easing;e.isEmptyStep?n.applyEmptyStep(o):n.setStyles(e.styles,o,t.errors,t.options),t.previousNode=e}visitKeyframes(e,t){let n=t.currentAnimateTimings,r=t.currentTimeline.duration,o=n.duration,s=t.createSubContext().currentTimeline;s.easing=n.easing,e.styles.forEach(d=>{let m=d.offset||0;s.forwardTime(m*o),s.setStyles(d.styles,d.easing,t.errors,t.options),s.applyStylesToKeyframe()}),t.currentTimeline.mergeTimelineCollectedStyles(s),t.transformIntoNewTimeline(r+o),t.previousNode=e}visitQuery(e,t){let n=t.currentTimeline.currentTime,r=e.options||{},o=r.delay?Lt(r.delay):0;o&&(t.previousNode.type===W.Style||n==0&&t.currentTimeline.hasCurrentStyleProperties())&&(t.currentTimeline.snapshotCurrentStyles(),t.previousNode=Qr);let a=n,s=t.invokeQuery(e.selector,e.originalSelector,e.limit,e.includeSelf,!!r.optional,t.errors);t.currentQueryTotal=s.length;let d=null;s.forEach((m,_)=>{t.currentQueryIndex=_;let b=t.createSubContext(e.options,m);o&&b.delayNextStep(o),m===t.element&&(d=b.currentTimeline),ct(this,e.animation,b),b.currentTimeline.applyStylesToKeyframe();let y=b.currentTimeline.currentTime;a=Math.max(a,y)}),t.currentQueryIndex=0,t.currentQueryTotal=0,t.transformIntoNewTimeline(a),d&&(t.currentTimeline.mergeTimelineCollectedStyles(d),t.currentTimeline.snapshotCurrentStyles()),t.previousNode=e}visitStagger(e,t){let n=t.parentContext,r=t.currentTimeline,o=e.timings,a=Math.abs(o.duration),s=a*(t.currentQueryTotal-1),d=a*t.currentQueryIndex;switch(o.duration<0?"reverse":o.easing){case"reverse":d=s-d;break;case"full":d=n.currentStaggerTime;break}let _=t.currentTimeline;d&&_.delayNextStep(d);let b=_.currentTime;ct(this,e.animation,t),t.previousNode=e,n.currentStaggerTime=r.currentTime-b+(r.startTime-n.currentTimeline.startTime)}},Qr={},Pa=class i{_driver;element;subInstructions;_enterClassName;_leaveClassName;errors;timelines;parentContext=null;currentTimeline;currentAnimateTimings=null;previousNode=Qr;subContextCount=0;options={};currentQueryIndex=0;currentQueryTotal=0;currentStaggerTime=0;constructor(e,t,n,r,o,a,s,d){this._driver=e,this.element=t,this.subInstructions=n,this._enterClassName=r,this._leaveClassName=o,this.errors=a,this.timelines=s,this.currentTimeline=d||new Kr(this._driver,t,0),s.push(this.currentTimeline)}get params(){return this.options.params}updateOptions(e,t){if(!e)return;let n=e,r=this.options;n.duration!=null&&(r.duration=Lt(n.duration)),n.delay!=null&&(r.delay=Lt(n.delay));let o=n.params;if(o){let a=r.params;a||(a=this.options.params={}),Object.keys(o).forEach(s=>{(!t||!a.hasOwnProperty(s))&&(a[s]=ii(o[s],a,this.errors))})}}_copyOptions(){let e={};if(this.options){let t=this.options.params;if(t){let n=e.params={};Object.keys(t).forEach(r=>{n[r]=t[r]})}}return e}createSubContext(e=null,t,n){let r=t||this.element,o=new i(this._driver,r,this.subInstructions,this._enterClassName,this._leaveClassName,this.errors,this.timelines,this.currentTimeline.fork(r,n||0));return o.previousNode=this.previousNode,o.currentAnimateTimings=this.currentAnimateTimings,o.options=this._copyOptions(),o.updateOptions(e),o.currentQueryIndex=this.currentQueryIndex,o.currentQueryTotal=this.currentQueryTotal,o.parentContext=this,this.subContextCount++,o}transformIntoNewTimeline(e){return this.previousNode=Qr,this.currentTimeline=this.currentTimeline.fork(this.element,e),this.timelines.push(this.currentTimeline),this.currentTimeline}appendInstructionToTimeline(e,t,n){let r={duration:t??e.duration,delay:this.currentTimeline.currentTime+(n??0)+e.delay,easing:""},o=new ka(this._driver,e.element,e.keyframes,e.preStyleProps,e.postStyleProps,r,e.stretchStartingKeyframe);return this.timelines.push(o),r}incrementTime(e){this.currentTimeline.forwardTime(this.currentTimeline.duration+e)}delayNextStep(e){e>0&&this.currentTimeline.delayNextStep(e)}invokeQuery(e,t,n,r,o,a){let s=[];if(r&&s.push(this.element),e.length>0){e=e.replace($p,"."+this._enterClassName),e=e.replace(Up,"."+this._leaveClassName);let d=n!=1,m=this._driver.query(this.element,e,d);n!==0&&(m=n<0?m.slice(m.length+n,m.length):m.slice(0,n)),s.push(...m)}return!o&&s.length==0&&a.push(oc(t)),s}},Kr=class i{_driver;element;startTime;_elementTimelineStylesLookup;duration=0;easing=null;_previousKeyframe=new Map;_currentKeyframe=new Map;_keyframes=new Map;_styleSummary=new Map;_localTimelineStyles=new Map;_globalTimelineStyles;_pendingStyles=new Map;_backFill=new Map;_currentEmptyStepKeyframe=null;constructor(e,t,n,r){this._driver=e,this.element=t,this.startTime=n,this._elementTimelineStylesLookup=r,this._elementTimelineStylesLookup||(this._elementTimelineStylesLookup=new Map),this._globalTimelineStyles=this._elementTimelineStylesLookup.get(t),this._globalTimelineStyles||(this._globalTimelineStyles=this._localTimelineStyles,this._elementTimelineStylesLookup.set(t,this._localTimelineStyles)),this._loadKeyframe()}containsAnimation(){switch(this._keyframes.size){case 0:return!1;case 1:return this.hasCurrentStyleProperties();default:return!0}}hasCurrentStyleProperties(){return this._currentKeyframe.size>0}get currentTime(){return this.startTime+this.duration}delayNextStep(e){let t=this._keyframes.size===1&&this._pendingStyles.size;this.duration||t?(this.forwardTime(this.currentTime+e),t&&this.snapshotCurrentStyles()):this.startTime+=e}fork(e,t){return this.applyStylesToKeyframe(),new i(this._driver,e,t||this.currentTime,this._elementTimelineStylesLookup)}_loadKeyframe(){this._currentKeyframe&&(this._previousKeyframe=this._currentKeyframe),this._currentKeyframe=this._keyframes.get(this.duration),this._currentKeyframe||(this._currentKeyframe=new Map,this._keyframes.set(this.duration,this._currentKeyframe))}forwardFrame(){this.duration+=Vp,this._loadKeyframe()}forwardTime(e){this.applyStylesToKeyframe(),this.duration=e,this._loadKeyframe()}_updateStyle(e,t){this._localTimelineStyles.set(e,t),this._globalTimelineStyles.set(e,t),this._styleSummary.set(e,{time:this.currentTime,value:t})}allowOnlyTimelineStyles(){return this._currentEmptyStepKeyframe!==this._currentKeyframe}applyEmptyStep(e){e&&this._previousKeyframe.set("easing",e);for(let[t,n]of this._globalTimelineStyles)this._backFill.set(t,n||gt),this._currentKeyframe.set(t,gt);this._currentEmptyStepKeyframe=this._currentKeyframe}setStyles(e,t,n,r){t&&this._previousKeyframe.set("easing",t);let o=r&&r.params||{},a=Bp(e,this._globalTimelineStyles);for(let[s,d]of a){let m=ii(d,o,n);this._pendingStyles.set(s,m),this._localTimelineStyles.has(s)||this._backFill.set(s,this._globalTimelineStyles.get(s)??gt),this._updateStyle(s,m)}}applyStylesToKeyframe(){this._pendingStyles.size!=0&&(this._pendingStyles.forEach((e,t)=>{this._currentKeyframe.set(t,e)}),this._pendingStyles.clear(),this._localTimelineStyles.forEach((e,t)=>{this._currentKeyframe.has(t)||this._currentKeyframe.set(t,e)}))}snapshotCurrentStyles(){for(let[e,t]of this._localTimelineStyles)this._pendingStyles.set(e,t),this._updateStyle(e,t)}getFinalKeyframe(){return this._keyframes.get(this.duration)}get properties(){let e=[];for(let t in this._currentKeyframe)e.push(t);return e}mergeTimelineCollectedStyles(e){e._styleSummary.forEach((t,n)=>{let r=this._styleSummary.get(n);(!r||t.time>r.time)&&this._updateStyle(n,t.value)})}buildKeyframes(){this.applyStylesToKeyframe();let e=new Set,t=new Set,n=this._keyframes.size===1&&this.duration===0,r=[];this._keyframes.forEach((s,d)=>{let m=new Map([...this._backFill,...s]);m.forEach((_,b)=>{_===ti?e.add(b):_===gt&&t.add(b)}),n||m.set("offset",d/this.duration),r.push(m)});let o=[...e.values()],a=[...t.values()];if(n){let s=r[0],d=new Map(s);s.set("offset",0),d.set("offset",1),r=[s,d]}return La(this.element,r,o,a,this.duration,this.startTime,this.easing,!1)}},ka=class extends Kr{keyframes;preStyleProps;postStyleProps;_stretchStartingKeyframe;timings;constructor(e,t,n,r,o,a,s=!1){super(e,t,a.delay),this.keyframes=n,this.preStyleProps=r,this.postStyleProps=o,this._stretchStartingKeyframe=s,this.timings={duration:a.duration,delay:a.delay,easing:a.easing}}containsAnimation(){return this.keyframes.length>1}buildKeyframes(){let e=this.keyframes,{delay:t,duration:n,easing:r}=this.timings;if(this._stretchStartingKeyframe&&t){let o=[],a=n+t,s=t/a,d=new Map(e[0]);d.set("offset",0),o.push(d);let m=new Map(e[0]);m.set("offset",Ec(s)),o.push(m);let _=e.length-1;for(let b=1;b<=_;b++){let y=new Map(e[b]),P=y.get("offset"),E=t+P*n;y.set("offset",Ec(E/a)),o.push(y)}n=a,t=0,r="",e=o}return La(this.element,e,this.preStyleProps,this.postStyleProps,n,t,r,!0)}};function Ec(i,e=3){let t=Math.pow(10,e-1);return Math.round(i*t)/t}function Bp(i,e){let t=new Map,n;return i.forEach(r=>{if(r==="*"){n??=e.keys();for(let o of n)t.set(o,gt)}else for(let[o,a]of r)t.set(o,a)}),t}function Mc(i,e,t,n,r,o,a,s,d,m,_,b,y){return{type:0,element:i,triggerName:e,isRemovalTransition:r,fromState:t,fromStyles:o,toState:n,toStyles:a,timelines:s,queriedElements:d,preStyleProps:m,postStyleProps:_,totalTime:b,errors:y}}var Ca={},Xr=class{_triggerName;ast;_stateStyles;constructor(e,t,n){this._triggerName=e,this.ast=t,this._stateStyles=n}match(e,t,n,r){return qp(this.ast.matchers,e,t,n,r)}buildStyles(e,t,n){let r=this._stateStyles.get("*");return e!==void 0&&(r=this._stateStyles.get(e?.toString())||r),r?r.buildStyles(t,n):new Map}build(e,t,n,r,o,a,s,d,m,_){let b=[],y=this.ast.options&&this.ast.options.params||Ca,P=s&&s.params||Ca,E=this.buildStyles(n,P,b),k=d&&d.params||Ca,Q=this.buildStyles(r,k,b),pe=new Set,D=new Map,K=new Map,B=r==="void",xe={params:Lc(k,y),delay:this.ast.options?.delay},de=_?[]:Fc(e,t,this.ast.animation,o,a,E,Q,xe,m,b),ye=0;return de.forEach(He=>{ye=Math.max(He.duration+He.delay,ye)}),b.length?Mc(t,this._triggerName,n,r,B,E,Q,[],[],D,K,ye,b):(de.forEach(He=>{let Gt=He.element,on=lt(D,Gt,new Set);He.preStyleProps.forEach(vt=>on.add(vt));let Fe=lt(K,Gt,new Set);He.postStyleProps.forEach(vt=>Fe.add(vt)),Gt!==t&&pe.add(Gt)}),Mc(t,this._triggerName,n,r,B,E,Q,de,[...pe.values()],D,K,ye))}};function qp(i,e,t,n,r){return i.some(o=>o(e,t,n,r))}function Lc(i,e){let t=G({},e);return Object.entries(i).forEach(([n,r])=>{r!=null&&(t[n]=r)}),t}var Oa=class{styles;defaultParams;normalizer;constructor(e,t,n){this.styles=e,this.defaultParams=t,this.normalizer=n}buildStyles(e,t){let n=new Map,r=Lc(e,this.defaultParams);return this.styles.styles.forEach(o=>{typeof o!="string"&&o.forEach((a,s)=>{a&&(a=ii(a,r,t));let d=this.normalizer.normalizePropertyName(s,t);a=this.normalizer.normalizeStyleValue(s,d,a,t),n.set(s,a)})}),n}};function Wp(i,e,t){return new Aa(i,e,t)}var Aa=class{name;ast;_normalizer;transitionFactories=[];fallbackTransition;states=new Map;constructor(e,t,n){this.name=e,this.ast=t,this._normalizer=n,t.states.forEach(r=>{let o=r.options&&r.options.params||{};this.states.set(r.name,new Oa(r.style,o,n))}),Pc(this.states,"true","1"),Pc(this.states,"false","0"),t.transitions.forEach(r=>{this.transitionFactories.push(new Xr(e,r,this.states))}),this.fallbackTransition=Gp(e,this.states)}get containsQueries(){return this.ast.queryCount>0}matchTransition(e,t,n,r){return this.transitionFactories.find(a=>a.match(e,t,n,r))||null}matchStyles(e,t,n){return this.fallbackTransition.buildStyles(e,t,n)}};function Gp(i,e,t){let n=[(a,s)=>!0],r={type:W.Sequence,steps:[],options:null},o={type:W.Transition,animation:r,matchers:n,options:null,queryCount:0,depCount:0};return new Xr(i,o,e)}function Pc(i,e,t){i.has(e)?i.has(t)||i.set(t,i.get(e)):i.has(t)&&i.set(e,i.get(t))}var Yp=new Vi,Ia=class{bodyNode;_driver;_normalizer;_animations=new Map;_playersById=new Map;players=[];constructor(e,t,n){this.bodyNode=e,this._driver=t,this._normalizer=n}register(e,t){let n=[],r=[],o=Nc(this._driver,t,n,r);if(n.length)throw cc(n);this._animations.set(e,o)}_buildPlayer(e,t,n){let r=e.element,o=ma(this._normalizer,e.keyframes,t,n);return this._driver.animate(r,o,e.duration,e.delay,e.easing,[],!0)}create(e,t,n={}){let r=[],o=this._animations.get(e),a,s=new Map;if(o?(a=Fc(this._driver,t,o,_a,Vr,new Map,new Map,n,Yp,r),a.forEach(_=>{let b=lt(s,_.element,new Map);_.postStyleProps.forEach(y=>b.set(y,null))})):(r.push(dc()),a=[]),r.length)throw pc(r);s.forEach((_,b)=>{_.forEach((y,P)=>{_.set(P,this._driver.computeStyle(b,P,gt))})});let d=a.map(_=>{let b=s.get(_.element);return this._buildPlayer(_,new Map,b)}),m=Zt(d);return this._playersById.set(e,m),m.onDestroy(()=>this.destroy(e)),this.players.push(m),m}destroy(e){let t=this._getPlayer(e);t.destroy(),this._playersById.delete(e);let n=this.players.indexOf(t);n>=0&&this.players.splice(n,1)}_getPlayer(e){let t=this._playersById.get(e);if(!t)throw mc(e);return t}listen(e,t,n,r){let o=Lr(t,"","","");return Fr(this._getPlayer(e),n,o,r),()=>{}}command(e,t,n,r){if(n=="register"){this.register(e,r[0]);return}if(n=="create"){let a=r[0]||{};this.create(e,t,a);return}let o=this._getPlayer(e);switch(n){case"play":o.play();break;case"pause":o.pause();break;case"reset":o.reset();break;case"restart":o.restart();break;case"finish":o.finish();break;case"init":o.init();break;case"setPosition":o.setPosition(parseFloat(r[0]));break;case"destroy":this.destroy(e);break}}},kc="ng-animate-queued",Qp=".ng-animate-queued",Sa="ng-animate-disabled",Kp=".ng-animate-disabled",Xp="ng-star-inserted",Jp=".ng-star-inserted",Zp=[],jc={namespaceId:"",setForRemoval:!1,setForMove:!1,hasAnimation:!1,removedBeforeQueried:!1},em={namespaceId:"",setForMove:!1,setForRemoval:!1,hasAnimation:!1,removedBeforeQueried:!0},xt="__ng_removed",zi=class{namespaceId;value;options;get params(){return this.options.params}constructor(e,t=""){this.namespaceId=t;let n=e&&e.hasOwnProperty("value"),r=n?e.value:e;if(this.value=nm(r),n){let o=e,{value:a}=o,s=As(o,["value"]);this.options=s}else this.options={};this.options.params||(this.options.params={})}absorbOptions(e){let t=e.params;if(t){let n=this.options.params;Object.keys(t).forEach(r=>{n[r]==null&&(n[r]=t[r])})}}},ji="void",xa=new zi(ji),Da=class{id;hostElement;_engine;players=[];_triggers=new Map;_queue=[];_elementListeners=new Map;_hostClassName;constructor(e,t,n){this.id=e,this.hostElement=t,this._engine=n,this._hostClassName="ng-tns-"+e,ft(t,this._hostClassName)}listen(e,t,n,r){if(!this._triggers.has(t))throw uc(n,t);if(n==null||n.length==0)throw hc(t);if(!im(n))throw gc(n,t);let o=lt(this._elementListeners,e,[]),a={name:t,phase:n,callback:r};o.push(a);let s=lt(this._engine.statesByElement,e,new Map);return s.has(t)||(ft(e,Ni),ft(e,Ni+"-"+t),s.set(t,xa)),()=>{this._engine.afterFlush(()=>{let d=o.indexOf(a);d>=0&&o.splice(d,1),this._triggers.has(t)||s.delete(t)})}}register(e,t){return this._triggers.has(e)?!1:(this._triggers.set(e,t),!0)}_getTrigger(e){let t=this._triggers.get(e);if(!t)throw fc(e);return t}trigger(e,t,n,r=!0){let o=this._getTrigger(t),a=new $i(this.id,t,e),s=this._engine.statesByElement.get(e);s||(ft(e,Ni),ft(e,Ni+"-"+t),this._engine.statesByElement.set(e,s=new Map));let d=s.get(t),m=new zi(n,this.id);if(!(n&&n.hasOwnProperty("value"))&&d&&m.absorbOptions(d.options),s.set(t,m),d||(d=xa),!(m.value===ji)&&d.value===m.value){if(!am(d.params,m.params)){let k=[],Q=o.matchStyles(d.value,d.params,k),pe=o.matchStyles(m.value,m.params,k);k.length?this._engine.reportError(k):this._engine.afterFlush(()=>{hn(e,Q),St(e,pe)})}return}let y=lt(this._engine.playersByElement,e,[]);y.forEach(k=>{k.namespaceId==this.id&&k.triggerName==t&&k.queued&&k.destroy()});let P=o.matchTransition(d.value,m.value,e,m.params),E=!1;if(!P){if(!r)return;P=o.fallbackTransition,E=!0}return this._engine.totalQueuedPlayers++,this._queue.push({element:e,triggerName:t,transition:P,fromState:d,toState:m,player:a,isFallbackTransition:E}),E||(ft(e,kc),a.onStart(()=>{ri(e,kc)})),a.onDone(()=>{let k=this.players.indexOf(a);k>=0&&this.players.splice(k,1);let Q=this._engine.playersByElement.get(e);if(Q){let pe=Q.indexOf(a);pe>=0&&Q.splice(pe,1)}}),this.players.push(a),y.push(a),a}deregister(e){this._triggers.delete(e),this._engine.statesByElement.forEach(t=>t.delete(e)),this._elementListeners.forEach((t,n)=>{this._elementListeners.set(n,t.filter(r=>r.name!=e))})}clearElementCache(e){this._engine.statesByElement.delete(e),this._elementListeners.delete(e);let t=this._engine.playersByElement.get(e);t&&(t.forEach(n=>n.destroy()),this._engine.playersByElement.delete(e))}_signalRemovalForInnerTriggers(e,t){let n=this._engine.driver.query(e,Fi,!0);n.forEach(r=>{if(r[xt])return;let o=this._engine.fetchNamespacesByElement(r);o.size?o.forEach(a=>a.triggerLeaveAnimation(r,t,!1,!0)):this.clearElementCache(r)}),this._engine.afterFlushAnimationsDone(()=>n.forEach(r=>this.clearElementCache(r)))}triggerLeaveAnimation(e,t,n,r){let o=this._engine.statesByElement.get(e),a=new Map;if(o){let s=[];if(o.forEach((d,m)=>{if(a.set(m,d.value),this._triggers.has(m)){let _=this.trigger(e,m,ji,r);_&&s.push(_)}}),s.length)return this._engine.markElementAsRemoved(this.id,e,!0,t,a),n&&Zt(s).onDone(()=>this._engine.processLeaveNode(e)),!0}return!1}prepareLeaveAnimationListeners(e){let t=this._elementListeners.get(e),n=this._engine.statesByElement.get(e);if(t&&n){let r=new Set;t.forEach(o=>{let a=o.name;if(r.has(a))return;r.add(a);let d=this._triggers.get(a).fallbackTransition,m=n.get(a)||xa,_=new zi(ji),b=new $i(this.id,a,e);this._engine.totalQueuedPlayers++,this._queue.push({element:e,triggerName:a,transition:d,fromState:m,toState:_,player:b,isFallbackTransition:!0})})}}removeNode(e,t){let n=this._engine;if(e.childElementCount&&this._signalRemovalForInnerTriggers(e,t),this.triggerLeaveAnimation(e,t,!0))return;let r=!1;if(n.totalAnimations){let o=n.players.length?n.playersByQueriedElement.get(e):[];if(o&&o.length)r=!0;else{let a=e;for(;a=a.parentNode;)if(n.statesByElement.get(a)){r=!0;break}}}if(this.prepareLeaveAnimationListeners(e),r)n.markElementAsRemoved(this.id,e,!1,t);else{let o=e[xt];(!o||o===jc)&&(n.afterFlush(()=>this.clearElementCache(e)),n.destroyInnerAnimations(e),n._onRemovalComplete(e,t))}}insertNode(e,t){ft(e,this._hostClassName)}drainQueuedTransitions(e){let t=[];return this._queue.forEach(n=>{let r=n.player;if(r.destroyed)return;let o=n.element,a=this._elementListeners.get(o);a&&a.forEach(s=>{if(s.name==n.triggerName){let d=Lr(o,n.triggerName,n.fromState.value,n.toState.value);d._data=e,Fr(n.player,s.phase,d,s.callback)}}),r.markedForDestroy?this._engine.afterFlush(()=>{r.destroy()}):t.push(n)}),this._queue=[],t.sort((n,r)=>{let o=n.transition.ast.depCount,a=r.transition.ast.depCount;return o==0||a==0?o-a:this._engine.driver.containsElement(n.element,r.element)?1:-1})}destroy(e){this.players.forEach(t=>t.destroy()),this._signalRemovalForInnerTriggers(this.hostElement,e)}},Ra=class{bodyNode;driver;_normalizer;players=[];newHostElements=new Map;playersByElement=new Map;playersByQueriedElement=new Map;statesByElement=new Map;disabledNodes=new Set;totalAnimations=0;totalQueuedPlayers=0;_namespaceLookup={};_namespaceList=[];_flushFns=[];_whenQuietFns=[];namespacesByHostElement=new Map;collectedEnterElements=[];collectedLeaveElements=[];onRemovalComplete=(e,t)=>{};_onRemovalComplete(e,t){this.onRemovalComplete(e,t)}constructor(e,t,n){this.bodyNode=e,this.driver=t,this._normalizer=n}get queuedPlayers(){let e=[];return this._namespaceList.forEach(t=>{t.players.forEach(n=>{n.queued&&e.push(n)})}),e}createNamespace(e,t){let n=new Da(e,t,this);return this.bodyNode&&this.driver.containsElement(this.bodyNode,t)?this._balanceNamespaceList(n,t):(this.newHostElements.set(t,n),this.collectEnterElement(t)),this._namespaceLookup[e]=n}_balanceNamespaceList(e,t){let n=this._namespaceList,r=this.namespacesByHostElement;if(n.length-1>=0){let a=!1,s=this.driver.getParentElement(t);for(;s;){let d=r.get(s);if(d){let m=n.indexOf(d);n.splice(m+1,0,e),a=!0;break}s=this.driver.getParentElement(s)}a||n.unshift(e)}else n.push(e);return r.set(t,e),e}register(e,t){let n=this._namespaceLookup[e];return n||(n=this.createNamespace(e,t)),n}registerTrigger(e,t,n){let r=this._namespaceLookup[e];r&&r.register(t,n)&&this.totalAnimations++}destroy(e,t){e&&(this.afterFlush(()=>{}),this.afterFlushAnimationsDone(()=>{let n=this._fetchNamespace(e);this.namespacesByHostElement.delete(n.hostElement);let r=this._namespaceList.indexOf(n);r>=0&&this._namespaceList.splice(r,1),n.destroy(t),delete this._namespaceLookup[e]}))}_fetchNamespace(e){return this._namespaceLookup[e]}fetchNamespacesByElement(e){let t=new Set,n=this.statesByElement.get(e);if(n){for(let r of n.values())if(r.namespaceId){let o=this._fetchNamespace(r.namespaceId);o&&t.add(o)}}return t}trigger(e,t,n,r){if(qr(t)){let o=this._fetchNamespace(e);if(o)return o.trigger(t,n,r),!0}return!1}insertNode(e,t,n,r){if(!qr(t))return;let o=t[xt];if(o&&o.setForRemoval){o.setForRemoval=!1,o.setForMove=!0;let a=this.collectedLeaveElements.indexOf(t);a>=0&&this.collectedLeaveElements.splice(a,1)}if(e){let a=this._fetchNamespace(e);a&&a.insertNode(t,n)}r&&this.collectEnterElement(t)}collectEnterElement(e){this.collectedEnterElements.push(e)}markElementAsDisabled(e,t){t?this.disabledNodes.has(e)||(this.disabledNodes.add(e),ft(e,Sa)):this.disabledNodes.has(e)&&(this.disabledNodes.delete(e),ri(e,Sa))}removeNode(e,t,n){if(qr(t)){let r=e?this._fetchNamespace(e):null;r?r.removeNode(t,n):this.markElementAsRemoved(e,t,!1,n);let o=this.namespacesByHostElement.get(t);o&&o.id!==e&&o.removeNode(t,n)}else this._onRemovalComplete(t,n)}markElementAsRemoved(e,t,n,r,o){this.collectedLeaveElements.push(t),t[xt]={namespaceId:e,setForRemoval:r,hasAnimation:n,removedBeforeQueried:!1,previousTriggersValues:o}}listen(e,t,n,r,o){return qr(t)?this._fetchNamespace(e).listen(t,n,r,o):()=>{}}_buildInstruction(e,t,n,r,o){return e.transition.build(this.driver,e.element,e.fromState.value,e.toState.value,n,r,e.fromState.options,e.toState.options,t,o)}destroyInnerAnimations(e){let t=this.driver.query(e,Fi,!0);t.forEach(n=>this.destroyActiveAnimationsForElement(n)),this.playersByQueriedElement.size!=0&&(t=this.driver.query(e,zr,!0),t.forEach(n=>this.finishActiveQueriedAnimationOnElement(n)))}destroyActiveAnimationsForElement(e){let t=this.playersByElement.get(e);t&&t.forEach(n=>{n.queued?n.markedForDestroy=!0:n.destroy()})}finishActiveQueriedAnimationOnElement(e){let t=this.playersByQueriedElement.get(e);t&&t.forEach(n=>n.finish())}whenRenderingDone(){return new Promise(e=>{if(this.players.length)return Zt(this.players).onDone(()=>e());e()})}processLeaveNode(e){let t=e[xt];if(t&&t.setForRemoval){if(e[xt]=jc,t.namespaceId){this.destroyInnerAnimations(e);let n=this._fetchNamespace(t.namespaceId);n&&n.clearElementCache(e)}this._onRemovalComplete(e,t.setForRemoval)}e.classList?.contains(Sa)&&this.markElementAsDisabled(e,!1),this.driver.query(e,Kp,!0).forEach(n=>{this.markElementAsDisabled(n,!1)})}flush(e=-1){let t=[];if(this.newHostElements.size&&(this.newHostElements.forEach((n,r)=>this._balanceNamespaceList(n,r)),this.newHostElements.clear()),this.totalAnimations&&this.collectedEnterElements.length)for(let n=0;n<this.collectedEnterElements.length;n++){let r=this.collectedEnterElements[n];ft(r,Xp)}if(this._namespaceList.length&&(this.totalQueuedPlayers||this.collectedLeaveElements.length)){let n=[];try{t=this._flushAnimations(n,e)}finally{for(let r=0;r<n.length;r++)n[r]()}}else for(let n=0;n<this.collectedLeaveElements.length;n++){let r=this.collectedLeaveElements[n];this.processLeaveNode(r)}if(this.totalQueuedPlayers=0,this.collectedEnterElements.length=0,this.collectedLeaveElements.length=0,this._flushFns.forEach(n=>n()),this._flushFns=[],this._whenQuietFns.length){let n=this._whenQuietFns;this._whenQuietFns=[],t.length?Zt(t).onDone(()=>{n.forEach(r=>r())}):n.forEach(r=>r())}}reportError(e){throw _c(e)}_flushAnimations(e,t){let n=new Vi,r=[],o=new Map,a=[],s=new Map,d=new Map,m=new Map,_=new Set;this.disabledNodes.forEach(A=>{_.add(A);let L=this.driver.query(A,Qp,!0);for(let V=0;V<L.length;V++)_.add(L[V])});let b=this.bodyNode,y=Array.from(this.statesByElement.keys()),P=Ic(y,this.collectedEnterElements),E=new Map,k=0;P.forEach((A,L)=>{let V=_a+k++;E.set(L,V),A.forEach(X=>ft(X,V))});let Q=[],pe=new Set,D=new Set;for(let A=0;A<this.collectedLeaveElements.length;A++){let L=this.collectedLeaveElements[A],V=L[xt];V&&V.setForRemoval&&(Q.push(L),pe.add(L),V.hasAnimation?this.driver.query(L,Jp,!0).forEach(X=>pe.add(X)):D.add(L))}let K=new Map,B=Ic(y,Array.from(pe));B.forEach((A,L)=>{let V=Vr+k++;K.set(L,V),A.forEach(X=>ft(X,V))}),e.push(()=>{P.forEach((A,L)=>{let V=E.get(L);A.forEach(X=>ri(X,V))}),B.forEach((A,L)=>{let V=K.get(L);A.forEach(X=>ri(X,V))}),Q.forEach(A=>{this.processLeaveNode(A)})});let xe=[],de=[];for(let A=this._namespaceList.length-1;A>=0;A--)this._namespaceList[A].drainQueuedTransitions(t).forEach(V=>{let X=V.player,Ee=V.element;if(xe.push(X),this.collectedEnterElements.length){let Pe=Ee[xt];if(Pe&&Pe.setForMove){if(Pe.previousTriggersValues&&Pe.previousTriggersValues.has(V.triggerName)){let Je=Pe.previousTriggersValues.get(V.triggerName),Ge=this.statesByElement.get(V.element);if(Ge&&Ge.has(V.triggerName)){let an=Ge.get(V.triggerName);an.value=Je,Ge.set(V.triggerName,an)}}X.destroy();return}}let le=!b||!this.driver.containsElement(b,Ee),Ue=K.get(Ee),me=E.get(Ee),ue=this._buildInstruction(V,n,me,Ue,le);if(ue.errors&&ue.errors.length){de.push(ue);return}if(le){X.onStart(()=>hn(Ee,ue.fromStyles)),X.onDestroy(()=>St(Ee,ue.toStyles)),r.push(X);return}if(V.isFallbackTransition){X.onStart(()=>hn(Ee,ue.fromStyles)),X.onDestroy(()=>St(Ee,ue.toStyles)),r.push(X);return}let ge=[];ue.timelines.forEach(Pe=>{Pe.stretchStartingKeyframe=!0,this.disabledNodes.has(Pe.element)||ge.push(Pe)}),ue.timelines=ge,n.append(Ee,ue.timelines);let Cn={instruction:ue,player:X,element:Ee};a.push(Cn),ue.queriedElements.forEach(Pe=>lt(s,Pe,[]).push(X)),ue.preStyleProps.forEach((Pe,Je)=>{if(Pe.size){let Ge=d.get(Je);Ge||d.set(Je,Ge=new Set),Pe.forEach((an,Hn)=>Ge.add(Hn))}}),ue.postStyleProps.forEach((Pe,Je)=>{let Ge=m.get(Je);Ge||m.set(Je,Ge=new Set),Pe.forEach((an,Hn)=>Ge.add(Hn))})});if(de.length){let A=[];de.forEach(L=>{A.push(bc(L.triggerName,L.errors))}),xe.forEach(L=>L.destroy()),this.reportError(A)}let ye=new Map,He=new Map;a.forEach(A=>{let L=A.element;n.has(L)&&(He.set(L,L),this._beforeAnimationBuild(A.player.namespaceId,A.instruction,ye))}),r.forEach(A=>{let L=A.element;this._getPreviousPlayers(L,!1,A.namespaceId,A.triggerName,null).forEach(X=>{lt(ye,L,[]).push(X),X.destroy()})});let Gt=Q.filter(A=>Dc(A,d,m)),on=new Map;Ac(on,this.driver,D,m,gt).forEach(A=>{Dc(A,d,m)&&Gt.push(A)});let vt=new Map;P.forEach((A,L)=>{Ac(vt,this.driver,new Set(A),d,ti)}),Gt.forEach(A=>{let L=on.get(A),V=vt.get(A);on.set(A,new Map([...L?.entries()??[],...V?.entries()??[]]))});let yn=[],$n=[],or={};a.forEach(A=>{let{element:L,player:V,instruction:X}=A;if(n.has(L)){if(_.has(L)){V.onDestroy(()=>St(L,X.toStyles)),V.disabled=!0,V.overrideTotalTime(X.totalTime),r.push(V);return}let Ee=or;if(He.size>1){let Ue=L,me=[];for(;Ue=Ue.parentNode;){let ue=He.get(Ue);if(ue){Ee=ue;break}me.push(Ue)}me.forEach(ue=>He.set(ue,Ee))}let le=this._buildAnimation(V.namespaceId,X,ye,o,vt,on);if(V.setRealPlayer(le),Ee===or)yn.push(V);else{let Ue=this.playersByElement.get(Ee);Ue&&Ue.length&&(V.parentPlayer=Zt(Ue)),r.push(V)}}else hn(L,X.fromStyles),V.onDestroy(()=>St(L,X.toStyles)),$n.push(V),_.has(L)&&r.push(V)}),$n.forEach(A=>{let L=o.get(A.element);if(L&&L.length){let V=Zt(L);A.setRealPlayer(V)}}),r.forEach(A=>{A.parentPlayer?A.syncPlayerEvents(A.parentPlayer):A.destroy()});for(let A=0;A<Q.length;A++){let L=Q[A],V=L[xt];if(ri(L,Vr),V&&V.hasAnimation)continue;let X=[];if(s.size){let le=s.get(L);le&&le.length&&X.push(...le);let Ue=this.driver.query(L,zr,!0);for(let me=0;me<Ue.length;me++){let ue=s.get(Ue[me]);ue&&ue.length&&X.push(...ue)}}let Ee=X.filter(le=>!le.destroyed);Ee.length?rm(this,L,Ee):this.processLeaveNode(L)}return Q.length=0,yn.forEach(A=>{this.players.push(A),A.onDone(()=>{A.destroy();let L=this.players.indexOf(A);this.players.splice(L,1)}),A.play()}),yn}afterFlush(e){this._flushFns.push(e)}afterFlushAnimationsDone(e){this._whenQuietFns.push(e)}_getPreviousPlayers(e,t,n,r,o){let a=[];if(t){let s=this.playersByQueriedElement.get(e);s&&(a=s)}else{let s=this.playersByElement.get(e);if(s){let d=!o||o==ji;s.forEach(m=>{m.queued||!d&&m.triggerName!=r||a.push(m)})}}return(n||r)&&(a=a.filter(s=>!(n&&n!=s.namespaceId||r&&r!=s.triggerName))),a}_beforeAnimationBuild(e,t,n){let r=t.triggerName,o=t.element,a=t.isRemovalTransition?void 0:e,s=t.isRemovalTransition?void 0:r;for(let d of t.timelines){let m=d.element,_=m!==o,b=lt(n,m,[]);this._getPreviousPlayers(m,_,a,s,t.toState).forEach(P=>{let E=P.getRealPlayer();E.beforeDestroy&&E.beforeDestroy(),P.destroy(),b.push(P)})}hn(o,t.fromStyles)}_buildAnimation(e,t,n,r,o,a){let s=t.triggerName,d=t.element,m=[],_=new Set,b=new Set,y=t.timelines.map(E=>{let k=E.element;_.add(k);let Q=k[xt];if(Q&&Q.removedBeforeQueried)return new Ft(E.duration,E.delay);let pe=k!==d,D=om((n.get(k)||Zp).map(ye=>ye.getRealPlayer())).filter(ye=>{let He=ye;return He.element?He.element===k:!1}),K=o.get(k),B=a.get(k),xe=ma(this._normalizer,E.keyframes,K,B),de=this._buildPlayer(E,xe,D);if(E.subTimeline&&r&&b.add(k),pe){let ye=new $i(e,s,k);ye.setRealPlayer(de),m.push(ye)}return de});m.forEach(E=>{lt(this.playersByQueriedElement,E.element,[]).push(E),E.onDone(()=>tm(this.playersByQueriedElement,E.element,E))}),_.forEach(E=>ft(E,ba));let P=Zt(y);return P.onDestroy(()=>{_.forEach(E=>ri(E,ba)),St(d,t.toStyles)}),b.forEach(E=>{lt(r,E,[]).push(P)}),P}_buildPlayer(e,t,n){return t.length>0?this.driver.animate(e.element,t,e.duration,e.delay,e.easing,n):new Ft(e.duration,e.delay)}},$i=class{namespaceId;triggerName;element;_player=new Ft;_containsRealPlayer=!1;_queuedCallbacks=new Map;destroyed=!1;parentPlayer=null;markedForDestroy=!1;disabled=!1;queued=!0;totalTime=0;constructor(e,t,n){this.namespaceId=e,this.triggerName=t,this.element=n}setRealPlayer(e){this._containsRealPlayer||(this._player=e,this._queuedCallbacks.forEach((t,n)=>{t.forEach(r=>Fr(e,n,void 0,r))}),this._queuedCallbacks.clear(),this._containsRealPlayer=!0,this.overrideTotalTime(e.totalTime),this.queued=!1)}getRealPlayer(){return this._player}overrideTotalTime(e){this.totalTime=e}syncPlayerEvents(e){let t=this._player;t.triggerCallback&&e.onStart(()=>t.triggerCallback("start")),e.onDone(()=>this.finish()),e.onDestroy(()=>this.destroy())}_queueEvent(e,t){lt(this._queuedCallbacks,e,[]).push(t)}onDone(e){this.queued&&this._queueEvent("done",e),this._player.onDone(e)}onStart(e){this.queued&&this._queueEvent("start",e),this._player.onStart(e)}onDestroy(e){this.queued&&this._queueEvent("destroy",e),this._player.onDestroy(e)}init(){this._player.init()}hasStarted(){return this.queued?!1:this._player.hasStarted()}play(){!this.queued&&this._player.play()}pause(){!this.queued&&this._player.pause()}restart(){!this.queued&&this._player.restart()}finish(){this._player.finish()}destroy(){this.destroyed=!0,this._player.destroy()}reset(){!this.queued&&this._player.reset()}setPosition(e){this.queued||this._player.setPosition(e)}getPosition(){return this.queued?0:this._player.getPosition()}triggerCallback(e){let t=this._player;t.triggerCallback&&t.triggerCallback(e)}};function tm(i,e,t){let n=i.get(e);if(n){if(n.length){let r=n.indexOf(t);n.splice(r,1)}n.length==0&&i.delete(e)}return n}function nm(i){return i??null}function qr(i){return i&&i.nodeType===1}function im(i){return i=="start"||i=="done"}function Oc(i,e){let t=i.style.display;return i.style.display=e??"none",t}function Ac(i,e,t,n,r){let o=[];t.forEach(d=>o.push(Oc(d)));let a=[];n.forEach((d,m)=>{let _=new Map;d.forEach(b=>{let y=e.computeStyle(m,b,r);_.set(b,y),(!y||y.length==0)&&(m[xt]=em,a.push(m))}),i.set(m,_)});let s=0;return t.forEach(d=>Oc(d,o[s++])),a}function Ic(i,e){let t=new Map;if(i.forEach(s=>t.set(s,[])),e.length==0)return t;let n=1,r=new Set(e),o=new Map;function a(s){if(!s)return n;let d=o.get(s);if(d)return d;let m=s.parentNode;return t.has(m)?d=m:r.has(m)?d=n:d=a(m),o.set(s,d),d}return e.forEach(s=>{let d=a(s);d!==n&&t.get(d).push(s)}),t}function ft(i,e){i.classList?.add(e)}function ri(i,e){i.classList?.remove(e)}function rm(i,e,t){Zt(t).onDone(()=>i.processLeaveNode(e))}function om(i){let e=[];return Vc(i,e),e}function Vc(i,e){for(let t=0;t<i.length;t++){let n=i[t];n instanceof kn?Vc(n.players,e):e.push(n)}}function am(i,e){let t=Object.keys(i),n=Object.keys(e);if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++){let o=t[r];if(!e.hasOwnProperty(o)||i[o]!==e[o])return!1}return!0}function Dc(i,e,t){let n=t.get(i);if(!n)return!1;let r=e.get(i);return r?n.forEach(o=>r.add(o)):e.set(i,n),t.delete(i),!0}var oi=class{_driver;_normalizer;_transitionEngine;_timelineEngine;_triggerCache={};onRemovalComplete=(e,t)=>{};constructor(e,t,n){this._driver=t,this._normalizer=n,this._transitionEngine=new Ra(e.body,t,n),this._timelineEngine=new Ia(e.body,t,n),this._transitionEngine.onRemovalComplete=(r,o)=>this.onRemovalComplete(r,o)}registerTrigger(e,t,n,r,o){let a=e+"-"+r,s=this._triggerCache[a];if(!s){let d=[],m=[],_=Nc(this._driver,o,d,m);if(d.length)throw lc(r,d);s=Wp(r,_,this._normalizer),this._triggerCache[a]=s}this._transitionEngine.registerTrigger(t,r,s)}register(e,t){this._transitionEngine.register(e,t)}destroy(e,t){this._transitionEngine.destroy(e,t)}onInsert(e,t,n,r){this._transitionEngine.insertNode(e,t,n,r)}onRemove(e,t,n){this._transitionEngine.removeNode(e,t,n)}disableAnimations(e,t){this._transitionEngine.markElementAsDisabled(e,t)}process(e,t,n,r){if(n.charAt(0)=="@"){let[o,a]=ua(n),s=r;this._timelineEngine.command(o,t,a,s)}else this._transitionEngine.trigger(e,t,n,r)}listen(e,t,n,r,o){if(n.charAt(0)=="@"){let[a,s]=ua(n);return this._timelineEngine.listen(a,t,s,o)}return this._transitionEngine.listen(e,t,n,r,o)}flush(e=-1){this._transitionEngine.flush(e)}get players(){return[...this._transitionEngine.players,...this._timelineEngine.players]}whenRenderingDone(){return this._transitionEngine.whenRenderingDone()}afterFlushAnimationsDone(e){this._transitionEngine.afterFlushAnimationsDone(e)}};function sm(i,e){let t=null,n=null;return Array.isArray(e)&&e.length?(t=Ta(e[0]),e.length>1&&(n=Ta(e[e.length-1]))):e instanceof Map&&(t=Ta(e)),t||n?new lm(i,t,n):null}var lm=(()=>{class i{_element;_startStyles;_endStyles;static initialStylesByElement=new WeakMap;_state=0;_initialStyles;constructor(t,n,r){this._element=t,this._startStyles=n,this._endStyles=r;let o=i.initialStylesByElement.get(t);o||i.initialStylesByElement.set(t,o=new Map),this._initialStyles=o}start(){this._state<1&&(this._startStyles&&St(this._element,this._startStyles,this._initialStyles),this._state=1)}finish(){this.start(),this._state<2&&(St(this._element,this._initialStyles),this._endStyles&&(St(this._element,this._endStyles),this._endStyles=null),this._state=1)}destroy(){this.finish(),this._state<3&&(i.initialStylesByElement.delete(this._element),this._startStyles&&(hn(this._element,this._startStyles),this._endStyles=null),this._endStyles&&(hn(this._element,this._endStyles),this._endStyles=null),St(this._element,this._initialStyles),this._state=3)}}return i})();function Ta(i){let e=null;return i.forEach((t,n)=>{cm(n)&&(e=e||new Map,e.set(n,t))}),e}function cm(i){return i==="display"||i==="position"}var Jr=class{element;keyframes;options;_specialStyles;_onDoneFns=[];_onStartFns=[];_onDestroyFns=[];_duration;_delay;_initialized=!1;_finished=!1;_started=!1;_destroyed=!1;_finalKeyframe;_originalOnDoneFns=[];_originalOnStartFns=[];domPlayer=null;time=0;parentPlayer=null;currentSnapshot=new Map;constructor(e,t,n,r){this.element=e,this.keyframes=t,this.options=n,this._specialStyles=r,this._duration=n.duration,this._delay=n.delay||0,this.time=this._duration+this._delay}_onFinish(){this._finished||(this._finished=!0,this._onDoneFns.forEach(e=>e()),this._onDoneFns=[])}init(){this._buildPlayer()&&this._preparePlayerBeforeStart()}_buildPlayer(){if(this._initialized)return this.domPlayer;this._initialized=!0;let e=this.keyframes,t=this._triggerWebAnimation(this.element,e,this.options);if(!t)return this._onFinish(),null;this.domPlayer=t,this._finalKeyframe=e.length?e[e.length-1]:new Map;let n=()=>this._onFinish();return t.addEventListener("finish",n),this.onDestroy(()=>{t.removeEventListener("finish",n)}),t}_preparePlayerBeforeStart(){this._delay?this._resetDomPlayerState():this.domPlayer?.pause()}_convertKeyframesToObject(e){let t=[];return e.forEach(n=>{t.push(Object.fromEntries(n))}),t}_triggerWebAnimation(e,t,n){let r=this._convertKeyframesToObject(t);try{return e.animate(r,n)}catch(o){return null}}onStart(e){this._originalOnStartFns.push(e),this._onStartFns.push(e)}onDone(e){this._originalOnDoneFns.push(e),this._onDoneFns.push(e)}onDestroy(e){this._onDestroyFns.push(e)}play(){let e=this._buildPlayer();e&&(this.hasStarted()||(this._onStartFns.forEach(t=>t()),this._onStartFns=[],this._started=!0,this._specialStyles&&this._specialStyles.start()),e.play())}pause(){this.init(),this.domPlayer?.pause()}finish(){this.init(),this.domPlayer&&(this._specialStyles&&this._specialStyles.finish(),this._onFinish(),this.domPlayer.finish())}reset(){this._resetDomPlayerState(),this._destroyed=!1,this._finished=!1,this._started=!1,this._onStartFns=this._originalOnStartFns,this._onDoneFns=this._originalOnDoneFns}_resetDomPlayerState(){this.domPlayer?.cancel()}restart(){this.reset(),this.play()}hasStarted(){return this._started}destroy(){this._destroyed||(this._destroyed=!0,this._resetDomPlayerState(),this._onFinish(),this._specialStyles&&this._specialStyles.destroy(),this._onDestroyFns.forEach(e=>e()),this._onDestroyFns=[])}setPosition(e){this.domPlayer||this.init(),this.domPlayer&&(this.domPlayer.currentTime=e*this.time)}getPosition(){return this.domPlayer?+(this.domPlayer.currentTime??0)/this.time:this._initialized?1:0}get totalTime(){return this._delay+this._duration}beforeDestroy(){let e=new Map;this.hasStarted()&&this._finalKeyframe.forEach((n,r)=>{r!=="offset"&&e.set(r,this._finished?n:Hr(this.element,r))}),this.currentSnapshot=e}triggerCallback(e){let t=e==="start"?this._onStartFns:this._onDoneFns;t.forEach(n=>n()),t.length=0}},Zr=class{validateStyleProperty(e){return!0}validateAnimatableStyleProperty(e){return!0}containsElement(e,t){return ha(e,t)}getParentElement(e){return jr(e)}query(e,t,n){return ga(e,t,n)}computeStyle(e,t,n){return Hr(e,t)}animate(e,t,n,r,o,a=[]){let s=r==0?"both":"forwards",d={duration:n,delay:r,fill:s};o&&(d.easing=o);let m=new Map,_=a.filter(P=>P instanceof Jr);Sc(n,r)&&_.forEach(P=>{P.currentSnapshot.forEach((E,k)=>m.set(k,E))});let b=yc(t).map(P=>new Map(P));b=xc(e,b,m);let y=sm(e,b);return new Jr(e,b,d,y)}};var Wr="@",zc="@.disabled",eo=class{namespaceId;delegate;engine;_onDestroy;\u0275type=0;constructor(e,t,n,r){this.namespaceId=e,this.delegate=t,this.engine=n,this._onDestroy=r}get data(){return this.delegate.data}destroyNode(e){this.delegate.destroyNode?.(e)}destroy(){this.engine.destroy(this.namespaceId,this.delegate),this.engine.afterFlushAnimationsDone(()=>{queueMicrotask(()=>{this.delegate.destroy()})}),this._onDestroy?.()}createElement(e,t){return this.delegate.createElement(e,t)}createComment(e){return this.delegate.createComment(e)}createText(e){return this.delegate.createText(e)}appendChild(e,t){this.delegate.appendChild(e,t),this.engine.onInsert(this.namespaceId,t,e,!1)}insertBefore(e,t,n,r=!0){this.delegate.insertBefore(e,t,n),this.engine.onInsert(this.namespaceId,t,e,r)}removeChild(e,t,n,r){if(r){this.delegate.removeChild(e,t,n,r);return}this.parentNode(t)&&this.engine.onRemove(this.namespaceId,t,this.delegate)}selectRootElement(e,t){return this.delegate.selectRootElement(e,t)}parentNode(e){return this.delegate.parentNode(e)}nextSibling(e){return this.delegate.nextSibling(e)}setAttribute(e,t,n,r){this.delegate.setAttribute(e,t,n,r)}removeAttribute(e,t,n){this.delegate.removeAttribute(e,t,n)}addClass(e,t){this.delegate.addClass(e,t)}removeClass(e,t){this.delegate.removeClass(e,t)}setStyle(e,t,n,r){this.delegate.setStyle(e,t,n,r)}removeStyle(e,t,n){this.delegate.removeStyle(e,t,n)}setProperty(e,t,n){t.charAt(0)==Wr&&t==zc?this.disableAnimations(e,!!n):this.delegate.setProperty(e,t,n)}setValue(e,t){this.delegate.setValue(e,t)}listen(e,t,n,r){return this.delegate.listen(e,t,n,r)}disableAnimations(e,t){this.engine.disableAnimations(e,t)}},Na=class extends eo{factory;constructor(e,t,n,r,o){super(t,n,r,o),this.factory=e,this.namespaceId=t}setProperty(e,t,n){t.charAt(0)==Wr?t.charAt(1)=="."&&t==zc?(n=n===void 0?!0:!!n,this.disableAnimations(e,n)):this.engine.process(this.namespaceId,e,t.slice(1),n):this.delegate.setProperty(e,t,n)}listen(e,t,n,r){if(t.charAt(0)==Wr){let o=dm(e),a=t.slice(1),s="";return a.charAt(0)!=Wr&&([a,s]=pm(a)),this.engine.listen(this.namespaceId,o,a,s,d=>{let m=d._data||-1;this.factory.scheduleListenerCallback(m,n,d)})}return this.delegate.listen(e,t,n,r)}};function dm(i){switch(i){case"body":return document.body;case"document":return document;case"window":return window;default:return i}}function pm(i){let e=i.indexOf("."),t=i.substring(0,e),n=i.slice(e+1);return[t,n]}var to=class{delegate;engine;_zone;_currentId=0;_microtaskId=1;_animationCallbacksBuffer=[];_rendererCache=new Map;_cdRecurDepth=0;constructor(e,t,n){this.delegate=e,this.engine=t,this._zone=n,t.onRemovalComplete=(r,o)=>{o?.removeChild(null,r)}}createRenderer(e,t){let r=this.delegate.createRenderer(e,t);if(!e||!t?.data?.animation){let m=this._rendererCache,_=m.get(r);if(!_){let b=()=>m.delete(r);_=new eo("",r,this.engine,b),m.set(r,_)}return _}let o=t.id,a=t.id+"-"+this._currentId;this._currentId++,this.engine.register(a,e);let s=m=>{Array.isArray(m)?m.forEach(s):this.engine.registerTrigger(o,a,e,m.name,m)};return t.data.animation.forEach(s),new Na(this,a,r,this.engine)}begin(){this._cdRecurDepth++,this.delegate.begin&&this.delegate.begin()}_scheduleCountTask(){queueMicrotask(()=>{this._microtaskId++})}scheduleListenerCallback(e,t,n){if(e>=0&&e<this._microtaskId){this._zone.run(()=>t(n));return}let r=this._animationCallbacksBuffer;r.length==0&&queueMicrotask(()=>{this._zone.run(()=>{r.forEach(o=>{let[a,s]=o;a(s)}),this._animationCallbacksBuffer=[]})}),r.push([t,n])}end(){this._cdRecurDepth--,this._cdRecurDepth==0&&this._zone.runOutsideAngular(()=>{this._scheduleCountTask(),this.engine.flush(this._microtaskId)}),this.delegate.end&&this.delegate.end()}whenRenderingDone(){return this.engine.whenRenderingDone()}componentReplaced(e){this.engine.flush(),this.delegate.componentReplaced?.(e)}};var um=(()=>{class i extends oi{constructor(t,n,r){super(t,n,r)}ngOnDestroy(){this.flush()}static \u0275fac=function(n){return new(n||i)(gr(fr),gr(In),gr(Dn))};static \u0275prov=U({token:i,factory:i.\u0275fac})}return i})();function hm(){return new Gr}function gm(){return new to(f(el),f(oi),f(Xn))}var $c=[{provide:Dn,useFactory:hm},{provide:oi,useClass:um},{provide:Hs,useFactory:gm}],D0=[{provide:In,useClass:Fa},{provide:na,useValue:"NoopAnimations"},...$c],fm=[{provide:In,useFactory:()=>new Zr},{provide:na,useFactory:()=>"BrowserAnimations"},...$c];function Hc(){return $s("NgEagerAnimations"),[...fm]}function _m(i,e){if(i&1){let t=O();l(0,"mat-checkbox",6),te("ngModelChange",function(r){x(t);let o=h();return ee(o.checkboxChecked,r)||(o.checkboxChecked=r),T(r)}),u(1),c()}if(i&2){let t=h();Z("ngModel",t.checkboxChecked),p(),F(t.data.checkboxLabel)}}var no=class i{dialogRef=f(Er);data=f(Mr);checkboxChecked=!1;cancel(){this.dialogRef.close({confirmed:!1})}confirm(){this.dialogRef.close({confirmed:!0,checkboxChecked:this.checkboxChecked})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-confirm-dialog"]],decls:10,vars:6,consts:[["mat-dialog-title",""],[1,"confirm-dialog__message"],[1,"confirm-dialog__checkbox",3,"ngModel"],["align","end"],["mat-button","",3,"click"],["mat-flat-button","",3,"click","color"],[1,"confirm-dialog__checkbox",3,"ngModelChange","ngModel"]],template:function(t,n){t&1&&(l(0,"h2",0),u(1),c(),l(2,"p",1),u(3),c(),C(4,_m,2,2,"mat-checkbox",2),l(5,"mat-dialog-actions",3)(6,"button",4),v("click",function(){return n.cancel()}),u(7),c(),l(8,"button",5),v("click",function(){return n.confirm()}),u(9),c()()),t&2&&(p(),F(n.data.title),p(2),F(n.data.message),p(),S(n.data.checkboxLabel?4:-1),p(3),F(n.data.cancelLabel??"Cancel"),p(),w("color",n.data.isDestructive?"warn":"primary"),p(),Oe(" ",n.data.confirmLabel??"Confirm"," "))},dependencies:[kr,Or,qe,ei,zl,Vl,st,ot,at],styles:[".confirm-dialog__message[_ngcontent-%COMP%]{margin:0 24px 8px;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;line-height:1.5}.confirm-dialog__checkbox[_ngcontent-%COMP%]{display:block;margin:0 24px 8px;font-size:.875rem}"]})};var si=class i{snackBar=f(gl);success(e,t=2e3){this.snackBar.open(e,"",{duration:t,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-success"]})}error(e,t=3e3){this.snackBar.open(e,"",{duration:t,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-error"]})}info(e,t=2e3){this.snackBar.open(e,"",{duration:t,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-info"]})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var bm=()=>[];function vm(i,e){if(i&1){let t=O();l(0,"div",3)(1,"ds-entity-card",4),v("selected",function(r){x(t);let o=h();return T(o.onItemSelected(r))}),c(),l(2,"button",5),v("click",function(r){let o=x(t).$implicit,a=h();return r.stopPropagation(),T(a.onDeleteRequested(o.id))}),l(3,"mat-icon"),u(4,"close"),c()()()}if(i&2){let t=e.$implicit;p(),w("id",t.id)("name",t.name)("description",t.description)("badges",t.badges??_r(4,bm))}}var Hi="__",io=class i{router=f(Nt);projectStateService=f(_e);dialog=f(Pr);destroyRef=f(Kn);notification=f(si);projects=Me(this.projectStateService.projectList$);forcedProject=Me(this.projectStateService.forcedProject$,{initialValue:null});projectItems=Ct(()=>{let e=this.projects();if(!e)return[];let t=e.filter(y=>!y.name.includes(Hi)),n=e.filter(y=>y.name.includes(Hi)),r=new Set(t.map(y=>y.name)),o=y=>y.split(Hi)[0]??null,a=new Set(n.map(y=>o(y.name)).filter(y=>y!==null&&r.has(y))),s=[],d=[...a].sort((y,P)=>y.localeCompare(P));for(let y of d){let P=t.find(k=>k.name===y);s.push(he(G({},this.toEntityListItem(P)),{groupKey:y,groupLabel:y}));let E=n.filter(k=>o(k.name)===y).sort((k,Q)=>k.name.localeCompare(Q.name));for(let k of E){let Q=k.name.slice(y.length+Hi.length);s.push(he(G({},this.toEntityListItem(k)),{name:Q,description:k.name,groupKey:y,groupLabel:y}))}}let m=[...t].filter(y=>!a.has(y.name)&&!y.volatile).sort((y,P)=>y.name.localeCompare(P.name));for(let y of m)s.push(he(G({},this.toEntityListItem(y)),{groupKey:"__standalone__",groupLabel:"Projects"}));let _=[...t].filter(y=>!a.has(y.name)&&y.volatile).sort((y,P)=>y.name.localeCompare(P.name));for(let y of _)s.push(he(G({},this.toEntityListItem(y)),{groupKey:"__volatile__",groupLabel:"Temporary"}));let b=n.filter(y=>{let P=o(y.name);return P!==null&&!r.has(P)}).sort((y,P)=>y.name.localeCompare(P.name));for(let y of b)s.push(he(G({},this.toEntityListItem(y)),{groupKey:"__orphaned__",groupLabel:"Orphaned worktrees"}));return s});showCreateButton=Ct(()=>!this.forcedProject());constructor(){this.projectStateService.selectedProject$.pipe(rt(),De(e=>!!e),De(()=>this.router.url.split("?")[0]==="/"),hr(1)).subscribe(e=>{this.router.navigate(["project",e.name])})}onItemSelected(e){this.projectStateService.selectProject(e),this.router.navigate(["project",e])}onCreateRequested(){this.router.navigate(["project","new"])}onDeleteRequested(e){let t=e.includes(Hi);this.dialog.open(no,{width:"400px",panelClass:"confirm-dialog-panel",data:G({title:"Delete project",message:`This will remove the project "${e}" from Coday and archive its configuration. The project source code on disk is not affected.`,confirmLabel:"Delete",cancelLabel:"Cancel",isDestructive:!0},t?{checkboxLabel:"Also remove git worktree from disk"}:{})}).afterClosed().pipe(De(r=>r?.confirmed===!0),rt(this.destroyRef)).subscribe(r=>{this.notification.info("Deleting project\u2026"),this.projectStateService.deleteProject(e,r.checkboxChecked).pipe(rt(this.destroyRef)).subscribe({next:()=>{this.notification.success(`Project "${e}" deleted`),this.router.url.includes(`/project/${encodeURIComponent(e)}`)&&this.router.navigate(["/"])},error:o=>{console.error("[PROJECT-LIST] Failed to delete project:",o),this.notification.error(o?.error?.error??"Failed to delete project")}})})}toEntityListItem(e){return{id:e.name,name:e.name,badges:e.volatile?[{label:"temp",variant:"warning"}]:[]}}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-project-selection"]],decls:4,vars:4,consts:[["projectCard",""],["title","Projects","contentMaxWidth","1400px","searchPlaceholder","Filter projects\u2026","emptyMessage","No projects found.",3,"itemSelected","createRequested","items","itemTemplate","showCreate","autoFocusSearch"],["toolbar-start","","src","CODAY-Logo.png","alt","Coday",1,"project-list__logo"],[1,"project-card-wrapper"],[3,"selected","id","name","description","badges"],["mat-icon-button","","title","Delete project",1,"project-card-wrapper__delete",3,"click"]],template:function(t,n){if(t&1&&(l(0,"ds-entity-list",1),v("itemSelected",function(o){return n.onItemSelected(o)})("createRequested",function(){return n.onCreateRequested()}),R(1,"img",2),c(),cn(2,vm,5,5,"ng-template",null,0,Zn)),t&2){let r=Pn(3);w("items",n.projectItems())("itemTemplate",r)("showCreate",n.showCreateButton())("autoFocusSearch",!0)}},dependencies:[jl,Nl,Te,ae,ze],styles:[".project-list__logo[_ngcontent-%COMP%]{height:28px;width:auto}.project-card-wrapper[_ngcontent-%COMP%]{position:relative}.project-card-wrapper__delete[_ngcontent-%COMP%]{position:absolute;top:4px;right:4px;width:28px;height:28px;line-height:28px;padding:0;opacity:0;transition:opacity .15s ease;color:var(--color-text-secondary, #6e6e73)}.project-card-wrapper__delete[_ngcontent-%COMP%] .mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px}.project-card-wrapper__delete[_ngcontent-%COMP%]:hover{color:var(--color-error, #ff3b30)}.project-card-wrapper[_ngcontent-%COMP%]:hover .project-card-wrapper__delete[_ngcontent-%COMP%]{opacity:1}"]})};var we=class i{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new q("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();enterToSendSubject=new q(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new q(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new q("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new q(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new q(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new q(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new q(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new q(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new q(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new q(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new q(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new q(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new q(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.asObservable();themeSubject=new q("light");theme$=this.themeSubject.asObservable();constructor(){console.log("[PREFERENCES] Initializing preferences service"),typeof window<"u"&&window.codayDesktop?.storage&&(this.isDesktopApp=!0,this.electronStorage=window.codayDesktop.storage,console.log("[PREFERENCES] Running in desktop app mode with persistent storage")),this.initializePreferences()}initializePreferences(){this.isDesktopApp?this.loadPreferencesAsync():this.loadPreferencesSync()}loadPreferencesSync(){let e=this.getPreferenceSync("voiceLanguage","en-US")??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=this.getPreferenceSync("useEnterToSend",!0)??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let n=this.getPreferenceSync("voiceAnnounceEnabled",!1)??!1;this.voiceAnnounceEnabledSubject.next(n);let r=this.getPreferenceSync("voiceMode","speech")??"speech";this.voiceModeSubject.next(r);let o=this.getPreferenceSync("voiceReadFullText",!1)??!1;this.voiceReadFullTextSubject.next(o);let a=this.getPreferenceSync("voiceVolume",.8)??.8;this.voiceVolumeSubject.next(a);let s=this.getPreferenceSync("voiceRate",1.2)??1.2;this.voiceRateSubject.next(s);let d=this.getPreferenceSync("selectedVoice",null)??null;this.selectedVoiceSubject.next(d);let m=this.getPreferenceSync("printTechnicalMessages",!1)??!1;this.printTechnicalMessagesSubject.next(m);let _=this.getPreferenceSync("hideTechnicalMessages",!0)??!0;this.hideTechnicalMessagesSubject.next(_);let b=this.getPreferenceSync("hideWarningMessages",!1)??!1;this.hideWarningMessagesSubject.next(b);let y=this.getPreferenceSync("agentNotificationEnabled",!1)??!1;this.agentNotificationEnabledSubject.next(y);let P=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(P);let E=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(E);let k=this.getPreferenceSync("theme","light")??"light";this.themeSubject.next(k),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return H(this,null,function*(){let e=(yield this.getPreferenceAsync("voiceLanguage","en-US"))??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=(yield this.getPreferenceAsync("useEnterToSend",!0))??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let n=(yield this.getPreferenceAsync("voiceAnnounceEnabled",!1))??!1;this.voiceAnnounceEnabledSubject.next(n);let r=(yield this.getPreferenceAsync("voiceMode","speech"))??"speech";this.voiceModeSubject.next(r);let o=(yield this.getPreferenceAsync("voiceReadFullText",!1))??!1;this.voiceReadFullTextSubject.next(o);let a=(yield this.getPreferenceAsync("voiceVolume",.8))??.8;this.voiceVolumeSubject.next(a);let s=(yield this.getPreferenceAsync("voiceRate",1.2))??1.2;this.voiceRateSubject.next(s);let d=(yield this.getPreferenceAsync("selectedVoice",null))??null;this.selectedVoiceSubject.next(d);let m=(yield this.getPreferenceAsync("printTechnicalMessages",!1))??!1;this.printTechnicalMessagesSubject.next(m);let _=(yield this.getPreferenceAsync("hideTechnicalMessages",!0))??!0;this.hideTechnicalMessagesSubject.next(_);let b=(yield this.getPreferenceAsync("hideWarningMessages",!1))??!1;this.hideWarningMessagesSubject.next(b);let y=(yield this.getPreferenceAsync("agentNotificationEnabled",!1))??!1;this.agentNotificationEnabledSubject.next(y);let P=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(P);let E=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(E);let k=(yield this.getPreferenceAsync("theme","light"))??"light";this.themeSubject.next(k),console.log("[PREFERENCES] All preferences initialized successfully (async)")})}getPreference(e,t){return this.getPreferenceSync(e,t)}getPreferenceSync(e,t){try{let n=localStorage.getItem(this.STORAGE_KEY);if(!n)return t;let r=JSON.parse(n);return r[e]!==void 0?r[e]:t}catch(n){return t}}getPreferenceAsync(e,t){return H(this,null,function*(){if(!this.electronStorage)return this.getPreferenceSync(e,t);try{let n=yield this.electronStorage.get(this.STORAGE_KEY);if(!n)return t;let r=JSON.parse(n);return r[e]!==void 0?r[e]:t}catch(n){return t}})}setPreference(e,t){this.isDesktopApp?this.setPreferenceAsync(e,t):this.setPreferenceSync(e,t)}setPreferenceSync(e,t){try{let n=localStorage.getItem(this.STORAGE_KEY),r=n?JSON.parse(n):{};r[e]=t,localStorage.setItem(this.STORAGE_KEY,JSON.stringify(r)),this.updateSubject(e,t)}catch(n){console.error("Failed to set preference:",n)}}setPreferenceAsync(e,t){return H(this,null,function*(){if(!this.electronStorage){this.setPreferenceSync(e,t);return}try{let n=yield this.electronStorage.get(this.STORAGE_KEY),r=n?JSON.parse(n):{};r[e]=t,yield this.electronStorage.set(this.STORAGE_KEY,JSON.stringify(r)),this.updateSubject(e,t)}catch(n){console.error("Failed to set preference:",n)}})}updateSubject(e,t){e==="voiceLanguage"&&this.voiceLanguageSubject.next(t),e==="useEnterToSend"&&this.enterToSendSubject.next(t),e==="voiceAnnounceEnabled"&&this.voiceAnnounceEnabledSubject.next(t),e==="voiceMode"&&this.voiceModeSubject.next(t),e==="voiceReadFullText"&&this.voiceReadFullTextSubject.next(t),e==="voiceVolume"&&this.voiceVolumeSubject.next(t),e==="voiceRate"&&this.voiceRateSubject.next(t),e==="selectedVoice"&&this.selectedVoiceSubject.next(t),e==="printTechnicalMessages"&&this.printTechnicalMessagesSubject.next(t),e==="hideTechnicalMessages"&&this.hideTechnicalMessagesSubject.next(t),e==="hideWarningMessages"&&this.hideWarningMessagesSubject.next(t),e==="agentNotificationEnabled"&&this.agentNotificationEnabledSubject.next(t),e==="notificationSoundEnabled"&&this.notificationSoundEnabledSubject.next(t),e==="browserNotificationEnabled"&&this.browserNotificationEnabledSubject.next(t),e==="theme"&&this.themeSubject.next(t)}setVoiceLanguage(e){console.log("[PREFERENCES] Setting voice language to:",e),this.setPreference("voiceLanguage",e)}getVoiceLanguage(){return this.getPreference("voiceLanguage","en-US")??"en-US"}setEnterToSend(e){console.log("[PREFERENCES] Setting Enter to send to:",e),this.setPreference("useEnterToSend",e)}getEnterToSend(){return this.getPreference("useEnterToSend",!1)??!1}setVoiceAnnounceEnabled(e){console.log("[PREFERENCES] Setting voice announce enabled to:",e),this.setPreference("voiceAnnounceEnabled",e)}getVoiceAnnounceEnabled(){return this.getPreference("voiceAnnounceEnabled",!1)??!1}setVoiceMode(e){console.log("[PREFERENCES] Setting voice mode to:",e),this.setPreference("voiceMode",e)}getVoiceMode(){return this.getPreference("voiceMode","speech")??"speech"}setVoiceReadFullText(e){console.log("[PREFERENCES] Setting voice read full text to:",e),this.setPreference("voiceReadFullText",e)}getVoiceReadFullText(){return this.getPreference("voiceReadFullText",!1)??!1}setVoiceVolume(e){let t=Math.max(0,Math.min(1,e));console.log("[PREFERENCES] Setting voice volume to:",t),this.setPreference("voiceVolume",t)}getVoiceVolume(){return this.getPreference("voiceVolume",.8)??.8}setVoiceRate(e){let t=Math.max(.5,Math.min(2,e));console.log("[PREFERENCES] Setting voice rate to:",t),this.setPreference("voiceRate",t)}getVoiceRate(){return this.getPreference("voiceRate",1.2)??1.2}setSelectedVoice(e){console.log("[PREFERENCES] Setting selected voice to:",e),this.setPreference("selectedVoice",e)}getSelectedVoice(){return this.getPreference("selectedVoice",null)??null}setPrintTechnicalMessages(e){console.log("[PREFERENCES] Setting print technical messages to:",e),this.setPreference("printTechnicalMessages",e)}getPrintTechnicalMessages(){return this.getPreference("printTechnicalMessages",!1)??!1}setHideTechnicalMessages(e){console.log("[PREFERENCES] Setting hide technical messages to:",e),this.setPreference("hideTechnicalMessages",e)}getHideTechnicalMessages(){return this.getPreference("hideTechnicalMessages",!0)??!0}setHideWarningMessages(e){console.log("[PREFERENCES] Setting hide warning messages to:",e),this.setPreference("hideWarningMessages",e)}getHideWarningMessages(){return this.getPreference("hideWarningMessages",!1)??!1}setAgentNotificationEnabled(e){console.log("[PREFERENCES] Setting agent notification enabled to:",e),this.setPreference("agentNotificationEnabled",e)}getAgentNotificationEnabled(){return this.getPreference("agentNotificationEnabled",!1)??!1}setNotificationSoundEnabled(e){console.log("[PREFERENCES] Setting notification sound enabled to:",e),this.setPreference("notificationSoundEnabled",e)}getNotificationSoundEnabled(){return this.getPreference("notificationSoundEnabled",!0)??!0}setBrowserNotificationEnabled(e){console.log("[PREFERENCES] Setting browser notification enabled to:",e),this.setPreference("browserNotificationEnabled",e)}getBrowserNotificationEnabled(){return this.getPreference("browserNotificationEnabled",!1)??!1}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};function ja(i,e=80){if(i.length<=e)return i;try{if(i.trim().startsWith("{")||i.trim().startsWith("[")){let t=JSON.parse(i),n=JSON.stringify(t);return n.length<=e?n:n.substring(0,e)+`...(${n.length} chars)`}}catch(t){}return i.substring(0,e)+"..."}var Ne=class{constructor(e,t){this.type=t;if(e.timestamp)this.timestamp=e.timestamp;else{let n=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${n}`}this.parentKey=e.parentKey,this.threadId=e.threadId,this.length=0}timestamp;parentKey;static type;length;threadId;get date(){let e=this.timestamp.lastIndexOf("-");if(e>0){let t=this.timestamp.substring(e+1);if(t.length===5&&/^[a-z0-9]+$/.test(t))return new Date(this.timestamp.substring(0,e))}return new Date(this.timestamp)}},ro=class extends Ne{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new dt({answer:e,parentKey:this.timestamp,invite:this.invite})}},li=class i extends Ne{static type="heartbeat";constructor(e){super(e,i.type)}},en=class i extends ro{defaultValue;static type="invite";constructor(e){super(e,i.type),this.defaultValue=e.defaultValue}},Va="InviteEventDefault",dt=class i extends Ne{answer;invite;name;static type="answer";constructor(e){super(e,i.type),this.answer=e.answer??"No answer",this.invite=e.invite,this.name=e.name}},Vt=class i extends Ne{speaker;text;static type="text";constructor(e){super(e,i.type),this.speaker=e.speaker,this.text=e.text}},gn=class i extends Ne{chunk;static type="text_chunk";constructor(e){super(e,i.type),this.chunk=e.chunk,this.length=this.chunk.length}},Nn=class i extends Ne{warning;static type="warn";constructor(e){super(e,i.type),this.warning=e.warning}},Tt=class i extends Ne{error;static type="error";constructor(e){super(e,i.type),this.error=e.error}},tn=class i extends ro{options;optionalQuestion;allowFreeText;static type="choice";constructor(e){super(e,i.type),this.options=e.options,this.optionalQuestion=e.optionalQuestion,this.allowFreeText=e.allowFreeText??!1}},wt=class i extends Ne{toolRequestId;name;args;static type="tool_request";constructor(e){super(e,i.type),this.toolRequestId=e.toolRequestId??this.timestamp,this.name=e.name,this.args=e.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(e){return new _t({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=ja(this.args,e);return`\u{1F527} ${this.name}(${t})`}},_t=class i extends Ne{toolRequestId;output;static type="tool_response";constructor(e){if(super(e,i.type),this.toolRequestId=e.toolRequestId||this.timestamp||new Date().toISOString(),this.output=e.output,typeof this.output=="string")this.length=this.output.length+this.toolRequestId.length+20;else if(this.output.type==="text")this.length=this.output.content.length+this.toolRequestId.length+20;else if(this.output.type==="image"){let t=(this.output.width??0)*(this.output.height??0)/750;this.length=(t?t*3.5:this.output.content.length)+this.toolRequestId.length+20}else this.length=this.toolRequestId.length+20}getTextOutput(){return typeof this.output=="string"?this.output:this.output.type==="text"?this.output.content:this.output.type==="image"?`[Image: ${this.output.mimeType}]`:""}toSingleLineString(e=50){let t=this.getTextOutput(),n=ja(t,e),r=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${n}${r}`}},fn=class i extends Ne{static type="thinking";static debounce=5e3;constructor(e){super(e,i.type)}},Fn=class i extends Ne{summary;static type="summary";constructor(e){super(e,i.type),this.summary=e.summary,this.length=this.summary.length}toSingleLineString(e=80){return`\u{1F4CB} Summary: ${ja(this.summary,e)}`}},Et=class i extends Ne{role;name;content;static type="message";constructor(e){super(e,i.type),this.role=e.role,this.name=e.name,this.content=e.content,this.length=this.content.map(t=>{if(t.type==="text")return t.content.length;if(t.type==="image"){let n=(t.width||0)*(t.height||0)/750;return n?n*3.5:t.content.length}return 0}).reduce((t,n)=>t+n,0)}getTextContent(){return this.content.filter(e=>e.type==="text").map(e=>e.content).join(`
2
+ `)}},ci=class i extends Ne{threadId;name;summary;users;static type="thread_update";constructor(e){super(e,i.type),this.threadId=e.threadId,this.name=e.name,this.summary=e.summary,this.users=e.users}},_n=class i extends Ne{filename;operation;size;mimeType;static type="file";constructor(e){super(e,i.type),this.filename=e.filename,this.operation=e.operation,this.size=e.size,this.mimeType=e.mimeType}toSingleLineString(){let e=this.operation==="created"?"\u{1F4C4}":this.operation==="updated"?"\u{1F4DD}":"\u{1F5D1}\uFE0F",t=this.size?` (${(this.size/1024).toFixed(1)} KB)`:"";return`${e} ${this.operation}: ${this.filename}${t}`}},di=class i extends Ne{authUrl;state;integrationName;static type="oauth_request";constructor(e){super(e,i.type),this.authUrl=e.authUrl,this.state=e.state,this.integrationName=e.integrationName}},zt=class i extends Ne{subThreadId;agentName;static type="delegation";constructor(e){super(e,i.type),this.subThreadId=e.subThreadId,this.agentName=e.agentName}},Mt=class i extends Ne{code;state;integrationName;error;errorDescription;static type="oauth_callback";constructor(e){super(e,i.type),this.code=e.code,this.state=e.state,this.integrationName=e.integrationName,this.error=e.error,this.errorDescription=e.errorDescription}},ym={[Et.type]:Et,[dt.type]:dt,[tn.type]:tn,[zt.type]:zt,[Tt.type]:Tt,[li.type]:li,[en.type]:en,[wt.type]:wt,[_t.type]:_t,[Vt.type]:Vt,[gn.type]:gn,[fn.type]:fn,[Nn.type]:Nn,[ci.type]:ci,[Fn.type]:Fn,[_n.type]:_n,[di.type]:di,[Mt.type]:Mt};function Ui(i){let e=ym[i.type];return e?new e(i):void 0}var k_=[{id:"builtin-plan",name:"plan",description:"Build a plan to complete the given task",source:"builtin",commands:[`@ We start a 3 phase process to build a comprehensive execution plan for the following task:
3
+
4
+ <task>
5
+ {{PARAMETERS}}
6
+ </task>
7
+
8
+ There will be 3 phases:
9
+ 1. Research and understanding
10
+ 2. Clarifying questions
11
+ 3. Plan creation
12
+
13
+ Do not try to do all at once, wait for my request at each time.
14
+
15
+ Now we start with phase 1:
16
+
17
+ 1. **Analyze the request** to identify:
18
+ - Core requirements and objectives
19
+ - Implicit assumptions or expectations
20
+ - Technical scope and constraints
21
+
22
+ 2. **Research relevant context** using available tools:
23
+ - Use whatever tools you have available (file reading, API calls, search, etc.)
24
+ - Gather information about existing patterns, structures, and conventions
25
+ - Identify relevant files, modules, or resources
26
+ - Document key findings briefly
27
+
28
+ 3. **Assess feasibility**:
29
+ - Identify potential challenges or blockers
30
+ - Note any dependencies or prerequisites
31
+ - Consider alternative approaches if applicable
32
+
33
+ Do not assume you have specific tools - use what's available to you.
34
+
35
+ Do not produce any document at this stage as you will have access to the accumulated research results later.
36
+ `,`@ let's continue with Phase 2: Clarifying Questions regarding the initial task.
37
+
38
+ <task>
39
+ {{PARAMETERS}}
40
+ </task>
41
+
42
+ Based on your research and understanding:
43
+
44
+ 1. **Identify ambiguities** or missing information that could impact the completion of the task
45
+ - no boundaries
46
+ - insufficient definition of done
47
+ - lack of pre-requisites
48
+
49
+ 2. **Ask focused questions** if clarification is needed:
50
+ - Use the 'invite' or 'choice' tools for user input
51
+ - Keep questions concise and specific
52
+ - Prioritize questions that significantly impact the approach
53
+
54
+ 3. **Skip this phase** if the requirements are clear enough to proceed
55
+
56
+ Remember: Only ask questions that are truly necessary to create a solid plan.`,`@ finish with Phase 3: Plan Creation
57
+
58
+ Break down the task into 3-10 clear, actionable steps. Each step should be substantial enough to represent meaningful progress, but focused enough to be completed in one session.
59
+
60
+ Create a detailed execution plan:
61
+ - if you have access to the exchange area, save the plan there as 'plan.md'.
62
+ - otherwise, output the plan in the conversation.
63
+ - do not write any other document
64
+
65
+ The plan must follow this Markdown structure:
66
+
67
+ # Execution Plan: [Task Title]
68
+
69
+ ## Overview
70
+ 1-2 sentence summary of what will be accomplished.
71
+
72
+ ## Context
73
+ Key information and constraints identified during research:
74
+ - Relevant patterns/conventions found
75
+ - Constraints or limitations
76
+ - Dependencies or prerequisites
77
+ - Key resources or materials involved
78
+
79
+ ## Steps
80
+
81
+ ### Step 1: [Step Title]
82
+ - **What to do**: Clear description of the action to take
83
+ - **Resources needed**: List files, tools, information, or materials required
84
+ - **Expected outcome**: What should be produced or achieved
85
+ - **Validation**: How to verify this step is complete
86
+ - **Dependencies**: Which previous steps must complete first (or "None")
87
+
88
+ ### Step 2: [Step Title]
89
+ [Same structure as Step 1]
90
+
91
+ [Continue for all steps...]
92
+
93
+ ## Success Criteria
94
+ How to verify the task is fully complete:
95
+ 1. Objective measures of completion
96
+ 2. Quality checks or review points
97
+ 3. Final validation steps
98
+
99
+ ## Risks & Considerations
100
+ - Potential challenges or obstacles
101
+ - Alternative approaches considered
102
+ - Areas requiring special attention
103
+ - Future improvements or follow-up items
104
+
105
+ ---
106
+
107
+ After outputting the plan in the right place (in exchange or in conversation or according to user directives):
108
+ - do not produce other outputs nor documents
109
+ - do not start executing the plan`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""},{id:"builtin-execute-plan",name:"execute-plan",description:"Execute a previously created plan step by step, with validation and progress tracking.",source:"builtin",commands:[`@ Execute the plan from the exchange area or outlined previously in the conversation:
110
+
111
+ ## Preparation
112
+ 1. **Load the plan**: Read from exchange area (plan.md) or use previously discussed plan
113
+ 2. **Review**: Understand the overall objective, context, and step sequence
114
+ 3. **Pre-check**: Verify prerequisites are met; report any obvious issues
115
+
116
+ ## Step-by-Step Execution
117
+
118
+ For each step in order:
119
+
120
+ 1. **Announce**: State which step you're starting and what you'll do
121
+ 2. **Check dependencies**: Verify required previous steps are complete
122
+ 3. **Execute**: Perform the actions specified in the step
123
+ 4. **Validate**: Apply the validation criteria from the plan
124
+ 5. **Report**: Confirm completion and note any deviations
125
+
126
+ **For significant or risky steps**: Ask user confirmation before proceeding (use 'choice' tool)
127
+
128
+ ## Issue Handling
129
+
130
+ If a step fails:
131
+ - Report the issue clearly
132
+ - Suggest solutions (retry, skip if non-critical, or stop)
133
+ - Use 'choice' tool to ask how to proceed if needed
134
+
135
+ ## Completion
136
+
137
+ 1. **Final verification**: Apply success criteria from the plan
138
+ 2. **Summary**: Report what was accomplished, any deviations, validation results, and next steps
139
+
140
+ ## Guidelines
141
+ - Follow the plan's order unless circumstances require adaptation
142
+ - Communicate progress clearly at each step, without excessive details
143
+ - Ask for guidance when the plan is unclear or issues arise`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""},{id:"builtin-re-prompt",name:"re-prompt",description:"Transform a vague request into a detailed, actionable prompt",source:"builtin",commands:[`@ I need you to analyze and reformulate the following request to make it more precise and actionable.
144
+
145
+ ## User's initial request
146
+
147
+ {{PARAMETERS}}
148
+
149
+ ## Your task
150
+
151
+ 1. **Analyze the request** to identify:
152
+ - What is explicitly stated
153
+ - What is implicit or assumed
154
+ - What information is missing or ambiguous
155
+ - The likely intent behind the request
156
+
157
+ 2. **Ask clarifying questions** if needed:
158
+ - If the request is too vague or has multiple interpretations
159
+ - If critical information is missing
160
+ - Use the 'invite' or 'choice' tools to gather necessary details
161
+
162
+ 3. **Reformulate the request** into a clear, detailed, and actionable prompt:
163
+ - Make implicit requirements explicit
164
+ - Add relevant context from the current project
165
+ - Specify expected outcomes or deliverables
166
+ - Break down complex requests into clear steps if needed
167
+ - Use precise technical terminology when appropriate
168
+
169
+ 4. **Present the reformulated request** and ask for confirmation:
170
+ - Show the enhanced version clearly
171
+ - Explain key changes or additions you made
172
+ - Ask if this matches the user's intent
173
+
174
+ The goal is to transform a rough idea into a well-defined request that will produce better AI responses.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""},{id:"builtin-memory-learn",name:"memory-learn",description:"Extract and memorize new knowledge gained from recent context",source:"builtin",commands:[`@ Learn about the following topic and memorize relevant insights if defined:
175
+
176
+ <topic>
177
+ {{PARAMETERS}}
178
+ </topic>
179
+
180
+ If no specific topic is provided, extract learnings from the entire recent conversation context.
181
+
182
+ ## Process
183
+
184
+ 1. **Identify new knowledge**: From the recent conversation context, identify what you learned that:
185
+ - Was not in the initially given context
186
+ - Is specific to this user or project (not generic knowledge)
187
+ - Is useful and worth remembering
188
+ - Represents understanding, not just file copies
189
+
190
+ 2. **Organize insights**: Split the knowledge into cohesive subjects, each with:
191
+ - **Title**: Short and descriptive (one sentence maximum)
192
+ - **Content**: Detailed explanation of what was learned
193
+ - Length: at most 3 paragraphs or short extracts and notes
194
+ - Format: Well-structured markdown
195
+ - Focus: Specific patterns, decisions, constraints, or insights
196
+
197
+ 3. **Check for redundancy**: Before memorizing:
198
+ - Review the list of existing memories to avoid duplication
199
+ - If a similar memory exists, consider updating it instead of creating a new one
200
+ - delete memories if needed
201
+
202
+ 4. **Memorize**: Use the memorization tools to save each subject:
203
+ - Choose appropriate level if available (PROJECT or USER)
204
+ - Ensure clear structure and completeness
205
+ - Memorize one subject at a time
206
+
207
+ ## Guidelines
208
+ - Focus on actionable insights, not generic facts
209
+ - Ensure memories are self-contained and clear
210
+ - Avoid redundancy with existing memories
211
+ - Prioritize quality over quantity`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""},{id:"builtin-memory-curate",name:"memory-curate",description:"Analyze and clean up the memory system by consolidating redundancies and removing outdated information",source:"builtin",commands:[`@ we start a 4 phase memory curation process. Complete only the requested phase at each time.
212
+
213
+ Phase 1: Analyze redundancies
214
+
215
+ Review all current memories to identify:
216
+
217
+ 1. **Redundant memories** that:
218
+ - Cover similar or overlapping topics
219
+ - Contain duplicate information
220
+ - Could be consolidated for better clarity
221
+
222
+ 2. **For each group of redundant memories**:
223
+ - List the memory titles involved
224
+ - Explain the redundancy briefly
225
+ - Propose a consolidation approach
226
+
227
+ Do not make changes yet - just analyze and report findings.`,`@ Phase 2: Consolidate redundancies
228
+
229
+ Based on the analysis from Phase 1:
230
+
231
+ 1. **For each identified redundancy**:
232
+ - Delete the individual redundant memories using deleteMemory
233
+ - Create a new consolidated memory that:
234
+ - Maintains all critical details from the originals
235
+ - Provides clear, well-structured content
236
+ - Uses appropriate level (PROJECT or USER)
237
+ - Explain your consolidation reasoning
238
+
239
+ 2. **Be proactive but careful**: Preserve important details while eliminating duplication.`,`@ Phase 3: Check for outdated information
240
+
241
+ Review remaining memories for accuracy and relevance:
242
+
243
+ 1. **Compare each memory against**:
244
+ - Other memories for inconsistencies
245
+ - Current project context for outdated information
246
+ - Core documentation for misalignments
247
+
248
+ 2. **For each problematic memory**:
249
+ - List the memory title with brief explanation of the issue
250
+ - Take appropriate action:
251
+ - Delete if outdated or incorrect
252
+ - Update if incomplete or partially incorrect
253
+ - Consolidate if it fits better elsewhere
254
+ - Explain your reasoning clearly
255
+
256
+ Be thorough in your analysis.`,`@ Phase 4: Final verification
257
+
258
+ Verify the memory system's overall health:
259
+
260
+ 1. **Review the current state**:
261
+ - Check overall structure and organization
262
+ - Verify each memory for completeness and validity
263
+ - Confirm proper categorization (PROJECT vs USER)
264
+
265
+ 2. **Document the results**:
266
+ - Summarize what was consolidated or removed
267
+ - List any remaining issues or concerns
268
+ - Provide recommendations for maintaining memory quality
269
+
270
+ This ensures the memory system stays efficient and valuable.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""}];var U_=[Et.type,wt.type,_t.type,Fn.type,en.type,tn.type,dt.type,zt.type];var Uc={CONFLUENCE:[],GIT:[],GIT_WORKTREE:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},sb=Object.keys(Uc).filter(i=>Uc[i]?.length===0);var $t=class i{eventSource=null;eventsSubject=new ce;connectionStatusSubject=new q({connected:!1,reconnectAttempts:0,maxAttempts:3});reconnectAttempts=0;MAX_RECONNECT_ATTEMPTS=3;RECONNECT_DELAY=2e3;events$=this.eventsSubject.asObservable();connectionStatus$=this.connectionStatusSubject.asObservable();ngZone=f(Xn);connectToThread(e,t){console.log("[SSE] Connecting to thread event stream:",e,t),this.eventSource&&(console.log("[SSE] Closing existing EventSource"),this.eventSource.close());let n=`/api/projects/${e}/threads/${t}/event-stream`;console.log("[SSE] EventSource URL:",n),this.eventSource=new EventSource(n),this.setupEventHandlers()}setupEventHandlers(){this.eventSource&&(this.eventSource.onmessage=e=>{this.ngZone.run(()=>{console.log("[SSE] Message received:",e.data.substring(0,100)),this.reconnectAttempts=0,this.updateConnectionStatus(!0,0);try{let t=JSON.parse(e.data),n=Ui(t);n?(console.log("[SSE] Event:",n.type),this.eventsSubject.next(n)):console.warn("[SSE] Failed to build event:",t.type)}catch(t){console.error("[SSE] Parse error:",t.message)}})},this.eventSource.onopen=()=>{this.ngZone.run(()=>{console.log("[SSE] Connection established"),this.reconnectAttempts=0,this.updateConnectionStatus(!0,0)})},this.eventSource.onerror=e=>{this.ngZone.run(()=>{console.log("[SSE] EventSource error:",e),this.eventSource?.readyState===EventSource.CLOSED&&(console.log("[SSE] Connection closed"),this.updateConnectionStatus(!1,this.reconnectAttempts),this.reconnectAttempts<this.MAX_RECONNECT_ATTEMPTS?(console.log(`[SSE] Attempting reconnect ${this.reconnectAttempts+1}/${this.MAX_RECONNECT_ATTEMPTS}`),this.eventsSubject.next(new Tt({error:new Error(`Connection lost. Attempting to reconnect (${this.reconnectAttempts+1}/${this.MAX_RECONNECT_ATTEMPTS})...`)})),setTimeout(()=>{this.reconnectAttempts++,console.warn("[SSE] Reconnection may not work properly with thread-based connections")},this.RECONNECT_DELAY)):(console.log("[SSE] Max reconnection attempts reached"),this.eventsSubject.next(new Tt({error:new Error("Connection lost permanently. Please refresh the page.")}))))})})}disconnect(){this.eventSource&&(console.log("[SSE] Disconnecting EventSource"),this.eventSource.close(),this.eventSource=null,this.updateConnectionStatus(!1,0))}updateConnectionStatus(e,t){this.connectionStatusSubject.next({connected:e,reconnectAttempts:t,maxAttempts:this.MAX_RECONNECT_ATTEMPTS})}ngOnDestroy(){this.disconnect(),this.eventsSubject.complete(),this.connectionStatusSubject.complete()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ht=class i{http=f(it);projectState=f(_e);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads`}listThreads(){return this.http.get(this.getBaseUrl())}getThread(e){return this.http.get(`${this.getBaseUrl()}/${e}`)}createThread(e){let t=e?{name:e}:{};return this.http.post(this.getBaseUrl(),t)}updateThread(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{name:t})}updateThreadUsers(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{users:t})}starThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/star`,{})}unstarThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}/star`)}deleteThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}`)}stopThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/stop`,{})}getThreadMessages(e){return this.http.get(`${this.getBaseUrl()}/${e}/messages`)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var We=class i{selectedThreadIdSubject=new q(null);isLoadingSubject=new q(!1);isLoadingThreadListSubject=new q(!1);refreshThreadListSubject=new ce;threadListSubject=new q([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=f(Ht);projectStateService=f(_e);projectName$=this.projectStateService.selectedProject$.pipe(Le(e=>e?.name),Xo());constructor(){wn([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(Zo(void 0))]).pipe(ut(([e])=>{e!==this.currentProjectName&&(console.log("[THREAD_STATE] Project changed, clearing thread list"),this.threadListSubject.next([]),this.currentProjectName=e),e?this.hasLoadedOncePerProject.get(e)?console.log("[THREAD_STATE] Refreshing thread list for project",e,"(no spinner)"):(console.log("[THREAD_STATE] Initial load for project",e,"- showing spinner"),this.isLoadingThreadListSubject.next(!0)):(console.log("[THREAD_STATE] No project selected, hiding spinner"),this.isLoadingThreadListSubject.next(!1))}),ea(([e])=>e?(console.log("[THREAD_STATE] Fetching threads for project:",e),this.threadApi.listThreads().pipe(Le(t=>({threads:t,projectName:e})),sn(t=>(console.error("[THREAD_STATE] Error loading thread list:",t),Tn({threads:[],projectName:e}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),Tn({threads:[],projectName:null}))),ut(({threads:e,projectName:t})=>{console.log("[THREAD_STATE] Thread list loaded:",e.length,"threads for project",t),t&&this.hasLoadedOncePerProject.set(t,!0),this.isLoadingThreadListSubject.next(!1),this.threadListSubject.next(e)})).subscribe()}threadList$=this.threadListSubject.asObservable();refreshSelectedThreadSubject=new ce;selectedThread$=wn([this.projectName$,this.selectedThreadIdSubject.pipe(Xo()),this.refreshSelectedThreadSubject.pipe(Zo(void 0))]).pipe(ea(([e,t])=>!e||!t?Tn(null):(this.isLoadingSubject.next(!0),this.threadApi.getThread(t).pipe(Ns({bufferSize:1,refCount:!0})))),ut(()=>{this.isLoadingSubject.next(!1)}));selectThread(e){this.selectedThreadIdSubject.next(e)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}getSelectedThreadIdOrThrow(){let e=this.selectedThreadIdSubject.value;if(!e)throw new Error("[THREAD_STATE] No thread selected");return e}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let e=this.selectedThreadIdSubject.value;if(!e){console.error("[THREAD_STATE] Cannot stop: no thread selected");return}console.log("[THREAD_STATE] Stopping thread:",e),this.threadApi.stopThread(e).subscribe({next:t=>console.log("[THREAD_STATE] Stop signal sent:",t.message),error:t=>console.error("[THREAD_STATE] Error stopping thread:",t)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}updateStarLocal(e,t,n){let o=this.threadListSubject.value.map(a=>{if(a.id!==e)return a;let s=a.starring||[];return t&&!s.includes(n)?he(G({},a),{starring:[...s,n]}):!t&&s.includes(n)?he(G({},a),{starring:s.filter(d=>d!==n)}):a});this.threadListSubject.next(o)}refreshSelectedThread(){this.refreshSelectedThreadSubject.next()}updateThreadUsers(e,t){return this.threadApi.updateThreadUsers(e,t).pipe(ut(()=>{this.refreshThreadList()}),sn(n=>(console.error("[THREAD_STATE] Error updating thread users:",n),Qn(()=>n))))}renameThread(e,t){let n=t.trim();return!n||n.length===0?(console.error("[THREAD_STATE] Cannot rename thread: name is empty after trimming"),Qn(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",e,"to:",n),this.threadApi.updateThread(e,n).pipe(ut(r=>{console.log("[THREAD_STATE] Thread renamed successfully:",r),this.refreshThreadList()}),sn(r=>(console.error("[THREAD_STATE] Error renaming thread:",r),Qn(()=>r)))))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var pi=class i{http=f(it);projectState=f(_e);threadState=f(We);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/messages`}getMessages(){return this.http.get(this.getBaseUrl())}sendMessage(e){return this.http.post(this.getBaseUrl(),e,{responseType:"text"})}sendFreeMessage(e){return this.http.post(this.getBaseUrl(),{message:e})}getMessage(e){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(e)}`)}deleteMessage(e){return this.http.delete(`${this.getBaseUrl()}/${encodeURIComponent(e)}`)}getFormattedMessage(e){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(e)}/formatted`,{responseType:"text"})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ut=class i{http=f(it);usernameSubject=new q(null);authEnabledSubject=new q(!1);username$=this.usernameSubject.asObservable();authEnabled$=this.authEnabledSubject.asObservable();fetchCurrentUser(){return this.http.get("/api/user/me").pipe(ut(e=>{this.usernameSubject.next(e.username),this.authEnabledSubject.next(e.authEnabled)}))}getUsername(){return this.usernameSubject.value}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var pt=class i{destroy$=new ce;currentProject=null;currentThread=null;messagesSubject=new q([]);isThinkingSubject=new q(!1);currentChoiceSubject=new q(null);projectTitleSubject=new q("Coday");currentInviteEventSubject=new q(null);messageToRestoreSubject=new q("");threadUpdateEventSubject=new q(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new q("");subThreadEventsSubject=new ce;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(e){return this.subThreadEventBuffers.get(e)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=f($t);messageApi=f(pi);userService=f(Ut);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling()}setTabTitleService(e){this.tabTitleService=e}connectToThread(e,t){this.currentProject=e,this.currentThread=t,this.eventStream.connectToThread(e,t)}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking()}sendMessage(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}let t=this.currentInviteEventSubject.value;if(t){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.currentInviteEventSubject.next(null);let n=t.buildAnswer(e);this.handleAnswerEvent(n),this.messageApi.sendMessage(n).subscribe({error:r=>{console.error("[CODAY] Send invite answer error:",r),this.currentInviteEventSubject.next(t),this.stopThinking()}})}else this.messageApi.sendFreeMessage(e).subscribe({error:n=>{console.error("[CODAY] Send error:",n)}})}sendChoice(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let t=this.currentChoiceEvent.buildAnswer(e);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(t).subscribe({next:()=>{},error:n=>{console.error("[CODAY-CHOICE] Choice error:",n),this.stopThinking()}})}else console.error("[CODAY-CHOICE] No choice event available for choice:",e)}deleteMessage(e){let t=this.messagesSubject.value.find(r=>r.id===e),n=this.extractTextContentFromMessage(t);return this.messageApi.deleteMessage(e).pipe(ut(r=>{r.success&&(this.removeMessagesFromIndex(e),n.trim()&&this.messageToRestoreSubject.next(n))}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive()}initializeEventHandling(){this.eventStream.events$.pipe(z(this.destroy$)).subscribe({next:e=>this.handleEvent(e),error:e=>console.error("[CODAY] Event stream error:",e),complete:()=>console.log("[CODAY] Event stream completed")})}handleEvent(e){if(e.threadId&&e.threadId!==this.currentThread){let t=this.subThreadEventBuffers.get(e.threadId);t?t.push(e):this.subThreadEventBuffers.set(e.threadId,[e]),this.subThreadEventsSubject.next(e);return}e instanceof Et?this.handleMessageEvent(e):e instanceof gn?this.handleTextChunkEvent(e):e instanceof Vt?this.handleTextEvent(e):e instanceof dt?this.handleAnswerEvent(e):e instanceof Tt?this.handleErrorEvent(e):e instanceof Nn?this.handleWarnEvent(e):e instanceof fn?this.handleThinkingEvent(e):e instanceof wt?this.handleToolRequestEvent(e):e instanceof _t?this.handleToolResponseEvent(e):e instanceof tn?this.handleChoiceEvent(e):e instanceof li?this.handleHeartBeatEvent(e):e instanceof en?this.handleInviteEvent(e):e instanceof ci?this.handleThreadUpdateEvent(e):e instanceof zt?this.handleDelegationEvent(e):e instanceof di||e instanceof Mt||console.warn("[CODAY] Unhandled event type:",e.type)}handleDelegationEvent(e){if(console.log("[CODAY] DelegationEvent received:",e.subThreadId,e.agentName),this.messagesSubject.value.findIndex(r=>r.subThreadId===e.subThreadId)===-1){let r={id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName};this.addMessage(r)}}handleThreadUpdateEvent(e){this.threadUpdateEventSubject.next(e)}handleMessageEvent(e){e.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let t={id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:e.date,type:"text"};this.addMessage(t)}handleTextChunkEvent(e){this.accumulatedChunks+=e.chunk,this.streamingTextSubject.next(this.accumulatedChunks)}handleTextEvent(e){let t={id:e.timestamp,role:e.speaker?"assistant":"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:e.date,type:e.speaker?"text":"technical"};this.addMessage(t)}handleAnswerEvent(e){let t={id:e.timestamp,role:"user",speaker:e.name??this.userService.getUsername()??"User",content:[{type:"text",content:e.answer}],timestamp:e.date,type:"text",parentKey:e.parentKey,invite:e.invite};this.addMessage(t)}handleErrorEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(e.error)}`}],timestamp:e.date,type:"error"};this.addMessage(t)}handleWarnEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Warning: ${JSON.stringify(e.warning)}`}],timestamp:e.date,type:"warning"};this.addMessage(t)}handleThinkingEvent(e){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(!1),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive()},fn.debounce+1e3))}handleToolRequestEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(t)}handleToolResponseEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(t)}handleChoiceEvent(e){this.stopThinking(),this.currentChoiceEvent=e,this.tabTitleService?.setSystemInactive();let t=e.options.map(r=>({value:r,label:r})),n=e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite;this.currentChoiceSubject.next({options:t,label:n,allowFreeText:e.allowFreeText})}handleHeartBeatEvent(e){}handleInviteEvent(e){this.stopThinking();let t=this.messagesSubject.value,n=t[t.length-1];if(!(!(e.invite===Va)&&n&&n.role==="assistant"&&n.content.some(a=>a.type==="text"&&a.content.includes(e.invite)))&&e.invite!==Va){let a={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.invite}],timestamp:e.date,type:"text"};this.addMessage(a)}this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive()}addMessage(e){let t=this.messagesSubject.value;t.some(n=>n.id===e.id)||this.messagesSubject.next([...t,e])}removeMessagesFromIndex(e){let t=this.messagesSubject.value,n=t.findIndex(o=>o.id===e);if(n===-1||n===0)return;let r=t.slice(0,n);this.messagesSubject.next(r),this.stopThinking()}extractTextContentFromMessage(e){return e?e.content.filter(t=>t.type==="text").map(t=>t.content).join(`
271
+
272
+ `):""}clearThinkingTimeout(){this.thinkingTimeout&&(clearTimeout(this.thinkingTimeout),this.thinkingTimeout=null)}stopThinking(){this.clearThinkingTimeout(),this.isThinkingSubject.next(!1),this.tabTitleService&&this.tabTitleService.setSystemInactive()}ngOnDestroy(){this.clearThinkingTimeout(),this.destroy$.next(),this.destroy$.complete(),this.currentInviteEventSubject.complete(),this.messageToRestoreSubject.complete(),this.threadUpdateEventSubject.complete(),this.streamingTextSubject.complete(),this.eventStream.disconnect()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var oo=class i{sanitizer=f(Rt);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`(${n})`,"gi"),o=e.replace(r,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(o)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=qs({name:"highlight",type:i,pure:!0})};var Sm=["messageInput"],xm=["fileInput"],Tm=(i,e)=>e.name;function wm(i,e){i&1&&(l(0,"div",3),R(1,"span",8),u(2," Recording... Click mic to stop "),c())}function Em(i,e){if(i&1&&(l(0,"span",13),u(1),c()),i&2){let t=h().$implicit,n=h(2);p(),F(" "+(n.getParameterFormat(t)||""))}}function Mm(i,e){if(i&1){let t=O();l(0,"div",10),v("click",function(){let r=x(t).$index,o=h(2);return T(o.selectAutocompleteItemByClick(r))})("keydown.enter",function(){let r=x(t).$index,o=h(2);return T(o.selectAutocompleteItemByClick(r))})("keydown.space",function(){let r=x(t).$index,o=h(2);return T(o.selectAutocompleteItemByClick(r))})("mouseenter",function(){let r=x(t).$index,o=h(2);return T(o.selectedAutocompleteIndex=r)}),l(1,"div",11),R(2,"span",12),Ri(3,"highlight"),C(4,Em,2,1,"span",13),c(),R(5,"div",14),Ri(6,"highlight"),c()}if(i&2){let t=e.$implicit,n=e.$index,r=h(2);J("selected",n===r.selectedAutocompleteIndex),Re("aria-selected",n===r.selectedAutocompleteIndex),p(2),w("innerHTML",aa(3,6,r.autocompleteTrigger+t.name,r.getAutocompleteQuery()),mt),p(2),S(r.hasParameterFormat(t)?4:-1),p(),w("innerHTML",aa(6,9,t.description,r.getAutocompleteQuery()),mt)}}function Pm(i,e){if(i&1&&(l(0,"div",4),Ce(1,Mm,7,12,"div",9,Tm),c()),i&2){let t=h();p(),Se(t.autocompleteItems)}}function km(i,e){if(i&1){let t=O();l(0,"ds-icon-button",17),v("action",function(){x(t);let r=h(2);return T(r.onStopClick())}),c()}}function Om(i,e){if(i&1){let t=O();l(0,"ds-icon-button",18),v("action",function(){x(t);let r=h(2);return T(r.sendMessage())}),c()}if(i&2){let t=h(2);J("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),w("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Am(i,e){if(i&1){let t=O();l(0,"ds-icon-button",20),v("action",function(){x(t);let r=h(3);return T(r.triggerFileUpload())}),c(),l(1,"input",21,1),v("change",function(r){x(t);let o=h(3);return T(o.onFileInputChange(r))}),c()}if(i&2){let t=h(3);w("disabled",t.isDisabled)}}function Im(i,e){if(i&1){let t=O();C(0,Am,3,1),l(1,"ds-icon-button",19),v("action",function(){x(t);let r=h(2);return T(r.toggleRecording())}),c()}if(i&2){let t=h(2);S(t.showWelcome?-1:0),p(),J("recording",t.isRecording)("hidden",t.message.trim()),w("icon",t.isRecording?"fiber_manual_record":"mic")("title",t.isRecording?"Click to stop recording":"Click to start recording")}}function Dm(i,e){if(i&1&&(l(0,"div",7),C(1,km,1,0,"ds-icon-button",15),C(2,Om,1,6,"ds-icon-button",16),C(3,Im,2,7),c()),i&2){let t=h();p(),S(t.isThinking?1:-1),p(),S(!t.isThinking||t.message.trim()?2:-1),p(),S(t.isThinking?-1:3)}}var mi=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new ie;messageSubmitted=new ie;voiceRecordingToggled=new ie;heightChanged=new ie;stopRequested=new ie;textareaFocused=new ie;messageInput;fileInput;message="";isRecording=!1;isFocused=!1;recognition=null;sessionHadTranscript=!1;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=!1;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=f(we);codayService=f(pt);agentApiService=f($l);promptApiService=f(Hl);projectStateService=f(_e);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),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=!1,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(!0)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(!0)))}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete()}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(o=>o.kind==="file");if(!n.length)return;e.preventDefault();let r=n.reduce((o,a)=>{let s=a.getAsFile();return s?[...o,s]:o},[]);r.length&&this.filesPasted.emit(r)}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 r=Array.from(n);this.filesPasted.emit(r),t.value=""}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),r=this.messageInput?.nativeElement;n&&!n.contains(t)&&r&&!r.contains(t)&&this.hideAutocomplete()}sendMessage(e=!1){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=!0,this.stopRequested.emit()}toggleRecording(){this.isRecording?this.stopRecording():this.startRecording()}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=!0,this.recognition.interimResults=!0,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="",r=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let o=r;o<t.results.length;o++)t.results[o].isFinal&&(n+=t.results[o][0].transcript,this.lastProcessedResultIndex=o+1);if(n){let o=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=!0,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(o)}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=!1,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=!1,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 H(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=!1,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(`
273
+
274
+ `),this.sessionHadTranscript=!1),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.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=!1,this.autocompleteItems=[],this.selectedAutocompleteIndex=0}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,r=n.parameterFormat;if(console.log(n),r===void 0)this.message=`/${e.name}`;else if(r==="")this.message=`/${e.name} `;else{this.message=`/${e.name} ${r}`;let o=this.message.indexOf('=""');o!==-1&&(t=o+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=N({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&tt(Sm,7)(xm,5),t&2){let r;je(r=Ve())&&(n.messageInput=r.first),je(r=Ve())&&(n.fileInput=r.first)}},hostBindings:function(t,n){t&1&&v("paste",function(o){return n.onPaste(o)})("click",function(o){return n.onDocumentClick(o)},zs)},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[Dt],decls:7,vars:12,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"],["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"],["variant","default",1,"voice-btn",3,"action","icon","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 r=O();l(0,"div",2),C(1,wm,3,0,"div",3),C(2,Pm,3,0,"div",4),l(3,"div",5)(4,"textarea",6,0),te("ngModelChange",function(a){return x(r),ee(n.message,a)||(n.message=a),T(a)}),v("keydown",function(a){return n.onKeyDown(a)})("input",function(){return n.onInput()})("focus",function(){return x(r),n.isFocused=!0,T(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),c(),C(6,Dm,4,3,"div",7),c()()}t&2&&(p(),S(n.isRecording?1:-1),p(),S(n.autocompleteVisible?2:-1),p(),J("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking),p(),Z("ngModel",n.message),w("placeholder",n.getPlaceholder())("disabled",n.isDisabled),p(2),S(n.isSessionInitializing?-1:6))},dependencies:[st,ht,ot,at,El,oo],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-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}.voice-btn.recording[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{color:var(--color-error);animation:_ngcontent-%COMP%_pulse 1.5s infinite}.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}}']})};var Rm=(i,e)=>e.label;function Nm(i,e){if(i&1){let t=O();l(0,"button",2),v("click",function(r){let o=x(t).$implicit,a=h();return T(a.executeAction(o,r))}),l(1,"mat-icon"),u(2),c()()}if(i&2){let t=e.$implicit;Re("title",t.tooltip||t.label),p(),Re("aria-label",t.label),p(),F(t.icon)}}var ao=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({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&&(l(0,"div",0),Ce(1,Nm,3,3,"button",1,Rm),c()),t&2&&(p(),Se(n.actions))},dependencies:[nt,ze,ae],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};function Ua(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jn=Ua();function Kc(i){jn=i}var Gi={exec:()=>null};function re(i,e=""){let t=typeof i=="string"?i:i.source,n={replace:(r,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(Ye.caret,"$1"),t=t.replace(r,a),n},getRegex:()=>new RegExp(t,e)};return n}var Ye={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},Fm=/^(?:[ \t]*(?:\n|$))+/,Lm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ba=/(?:[*+-]|\d{1,9}[.)])/,Xc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jc=re(Xc).replace(/bull/g,Ba).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),zm=re(Xc).replace(/bull/g,Ba).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),qa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$m=/^[^\n]+/,Wa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Hm=re(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Um=re(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ba).getRegex(),po="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ga=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Bm=re("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ga).replace("tag",po).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Zc=re(qa).replace("hr",Yi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",po).getRegex(),qm=re(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Zc).getRegex(),Ya={blockquote:qm,code:Lm,def:Hm,fences:jm,heading:Vm,hr:Yi,html:Bm,lheading:Jc,list:Um,newline:Fm,paragraph:Zc,table:Gi,text:$m},Bc=re("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",po).getRegex(),Wm=he(G({},Ya),{lheading:zm,table:Bc,paragraph:re(qa).replace("hr",Yi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bc).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",po).getRegex()}),Gm=he(G({},Ya),{html:re(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ga).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:re(qa).replace("hr",Yi).replace("heading",` *#{1,6} *[^
275
+ ]`).replace("lheading",Jc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),Ym=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ed=/^( {2,}|\\)\n(?!\s*$)/,Km=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mo=/[\p{P}\p{S}]/u,Qa=/[\s\p{P}\p{S}]/u,td=/[^\s\p{P}\p{S}]/u,Xm=re(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qa).getRegex(),nd=/(?!~)[\p{P}\p{S}]/u,Jm=/(?!~)[\s\p{P}\p{S}]/u,Zm=/(?:[^\s\p{P}\p{S}]|~)/u,eu=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,id=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,tu=re(id,"u").replace(/punct/g,mo).getRegex(),nu=re(id,"u").replace(/punct/g,nd).getRegex(),rd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",iu=re(rd,"gu").replace(/notPunctSpace/g,td).replace(/punctSpace/g,Qa).replace(/punct/g,mo).getRegex(),ru=re(rd,"gu").replace(/notPunctSpace/g,Zm).replace(/punctSpace/g,Jm).replace(/punct/g,nd).getRegex(),ou=re("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,td).replace(/punctSpace/g,Qa).replace(/punct/g,mo).getRegex(),au=re(/\\(punct)/,"gu").replace(/punct/g,mo).getRegex(),su=re(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),lu=re(Ga).replace("(?:-->|$)","-->").getRegex(),cu=re("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",lu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),lo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,du=re(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",lo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),od=re(/^!?\[(label)\]\[(ref)\]/).replace("label",lo).replace("ref",Wa).getRegex(),ad=re(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wa).getRegex(),pu=re("reflink|nolink(?!\\()","g").replace("reflink",od).replace("nolink",ad).getRegex(),qc=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ka={_backpedal:Gi,anyPunctuation:au,autolink:su,blockSkip:eu,br:ed,code:Qm,del:Gi,emStrongLDelim:tu,emStrongRDelimAst:iu,emStrongRDelimUnd:ou,escape:Ym,link:du,nolink:ad,punctuation:Xm,reflink:od,reflinkSearch:pu,tag:cu,text:Km,url:Gi},mu=he(G({},Ka),{link:re(/^!?\[(label)\]\((.*?)\)/).replace("label",lo).getRegex(),reflink:re(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",lo).getRegex()}),za=he(G({},Ka),{emStrongRDelimAst:ru,emStrongLDelim:nu,url:re(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",qc).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:re(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",qc).getRegex()}),uu=he(G({},za),{br:re(ed).replace("{2,}","*").getRegex(),text:re(za.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),so={normal:Ya,gfm:Wm,pedantic:Gm},Bi={normal:Ka,gfm:za,breaks:uu,pedantic:mu},hu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wc=i=>hu[i];function Bt(i,e){if(e){if(Ye.escapeTest.test(i))return i.replace(Ye.escapeReplace,Wc)}else if(Ye.escapeTestNoEncode.test(i))return i.replace(Ye.escapeReplaceNoEncode,Wc);return i}function Gc(i){try{i=encodeURI(i).replace(Ye.percentDecode,"%")}catch(e){return null}return i}function Yc(i,e){let t=i.replace(Ye.findPipe,(o,a,s)=>{let d=!1,m=a;for(;--m>=0&&s[m]==="\\";)d=!d;return d?"|":" |"}),n=t.split(Ye.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(Ye.slashPipe,"|");return n}function qi(i,e,t){let n=i.length;if(n===0)return"";let r=0;for(;r<n;){let o=i.charAt(n-r-1);if(o===e&&!t)r++;else if(o!==e&&t)r++;else break}return i.slice(0,n-r)}function gu(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===e[0])t++;else if(i[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function Qc(i,e,t,n,r){let o=e.href,a=e.title||null,s=i[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=!0;let d={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:o,title:a,text:s,tokens:n.inlineTokens(s)};return n.state.inLink=!1,d}function fu(i,e,t){let n=i.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
276
+ `).map(o=>{let a=o.match(t.other.beginningSpace);if(a===null)return o;let[s]=a;return s.length>=r.length?o.slice(r.length):o}).join(`
277
+ `)}var co=class{options;rules;lexer;constructor(i){this.options=i||jn}space(i){let e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){let e=this.rules.block.code.exec(i);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:qi(t,`
278
+ `)}}}fences(i){let e=this.rules.block.fences.exec(i);if(e){let t=e[0],n=fu(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(i){let e=this.rules.block.heading.exec(i);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let n=qi(t,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(t=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(i){let e=this.rules.block.hr.exec(i);if(e)return{type:"hr",raw:qi(e[0],`
279
+ `)}}blockquote(i){let e=this.rules.block.blockquote.exec(i);if(e){let t=qi(e[0],`
280
+ `).split(`
281
+ `),n="",r="",o=[];for(;t.length>0;){let a=!1,s=[],d;for(d=0;d<t.length;d++)if(this.rules.other.blockquoteStart.test(t[d]))s.push(t[d]),a=!0;else if(!a)s.push(t[d]);else break;t=t.slice(d);let m=s.join(`
282
+ `),_=m.replace(this.rules.other.blockquoteSetextReplace,`
283
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
284
+ ${m}`:m,r=r?`${r}
285
+ ${_}`:_;let b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(_,o,!0),this.lexer.state.top=b,t.length===0)break;let y=o.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){let P=y,E=P.raw+`
286
+ `+t.join(`
287
+ `),k=this.blockquote(E);o[o.length-1]=k,n=n.substring(0,n.length-P.raw.length)+k.raw,r=r.substring(0,r.length-P.text.length)+k.text;break}else if(y?.type==="list"){let P=y,E=P.raw+`
288
+ `+t.join(`
289
+ `),k=this.list(E);o[o.length-1]=k,n=n.substring(0,n.length-y.raw.length)+k.raw,r=r.substring(0,r.length-P.raw.length)+k.raw,t=E.substring(o.at(-1).raw.length).split(`
290
+ `);continue}}return{type:"blockquote",raw:n,tokens:o,text:r}}}list(i){let e=this.rules.block.list.exec(i);if(e){let t=e[1].trim(),n=t.length>1,r={type:"list",raw:"",ordered:n,start:n?+t.slice(0,-1):"",loose:!1,items:[]};t=n?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=n?t:"[*+-]");let o=this.rules.other.listItemRegex(t),a=!1;for(;i;){let d=!1,m="",_="";if(!(e=o.exec(i))||this.rules.block.hr.test(i))break;m=e[0],i=i.substring(m.length);let b=e[2].split(`
291
+ `,1)[0].replace(this.rules.other.listReplaceTabs,pe=>" ".repeat(3*pe.length)),y=i.split(`
292
+ `,1)[0],P=!b.trim(),E=0;if(this.options.pedantic?(E=2,_=b.trimStart()):P?E=e[1].length+1:(E=e[2].search(this.rules.other.nonSpaceChar),E=E>4?1:E,_=b.slice(E),E+=e[1].length),P&&this.rules.other.blankLine.test(y)&&(m+=y+`
293
+ `,i=i.substring(y.length+1),d=!0),!d){let pe=this.rules.other.nextBulletRegex(E),D=this.rules.other.hrRegex(E),K=this.rules.other.fencesBeginRegex(E),B=this.rules.other.headingBeginRegex(E),xe=this.rules.other.htmlBeginRegex(E);for(;i;){let de=i.split(`
294
+ `,1)[0],ye;if(y=de,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),ye=y):ye=y.replace(this.rules.other.tabCharGlobal," "),K.test(y)||B.test(y)||xe.test(y)||pe.test(y)||D.test(y))break;if(ye.search(this.rules.other.nonSpaceChar)>=E||!y.trim())_+=`
295
+ `+ye.slice(E);else{if(P||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||K.test(b)||B.test(b)||D.test(b))break;_+=`
296
+ `+y}!P&&!y.trim()&&(P=!0),m+=de+`
297
+ `,i=i.substring(de.length+1),b=ye.slice(E)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(m)&&(a=!0));let k=null,Q;this.options.gfm&&(k=this.rules.other.listIsTask.exec(_),k&&(Q=k[0]!=="[ ] ",_=_.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:m,task:!!k,checked:Q,loose:!1,text:_,tokens:[]}),r.raw+=m}let s=r.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let d=0;d<r.items.length;d++)if(this.lexer.state.top=!1,r.items[d].tokens=this.lexer.blockTokens(r.items[d].text,[]),!r.loose){let m=r.items[d].tokens.filter(b=>b.type==="space"),_=m.length>0&&m.some(b=>this.rules.other.anyLine.test(b.raw));r.loose=_}if(r.loose)for(let d=0;d<r.items.length;d++)r.items[d].loose=!0;return r}}html(i){let e=this.rules.block.html.exec(i);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(i){let e=this.rules.block.def.exec(i);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:n,title:r}}}table(i){let e=this.rules.block.table.exec(i);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Yc(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
298
+ `):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===n.length){for(let a of n)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<t.length;a++)o.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:o.align[a]});for(let a of r)o.rows.push(Yc(a,o.header.length).map((s,d)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[d]})));return o}}lheading(i){let e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){let e=this.rules.block.paragraph.exec(i);if(e){let t=e[1].charAt(e[1].length-1)===`
299
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){let e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){let e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){let e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){let e=this.rules.inline.link.exec(i);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let o=qi(t.slice(0,-1),"\\");if((t.length-o.length)%2===0)return}else{let o=gu(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let n=e[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(n);o&&(n=o[1],r=o[3])}else r=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?n=n.slice(1):n=n.slice(1,-1)),Qc(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(i,e){let t;if((t=this.rules.inline.reflink.exec(i))||(t=this.rules.inline.nolink.exec(i))){let n=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[n.toLowerCase()];if(!r){let o=t[0].charAt(0);return{type:"text",raw:o,text:o}}return Qc(t,r,t[0],this.lexer,this.rules)}}emStrong(i,e,t=""){let n=this.rules.inline.emStrongLDelim.exec(i);if(!(!n||n[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[2])||!t||this.rules.inline.punctuation.exec(t))){let r=[...n[0]].length-1,o,a,s=r,d=0,m=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,e=e.slice(-1*i.length+r);(n=m.exec(e))!=null;){if(o=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!o)continue;if(a=[...o].length,n[3]||n[4]){s+=a;continue}else if((n[5]||n[6])&&r%3&&!((r+a)%3)){d+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s+d);let _=[...n[0]][0].length,b=i.slice(0,r+n.index+_+a);if(Math.min(r,a)%2){let P=b.slice(1,-1);return{type:"em",raw:b,text:P,tokens:this.lexer.inlineTokens(P)}}let y=b.slice(2,-2);return{type:"strong",raw:b,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(i){let e=this.rules.inline.code.exec(i);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return n&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(i){let e=this.rules.inline.br.exec(i);if(e)return{type:"br",raw:e[0]}}del(i){let e=this.rules.inline.del.exec(i);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(i){let e=this.rules.inline.autolink.exec(i);if(e){let t,n;return e[2]==="@"?(t=e[1],n="mailto:"+t):(t=e[1],n=t),{type:"link",raw:e[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}}url(i){let e;if(e=this.rules.inline.url.exec(i)){let t,n;if(e[2]==="@")t=e[0],n="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(i){let e=this.rules.inline.text.exec(i);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},Pt=class $a{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||jn,this.options.tokenizer=this.options.tokenizer||new co,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ye,block:so.normal,inline:Bi.normal};this.options.pedantic?(t.block=so.pedantic,t.inline=Bi.pedantic):this.options.gfm&&(t.block=so.gfm,this.options.breaks?t.inline=Bi.breaks:t.inline=Bi.gfm),this.tokenizer.rules=t}static get rules(){return{block:so,inline:Bi}}static lex(e,t){return new $a(t).lex(e)}static lexInline(e,t){return new $a(t).inlineTokens(e)}lex(e){e=e.replace(Ye.carriageReturn,`
300
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(Ye.tabCharGlobal," ").replace(Ye.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(a=>(r=a.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let a=t.at(-1);r.raw.length===1&&a!==void 0?a.raw+=`
301
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
302
+ `)?"":`
303
+ `)+r.raw,a.text+=`
304
+ `+r.text,this.inlineQueue.at(-1).src=a.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
305
+ `)?"":`
306
+ `)+r.raw,a.text+=`
307
+ `+r.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startBlock){let a=1/0,s=e.slice(1),d;this.options.extensions.startBlock.forEach(m=>{d=m.call({lexer:this},s),typeof d=="number"&&d>=0&&(a=Math.min(a,d))}),a<1/0&&a>=0&&(o=e.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(o))){let a=t.at(-1);n&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
308
+ `)?"":`
309
+ `)+r.raw,a.text+=`
310
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=o.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
311
+ `)?"":`
312
+ `)+r.raw,a.text+=`
313
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let s=Object.keys(this.tokens.links);if(s.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)s.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let o=!1,a="";for(;e;){o||(a=""),o=!1;let s;if(this.options.extensions?.inline?.some(m=>(s=m.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let m=t.at(-1);s.type==="text"&&m?.type==="text"?(m.raw+=s.raw,m.text+=s.text):t.push(s);continue}if(s=this.tokenizer.emStrong(e,n,a)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.del(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),t.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let d=e;if(this.options.extensions?.startInline){let m=1/0,_=e.slice(1),b;this.options.extensions.startInline.forEach(y=>{b=y.call({lexer:this},_),typeof b=="number"&&b>=0&&(m=Math.min(m,b))}),m<1/0&&m>=0&&(d=e.substring(0,m+1))}if(s=this.tokenizer.inlineText(d)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),o=!0;let m=t.at(-1);m?.type==="text"?(m.raw+=s.raw,m.text+=s.text):t.push(s);continue}if(e){let m="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return t}},ui=class{options;parser;constructor(i){this.options=i||jn}space(i){return""}code({text:i,lang:e,escaped:t}){let n=(e||"").match(Ye.notSpaceStart)?.[0],r=i.replace(Ye.endingNewline,"")+`
314
+ `;return n?'<pre><code class="language-'+Bt(n)+'">'+(t?r:Bt(r,!0))+`</code></pre>
315
+ `:"<pre><code>"+(t?r:Bt(r,!0))+`</code></pre>
316
+ `}blockquote({tokens:i}){return`<blockquote>
317
+ ${this.parser.parse(i)}</blockquote>
318
+ `}html({text:i}){return i}def(i){return""}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
319
+ `}hr(i){return`<hr>
320
+ `}list(i){let e=i.ordered,t=i.start,n="";for(let a=0;a<i.items.length;a++){let s=i.items[a];n+=this.listitem(s)}let r=e?"ol":"ul",o=e&&t!==1?' start="'+t+'"':"";return"<"+r+o+`>
321
+ `+n+"</"+r+`>
322
+ `}listitem(i){let e="";if(i.task){let t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+Bt(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
323
+ `}checkbox({checked:i}){return"<input "+(i?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:i}){return`<p>${this.parser.parseInline(i)}</p>
324
+ `}table(i){let e="",t="";for(let r=0;r<i.header.length;r++)t+=this.tablecell(i.header[r]);e+=this.tablerow({text:t});let n="";for(let r=0;r<i.rows.length;r++){let o=i.rows[r];t="";for(let a=0;a<o.length;a++)t+=this.tablecell(o[a]);n+=this.tablerow({text:t})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
325
+ <thead>
326
+ `+e+`</thead>
327
+ `+n+`</table>
328
+ `}tablerow({text:i}){return`<tr>
329
+ ${i}</tr>
330
+ `}tablecell(i){let e=this.parser.parseInline(i.tokens),t=i.header?"th":"td";return(i.align?`<${t} align="${i.align}">`:`<${t}>`)+e+`</${t}>
331
+ `}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${Bt(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){let n=this.parser.parseInline(t),r=Gc(i);if(r===null)return n;i=r;let o='<a href="'+i+'"';return e&&(o+=' title="'+Bt(e)+'"'),o+=">"+n+"</a>",o}image({href:i,title:e,text:t,tokens:n}){n&&(t=this.parser.parseInline(n,this.parser.textRenderer));let r=Gc(i);if(r===null)return Bt(t);i=r;let o=`<img src="${i}" alt="${t}"`;return e&&(o+=` title="${Bt(e)}"`),o+=">",o}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:Bt(i.text)}},Xa=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},kt=class Ha{options;renderer;textRenderer;constructor(e){this.options=e||jn,this.options.renderer=this.options.renderer||new ui,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xa}static parse(e,t){return new Ha(t).parse(e)}static parseInline(e,t){return new Ha(t).parseInline(e)}parse(e,t=!0){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let s=o,d=this.options.extensions.renderers[s.type].call({parser:this},s);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){n+=d||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"def":{n+=this.renderer.def(a);continue}case"paragraph":{n+=this.renderer.paragraph(a);continue}case"text":{let s=a,d=this.renderer.text(s);for(;r+1<e.length&&e[r+1].type==="text";)s=e[++r],d+=`
332
+ `+this.renderer.text(s);t?n+=this.renderer.paragraph({type:"paragraph",raw:d,text:d,tokens:[{type:"text",raw:d,text:d,escaped:!0}]}):n+=d;continue}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){n+=s||"";continue}}let a=o;switch(a.type){case"escape":{n+=t.text(a);break}case"html":{n+=t.html(a);break}case"link":{n+=t.link(a);break}case"image":{n+=t.image(a);break}case"strong":{n+=t.strong(a);break}case"em":{n+=t.em(a);break}case"codespan":{n+=t.codespan(a);break}case"br":{n+=t.br(a);break}case"del":{n+=t.del(a);break}case"text":{n+=t.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}},Wi=class{options;block;constructor(i){this.options=i||jn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}emStrongMask(i){return i}provideLexer(){return this.block?Pt.lex:Pt.lexInline}provideParser(){return this.block?kt.parse:kt.parseInline}},_u=class{defaults=Ua();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=kt;Renderer=ui;TextRenderer=Xa;Lexer=Pt;Tokenizer=co;Hooks=Wi;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(let n of i)switch(t=t.concat(e.call(this,n)),n.type){case"table":{let r=n;for(let o of r.header)t=t.concat(this.walkTokens(o.tokens,e));for(let o of r.rows)for(let a of o)t=t.concat(this.walkTokens(a.tokens,e));break}case"list":{let r=n;t=t.concat(this.walkTokens(r.items,e));break}default:{let r=n;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let a=r[o].flat(1/0);t=t.concat(this.walkTokens(a,e))}):r.tokens&&(t=t.concat(this.walkTokens(r.tokens,e)))}}return t}use(...i){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(t=>{let n=G({},t);if(n.async=this.defaults.async||n.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=e.renderers[r.name];o?e.renderers[r.name]=function(...a){let s=r.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[r.level];o?o.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),n.extensions=e),t.renderer){let r=this.defaults.renderer||new ui(this.defaults);for(let o in t.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=t.renderer[a],d=r[a];r[a]=(...m)=>{let _=s.apply(r,m);return _===!1&&(_=d.apply(r,m)),_||""}}n.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new co(this.defaults);for(let o in t.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=t.tokenizer[a],d=r[a];r[a]=(...m)=>{let _=s.apply(r,m);return _===!1&&(_=d.apply(r,m)),_}}n.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new Wi;for(let o in t.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,s=t.hooks[a],d=r[a];Wi.passThroughHooks.has(o)?r[a]=m=>{if(this.defaults.async&&Wi.passThroughHooksRespectAsync.has(o))return H(this,null,function*(){let b=yield s.call(r,m);return d.call(r,b)});let _=s.call(r,m);return d.call(r,_)}:r[a]=(...m)=>{if(this.defaults.async)return H(this,null,function*(){let b=yield s.apply(r,m);return b===!1&&(b=yield d.apply(r,m)),b});let _=s.apply(r,m);return _===!1&&(_=d.apply(r,m)),_}}n.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,o=t.walkTokens;n.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),r&&(s=s.concat(r.call(this,a))),s}}this.defaults=G(G({},this.defaults),n)}),this}setOptions(i){return this.defaults=G(G({},this.defaults),i),this}lexer(i,e){return Pt.lex(i,e??this.defaults)}parser(i,e){return kt.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{let n=G({},t),r=G(G({},this.defaults),n),o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&n.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=i),r.async)return H(this,null,function*(){let a=r.hooks?yield r.hooks.preprocess(e):e,s=yield(r.hooks?yield r.hooks.provideLexer():i?Pt.lex:Pt.lexInline)(a,r),d=r.hooks?yield r.hooks.processAllTokens(s):s;r.walkTokens&&(yield Promise.all(this.walkTokens(d,r.walkTokens)));let m=yield(r.hooks?yield r.hooks.provideParser():i?kt.parse:kt.parseInline)(d,r);return r.hooks?yield r.hooks.postprocess(m):m}).catch(o);try{r.hooks&&(e=r.hooks.preprocess(e));let a=(r.hooks?r.hooks.provideLexer():i?Pt.lex:Pt.lexInline)(e,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():i?kt.parse:kt.parseInline)(a,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(i,e){return t=>{if(t.message+=`
333
+ Please report this to https://github.com/markedjs/marked.`,i){let n="<p>An error occurred:</p><pre>"+Bt(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},Ln=new _u;function se(i,e){return Ln.parse(i,e)}se.options=se.setOptions=function(i){return Ln.setOptions(i),se.defaults=Ln.defaults,Kc(se.defaults),se};se.getDefaults=Ua;se.defaults=jn;se.use=function(...i){return Ln.use(...i),se.defaults=Ln.defaults,Kc(se.defaults),se};se.walkTokens=function(i,e){return Ln.walkTokens(i,e)};se.parseInline=Ln.parseInline;se.Parser=kt;se.parser=kt.parse;se.Renderer=ui;se.TextRenderer=Xa;se.Lexer=Pt;se.lexer=Pt.lex;se.Tokenizer=co;se.Hooks=Wi;se.parse=se;var Ly=se.options,jy=se.setOptions,Vy=se.use,zy=se.walkTokens,$y=se.parseInline;var Hy=kt.parse,Uy=Pt.lex;var{entries:gd,setPrototypeOf:sd,isFrozen:bu,getPrototypeOf:vu,getOwnPropertyDescriptor:yu}=Object,{freeze:Ke,seal:bt,create:rs}=Object,{apply:os,construct:as}=typeof Reflect<"u"&&Reflect;Ke||(Ke=function(e){return e});bt||(bt=function(e){return e});os||(os=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return e.apply(t,r)});as||(as=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)});var uo=Xe(Array.prototype.forEach),Cu=Xe(Array.prototype.lastIndexOf),ld=Xe(Array.prototype.pop),Qi=Xe(Array.prototype.push),Su=Xe(Array.prototype.splice),go=Xe(String.prototype.toLowerCase),Ja=Xe(String.prototype.toString),Za=Xe(String.prototype.match),Ki=Xe(String.prototype.replace),xu=Xe(String.prototype.indexOf),Tu=Xe(String.prototype.trim),Ot=Xe(Object.prototype.hasOwnProperty),Qe=Xe(RegExp.prototype.test),Xi=wu(TypeError);function Xe(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return os(i,e,n)}}function wu(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return as(i,t)}}function Y(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:go;sd&&sd(i,null);let n=e.length;for(;n--;){let r=e[n];if(typeof r=="string"){let o=t(r);o!==r&&(bu(e)||(e[n]=o),r=o)}i[r]=!0}return i}function Eu(i){for(let e=0;e<i.length;e++)Ot(i,e)||(i[e]=null);return i}function qt(i){let e=rs(null);for(let[t,n]of gd(i))Ot(i,t)&&(Array.isArray(n)?e[t]=Eu(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=qt(n):e[t]=n);return e}function Ji(i,e){for(;i!==null;){let n=yu(i,e);if(n){if(n.get)return Xe(n.get);if(typeof n.value=="function")return Xe(n.value)}i=vu(i)}function t(){return null}return t}var cd=Ke(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),es=Ke(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ts=Ke(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Mu=Ke(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ns=Ke(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Pu=Ke(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),dd=Ke(["#text"]),pd=Ke(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),is=Ke(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),md=Ke(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ho=Ke(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ku=bt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ou=bt(/<%[\w\W]*|[\w\W]*%>/gm),Au=bt(/\$\{[\w\W]*/gm),Iu=bt(/^data-[\-\w.\u00B7-\uFFFF]+$/),Du=bt(/^aria-[\-\w]+$/),fd=bt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ru=bt(/^(?:\w+script|data):/i),Nu=bt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_d=bt(/^html$/i),Fu=bt(/^[a-z][.\w]*(-[.\w]+)+$/i),ud=Object.freeze({__proto__:null,ARIA_ATTR:Du,ATTR_WHITESPACE:Nu,CUSTOM_ELEMENT:Fu,DATA_ATTR:Iu,DOCTYPE_NAME:_d,ERB_EXPR:Ou,IS_ALLOWED_URI:fd,IS_SCRIPT_OR_DATA:Ru,MUSTACHE_EXPR:ku,TMPLIT_EXPR:Au}),Zi={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Lu=function(){return typeof window>"u"?null:window},ju=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch(a){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},hd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function bd(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Lu(),e=j=>bd(j);if(e.version="3.3.1",e.removed=[],!i||!i.document||i.document.nodeType!==Zi.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i,n=t,r=n.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:s,Element:d,NodeFilter:m,NamedNodeMap:_=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:b,DOMParser:y,trustedTypes:P}=i,E=d.prototype,k=Ji(E,"cloneNode"),Q=Ji(E,"remove"),pe=Ji(E,"nextSibling"),D=Ji(E,"childNodes"),K=Ji(E,"parentNode");if(typeof a=="function"){let j=t.createElement("template");j.content&&j.content.ownerDocument&&(t=j.content.ownerDocument)}let B,xe="",{implementation:de,createNodeIterator:ye,createDocumentFragment:He,getElementsByTagName:Gt}=t,{importNode:on}=n,Fe=hd();e.isSupported=typeof gd=="function"&&typeof K=="function"&&de&&de.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:vt,ERB_EXPR:yn,TMPLIT_EXPR:$n,DATA_ATTR:or,ARIA_ATTR:A,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:X}=ud,{IS_ALLOWED_URI:Ee}=ud,le=null,Ue=Y({},[...cd,...es,...ts,...ns,...dd]),me=null,ue=Y({},[...pd,...is,...md,...ho]),ge=Object.seal(rs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Cn=null,Pe=null,Je=Object.seal(rs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ge=!0,an=!0,Hn=!1,us=!0,Un=!1,ar=!0,Sn=!1,zo=!1,$o=!1,Bn=!1,sr=!1,lr=!1,hs=!0,gs=!1,lp="user-content-",Ho=!0,Ai=!1,qn={},At=null,Uo=Y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),fs=null,_s=Y({},["audio","video","img","source","image","track"]),Bo=null,bs=Y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),cr="http://www.w3.org/1998/Math/MathML",dr="http://www.w3.org/2000/svg",Yt="http://www.w3.org/1999/xhtml",Wn=Yt,qo=!1,Wo=null,cp=Y({},[cr,dr,Yt],Ja),pr=Y({},["mi","mo","mn","ms","mtext"]),mr=Y({},["annotation-xml"]),dp=Y({},["title","style","font","a","script"]),Ii=null,pp=["application/xhtml+xml","text/html"],mp="text/html",Ie=null,Gn=null,up=t.createElement("form"),vs=function(g){return g instanceof RegExp||g instanceof Function},Go=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Gn&&Gn===g)){if((!g||typeof g!="object")&&(g={}),g=qt(g),Ii=pp.indexOf(g.PARSER_MEDIA_TYPE)===-1?mp:g.PARSER_MEDIA_TYPE,Ie=Ii==="application/xhtml+xml"?Ja:go,le=Ot(g,"ALLOWED_TAGS")?Y({},g.ALLOWED_TAGS,Ie):Ue,me=Ot(g,"ALLOWED_ATTR")?Y({},g.ALLOWED_ATTR,Ie):ue,Wo=Ot(g,"ALLOWED_NAMESPACES")?Y({},g.ALLOWED_NAMESPACES,Ja):cp,Bo=Ot(g,"ADD_URI_SAFE_ATTR")?Y(qt(bs),g.ADD_URI_SAFE_ATTR,Ie):bs,fs=Ot(g,"ADD_DATA_URI_TAGS")?Y(qt(_s),g.ADD_DATA_URI_TAGS,Ie):_s,At=Ot(g,"FORBID_CONTENTS")?Y({},g.FORBID_CONTENTS,Ie):Uo,Cn=Ot(g,"FORBID_TAGS")?Y({},g.FORBID_TAGS,Ie):qt({}),Pe=Ot(g,"FORBID_ATTR")?Y({},g.FORBID_ATTR,Ie):qt({}),qn=Ot(g,"USE_PROFILES")?g.USE_PROFILES:!1,Ge=g.ALLOW_ARIA_ATTR!==!1,an=g.ALLOW_DATA_ATTR!==!1,Hn=g.ALLOW_UNKNOWN_PROTOCOLS||!1,us=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Un=g.SAFE_FOR_TEMPLATES||!1,ar=g.SAFE_FOR_XML!==!1,Sn=g.WHOLE_DOCUMENT||!1,Bn=g.RETURN_DOM||!1,sr=g.RETURN_DOM_FRAGMENT||!1,lr=g.RETURN_TRUSTED_TYPE||!1,$o=g.FORCE_BODY||!1,hs=g.SANITIZE_DOM!==!1,gs=g.SANITIZE_NAMED_PROPS||!1,Ho=g.KEEP_CONTENT!==!1,Ai=g.IN_PLACE||!1,Ee=g.ALLOWED_URI_REGEXP||fd,Wn=g.NAMESPACE||Yt,pr=g.MATHML_TEXT_INTEGRATION_POINTS||pr,mr=g.HTML_INTEGRATION_POINTS||mr,ge=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&vs(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ge.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&vs(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ge.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ge.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Un&&(an=!1),sr&&(Bn=!0),qn&&(le=Y({},dd),me=[],qn.html===!0&&(Y(le,cd),Y(me,pd)),qn.svg===!0&&(Y(le,es),Y(me,is),Y(me,ho)),qn.svgFilters===!0&&(Y(le,ts),Y(me,is),Y(me,ho)),qn.mathMl===!0&&(Y(le,ns),Y(me,md),Y(me,ho))),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Je.tagCheck=g.ADD_TAGS:(le===Ue&&(le=qt(le)),Y(le,g.ADD_TAGS,Ie))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Je.attributeCheck=g.ADD_ATTR:(me===ue&&(me=qt(me)),Y(me,g.ADD_ATTR,Ie))),g.ADD_URI_SAFE_ATTR&&Y(Bo,g.ADD_URI_SAFE_ATTR,Ie),g.FORBID_CONTENTS&&(At===Uo&&(At=qt(At)),Y(At,g.FORBID_CONTENTS,Ie)),g.ADD_FORBID_CONTENTS&&(At===Uo&&(At=qt(At)),Y(At,g.ADD_FORBID_CONTENTS,Ie)),Ho&&(le["#text"]=!0),Sn&&Y(le,["html","head","body"]),le.table&&(Y(le,["tbody"]),delete Cn.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');B=g.TRUSTED_TYPES_POLICY,xe=B.createHTML("")}else B===void 0&&(B=ju(P,r)),B!==null&&typeof xe=="string"&&(xe=B.createHTML(""));Ke&&Ke(g),Gn=g}},ys=Y({},[...es,...ts,...Mu]),Cs=Y({},[...ns,...Pu]),hp=function(g){let M=K(g);(!M||!M.tagName)&&(M={namespaceURI:Wn,tagName:"template"});let I=go(g.tagName),fe=go(M.tagName);return Wo[g.namespaceURI]?g.namespaceURI===dr?M.namespaceURI===Yt?I==="svg":M.namespaceURI===cr?I==="svg"&&(fe==="annotation-xml"||pr[fe]):!!ys[I]:g.namespaceURI===cr?M.namespaceURI===Yt?I==="math":M.namespaceURI===dr?I==="math"&&mr[fe]:!!Cs[I]:g.namespaceURI===Yt?M.namespaceURI===dr&&!mr[fe]||M.namespaceURI===cr&&!pr[fe]?!1:!Cs[I]&&(dp[I]||!ys[I]):!!(Ii==="application/xhtml+xml"&&Wo[g.namespaceURI]):!1},It=function(g){Qi(e.removed,{element:g});try{K(g).removeChild(g)}catch(M){Q(g)}},xn=function(g,M){try{Qi(e.removed,{attribute:M.getAttributeNode(g),from:M})}catch(I){Qi(e.removed,{attribute:null,from:M})}if(M.removeAttribute(g),g==="is")if(Bn||sr)try{It(M)}catch(I){}else try{M.setAttribute(g,"")}catch(I){}},Ss=function(g){let M=null,I=null;if($o)g="<remove></remove>"+g;else{let ke=Za(g,/^[\r\n\t ]+/);I=ke&&ke[0]}Ii==="application/xhtml+xml"&&Wn===Yt&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let fe=B?B.createHTML(g):g;if(Wn===Yt)try{M=new y().parseFromString(fe,Ii)}catch(ke){}if(!M||!M.documentElement){M=de.createDocument(Wn,"template",null);try{M.documentElement.innerHTML=qo?xe:fe}catch(ke){}}let Be=M.body||M.documentElement;return g&&I&&Be.insertBefore(t.createTextNode(I),Be.childNodes[0]||null),Wn===Yt?Gt.call(M,Sn?"html":"body")[0]:Sn?M.documentElement:Be},xs=function(g){return ye.call(g.ownerDocument||g,g,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},Yo=function(g){return g instanceof b&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof _)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},Ts=function(g){return typeof s=="function"&&g instanceof s};function Qt(j,g,M){uo(j,I=>{I.call(e,g,M,Gn)})}let ws=function(g){let M=null;if(Qt(Fe.beforeSanitizeElements,g,null),Yo(g))return It(g),!0;let I=Ie(g.nodeName);if(Qt(Fe.uponSanitizeElement,g,{tagName:I,allowedTags:le}),ar&&g.hasChildNodes()&&!Ts(g.firstElementChild)&&Qe(/<[/\w!]/g,g.innerHTML)&&Qe(/<[/\w!]/g,g.textContent)||g.nodeType===Zi.progressingInstruction||ar&&g.nodeType===Zi.comment&&Qe(/<[/\w]/g,g.data))return It(g),!0;if(!(Je.tagCheck instanceof Function&&Je.tagCheck(I))&&(!le[I]||Cn[I])){if(!Cn[I]&&Ms(I)&&(ge.tagNameCheck instanceof RegExp&&Qe(ge.tagNameCheck,I)||ge.tagNameCheck instanceof Function&&ge.tagNameCheck(I)))return!1;if(Ho&&!At[I]){let fe=K(g)||g.parentNode,Be=D(g)||g.childNodes;if(Be&&fe){let ke=Be.length;for(let Ze=ke-1;Ze>=0;--Ze){let Kt=k(Be[Ze],!0);Kt.__removalCount=(g.__removalCount||0)+1,fe.insertBefore(Kt,pe(g))}}}return It(g),!0}return g instanceof d&&!hp(g)||(I==="noscript"||I==="noembed"||I==="noframes")&&Qe(/<\/no(script|embed|frames)/i,g.innerHTML)?(It(g),!0):(Un&&g.nodeType===Zi.text&&(M=g.textContent,uo([vt,yn,$n],fe=>{M=Ki(M,fe," ")}),g.textContent!==M&&(Qi(e.removed,{element:g.cloneNode()}),g.textContent=M)),Qt(Fe.afterSanitizeElements,g,null),!1)},Es=function(g,M,I){if(hs&&(M==="id"||M==="name")&&(I in t||I in up))return!1;if(!(an&&!Pe[M]&&Qe(or,M))){if(!(Ge&&Qe(A,M))){if(!(Je.attributeCheck instanceof Function&&Je.attributeCheck(M,g))){if(!me[M]||Pe[M]){if(!(Ms(g)&&(ge.tagNameCheck instanceof RegExp&&Qe(ge.tagNameCheck,g)||ge.tagNameCheck instanceof Function&&ge.tagNameCheck(g))&&(ge.attributeNameCheck instanceof RegExp&&Qe(ge.attributeNameCheck,M)||ge.attributeNameCheck instanceof Function&&ge.attributeNameCheck(M,g))||M==="is"&&ge.allowCustomizedBuiltInElements&&(ge.tagNameCheck instanceof RegExp&&Qe(ge.tagNameCheck,I)||ge.tagNameCheck instanceof Function&&ge.tagNameCheck(I))))return!1}else if(!Bo[M]){if(!Qe(Ee,Ki(I,V,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&g!=="script"&&xu(I,"data:")===0&&fs[g])){if(!(Hn&&!Qe(L,Ki(I,V,"")))){if(I)return!1}}}}}}}return!0},Ms=function(g){return g!=="annotation-xml"&&Za(g,X)},Ps=function(g){Qt(Fe.beforeSanitizeAttributes,g,null);let{attributes:M}=g;if(!M||Yo(g))return;let I={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:me,forceKeepAttr:void 0},fe=M.length;for(;fe--;){let Be=M[fe],{name:ke,namespaceURI:Ze,value:Kt}=Be,Yn=Ie(ke),Qo=Kt,$e=ke==="value"?Qo:Tu(Qo);if(I.attrName=Yn,I.attrValue=$e,I.keepAttr=!0,I.forceKeepAttr=void 0,Qt(Fe.uponSanitizeAttribute,g,I),$e=I.attrValue,gs&&(Yn==="id"||Yn==="name")&&(xn(ke,g),$e=lp+$e),ar&&Qe(/((--!?|])>)|<\/(style|title|textarea)/i,$e)){xn(ke,g);continue}if(Yn==="attributename"&&Za($e,"href")){xn(ke,g);continue}if(I.forceKeepAttr)continue;if(!I.keepAttr){xn(ke,g);continue}if(!us&&Qe(/\/>/i,$e)){xn(ke,g);continue}Un&&uo([vt,yn,$n],Os=>{$e=Ki($e,Os," ")});let ks=Ie(g.nodeName);if(!Es(ks,Yn,$e)){xn(ke,g);continue}if(B&&typeof P=="object"&&typeof P.getAttributeType=="function"&&!Ze)switch(P.getAttributeType(ks,Yn)){case"TrustedHTML":{$e=B.createHTML($e);break}case"TrustedScriptURL":{$e=B.createScriptURL($e);break}}if($e!==Qo)try{Ze?g.setAttributeNS(Ze,ke,$e):g.setAttribute(ke,$e),Yo(g)?It(g):ld(e.removed)}catch(Os){xn(ke,g)}}Qt(Fe.afterSanitizeAttributes,g,null)},gp=function j(g){let M=null,I=xs(g);for(Qt(Fe.beforeSanitizeShadowDOM,g,null);M=I.nextNode();)Qt(Fe.uponSanitizeShadowNode,M,null),ws(M),Ps(M),M.content instanceof o&&j(M.content);Qt(Fe.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(j){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,I=null,fe=null,Be=null;if(qo=!j,qo&&(j="<!-->"),typeof j!="string"&&!Ts(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw Xi("dirty is not a string, aborting")}else throw Xi("toString is not a function");if(!e.isSupported)return j;if(zo||Go(g),e.removed=[],typeof j=="string"&&(Ai=!1),Ai){if(j.nodeName){let Kt=Ie(j.nodeName);if(!le[Kt]||Cn[Kt])throw Xi("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof s)M=Ss("<!---->"),I=M.ownerDocument.importNode(j,!0),I.nodeType===Zi.element&&I.nodeName==="BODY"||I.nodeName==="HTML"?M=I:M.appendChild(I);else{if(!Bn&&!Un&&!Sn&&j.indexOf("<")===-1)return B&&lr?B.createHTML(j):j;if(M=Ss(j),!M)return Bn?null:lr?xe:""}M&&$o&&It(M.firstChild);let ke=xs(Ai?j:M);for(;fe=ke.nextNode();)ws(fe),Ps(fe),fe.content instanceof o&&gp(fe.content);if(Ai)return j;if(Bn){if(sr)for(Be=He.call(M.ownerDocument);M.firstChild;)Be.appendChild(M.firstChild);else Be=M;return(me.shadowroot||me.shadowrootmode)&&(Be=on.call(n,Be,!0)),Be}let Ze=Sn?M.outerHTML:M.innerHTML;return Sn&&le["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&Qe(_d,M.ownerDocument.doctype.name)&&(Ze="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
334
+ `+Ze),Un&&uo([vt,yn,$n],Kt=>{Ze=Ki(Ze,Kt," ")}),B&&lr?B.createHTML(Ze):Ze},e.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Go(j),zo=!0},e.clearConfig=function(){Gn=null,zo=!1},e.isValidAttribute=function(j,g,M){Gn||Go({});let I=Ie(j),fe=Ie(g);return Es(I,fe,M)},e.addHook=function(j,g){typeof g=="function"&&Qi(Fe[j],g)},e.removeHook=function(j,g){if(g!==void 0){let M=Cu(Fe[j],g);return M===-1?void 0:Su(Fe[j],M,1)[0]}return ld(Fe[j])},e.removeHooks=function(j){Fe[j]=[]},e.removeAllHooks=function(){Fe=hd()},e}var vd=bd();var Wt=class i{renderer;constructor(){this.renderer=new ui,this.configureRenderer()}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),r=e(t);if(n){r=r.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let o=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;r=r.replace("<a ",`<a aria-label="${this.escapeHtml(o)}" `),r=r.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>')}return r}}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return!1;if(e.startsWith("//"))return!0;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return!1}}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return H(this,null,function*(){let t=yield se.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return vd.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=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vu=i=>({"user-message-wrapper":i});function zu(i,e){if(i&1&&(l(0,"div",5)(1,"div",9),u(2),c()()),i&2){let t=h(2);p(2),Oe(" ",t.message.speaker," ")}}function $u(i,e){if(i&1&&(l(0,"time",7),u(1),c()),i&2){let t=h(2);p(),F(t.formattedTimestamp)}}function Hu(i,e){if(i&1&&(l(0,"div",8),R(1,"app-message-context-menu",10),c()),i&2){let t=h(2);p(),w("actions",t.actions)}}function Uu(i,e){if(i&1&&(C(0,zu,3,1,"div",5),R(1,"div",6),C(2,$u,2,1,"time",7),C(3,Hu,2,1,"div",8)),i&2){let t=h();S(t.shouldShowSpeaker?0:-1),p(),w("innerHTML",t.renderedContent,mt),p(),S(t.formattedTimestamp?2:-1),p(),S(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function Bu(i,e){if(i&1&&(l(0,"a",12),u(1,"view"),c()),i&2){let t=h(2);w("href",t.eventLink,En)}}function qu(i,e){if(i&1&&(l(0,"div",2),R(1,"span",11),C(2,Bu,2,1,"a",12),c()),i&2){let t=h();p(),w("innerHTML",t.renderedContent,mt),p(),S(t.eventLink?2:-1)}}function Wu(i,e){if(i&1&&(l(0,"div",3),R(1,"app-message-context-menu",10),c()),i&2){let t=h();p(),w("actions",t.actions)}}function Gu(i,e){if(i&1&&(l(0,"div",4),R(1,"app-message-context-menu",10),c()),i&2){let t=h();p(),w("actions",t.actions)}}var hi=class i{destroy$=new ce;message;canDelete=!0;isOtherUser=!1;copyRequested=new ie;deleteRequested=new ie;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=f(Rt);notificationService=f(si);preferencesService=f(we);projectState=f(_e);threadState=f(We);markdownService=f(Wt);get messageClasses(){return{[this.message.role]:!0,[this.message.type]:!0,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return H(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(z(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(z(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=f(sa);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 isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
335
+ `).length>20}get actions(){let e=[];return this.message.role==="user"&&this.canDelete&&e.push({icon:"delete",label:"Delete from here",tooltip:"Delete this message and all following messages",action:()=>this.onDelete(),destructive:!0}),e.push({icon:"content_copy",label:"Copy message",tooltip:"Copy message content to clipboard",action:()=>this.onCopy()}),e}get eventLink(){if(!this.message.eventId)return null;let e=this.projectState.getSelectedProjectId(),t=this.threadState.getSelectedThreadId();return!e||!t?null:`/api/projects/${e}/threads/${t}/messages/${encodeURIComponent(this.message.eventId)}/formatted`}renderMarkdown(){return H(this,null,function*(){try{let e=yield this.renderRichContent(this.message.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e)}catch(e){console.error("Error parsing rich content:",e);let t=this.extractTextContent();this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t)}})}renderRichContent(e){return H(this,null,function*(){let t=[];for(let n of e)if(n.type==="text"){let r=yield this.markdownService.parse(n.content);t.push(`<div class="text-part">${r}</div>`)}else if(n.type==="image"){let r=`data:${n.mimeType};base64,${n.content}`,o=n.source||"Image",a=`
336
+ <div class="image-content">
337
+ <img src="${r}"
338
+ alt="${o}"
339
+ class="message-image"
340
+ style="max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.2s ease, box-shadow 0.2s ease;"
341
+ onclick="window.open(this.src, '_blank')" />
342
+ </div>
343
+ `;t.push(a)}return t.join("")})}onCopy(){let e=this.extractTextContent();e.trim()&&navigator.clipboard.writeText(e).then(()=>{console.log("[CHAT-MESSAGE] Message copied to clipboard"),this.notificationService.success("Message copied to clipboard")}).catch(t=>{console.error("[CHAT-MESSAGE] Failed to copy message:",t),this.notificationService.error("Failed to copy message")}),this.copyRequested.emit(this.message)}onDelete(){console.log("[CHAT-MESSAGE] Delete requested for message:",this.message.id),this.deleteRequested.emit(this.message)}extractTextContent(){return this.message.content.filter(e=>e.type==="text").map(e=>e.content).join(`
344
+
345
+ `)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[Qs([sa])],decls:6,vars:8,consts:[[1,"message-wrapper",3,"ngClass"],[1,"message",3,"ngClass"],[1,"simple-content","markdown-content"],[1,"actions","assistant-top-actions"],[1,"actions","user-top-actions"],[1,"message-header"],[1,"content","markdown-content",3,"innerHTML"],[1,"message-timestamp"],[1,"actions","bottom-actions"],[1,"speaker"],[3,"actions"],[3,"innerHTML"],["target","_blank",1,"event-link",3,"href"]],template:function(t,n){t&1&&(l(0,"div",0)(1,"div",1),C(2,Uu,4,4),C(3,qu,3,2,"div",2),c(),C(4,Wu,2,1,"div",3),C(5,Gu,2,1,"div",4),c()),t&2&&(w("ngClass",br(6,Vu,n.message.role==="user")),p(),w("ngClass",n.messageClasses),p(),S(n.isSimplified?-1:2),p(),S(n.isSimplified?3:-1),p(),S(!n.isLongMessage&&n.shouldShowActions&&n.message.role==="assistant"?4:-1),p(),S(n.shouldShowActions&&n.message.role==="user"?5:-1))},dependencies:[ao,Sr],styles:[".message-wrapper[_ngcontent-%COMP%]{margin:0;display:flex;align-items:flex-start;gap:.5rem}.message-wrapper.user-message-wrapper[_ngcontent-%COMP%]{margin:.75rem 0;flex-direction:row-reverse;align-items:flex-start}.message-wrapper.user-message-wrapper[_ngcontent-%COMP%]:has(.other-user){flex-direction:row}.message[_ngcontent-%COMP%]{position:relative}.message.user[_ngcontent-%COMP%]{padding:1rem 1.25rem .5rem}.message.user[_ngcontent-%COMP%] .message-timestamp[_ngcontent-%COMP%]{display:block;text-align:right;font-size:.7rem;color:var(--color-text-secondary, #6272a4);white-space:nowrap;margin-top:.4rem;opacity:.7}.message.user[_ngcontent-%COMP%]{background:var(--color-message-user);border-radius:18px 18px 6px;border:1px solid var(--glass-border);box-shadow:none;backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);width:fit-content;max-width:75%;min-width:120px;word-wrap:break-word;transition:transform .2s ease,box-shadow .2s ease}.message.user[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 12px 40px #1f268733}.message.user.other-user[_ngcontent-%COMP%]{border-bottom-right-radius:18px;border-bottom-left-radius:6px}.message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.message.system[_ngcontent-%COMP%], .message.technical[_ngcontent-%COMP%]{padding:.5rem .75rem;background:transparent;border:none;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none;margin:0;font-family:SF Mono,Monaco,Menlo,monospace;font-size:.85rem;color:var(--color-text-secondary);max-width:none;width:auto;min-width:auto}.message.system[_ngcontent-%COMP%]:hover, .message.technical[_ngcontent-%COMP%]:hover{transform:none;box-shadow:none}.message.hidden-technical[_ngcontent-%COMP%], .message.hidden-warning[_ngcontent-%COMP%]{display:none!important}.message.error[_ngcontent-%COMP%]{padding:1rem 1.25rem;background:#ff3b301f;border-left:3px solid var(--color-error);color:var(--color-error)}.message.warning[_ngcontent-%COMP%]{padding:1rem 1.25rem;background:#ff95001f;border-left:3px solid var(--color-warning);color:var(--color-warning)}.message-header[_ngcontent-%COMP%]{margin-bottom:.5rem}.speaker[_ngcontent-%COMP%]{font-weight:600;font-size:.85rem;color:var(--color-text-secondary, #6272a4)}.content[_ngcontent-%COMP%]{line-height:1.5}.context-menu-top[_ngcontent-%COMP%]{top:.5rem;right:.5rem;z-index:10}.context-menu-bottom[_ngcontent-%COMP%]{bottom:.5rem;right:.5rem;z-index:10}.user-top-actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;padding-top:.5rem;opacity:0;transition:opacity .2s ease}.user-message-wrapper[_ngcontent-%COMP%]:hover .user-top-actions[_ngcontent-%COMP%]{opacity:1}.assistant-top-actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;padding-top:.5rem;opacity:0;transition:opacity .2s ease}.message-wrapper[_ngcontent-%COMP%]:hover .assistant-top-actions[_ngcontent-%COMP%]{opacity:1}.simple-content[_ngcontent-%COMP%]{display:flex}.simple-content[_ngcontent-%COMP%] .event-link[_ngcontent-%COMP%]{margin-left:5px;font-size:.9em;color:var(--color-link, #3498db);text-decoration:none}.simple-content[_ngcontent-%COMP%] .event-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.text-part[_ngcontent-%COMP%]{margin:4px 0}.image-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;margin:1em 0}.message-image[_ngcontent-%COMP%]{display:block;max-width:100%;height:auto;margin:8px 0;border-radius:12px;cursor:pointer;box-shadow:var(--glass-shadow);transition:transform .3s ease,box-shadow .3s ease;border:1px solid var(--glass-border)}.message-image[_ngcontent-%COMP%]:hover{transform:scale(1.02) translateY(-2px);box-shadow:0 16px 48px #00000026}@media(max-width:768px){.message-image[_ngcontent-%COMP%]{border-radius:4px;margin:6px 0}}@media(max-width:480px){.message-image[_ngcontent-%COMP%]{margin:4px 0}}"]})};var Yu=["determinateSpinner"];function Qu(i,e){if(i&1&&(ta(),l(0,"svg",11),R(1,"circle",12),c()),i&2){let t=h();Re("viewBox",t._viewBox()),p(),yt("stroke-dasharray",t._strokeCircumference(),"px")("stroke-dashoffset",t._strokeCircumference()/2,"px")("stroke-width",t._circleStrokeWidth(),"%"),Re("r",t._circleRadius())}}var Ku=new Fs("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:yd})}),yd=100,Xu=10,gi=(()=>{class i{_elementRef=f(ln);_noopAnimations;get color(){return this._color||this._defaultColor}set color(t){this._color=t}_color;_defaultColor="primary";_determinateCircle;constructor(){let t=f(Ku),n=ul(),r=this._elementRef.nativeElement;this._noopAnimations=n==="di-disabled"&&!!t&&!t._forceAnimations,this.mode=r.nodeName.toLowerCase()==="mat-spinner"?"indeterminate":"determinate",!this._noopAnimations&&n==="reduced-motion"&&r.classList.add("mat-progress-spinner-reduced-motion"),t&&(t.color&&(this.color=this._defaultColor=t.color),t.diameter&&(this.diameter=t.diameter),t.strokeWidth&&(this.strokeWidth=t.strokeWidth))}mode;get value(){return this.mode==="determinate"?this._value:0}set value(t){this._value=Math.max(0,Math.min(100,t||0))}_value=0;get diameter(){return this._diameter}set diameter(t){this._diameter=t||0}_diameter=yd;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(t){this._strokeWidth=t||0}_strokeWidth;_circleRadius(){return(this.diameter-Xu)/2}_viewBox(){let t=this._circleRadius()*2+this.strokeWidth;return`0 0 ${t} ${t}`}_strokeCircumference(){return 2*Math.PI*this._circleRadius()}_strokeDashOffset(){return this.mode==="determinate"?this._strokeCircumference()*(100-this._value)/100:null}_circleStrokeWidth(){return this.strokeWidth/this.diameter*100}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=N({type:i,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(n,r){if(n&1&&tt(Yu,5),n&2){let o;je(o=Ve())&&(r._determinateCircle=o.first)}},hostAttrs:["role","progressbar","tabindex","-1",1,"mat-mdc-progress-spinner","mdc-circular-progress"],hostVars:18,hostBindings:function(n,r){n&2&&(Re("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",r.mode==="determinate"?r.value:null)("mode",r.mode),oa("mat-"+r.color),yt("width",r.diameter,"px")("height",r.diameter,"px")("--mat-progress-spinner-size",r.diameter+"px")("--mat-progress-spinner-active-indicator-width",r.diameter+"px"),J("_mat-animation-noopable",r._noopAnimations)("mdc-circular-progress--indeterminate",r.mode==="indeterminate"))},inputs:{color:"color",mode:"mode",value:[2,"value","value",Cr],diameter:[2,"diameter","diameter",Cr],strokeWidth:[2,"strokeWidth","strokeWidth",Cr]},exportAs:["matProgressSpinner"],decls:14,vars:11,consts:[["circle",""],["determinateSpinner",""],["aria-hidden","true",1,"mdc-circular-progress__determinate-container"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__determinate-circle-graphic"],["cx","50%","cy","50%",1,"mdc-circular-progress__determinate-circle"],["aria-hidden","true",1,"mdc-circular-progress__indeterminate-container"],[1,"mdc-circular-progress__spinner-layer"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-left"],[3,"ngTemplateOutlet"],[1,"mdc-circular-progress__gap-patch"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-right"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__indeterminate-circle-graphic"],["cx","50%","cy","50%"]],template:function(n,r){if(n&1&&(cn(0,Qu,2,8,"ng-template",null,0,Zn),l(2,"div",2,1),ta(),l(4,"svg",3),R(5,"circle",4),c()(),js(),l(6,"div",5)(7,"div",6)(8,"div",7),Mn(9,8),c(),l(10,"div",9),Mn(11,8),c(),l(12,"div",10),Mn(13,8),c()()()),n&2){let o=Pn(1);p(4),Re("viewBox",r._viewBox()),p(),yt("stroke-dasharray",r._strokeCircumference(),"px")("stroke-dashoffset",r._strokeDashOffset(),"px")("stroke-width",r._circleStrokeWidth(),"%"),Re("r",r._circleRadius()),p(4),w("ngTemplateOutlet",o),p(2),w("ngTemplateOutlet",o),p(2),w("ngTemplateOutlet",o)}},dependencies:[xr],styles:[`.mat-mdc-progress-spinner{--mat-progress-spinner-animation-multiplier: 1;display:block;overflow:hidden;line-height:0;position:relative;direction:ltr;transition:opacity 250ms cubic-bezier(0.4, 0, 0.6, 1)}.mat-mdc-progress-spinner circle{stroke-width:var(--mat-progress-spinner-active-indicator-width, 4px)}.mat-mdc-progress-spinner._mat-animation-noopable,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__determinate-circle{transition:none !important}.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-circle-graphic,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__spinner-layer,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-container{animation:none !important}.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-container circle{stroke-dasharray:0 !important}@media(forced-colors: active){.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic,.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle{stroke:currentColor;stroke:CanvasText}}.mat-progress-spinner-reduced-motion{--mat-progress-spinner-animation-multiplier: 1.25}.mdc-circular-progress__determinate-container,.mdc-circular-progress__indeterminate-circle-graphic,.mdc-circular-progress__indeterminate-container,.mdc-circular-progress__spinner-layer{position:absolute;width:100%;height:100%}.mdc-circular-progress__determinate-container{transform:rotate(-90deg)}.mdc-circular-progress--indeterminate .mdc-circular-progress__determinate-container{opacity:0}.mdc-circular-progress__indeterminate-container{font-size:0;letter-spacing:0;white-space:nowrap;opacity:0}.mdc-circular-progress--indeterminate .mdc-circular-progress__indeterminate-container{opacity:1;animation:mdc-circular-progress-container-rotate calc(1568.2352941176ms*var(--mat-progress-spinner-animation-multiplier)) linear infinite}.mdc-circular-progress__determinate-circle-graphic,.mdc-circular-progress__indeterminate-circle-graphic{fill:rgba(0,0,0,0)}.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle,.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:var(--mat-progress-spinner-active-indicator-color, var(--mat-sys-primary))}@media(forced-colors: active){.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle,.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:CanvasText}}.mdc-circular-progress__determinate-circle{transition:stroke-dashoffset 500ms cubic-bezier(0, 0, 0.2, 1)}.mdc-circular-progress__gap-patch{position:absolute;top:0;left:47.5%;box-sizing:border-box;width:5%;height:100%;overflow:hidden}.mdc-circular-progress__gap-patch .mdc-circular-progress__indeterminate-circle-graphic{left:-900%;width:2000%;transform:rotate(180deg)}.mdc-circular-progress__circle-clipper .mdc-circular-progress__indeterminate-circle-graphic{width:200%}.mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{left:-100%}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-left .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-left-spin calc(1333ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-right-spin calc(1333ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress__circle-clipper{display:inline-flex;position:relative;width:50%;height:100%;overflow:hidden}.mdc-circular-progress--indeterminate .mdc-circular-progress__spinner-layer{animation:mdc-circular-progress-spinner-layer-rotate calc(5332ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}@keyframes mdc-circular-progress-container-rotate{to{transform:rotate(360deg)}}@keyframes mdc-circular-progress-spinner-layer-rotate{12.5%{transform:rotate(135deg)}25%{transform:rotate(270deg)}37.5%{transform:rotate(405deg)}50%{transform:rotate(540deg)}62.5%{transform:rotate(675deg)}75%{transform:rotate(810deg)}87.5%{transform:rotate(945deg)}100%{transform:rotate(1080deg)}}@keyframes mdc-circular-progress-left-spin{from{transform:rotate(265deg)}50%{transform:rotate(130deg)}to{transform:rotate(265deg)}}@keyframes mdc-circular-progress-right-spin{from{transform:rotate(-265deg)}50%{transform:rotate(-130deg)}to{transform:rotate(-265deg)}}
346
+ `],encapsulation:2,changeDetection:0})}return i})();var fi=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Jt({type:i});static \u0275inj=Xt({imports:[mn]})}return i})();var Ju=(i,e)=>e.id;function Zu(i,e){if(i&1&&(l(0,"span",4),u(1),c()),i&2){let t=h();p(),F(t.taskSummary)}}function eh(i,e){i&1&&(l(0,"div",6),R(1,"mat-spinner",8),l(2,"span"),u(3,"Loading..."),c()()),i&2&&(p(),w("diameter",16))}function th(i,e){if(i&1&&R(0,"app-delegation-inline",9),i&2){let t=h().$implicit;w("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function nh(i,e){if(i&1&&R(0,"app-chat-message",10),i&2){let t=h().$implicit;w("message",t)("canDelete",!1)}}function ih(i,e){if(i&1&&C(0,th,1,2,"app-delegation-inline",9)(1,nh,1,2,"app-chat-message",10),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function rh(i,e){if(i&1&&(l(0,"div",7)(1,"div",11),u(2),c()()),i&2){let t=h(2);p(2),F(t.streamingText)}}function oh(i,e){if(i&1&&(l(0,"div",5),C(1,eh,4,1,"div",6),Ce(2,ih,2,1,null,null,Ju),C(4,rh,3,1,"div",7),c()),i&2){let t=h();p(),S(t.isLoading&&t.subMessages.length===0?1:-1),p(),Se(t.subMessages),p(2),S(t.streamingText?4:-1)}}var fo=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=f(pt);threadApi=f(Ht);get taskSummary(){let e=this.subMessages.find(t=>t.role==="user");if(e){let t=e.content.filter(n=>n.type==="text").map(n=>n.content).join(" ");return t.length>120?t.substring(0,120)+"...":t}return""}ngOnInit(){for(let e of this.codayService.getBufferedSubThreadEvents(this.subThreadId))this.handleSubThreadEvent(e);this.eventSubscription=this.codayService.subThreadEvents$.pipe(De(e=>e.threadId===this.subThreadId)).subscribe(e=>this.handleSubThreadEvent(e))}ngOnDestroy(){this.eventSubscription?.unsubscribe()}toggle(){this.isExpanded=!this.isExpanded,this.isExpanded&&!this.restLoaded&&this.loadSubThreadMessages()}loadSubThreadMessages(){this.isLoading=!0,this.threadApi.getThreadMessages(this.subThreadId).subscribe({next:e=>{if(e.messages){for(let t of e.messages){let n=Ui(t);n&&this.handleSubThreadEvent(n)}this.subMessages=[...this.subMessages].sort((t,n)=>t.id.localeCompare(n.id))}this.restLoaded=!0,this.isLoading=!1},error:e=>{console.error("[DELEGATION-INLINE] Failed to load sub-thread messages:",e),this.restLoaded=!0,this.isLoading=!1}})}handleSubThreadEvent(e){e instanceof dt?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof gn?this.streamingText+=e.chunk:e instanceof Et?(e.role==="assistant"&&(this.streamingText=""),this.addMessage({id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:new Date,type:"text"})):e instanceof wt?this.addMessage({id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:e.timestamp}):e instanceof _t?this.addMessage({id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:e.timestamp}):e instanceof zt?this.addMessage({id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName}):e instanceof Vt&&this.addMessage({id:e.timestamp,role:"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:new Date,type:"technical"})}addMessage(e){this.messageIds.has(e.id)||(this.messageIds.add(e.id),this.subMessages=[...this.subMessages,e])}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-delegation-inline"]],inputs:{subThreadId:"subThreadId",agentName:"agentName"},decls:8,vars:4,consts:[[1,"delegation-inline"],["role","button","tabindex","0",1,"delegation-header",3,"click","keydown.enter","keydown.space"],[1,"expand-icon"],[1,"agent-name"],[1,"task-summary"],[1,"delegation-body"],[1,"loading"],[1,"streaming-message"],[3,"diameter"],[3,"subThreadId","agentName"],[3,"message","canDelete"],[1,"content"]],template:function(t,n){t&1&&(l(0,"div",0)(1,"div",1),v("click",function(){return n.toggle()})("keydown.enter",function(){return n.toggle()})("keydown.space",function(){return n.toggle()}),l(2,"mat-icon",2),u(3),c(),l(4,"span",3),u(5),c(),C(6,Zu,2,1,"span",4),c(),C(7,oh,5,2,"div",5),c()),t&2&&(p(3),F(n.isExpanded?"expand_more":"chevron_right"),p(2),F(n.agentName),p(),S(n.taskSummary?6:-1),p(),S(n.isExpanded?7:-1))},dependencies:[i,nt,Te,ae,fi,gi,hi],styles:[".delegation-inline[_ngcontent-%COMP%]{margin:.5rem 0;border-left:3px solid var(--color-primary, #6366f1);border-radius:4px;background:var(--color-bg-secondary);overflow:hidden}.delegation-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;cursor:pointer;-webkit-user-select:none;user-select:none}.delegation-header[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.delegation-header[_ngcontent-%COMP%] .expand-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-text-secondary, #94a3b8)}.delegation-header[_ngcontent-%COMP%] .agent-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-primary, #6366f1);white-space:nowrap}.delegation-header[_ngcontent-%COMP%] .task-summary[_ngcontent-%COMP%]{flex:1;color:var(--color-text-secondary, #94a3b8);font-size:.85rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.delegation-body[_ngcontent-%COMP%]{padding:0 .75rem .75rem 1.5rem;border-top:1px solid var(--color-border-light)}.delegation-body[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem 0;color:var(--color-text-secondary, #94a3b8);font-size:.85rem}.delegation-body[_ngcontent-%COMP%] .sub-messages[_ngcontent-%COMP%]{padding:.5rem 0}"]})};var _i=class i{unreadCountSubject=new q(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=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var bi=class i{destroy$=new ce;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new q(!1);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=f(we);constructor(){this.initializeSpeechSynthesis(),this.subscribeToPreferences()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.stopSpeech()}initializeSpeechSynthesis(){if(!("speechSynthesis"in window)){console.warn("[VOICE-SERVICE] Speech synthesis not available"),this.voices=new Promise(e=>e([]));return}this.voices=new Promise((e,t)=>{let n=speechSynthesis.getVoices();if(n.length)e(n);else{let r=setTimeout(()=>{t("no voices found")},2e3);speechSynthesis.addEventListener("voiceschanged",()=>{let o=speechSynthesis.getVoices();o.length&&(clearTimeout(r),e(o))})}}),console.log("[VOICE-SERVICE] Speech synthesis initialized")}subscribeToPreferences(){this.preferencesService.voiceVolume$.pipe(z(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e)}),this.preferencesService.voiceRate$.pipe(z(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e)}),this.preferencesService.voiceLanguage$.pipe(z(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage()}),this.preferencesService.selectedVoice$.pipe(z(this.destroy$)).subscribe(e=>{this.setSelectedVoice(e)}),this.volume=this.preferencesService.getVoiceVolume(),this.rate=this.preferencesService.getVoiceRate(),this.language=this.preferencesService.getVoiceLanguage(),this.setSelectedVoice(this.preferencesService.getSelectedVoice())}isReady(){return"speechSynthesis"in window&&this.selectedVoice!==void 0}isSpeaking(){return speechSynthesis.speaking}speak(e,t){return H(this,null,function*(){if(!this.selectedVoice)return console.warn("[VOICE-SERVICE] No voice selected"),!1;if(!e.trim())return console.warn("[VOICE-SERVICE] No text to speak"),!1;let n=this.extractPlainText(e);if(!n.trim())return console.warn("[VOICE-SERVICE] No text to speak after markdown cleaning"),!1;this.stopSpeech();try{let r=new SpeechSynthesisUtterance(n);r.voice=this.selectedVoice,r.lang=this.selectedVoice.lang,r.volume=this.volume,r.rate=this.rate,this.currentOnEndCallback=t||null,t&&(r.onend=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t())},r.onerror=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t())}),this.currentUtterance=r,this.speakingSubject.next(!0);let o=r.onend,a=r.onerror;return r.onend=s=>{this.speakingSubject.next(!1),o&&o.call(r,s)},r.onerror=s=>{this.speakingSubject.next(!1),a&&a.call(r,s)},speechSynthesis.speak(r),console.log("[VOICE-SERVICE] Started speaking:",e.substring(0,50)+"..."),!0}catch(r){return console.error("[VOICE-SERVICE] Error speaking:",r),!1}})}stopSpeech(){if(this.currentUtterance||speechSynthesis.speaking){if(speechSynthesis.cancel(),this.currentUtterance=null,this.currentOnEndCallback){let e=this.currentOnEndCallback;this.currentOnEndCallback=null,e()}this.speakingSubject.next(!1),console.log("[VOICE-SERVICE] Speech stopped")}}ding(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(800,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),t.start(e.currentTime),t.stop(e.currentTime+.1),console.log("[VOICE-SERVICE] Notification sound played")}catch(e){console.error("[VOICE-SERVICE] Notification sound failed:",e)}}getVoicesForLanguage(){return H(this,null,function*(){try{let e=this.language.slice(0,2),t=yield this.voices;if(!t||t.length===0)return console.warn("[VOICE-SERVICE] No voices available on system"),[];let n=t.filter(r=>r.lang.toLowerCase().startsWith(e)).sort((r,o)=>r.localService&&!o.localService?-1:!r.localService&&o.localService?1:r.name.localeCompare(o.name));return console.log("[VOICE-SERVICE] Found matching voices:",n.length,"for language:",e),n.map(r=>({name:r.name,lang:r.lang,localService:r.localService,default:r.default,displayName:this.formatVoiceDisplayName(r)}))}catch(e){return console.error("[VOICE-SERVICE] Error getting voices for language:",e),[]}})}formatVoiceDisplayName(e){let t=e.localService?"\u{1F3E0}":"\u2601\uFE0F",n=e.default?" \u2B50":"";return`${t} ${e.name} (${e.lang})${n}`}setSelectedVoice(e){return H(this,null,function*(){if(!e){this.selectedVoice=void 0;return}let[t,n]=e.split("|");if(!t||!n){this.selectedVoice=void 0;return}let r=(yield this.voices)?.find(o=>o.name===t&&o.lang===n);r?(this.selectedVoice=r,console.log("[VOICE-SERVICE] Selected voice:",r.name,r.lang)):(this.selectedVoice=void 0,console.warn("[VOICE-SERVICE] Voice not found:",t,n))})}updateSelectedVoiceForLanguage(){return H(this,null,function*(){let e=yield this.getVoicesForLanguage();if(e.length===0){console.warn("[VOICE-SERVICE] No voices available for language:",this.language),this.selectedVoice=void 0,this.preferencesService.setSelectedVoice(null);return}let t=this.preferencesService.getSelectedVoice();if(t){let[r,o]=t.split("|"),a=o?.slice(0,2),s=this.language.slice(0,2);if(a===s&&e.some(m=>m.name===r&&m.lang===o)){console.log("[VOICE-SERVICE] Keeping current voice for language:",t);return}}let n=e[0];if(n){let r=`${n.name}|${n.lang}`;this.preferencesService.setSelectedVoice(r),console.log("[VOICE-SERVICE] Auto-selected voice for language change:",n.displayName)}})}testSelectedVoice(){setTimeout(()=>{if(!this.selectedVoice){console.log("[VOICE-SERVICE] No voice selected for test");return}this.stopSpeech();let e=this.getTestText();e&&this.speak(e)},100)}getTestText(){let e=this.language.slice(0,2),t={fr:"Bonjour, ceci est un test de la voix s\xE9lectionn\xE9e.",en:"Hello, this is a test of the selected voice.",es:"Hola, esta es una prueba de la voz seleccionada.",de:"Hallo, dies ist ein Test der ausgew\xE4hlten Stimme.",it:"Ciao, questo \xE8 un test della voce selezionata.",pt:"Ol\xE1, este \xE9 um teste da voz selecionada.",ja:"\u3053\u3093\u306B\u3061\u306F\u3001\u3053\u308C\u306F\u9078\u629E\u3055\u308C\u305F\u97F3\u58F0\u306E\u30C6\u30B9\u30C8\u3067\u3059\u3002",ko:"\uC548\uB155\uD558\uC138\uC694, \uC774\uAC83\uC740 \uC120\uD0DD\uB41C \uC74C\uC131\uC758 \uD14C\uC2A4\uD2B8\uC785\uB2C8\uB2E4.",zh:"\u4F60\u597D\uFF0C\u8FD9\u662F\u6240\u9009\u8BED\u97F3\u7684\u6D4B\u8BD5\u3002",ru:"\u041F\u0440\u0438\u0432\u0435\u0442, \u044D\u0442\u043E \u0442\u0435\u0441\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430.",ar:"\u0645\u0631\u062D\u0628\u0627\u060C \u0647\u0630\u0627 \u0627\u062E\u062A\u0628\u0627\u0631 \u0644\u0644\u0635\u0648\u062A \u0627\u0644\u0645\u062D\u062F\u062F."};return t[e]||t.en||"Hello, this is a test."}extractPlainText(e){let t=e.replace(/[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|⭐/gu,"").replace(/```[\s\S]*?```/g,"code block").replace(/`([^`]+)`/g,"$1").replace(/\*\*\*(.*?)\*\*\*/g,"$1").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/#{1,6}\s*(.*)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/https?:\/\/[^\s]+/g,"link").replace(/&nbsp;/g," ").replace(/&amp;/g,"and").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');return t=this.addNaturalPunctuation(t),t.replace(/\s+/g," ").trim()}addNaturalPunctuation(e){return e.replace(/\n+/g,`
347
+ `).split(`
348
+ `).map(t=>this.addPeriodIfNeeded(t.trim())).filter(t=>t.length>0).join(" ")}addPeriodIfNeeded(e){return e?/[.!?;:]$/.test(e)?e:e+".":""}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var _o=class i{thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;ngOnInit(){this.startThinkingAnimation()}ngOnDestroy(){this.stopThinkingAnimation()}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..."}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-thinking-loader"]],decls:8,vars:1,consts:[[1,"message-wrapper"],[1,"message","assistant","thinking-message"],[1,"content"],[1,"thinking-loader"],[1,"logo-container"],["src","CODAY-Logo.png","alt","Coday Logo",1,"coday-logo"],[1,"thinking-text"]],template:function(t,n){t&1&&(dn(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),ra(5,"img",5),pn(),dn(6,"p",6),u(7),pn()()()()()),t&2&&(p(7),F(n.currentThinkingPhrase))},dependencies:[nt],styles:[".message-wrapper[_ngcontent-%COMP%]{margin:0;display:flex;align-items:flex-start;gap:.5rem}.message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.message.thinking-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{line-height:1.5}.thinking-loader[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:.75rem 0}.logo-container[_ngcontent-%COMP%]{position:relative;width:32px;height:32px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.coday-logo[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:contain;animation:_ngcontent-%COMP%_pulse 2s ease-in-out infinite;filter:drop-shadow(0 1px 4px rgba(0,0,0,.1))}.thinking-text[_ngcontent-%COMP%]{font-size:.95rem;font-weight:400;color:var(--color-text-secondary);margin:0;animation:_ngcontent-%COMP%_fadeInOut 2s ease-in-out infinite;letter-spacing:.01em;font-style:italic}@keyframes _ngcontent-%COMP%_pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.1);opacity:.7}}@keyframes _ngcontent-%COMP%_fadeInOut{0%,to{opacity:.6}50%{opacity:1}}@media(max-width:768px){.logo-container[_ngcontent-%COMP%]{width:28px;height:28px}.thinking-text[_ngcontent-%COMP%]{font-size:.875rem}.thinking-loader[_ngcontent-%COMP%]{gap:.75rem}}@media print{.thinking-loader[_ngcontent-%COMP%]{display:none!important}}"]})};var ah=(i,e)=>e.id;function sh(i,e){if(i&1&&R(0,"app-delegation-inline",3),i&2){let t=h().$implicit;w("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function lh(i,e){if(i&1){let t=O();l(0,"app-chat-message",5),v("copyRequested",function(r){x(t);let o=h(2);return T(o.onCopyMessage(r))})("deleteRequested",function(r){x(t);let o=h(2);return T(o.onDeleteMessage(r))}),c()}if(i&2){let t=h(),n=t.$implicit,r=t.$index,o=h();w("message",n)("canDelete",o.canDeleteMessage(r))("isOtherUser",n.role==="user"&&!!o.currentUsername&&n.speaker!==o.currentUsername)}}function ch(i,e){if(i&1&&C(0,sh,1,2,"app-delegation-inline",3)(1,lh,1,3,"app-chat-message",4),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function dh(i,e){if(i&1&&(l(0,"div",1),R(1,"div",6),c()),i&2){let t=h();p(),w("innerHTML",t.renderedStreamingText,mt)}}function ph(i,e){i&1&&R(0,"app-thinking-loader")}function mh(i,e){if(i&1){let t=O();l(0,"button",7),v("click",function(){x(t);let r=h();return T(r.goToBottom())}),l(1,"mat-icon",8),u(2,"arrow_downward"),c()()}}var bo=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new ie;stopRequested=new ie;lastMessageCount=0;destroy$=new ce;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=f(ln);unreadService=f(_i);voiceSynthesisService=f(bi);preferencesService=f(we);codayService=f(pt);markdownService=f(Wt);sanitizer=f(Rt);ngOnInit(){this.findScrollContainer(),this.setupFocusListeners()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.scrollCheckTimeout&&clearTimeout(this.scrollCheckTimeout),window.removeEventListener("focus",this.handleWindowFocus),window.removeEventListener("blur",this.handleWindowBlur)}ngOnChanges(e){e.streamingText&&(this.renderStreamingText(),this.streamingText&&this.isTracking&&setTimeout(()=>this.scrollToBottom(),0))}ngAfterViewChecked(){if(this.messages.length!==this.lastMessageCount){console.log("[CHAT-HISTORY] Message count changed:",this.lastMessageCount,"->",this.messages.length);let e=this.messages.length-this.lastMessageCount;e>0&&(this.handleNewMessages(e),this.handleVoiceAnnouncement(e)),this.lastMessageCount=this.messages.length,this.isTracking&&this.scrollToBottom()}this.scrollContainer||this.findScrollContainer()}scrollToBottom(){try{this.scrollContainer||this.findScrollContainer(),this.scrollContainer&&(this.isProgrammaticScroll=!0,setTimeout(()=>{this.scrollContainer&&this.scrollContainer.scrollTo({top:this.scrollContainer.scrollHeight,behavior:"smooth"}),setTimeout(()=>{this.isProgrammaticScroll=!1},600)},50))}catch(e){console.error("Error scrolling to bottom:",e)}}trackByMessageId(e,t){return t.id}onCopyMessage(e){let t=e.content.filter(n=>n.type==="text").map(n=>n.content).join(`
349
+
350
+ `);navigator.clipboard.writeText(t).then(()=>console.log("Message copied")).catch(n=>console.error("Failed to copy:",n)),this.copyRequested.emit(e)}onStop(){this.stopRequested.emit()}canDeleteMessage(e){return e===0?!1:!this.isThinking}onDeleteMessage(e){if(console.log("[CHAT-HISTORY] Delete requested for message:",e.id),this.messages.findIndex(r=>r.id===e.id)===0){console.warn("[CHAT-HISTORY] Cannot delete first message");return}if(this.isThinking){console.warn("[CHAT-HISTORY] Cannot delete message while agent is thinking");return}if(e.role!=="user"){console.warn("[CHAT-HISTORY] Can only delete user messages");return}confirm(`Delete this message and all following messages?
351
+
352
+ This action cannot be undone once you post another message.`)&&(console.log("[CHAT-HISTORY] Proceeding with message deletion"),this.codayService.deleteMessage(e.id).subscribe({next:r=>{r.success?console.log("[CHAT-HISTORY] Message deleted successfully"):(console.error("[CHAT-HISTORY] Failed to delete message:",r.error),alert(`Failed to delete message: ${r.error}`))},error:r=>{console.error("[CHAT-HISTORY] Error deleting message:",r),alert(`Error deleting message: ${r.message||"Unknown error"}`)}}))}onScroll(){}findScrollContainer(){let e=this.elementRef.nativeElement;this.scrollContainer=e.closest(".chat-wrapper"),this.scrollContainer?(console.log("[CHAT-HISTORY] Scroll container found"),this.scrollContainer.addEventListener("scroll",this.handleScroll.bind(this)),this.lastScrollTop=this.scrollContainer.scrollTop,this.checkScrollPosition()):(console.warn("[CHAT-HISTORY] Scroll container not found"),setTimeout(()=>this.findScrollContainer(),100))}handleScroll=()=>{if(!this.scrollContainer)return;let e=this.scrollContainer.scrollTop;if(Math.abs(e-this.lastScrollTop)<1){this.lastScrollTop=e;return}if(this.isProgrammaticScroll){this.lastScrollTop=e;return}console.log("[CHAT-HISTORY] User scroll detected - disabling auto-scroll"),this.isTracking&&(this.isTracking=!1,this.showGoToBottom=!0),clearTimeout(this.scrollCheckTimeout),this.scrollCheckTimeout=setTimeout(()=>{this.checkScrollPosition()},500),this.lastScrollTop=e};checkScrollPosition(){if(!this.scrollContainer)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=this.scrollContainer,o=t-e-n<=this.NEAR_BOTTOM_THRESHOLD;o&&!this.isTracking&&(console.log("[CHAT-HISTORY] Near bottom - re-enabling auto-scroll"),this.isTracking=!0,this.showGoToBottom=!1,this.unreadService.markAllAsRead()),!this.isTracking&&!o&&(this.showGoToBottom=!0)}goToBottom(){console.log("[CHAT-HISTORY] Go to bottom clicked - re-enabling auto-scroll"),this.scrollToBottom(),this.isTracking=!0,this.showGoToBottom=!1,this.unreadService.markAllAsRead()}handleNewMessages(e){let n=this.messages.slice(-e).filter(o=>o.role==="assistant");if(n.length===0){console.log("[CHAT-HISTORY] No new assistant messages to count");return}if(this.shouldMarkNewMessagesAsUnread()){console.log("[CHAT-HISTORY] Marking",n.length,"new assistant messages as unread");for(let o=0;o<n.length;o++)this.unreadService.addUnread()}else console.log("[CHAT-HISTORY] New assistant messages are considered read (user is focused and tracking)")}shouldMarkNewMessagesAsUnread(){return document.hasFocus()?this.isTracking?!1:(console.log("[CHAT-HISTORY] User is not tracking (scrolled up) -> unread"),!0):(console.log("[CHAT-HISTORY] Tab does not have focus -> unread"),!0)}setupFocusListeners(){window.addEventListener("focus",this.handleWindowFocus),window.addEventListener("blur",this.handleWindowBlur)}handleWindowFocus=()=>{console.log("[CHAT-HISTORY] Window gained focus"),this.isTracking&&(console.log("[CHAT-HISTORY] User is tracking and focused -> marking messages as read"),this.unreadService.markAllAsRead())};handleWindowBlur=()=>{console.log("[CHAT-HISTORY] Window lost focus")};handleVoiceAnnouncement(e){if(!this.preferencesService.getVoiceAnnounceEnabled())return;let r=this.messages.slice(-e).filter(s=>s.role==="assistant");if(r.length===0){console.log("[CHAT-HISTORY] No new assistant messages to announce");return}let o=r[r.length-1];if(!o){console.warn("[CHAT-HISTORY] No last assistant message found");return}if(!this.isMessageRecentEnoughForAnnouncement(o)){console.log("[CHAT-HISTORY] Message too old for voice announcement");return}if(this.preferencesService.getVoiceMode()==="notification")console.log("[CHAT-HISTORY] Playing notification sound for new assistant message"),this.voiceSynthesisService.ding();else{let s=this.extractTextContentFromMessage(o);if(s.trim()){console.log("[CHAT-HISTORY] Announcing new assistant message via speech");let m=this.preferencesService.getVoiceReadFullText()?s:this.extractPartialText(s);this.voiceSynthesisService.speak(m).then(_=>{_||console.warn("[CHAT-HISTORY] Failed to announce message via speech")}).catch(_=>{console.error("[CHAT-HISTORY] Error during voice announcement:",_)})}}}isMessageRecentEnoughForAnnouncement(e){try{let t=e.timestamp.getTime();return Date.now()-t<=this.MESSAGE_FRESHNESS_THRESHOLD}catch(t){return console.warn("[CHAT-HISTORY] Error checking message freshness:",t),!0}}extractTextContentFromMessage(e){return e.content.filter(t=>t.type==="text").map(t=>t.content).join(`
353
+
354
+ `)}extractPartialText(e){return e.split(`
355
+ `).filter(a=>a.trim().length>0).reduce((a,s)=>{if(a.paragraphs>=3)return a;let d=s.length>80?1:0;return{paragraphs:a.paragraphs+d,text:a.text+(a.text?`
356
+ `:"")+s}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return H(this,null,function*(){if(!this.streamingText){this.renderedStreamingText="";return}try{let e=yield this.markdownService.parse(this.streamingText);this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(e)}catch(e){console.error("[CHAT-HISTORY] Error rendering streaming text markdown:",e),this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(this.streamingText)}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&v("scroll",function(){return n.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Dt],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn"],[3,"subThreadId","agentName"],[3,"message","canDelete","isOtherUser"],[3,"copyRequested","deleteRequested","message","canDelete","isOtherUser"],[1,"content","markdown-content",3,"innerHTML"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn",3,"click"],["fontSet","material-icons-outlined"]],template:function(t,n){t&1&&(l(0,"div",0),Ce(1,ch,2,1,null,null,ah),C(3,dh,2,1,"div",1),C(4,ph,1,0,"app-thinking-loader"),C(5,mh,3,0,"button",2),c()),t&2&&(p(),Se(n.messages),p(2),S(n.streamingText?3:-1),p(),S(n.isThinking?4:-1),p(),S(n.showGoToBottom?5:-1))},dependencies:[hi,ae,_o,wr,fo],styles:[".streaming-message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.streaming-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{color:var(--color-text);line-height:1.5}.go-to-bottom-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:30%!important;right:1rem!important;z-index:1000!important}@media(max-width:768px){.go-to-bottom-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;right:.75rem!important}.go-to-bottom-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.chat-history[_ngcontent-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.go-to-bottom-btn[_ngcontent-%COMP%]{display:none!important}}"]})};var uh=["buttonContainer"],hh=["freeTextInput"],gh=(i,e)=>e.value;function fh(i,e){i&1&&(l(0,"mat-icon",10),u(1,"keyboard_return"),c())}function _h(i,e){if(i&1){let t=O();l(0,"button",8),v("click",function(){let r=x(t).$implicit,o=h(2);return T(o.onOptionClick(r.value))}),l(1,"span",9),u(2),c(),C(3,fh,2,0,"mat-icon",10),c()}if(i&2){let t=e.$implicit,n=e.$index,r=h(2);J("highlighted",n===r.highlightedIndex),w("disabled",t.disabled)("id","choice-option-"+n),Re("aria-selected",n===r.highlightedIndex),p(2),F(t.label),p(),S(n===r.highlightedIndex?3:-1)}}function bh(i,e){if(i&1){let t=O();l(0,"div",6)(1,"span",11),u(2,"Or type your own answer:"),c(),l(3,"div",12)(4,"input",13,1),te("ngModelChange",function(r){x(t);let o=h(2);return ee(o.freeTextValue,r)||(o.freeTextValue=r),T(r)}),v("keydown",function(r){x(t);let o=h(2);return T(o.onFreeTextKeyDown(r))}),c(),l(6,"button",14),v("click",function(){x(t);let r=h(2);return T(r.onFreeTextSubmit())}),l(7,"mat-icon"),u(8,"send"),c()()()()}if(i&2){let t=h(2);p(4),Z("ngModel",t.freeTextValue),p(2),w("disabled",!t.freeTextValue.trim())}}function vh(i,e){if(i&1&&(l(0,"div",7)(1,"mat-icon"),u(2,"search"),c(),l(3,"span"),u(4),c()()),i&2){let t=h(2);p(4),F(t.searchText)}}function yh(i,e){if(i&1){let t=O();l(0,"div",2),R(1,"div",3),Ri(2,"async"),l(3,"div",4,0),v("keydown",function(r){x(t);let o=h();return T(o.onKeyDown(r))}),Ce(5,_h,4,7,"button",5,gh),c(),C(7,bh,9,2,"div",6),C(8,vh,5,1,"div",7),c()}if(i&2){let t=h();p(),w("innerHTML",Xs(2,4,t.renderedLabel$),mt),p(2),Re("aria-activedescendant","choice-option-"+t.highlightedIndex),p(2),Se(t.options),p(2),S(t.allowFreeText?7:-1),p(),S(t.searchText?8:-1)}}var vo=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new ie;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new ce;renderedLabelSubject=new q("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=f(Rt);markdownService=f(Wt);ngOnDestroy(){this.renderedLabelSubject.complete(),this.destroy$.next(),this.destroy$.complete(),this.searchTimeout&&clearTimeout(this.searchTimeout)}ngAfterViewInit(){this.isVisible&&this.buttonContainer&&setTimeout(()=>this.focusContainer(),100)}ngOnChanges(e){e.isVisible&&e.isVisible.currentValue&&!e.isVisible.previousValue&&(this.highlightedIndex=0,setTimeout(()=>this.focusContainer(),150)),e.options&&!e.options.firstChange&&(this.highlightedIndex=0,this.searchText="",this.freeTextValue="")}focusContainer(){this.buttonContainer?.nativeElement&&this.buttonContainer.nativeElement.focus()}onKeyDown(e){if(this.options.filter(n=>!n.disabled).length!==0)switch(e.key){case"ArrowDown":e.preventDefault(),this.moveHighlight(1);break;case"ArrowUp":e.preventDefault(),this.moveHighlight(-1);break;case"Enter":case" ":e.preventDefault(),this.selectHighlighted();break;case"Home":e.preventDefault(),this.highlightFirst();break;case"End":e.preventDefault(),this.highlightLast();break;case"Escape":e.preventDefault();break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.handleTypeAhead(e.key);break}}moveHighlight(e){let t=this.options.map((o,a)=>({opt:o,idx:a})).filter(({opt:o})=>!o.disabled).map(({idx:o})=>o);if(t.length===0)return;let r=t.findIndex(o=>o===this.highlightedIndex)+e;if(r>=0&&r<t.length){let o=t[r];o!==void 0&&(this.highlightedIndex=o,this.scrollToHighlighted())}else if(e===1&&r>=t.length){let o=t[0];o!==void 0&&(this.highlightedIndex=o,this.scrollToHighlighted())}else if(e===-1&&r<0){let o=t[t.length-1];o!==void 0&&(this.highlightedIndex=o,this.scrollToHighlighted())}}highlightFirst(){let e=this.options.findIndex(t=>!t.disabled);e>=0&&(this.highlightedIndex=e,this.scrollToHighlighted())}highlightLast(){let e=this.options.map((t,n)=>({opt:t,idx:n})).filter(({opt:t})=>!t.disabled).map(({idx:t})=>t);if(e.length>0){let t=e[e.length-1];t!==void 0&&(this.highlightedIndex=t,this.scrollToHighlighted())}}scrollToHighlighted(){setTimeout(()=>{let e=document.getElementById("choice-option-"+this.highlightedIndex);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}selectHighlighted(){let e=this.options[this.highlightedIndex];e&&!e.disabled&&this.onOptionClick(e.value)}handleTypeAhead(e){this.searchText+=e.toLowerCase();let t=this.options.findIndex(n=>!n.disabled&&n.label.toLowerCase().startsWith(this.searchText));t>=0&&(this.highlightedIndex=t,this.scrollToHighlighted()),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchText=""},1e3)}onOptionClick(e){this.choiceSelected.emit(e)}onFreeTextSubmit(){let e=this.freeTextValue.trim();e&&(this.freeTextValue="",this.choiceSelected.emit(e))}onFreeTextKeyDown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.onFreeTextSubmit())}renderLabelMarkdown(e){return H(this,null,function*(){if(!e){this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(""));return}try{let t=yield this.markdownService.parse(e);this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(t))}catch(t){console.error("[CHOICE-SELECT] Error parsing label markdown:",t),this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(e))}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&tt(uh,5)(hh,5),t&2){let r;je(r=Ve())&&(n.buttonContainer=r.first),je(r=Ve())&&(n.freeTextInput=r.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Dt],decls:1,vars:1,consts:[["buttonContainer",""],["freeTextInput",""],[1,"choice-container"],[1,"choice-label",3,"innerHTML"],["role","listbox","tabindex","0",1,"choice-buttons",3,"keydown"],["type","button","role","option",1,"choice-button",3,"highlighted","disabled","id"],[1,"free-text-section"],[1,"search-indicator"],["type","button","role","option",1,"choice-button",3,"click","disabled","id"],[1,"choice-button-label"],[1,"choice-button-icon"],[1,"free-text-hint"],[1,"free-text-input-row"],["type","text","placeholder","Type a custom answer\u2026","aria-label","Custom answer",1,"free-text-input",3,"ngModelChange","keydown","ngModel"],["type","button","aria-label","Send custom answer",1,"free-text-send-btn",3,"click","disabled"]],template:function(t,n){t&1&&C(0,yh,9,6,"div",2),t&2&&S(n.isVisible?0:-1)},dependencies:[Te,ae,st,ht,ot,at,Zs],styles:[".choice-container[_ngcontent-%COMP%]{width:100%;display:flex;flex-direction:column;gap:1rem}.choice-label[_ngcontent-%COMP%]{display:block;font-weight:500;color:var(--color-text);font-size:1rem;line-height:1.5}.choice-label[_ngcontent-%COMP%] p{margin:0 0 .5rem}.choice-label[_ngcontent-%COMP%] p:last-child{margin-bottom:0}.choice-label[_ngcontent-%COMP%] code{background:var(--color-code-bg);padding:.2em .4em;border-radius:4px;font-family:monospace;font-size:.9em}.choice-label[_ngcontent-%COMP%] strong{font-weight:600}.choice-buttons[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-height:400px;overflow-y:auto;padding:.5rem;background:var(--color-background);border:2px solid var(--color-border);border-radius:12px;outline:none}.choice-buttons[_ngcontent-%COMP%]:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:var(--color-background);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.choice-button[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;width:100%;padding:.75rem 1rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;text-align:left;cursor:pointer;transition:all .2s ease}.choice-button[_ngcontent-%COMP%]:hover:not(:disabled):not(.highlighted){background:var(--color-bg-hover);border-color:var(--color-primary);transform:translate(2px)}.choice-button.highlighted[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary);box-shadow:0 2px 8px #007aff4d}.choice-button.highlighted[_ngcontent-%COMP%] .choice-button-icon[_ngcontent-%COMP%]{color:#fff}.choice-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.choice-button[_ngcontent-%COMP%]:focus{outline:none}.choice-button-label[_ngcontent-%COMP%]{flex:1;line-height:1.5}.choice-button-icon[_ngcontent-%COMP%]{flex-shrink:0;margin-left:.5rem;font-size:1.2rem;width:1.2rem;height:1.2rem}.free-text-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.free-text-hint[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.free-text-input-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center}.free-text-input[_ngcontent-%COMP%]{flex:1;padding:.625rem .875rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.free-text-input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.free-text-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.7}.free-text-send-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:8px;background:var(--color-primary);color:#fff;cursor:pointer;transition:background .2s ease,opacity .2s ease}.free-text-send-btn[_ngcontent-%COMP%]:hover:not(:disabled){opacity:.9}.free-text-send-btn[_ngcontent-%COMP%]:disabled{opacity:.4;cursor:not-allowed}.free-text-send-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.2rem;width:1.2rem;height:1.2rem}.search-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:var(--color-primary);color:#fff;border-radius:8px;font-size:.9rem;font-weight:500;animation:_ngcontent-%COMP%_fadeIn .2s ease}.search-indicator[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem;color:#fff}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media(max-width:480px){.choice-container[_ngcontent-%COMP%]{gap:.75rem}.choice-label[_ngcontent-%COMP%]{font-size:.95rem}.choice-buttons[_ngcontent-%COMP%]{max-height:300px;gap:.375rem}.choice-button[_ngcontent-%COMP%]{font-size:.95rem;padding:.625rem .875rem}}@media print{.choice-buttons[_ngcontent-%COMP%]{max-height:none;overflow:visible}.search-indicator[_ngcontent-%COMP%]{display:none!important}}"]})};var vi="coday_oauth_callback",yo=class i{route=f(Tr);message="Authentication in progress...";ngOnInit(){console.log("[OAuth Callback] Component initialized");let e=this.route.snapshot.queryParamMap.get("code"),t=this.route.snapshot.queryParamMap.get("state"),n=this.route.snapshot.queryParamMap.get("error"),r=this.route.snapshot.queryParamMap.get("error_description");if(console.log("[OAuth Callback] Code:",e,"State:",t,"Error:",n,"Opener:",!!window.opener),n){if(console.log("[OAuth Callback] OAuth error received:",n,r),!window.opener){console.warn("[OAuth Callback] No window.opener \u2014 using localStorage fallback for error"),localStorage.setItem(vi,JSON.stringify({error:n,state:t,errorDescription:r})),this.message="Authentication failed. You can close this window.",setTimeout(()=>window.close(),1e3);return}try{window.opener.postMessage({error:n,state:t,errorDescription:r},window.location.origin),console.log("[OAuth Callback] Error postMessage sent successfully"),setTimeout(()=>{console.log("[OAuth Callback] Closing popup after error"),window.close()},1e3)}catch(o){console.error("[OAuth Callback] Error sending error postMessage:",o),alert("OAuth error: Failed to communicate with parent window")}return}if(!e){console.error("[OAuth Callback] Missing authorization code"),this.message="OAuth callback error: Missing authorization code.";return}if(!window.opener){console.warn("[OAuth Callback] No window.opener \u2014 using localStorage fallback"),localStorage.setItem(vi,JSON.stringify({code:e,state:t})),this.message="Authentication complete. You can close this window.",setTimeout(()=>window.close(),1e3);return}try{console.log("[OAuth Callback] Sending postMessage to parent"),window.opener.postMessage({code:e,state:t},window.location.origin),console.log("[OAuth Callback] postMessage sent successfully"),setTimeout(()=>{console.log("[OAuth Callback] Closing popup"),window.close()},1e3)}catch(o){console.error("[OAuth Callback] Error sending postMessage:",o),alert("OAuth callback error: Failed to communicate with parent window")}}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-oauth-callback"]],decls:2,vars:1,template:function(t,n){t&1&&(dn(0,"p"),u(1),pn()),t&2&&(p(),F(n.message))},encapsulation:2})};var bn=class i{eventStream=f($t);messageApi=f(pi);pendingStates=new Map;popupCheckInterval=null;popupClosedAt=null;static POPUP_CLOSE_GRACE_MS=2e3;pendingRequest$=new q(null);messageHandler=e=>this.handlePopupMessage(e);storageHandler=e=>this.handleStorageEvent(e);constructor(){this.eventStream.events$.pipe(De(e=>e.type==="oauth_request")).subscribe(e=>this.handleOAuthRequest(e)),window.addEventListener("message",this.messageHandler),window.addEventListener("storage",this.storageHandler),this.drainLocalStorage()}ngOnDestroy(){window.removeEventListener("message",this.messageHandler),window.removeEventListener("storage",this.storageHandler),this.pendingRequest$.complete(),this.popupCheckInterval&&clearInterval(this.popupCheckInterval)}startPopupMonitoring(e,t){this.popupCheckInterval&&clearInterval(this.popupCheckInterval),this.popupCheckInterval=setInterval(()=>{if(e.closed){if(this.popupClosedAt===null){this.popupClosedAt=Date.now(),console.log("[OAuth Service] Popup closed, waiting for postMessage grace period...");return}if(Date.now()-this.popupClosedAt<i.POPUP_CLOSE_GRACE_MS)return;if(console.log("[OAuth Service] Grace period elapsed, popup closed by user"),clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null,this.pendingStates.has(t)){console.warn("[OAuth Service] OAuth cancelled - popup closed without completing authentication");let r=this.pendingStates.get(t);if(this.pendingStates.delete(t),r){let o=new Mt({state:t,integrationName:r,error:"user_cancelled",errorDescription:"User closed the popup without completing authentication"});this.messageApi.sendMessage(o).subscribe({next:()=>console.log("[OAuth Service] Cancellation sent to backend"),error:a=>console.error("[OAuth Service] Failed to send cancellation:",a)})}}}else this.popupClosedAt!==null&&(console.log("[OAuth Service] Popup reopened/navigating, resetting grace period"),this.popupClosedAt=null)},500)}openPopup(e){console.log("[OAuth Service] Opening popup from user gesture:",e.integrationName);let t=600,n=900,r=window.screenX+(window.outerWidth-t)/2,o=window.screenY+(window.outerHeight-n)/2,a=`width=${t},height=${n},left=${r},top=${o},popup=yes,resizable=yes,scrollbars=yes`,s=window.open(e.authUrl,"oauth_popup",a);console.log("[OAuth Service] Popup opened:",!!s),s?(s.focus(),this.startPopupMonitoring(s,e.state),this.pendingRequest$.next(null)):console.warn("[OAuth Service] Popup was blocked by the browser")}cancelRequest(e){console.log("[OAuth Service] OAuth cancelled by user via inline panel"),this.pendingStates.delete(e.state),this.pendingRequest$.next(null);let t=new Mt({state:e.state,integrationName:e.integrationName,error:"user_cancelled",errorDescription:"User dismissed the authorization panel"});this.messageApi.sendMessage(t).subscribe({next:()=>console.log("[OAuth Service] Cancellation sent to backend"),error:n=>console.error("[OAuth Service] Failed to send cancellation:",n)})}handleOAuthRequest(e){console.log("[OAuth Service] Received OAuthRequestEvent:",e.integrationName,e.state),this.pendingStates.set(e.state,e.integrationName),console.log("[OAuth Service] Pending states:",Array.from(this.pendingStates.keys())),this.pendingRequest$.next(e)}handlePopupMessage(e){if(console.log("[OAuth Service] Received postMessage:",e.origin,e.data),e.origin!==window.location.origin){console.warn("[OAuth Service] Rejected message from different origin:",e.origin);return}this.processCallbackData(e.data)}handleStorageEvent(e){e.key!==vi||!e.newValue||(console.log("[OAuth Service] Received localStorage callback fallback"),this.drainLocalStorage())}drainLocalStorage(){let e=localStorage.getItem(vi);if(e){localStorage.removeItem(vi),console.log("[OAuth Service] Processing localStorage OAuth callback fallback");try{let t=JSON.parse(e);this.processCallbackData(t)}catch(t){console.error("[OAuth Service] Failed to parse localStorage OAuth callback:",t)}}}processCallbackData(e){let{code:t,state:n,error:r,errorDescription:o}=e??{};if(r){console.log("[OAuth Service] OAuth error received:",r,o);let m=this.pendingStates.get(n);if(m){this.pendingStates.delete(n),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null);let _=new Mt({state:n,integrationName:m,error:r,errorDescription:o});this.messageApi.sendMessage(_).subscribe({next:()=>console.log("[OAuth Service] Error callback sent to backend"),error:b=>console.error("[OAuth Service] Failed to send error callback:",b)})}return}if(!t){console.warn("[OAuth Service] Message missing code:",e);return}console.log("[OAuth Service] Processing callback - code:",t,"state:",n);let a=n?this.pendingStates.get(n):void 0,s=n;if(!a&&this.pendingStates.size===1){let m=this.pendingStates.entries().next().value;if(m){let[_,b]=m;console.warn("[OAuth Service] State missing from callback, using sole pending flow:",b),a=b,s=_}}if(!a){console.warn("[OAuth Service] Unknown or ambiguous state:",n,"Pending states:",Array.from(this.pendingStates.keys()));return}console.log("[OAuth Service] Found integration:",a),this.pendingStates.delete(s),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null);let d=new Mt({code:t,state:s,integrationName:a});console.log("[OAuth Service] Sending callback to backend..."),this.messageApi.sendMessage(d).subscribe({next:()=>console.log("[OAuth Service] Callback sent to backend successfully"),error:m=>console.error("[OAuth Service] Failed to send callback:",m)})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};function Ch(i,e){if(i&1){let t=O();l(0,"div",0)(1,"div",1)(2,"mat-icon"),u(3,"lock_open"),c()(),l(4,"div",2)(5,"p",3),u(6,"Authorization required"),c(),l(7,"p",4)(8,"strong"),u(9),c(),u(10," needs your permission to continue. "),c()(),l(11,"div",5)(12,"button",6),v("click",function(){let r=x(t),o=h();return T(o.onCancel(r))}),u(13,"Cancel"),c(),l(14,"button",7),v("click",function(){let r=x(t),o=h();return T(o.onAuthorize(r))}),l(15,"mat-icon"),u(16,"open_in_new"),c(),u(17," Authorize "),c()()()}i&2&&(p(9),F(e.integrationName))}var Co=class i{oauthService=f(bn);pendingRequest=Me(this.oauthService.pendingRequest$,{initialValue:null});onAuthorize(e){this.oauthService.openPopup(e)}onCancel(e){this.oauthService.cancelRequest(e)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-oauth-request-panel"]],decls:1,vars:1,consts:[[1,"oauth-panel"],[1,"oauth-icon"],[1,"oauth-content"],[1,"oauth-title"],[1,"oauth-description"],[1,"oauth-actions"],["type","button",1,"oauth-btn","oauth-btn--cancel",3,"click"],["type","button",1,"oauth-btn","oauth-btn--authorize",3,"click"]],template:function(t,n){if(t&1&&C(0,Ch,18,1,"div",0),t&2){let r;S((r=n.pendingRequest())?0:-1,r)}},dependencies:[Te,ae],styles:[".oauth-panel[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:1rem;border:1px solid var(--color-border);border-radius:12px;background:var(--color-background);width:100%}@media(max-width:480px){.oauth-panel[_ngcontent-%COMP%]{flex-direction:column;align-items:flex-start}}.oauth-icon[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border-radius:50%;background:var(--color-primary);color:#fff}.oauth-icon[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.oauth-content[_ngcontent-%COMP%]{flex:1;min-width:0}.oauth-title[_ngcontent-%COMP%]{margin:0 0 .25rem;font-weight:600;font-size:.95rem;color:var(--color-text)}.oauth-description[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary)}.oauth-actions[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-shrink:0}.oauth-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;padding:.5rem 1rem;border-radius:8px;border:1px solid var(--color-border);font-size:.9rem;font-family:inherit;cursor:pointer;transition:all .2s ease}.oauth-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.oauth-btn--cancel[_ngcontent-%COMP%]{background:var(--color-background);color:var(--color-text-secondary)}.oauth-btn--cancel[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);color:var(--color-text)}.oauth-btn--authorize[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary)}.oauth-btn--authorize[_ngcontent-%COMP%]:hover{opacity:.9}"],changeDetection:0})};var So=class i{http=f(it);projectState=f(_e);threadState=f(We);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/files`}uploadFile(e){let t=this.projectState.getSelectedProjectIdOrThrow(),n=this.threadState.getSelectedThreadIdOrThrow();return new ur(r=>{let o=new FileReader;o.onload=()=>{let s=o.result.split(",")[1];this.http.post(`/api/projects/${t}/threads/${n}/upload`,{content:s,mimeType:e.type||"application/octet-stream",filename:e.name}).subscribe({next:d=>{r.next({success:d.success,filename:d.filename}),r.complete()},error:d=>r.error(d)})},o.onerror=()=>r.error(new Error("Failed to read file")),o.readAsDataURL(e)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(Le(e=>e.files))}downloadFile(e){let t=encodeURIComponent(e);return this.http.get(`${this.getBaseUrl()}/${t}`,{responseType:"blob"})}deleteFile(e){let t=encodeURIComponent(e);return this.http.delete(`${this.getBaseUrl()}/${t}`)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var yi=class i{fileApi=f(So);eventStream=f($t);filesSignal=et([]);isLoadingSignal=et(!1);currentProjectSignal=et(null);currentThreadSignal=et(null);files=Ct(()=>this.filesSignal());isLoading=Ct(()=>this.isLoadingSignal());fileCount=Ct(()=>this.filesSignal().length);constructor(){this.subscribeToFileEvents()}initializeForThread(e,t){this.currentProjectSignal.set(e),this.currentThreadSignal.set(t),this.refreshFileList()}clear(){this.filesSignal.set([]),this.currentProjectSignal.set(null),this.currentThreadSignal.set(null)}refreshFileList(){this.isLoadingSignal.set(!0),this.fileApi.listFiles().subscribe({next:e=>{let t=e.map(n=>he(G({},n),{lastModified:new Date(n.lastModified)})).sort((n,r)=>r.lastModified.getTime()-n.lastModified.getTime());this.filesSignal.set(t),this.isLoadingSignal.set(!1)},error:e=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",e),this.isLoadingSignal.set(!1)}})}uploadFile(e){return H(this,null,function*(){return new Promise(t=>{this.fileApi.uploadFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:!0})},error:n=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",n),t({success:!1,error:n.message||"Upload failed"})}})})})}downloadAllFiles(){let e=this.filesSignal();if(e.length===0){console.warn("[FILE_EXCHANGE_STATE] No files to download");return}e.forEach((t,n)=>{setTimeout(()=>{this.downloadFile(t.filename)},n*300)})}downloadFile(e){this.fileApi.downloadFile(e).subscribe({next:t=>{let n=window.URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,r.click(),window.URL.revokeObjectURL(n)},error:t=>{console.error("[FILE_EXCHANGE_STATE] Download error:",t)}})}deleteFile(e){return H(this,null,function*(){return new Promise(t=>{this.fileApi.deleteFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:!0})},error:n=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",n),t({success:!1,error:n.message||"Delete failed"})}})})})}subscribeToFileEvents(){this.eventStream.events$.pipe(De(e=>e instanceof _n),rt()).subscribe(e=>{this.handleFileEvent(e)})}handleFileEvent(e){let t=this.filesSignal();switch(e.operation){case"created":{let n=e.timestamp,r=e.timestamp.lastIndexOf("-");if(r>0){let a=e.timestamp.substring(r+1);a.length===5&&/^[a-z0-9]+$/.test(a)&&(n=e.timestamp.substring(0,r))}let o={filename:e.filename,size:e.size||0,lastModified:new Date(n)};this.filesSignal.set([o,...t]);break}case"updated":{let n=t.filter(d=>d.filename!==e.filename),r=t.find(d=>d.filename===e.filename),o=e.timestamp,a=e.timestamp.lastIndexOf("-");if(a>0){let d=e.timestamp.substring(a+1);d.length===5&&/^[a-z0-9]+$/.test(d)&&(o=e.timestamp.substring(0,a))}let s={filename:e.filename,size:e.size||r?.size||0,lastModified:new Date(o)};this.filesSignal.set([s,...n]);break}case"deleted":{let n=t.filter(r=>r.filename!==e.filename);this.filesSignal.set(n);break}}}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};function Sh(i,e){if(i&1&&R(0,"div",1),i&2){let t=h();w("innerHTML",t.renderedContent,mt)}}function xh(i,e){if(i&1&&R(0,"iframe",2),i&2){let t=h();w("srcdoc",t.content,mt)}}function Th(i,e){if(i&1&&(l(0,"pre",3),u(1),c()),i&2){let t=h();p(),F(t.content)}}var xo=class i{content="";format="text";renderedContent="";sanitizer=f(Rt);markdownService=f(Wt);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return H(this,null,function*(){try{let e=yield this.markdownService.parse(this.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e)}catch(e){console.error("[CONTENT_RENDERER] Error rendering markdown:",e),this.content=this.content}})}formatJson(){try{let e=JSON.parse(this.content);this.content=JSON.stringify(e,null,2)}catch(e){console.error("[CONTENT_RENDERER] Error formatting JSON:",e)}}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Dt],decls:4,vars:2,consts:[[1,"content-renderer",3,"ngClass"],[1,"markdown-content",3,"innerHTML"],["sandbox","allow-same-origin",1,"html-viewer",3,"srcdoc"],[1,"code-content"]],template:function(t,n){t&1&&(l(0,"div",0),C(1,Sh,1,1,"div",1)(2,xh,1,1,"iframe",2)(3,Th,2,1,"pre",3),c()),t&2&&(w("ngClass","format-"+n.format),p(),S(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[nt,Sr],styles:[".content-renderer[_ngcontent-%COMP%]{width:100%;height:100%;overflow:auto;padding:1rem}.markdown-content[_ngcontent-%COMP%]{line-height:1.6;color:var(--color-text)}.code-content[_ngcontent-%COMP%]{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9rem;line-height:1.5;margin:0;white-space:pre-wrap;word-wrap:break-word;color:var(--color-text)}.format-json[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-code-text, #d63384)}.format-yaml[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%], .format-text[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-text)}.html-viewer[_ngcontent-%COMP%]{width:100%;height:100%;min-height:400px;border:1px solid var(--color-border);border-radius:8px;background:#fff}"]})};var Ci=class i{http=f(it);MAX_FILE_SIZE=20*1024*1024;isViewable(e){return e<=this.MAX_FILE_SIZE}isFormatViewable(e){let t=e.split(".").pop()?.toLowerCase();return!(t&&["pdf","png","jpg","jpeg","gif","webp","zip","tar","gz","exe","bin","doc","docx","xls","xlsx","ppt","pptx"].includes(t))}detectFormat(e){switch(e.split(".").pop()?.toLowerCase()){case"md":return"markdown";case"json":return"json";case"yaml":case"yml":return"yaml";case"html":case"htm":return"html";default:return"text"}}loadFileContent(e,t,n){let r=`/api/projects/${e}/threads/${t}/files/${encodeURIComponent(n)}`,o=this.detectFormat(n);return this.http.get(r,{responseType:"text",observe:"response"}).pipe(Le(a=>{let s=a.body||"",d=new Blob([s]).size;return{content:s,format:o,filename:n,size:d}}),sn(a=>(console.error("[CONTENT_VIEWER] Error loading file:",n,a),Qn(()=>new Error(`Failed to load file: ${a.message||"Unknown error"}`)))))}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};function wh(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){x(t);let r=h();return T(r.download())}),l(1,"mat-icon"),u(2,"download"),c()()}}function Eh(i,e){i&1&&(l(0,"div",9),R(1,"mat-spinner",13),l(2,"p"),u(3,"Loading file content..."),c()())}function Mh(i,e){if(i&1){let t=O();l(0,"div",10)(1,"mat-icon",14),u(2,"error_outline"),c(),l(3,"p",15),u(4),c(),l(5,"button",16),v("click",function(){x(t);let r=h();return T(r.download())}),l(6,"mat-icon"),u(7,"download"),c(),u(8," Download instead "),c()()}if(i&2){let t=h();p(4),F(t.error)}}function Ph(i,e){if(i&1&&R(0,"app-content-renderer",11),i&2){let t=h();w("content",t.fileContent.content)("format",t.fileContent.format)}}var To=class i{destroy$=new ce;file;projectName;threadId;closeViewer=new ie;contentService=f(Ci);eventStream=f($t);fileContent=null;isLoading=!1;error="";ngOnInit(){this.loadContent(),this.subscribeToFileEvents()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadContent(){if(!this.contentService.isViewable(this.file.size)){this.error=`File too large to view (${this.contentService.formatSize(this.file.size)}). Maximum size: 20 MB.`;return}this.isLoading=!0,this.error="",this.contentService.loadFileContent(this.projectName,this.threadId,this.file.filename).subscribe({next:e=>{console.log("[CONTENT_VIEWER] Content loaded:",e.filename),this.fileContent=e,this.isLoading=!1},error:e=>{console.error("[CONTENT_VIEWER] Error loading content:",e),this.error=e.message||"Failed to load file content",this.isLoading=!1}})}onClose(){this.closeViewer.emit()}download(){let e=new Blob([this.fileContent?.content||""],{type:"text/plain"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=this.file.filename,n.click(),window.URL.revokeObjectURL(t)}formatSize(e){return this.contentService.formatSize(e)}subscribeToFileEvents(){this.eventStream.events$.pipe(De(e=>e instanceof _n),De(e=>e.filename===this.file.filename),De(e=>e.operation==="updated"),z(this.destroy$)).subscribe(e=>{console.log("[CONTENT_VIEWER] File updated event received, reloading:",e.filename),e.size&&(this.file.size=e.size),this.loadContent()})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-content-viewer"]],inputs:{file:"file",projectName:"projectName",threadId:"threadId"},outputs:{closeViewer:"closeViewer"},decls:16,vars:6,consts:[[1,"viewer-container"],[1,"viewer-header"],[1,"header-info"],[1,"filename"],[1,"file-size"],[1,"header-actions"],["mat-icon-button","","title","Download","type","button"],["mat-icon-button","","title","Close","type","button",3,"click"],[1,"viewer-content"],[1,"loading-state"],[1,"error-state"],[3,"content","format"],["mat-icon-button","","title","Download","type","button",3,"click"],["diameter","48"],[1,"error-icon"],[1,"error-message"],["mat-raised-button","","color","primary","type","button",3,"click"]],template:function(t,n){t&1&&(l(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),u(4),c(),l(5,"span",4),u(6),c()(),l(7,"div",5),C(8,wh,3,0,"button",6),l(9,"button",7),v("click",function(){return n.onClose()}),l(10,"mat-icon"),u(11,"chevron_right"),c()()()(),l(12,"div",8),C(13,Eh,4,0,"div",9),C(14,Mh,9,1,"div",10),C(15,Ph,1,2,"app-content-renderer",11),c()()),t&2&&(p(4),F(n.file.filename),p(2),F(n.formatSize(n.file.size)),p(2),S(n.fileContent&&!n.isLoading&&!n.error?8:-1),p(5),S(n.isLoading?13:-1),p(),S(n.error?14:-1),p(),S(n.fileContent&&!n.isLoading&&!n.error?15:-1))},dependencies:[nt,Te,ae,qe,ei,ze,fi,gi,xo],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.viewer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--color-bg)}.viewer-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:1rem;border-bottom:1px solid var(--color-border);background:var(--color-bg);flex-shrink:0}.header-info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.filename[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-size[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary)}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0}.viewer-content[_ngcontent-%COMP%]{flex:1;overflow:auto;background:var(--color-bg)}.loading-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;color:var(--color-text-secondary)}.error-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;padding:2rem;text-align:center}.error-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;color:var(--color-error)}.error-message[_ngcontent-%COMP%]{color:var(--color-text);margin:0;max-width:400px}"]})};var kh=Math.pow(10,8)*24*60*60*1e3,CT=-kh,wo=6048e5,Cd=864e5;var Oh=3600;var Sd=Oh*24,ST=Sd*7,Ah=Sd*365.2425,Ih=Ah/12,xT=Ih*3,ls=Symbol.for("constructDateFrom");function Ae(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&ls in i?i[ls](e):i instanceof Date?new i.constructor(e):new Date(e)}function ve(i,e){return Ae(e||i,i)}function xd(i,e,t){let n=ve(i,t?.in);return isNaN(e)?Ae(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var Dh={};function vn(){return Dh}function nn(i,e){let t=vn(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=ve(i,e?.in),o=r.getDay(),a=(o<n?7:0)+o-n;return r.setDate(r.getDate()-a),r.setHours(0,0,0,0),r}function Vn(i,e){return nn(i,he(G({},e),{weekStartsOn:1}))}function Eo(i,e){let t=ve(i,e?.in),n=t.getFullYear(),r=Ae(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let o=Vn(r),a=Ae(t,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let s=Vn(a);return t.getTime()>=o.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function cs(i){let e=ve(i),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+i-+t}function Si(i,...e){let t=Ae.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function xi(i,e){let t=ve(i,e?.in);return t.setHours(0,0,0,0),t}function Mo(i,e,t){let[n,r]=Si(t?.in,i,e),o=xi(n),a=xi(r),s=+o-cs(o),d=+a-cs(a);return Math.round((s-d)/Cd)}function Td(i,e){let t=Eo(i,e),n=Ae(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Vn(n)}function wd(i){return Ae(i,Date.now())}function Ed(i,e,t){let[n,r]=Si(t?.in,i,e);return+xi(n)==+xi(r)}function Md(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function Pd(i){return!(!Md(i)&&typeof i!="number"||isNaN(+ve(i)))}function Od(i,e,t){let[n,r]=Si(t?.in,i,e),o=kd(n,r),a=Math.abs(Mo(n,r));n.setDate(n.getDate()-o*a);let s=+(kd(n,r)===-o),d=o*(a-s);return d===0?0:d}function kd(i,e){let t=i.getFullYear()-e.getFullYear()||i.getMonth()-e.getMonth()||i.getDate()-e.getDate()||i.getHours()-e.getHours()||i.getMinutes()-e.getMinutes()||i.getSeconds()-e.getSeconds()||i.getMilliseconds()-e.getMilliseconds();return t<0?-1:t>0?1:t}function Ad(i,e){let t=ve(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var Rh={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Id=(i,e,t)=>{let n,r=Rh[i];return typeof r=="string"?n=r:e===1?n=r.one:n=r.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function Po(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var Nh={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Fh={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Lh={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Dd={date:Po({formats:Nh,defaultWidth:"full"}),time:Po({formats:Fh,defaultWidth:"full"}),dateTime:Po({formats:Lh,defaultWidth:"full"})};var jh={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Rd=(i,e,t,n)=>jh[i];function Ti(i){return(e,t)=>{let n=t?.context?String(t.context):"standalone",r;if(n==="formatting"&&i.formattingValues){let a=i.defaultFormattingWidth||i.defaultWidth,s=t?.width?String(t.width):a;r=i.formattingValues[s]||i.formattingValues[a]}else{let a=i.defaultWidth,s=t?.width?String(t.width):i.defaultWidth;r=i.values[s]||i.values[a]}let o=i.argumentCallback?i.argumentCallback(e):e;return r[o]}}var Vh={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zh={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$h={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Hh={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Uh={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Bh={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},qh=(i,e)=>{let t=Number(i),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},Nd={ordinalNumber:qh,era:Ti({values:Vh,defaultWidth:"wide"}),quarter:Ti({values:zh,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Ti({values:$h,defaultWidth:"wide"}),day:Ti({values:Hh,defaultWidth:"wide"}),dayPeriod:Ti({values:Uh,defaultWidth:"wide",formattingValues:Bh,defaultFormattingWidth:"wide"})};function wi(i){return(e,t={})=>{let n=t.width,r=n&&i.matchPatterns[n]||i.matchPatterns[i.defaultMatchWidth],o=e.match(r);if(!o)return null;let a=o[0],s=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],d=Array.isArray(s)?Gh(s,b=>b.test(a)):Wh(s,b=>b.test(a)),m;m=i.valueCallback?i.valueCallback(d):d,m=t.valueCallback?t.valueCallback(m):m;let _=e.slice(a.length);return{value:m,rest:_}}}function Wh(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function Gh(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function Fd(i){return(e,t={})=>{let n=e.match(i.matchPattern);if(!n)return null;let r=n[0],o=e.match(i.parsePattern);if(!o)return null;let a=i.valueCallback?i.valueCallback(o[0]):o[0];a=t.valueCallback?t.valueCallback(a):a;let s=e.slice(r.length);return{value:a,rest:s}}}var Yh=/^(\d+)(th|st|nd|rd)?/i,Qh=/\d+/i,Kh={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Xh={any:[/^b/i,/^(a|c)/i]},Jh={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Zh={any:[/1/i,/2/i,/3/i,/4/i]},eg={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},tg={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ng={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ig={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},rg={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},og={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ld={ordinalNumber:Fd({matchPattern:Yh,parsePattern:Qh,valueCallback:i=>parseInt(i,10)}),era:wi({matchPatterns:Kh,defaultMatchWidth:"wide",parsePatterns:Xh,defaultParseWidth:"any"}),quarter:wi({matchPatterns:Jh,defaultMatchWidth:"wide",parsePatterns:Zh,defaultParseWidth:"any",valueCallback:i=>i+1}),month:wi({matchPatterns:eg,defaultMatchWidth:"wide",parsePatterns:tg,defaultParseWidth:"any"}),day:wi({matchPatterns:ng,defaultMatchWidth:"wide",parsePatterns:ig,defaultParseWidth:"any"}),dayPeriod:wi({matchPatterns:rg,defaultMatchWidth:"any",parsePatterns:og,defaultParseWidth:"any"})};var ds={code:"en-US",formatDistance:Id,formatLong:Dd,formatRelative:Rd,localize:Nd,match:Ld,options:{weekStartsOn:0,firstWeekContainsDate:1}};function jd(i,e){let t=ve(i,e?.in);return Mo(t,Ad(t))+1}function Vd(i,e){let t=ve(i,e?.in),n=+Vn(t)-+Td(t);return Math.round(n/wo)+1}function ko(i,e){let t=ve(i,e?.in),n=t.getFullYear(),r=vn(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=Ae(e?.in||i,0);a.setFullYear(n+1,0,o),a.setHours(0,0,0,0);let s=nn(a,e),d=Ae(e?.in||i,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);let m=nn(d,e);return+t>=+s?n+1:+t>=+m?n:n-1}function zd(i,e){let t=vn(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=ko(i,e),o=Ae(e?.in||i,0);return o.setFullYear(r,0,n),o.setHours(0,0,0,0),nn(o,e)}function $d(i,e){let t=ve(i,e?.in),n=+nn(t,e)-+zd(t,e);return Math.round(n/wo)+1}function oe(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var rn={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return oe(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):oe(t+1,2)},d(i,e){return oe(i.getDate(),e.length)},a(i,e){let t=i.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return t==="am"?"a.m.":"p.m."}},h(i,e){return oe(i.getHours()%12||12,e.length)},H(i,e){return oe(i.getHours(),e.length)},m(i,e){return oe(i.getMinutes(),e.length)},s(i,e){return oe(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),r=Math.trunc(n*Math.pow(10,t-3));return oe(r,e.length)}};var Ei={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ps={G:function(i,e,t){let n=i.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(i,e,t){if(e==="yo"){let n=i.getFullYear(),r=n>0?n:1-n;return t.ordinalNumber(r,{unit:"year"})}return rn.y(i,e)},Y:function(i,e,t,n){let r=ko(i,n),o=r>0?r:1-r;if(e==="YY"){let a=o%100;return oe(a,2)}return e==="Yo"?t.ordinalNumber(o,{unit:"year"}):oe(o,e.length)},R:function(i,e){let t=Eo(i);return oe(t,e.length)},u:function(i,e){let t=i.getFullYear();return oe(t,e.length)},Q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return oe(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return oe(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(i,e,t){let n=i.getMonth();switch(e){case"M":case"MM":return rn.M(i,e);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(i,e,t){let n=i.getMonth();switch(e){case"L":return String(n+1);case"LL":return oe(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(i,e,t,n){let r=$d(i,n);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):oe(r,e.length)},I:function(i,e,t){let n=Vd(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):oe(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):rn.d(i,e)},D:function(i,e,t){let n=jd(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):oe(n,e.length)},E:function(i,e,t){let n=i.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(i,e,t,n){let r=i.getDay(),o=(r-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return oe(o,2);case"eo":return t.ordinalNumber(o,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(i,e,t,n){let r=i.getDay(),o=(r-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return oe(o,e.length);case"co":return t.ordinalNumber(o,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(i,e,t){let n=i.getDay(),r=n===0?7:n;switch(e){case"i":return String(r);case"ii":return oe(r,e.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(i,e,t){let r=i.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(i,e,t){let n=i.getHours(),r;switch(n===12?r=Ei.noon:n===0?r=Ei.midnight:r=n/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(i,e,t){let n=i.getHours(),r;switch(n>=17?r=Ei.evening:n>=12?r=Ei.afternoon:n>=4?r=Ei.morning:r=Ei.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(i,e,t){if(e==="ho"){let n=i.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return rn.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):rn.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):oe(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):oe(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):rn.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):rn.s(i,e)},S:function(i,e){return rn.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return Ud(n);case"XXXX":case"XX":return zn(n);default:return zn(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return Ud(n);case"xxxx":case"xx":return zn(n);default:return zn(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Hd(n,":");default:return"GMT"+zn(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Hd(n,":");default:return"GMT"+zn(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return oe(n,e.length)},T:function(i,e,t){return oe(+i,e.length)}};function Hd(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),r=Math.trunc(n/60),o=n%60;return o===0?t+String(r):t+String(r)+e+oe(o,2)}function Ud(i,e){return i%60===0?(i>0?"-":"+")+oe(Math.abs(i)/60,2):zn(i,e)}function zn(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),r=oe(Math.trunc(n/60),2),o=oe(n%60,2);return t+r+e+o}var Bd=(i,e)=>{switch(i){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},qd=(i,e)=>{switch(i){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},ag=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],r=t[2];if(!r)return Bd(i,e);let o;switch(n){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",Bd(n,e)).replace("{{time}}",qd(r,e))},Wd={p:qd,P:ag};var sg=/^D+$/,lg=/^Y+$/,cg=["D","DD","YY","YYYY"];function Gd(i){return sg.test(i)}function Yd(i){return lg.test(i)}function Qd(i,e,t){let n=dg(i,e,t);if(console.warn(n),cg.includes(i))throw new RangeError(n)}function dg(i,e,t){let n=i[0]==="Y"?"years":"days of the month";return`Use \`${i.toLowerCase()}\` instead of \`${i}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var pg=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,mg=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ug=/^'([^]*?)'?$/,hg=/''/g,gg=/[a-zA-Z]/;function ms(i,e,t){let n=vn(),r=t?.locale??n.locale??ds,o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=ve(i,t?.in);if(!Pd(s))throw new RangeError("Invalid time value");let d=e.match(mg).map(_=>{let b=_[0];if(b==="p"||b==="P"){let y=Wd[b];return y(_,r.formatLong)}return _}).join("").match(pg).map(_=>{if(_==="''")return{isToken:!1,value:"'"};let b=_[0];if(b==="'")return{isToken:!1,value:fg(_)};if(ps[b])return{isToken:!0,value:_};if(b.match(gg))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:_}});r.localize.preprocessor&&(d=r.localize.preprocessor(s,d));let m={firstWeekContainsDate:o,weekStartsOn:a,locale:r};return d.map(_=>{if(!_.isToken)return _.value;let b=_.value;(!t?.useAdditionalWeekYearTokens&&Yd(b)||!t?.useAdditionalDayOfYearTokens&&Gd(b))&&Qd(b,e,String(i));let y=ps[b[0]];return y(s,b,r.localize,m)}).join("")}function fg(i){let e=i.match(ug);return e?e[1].replace(hg,"'"):i}function Kd(i,e,t){return xd(i,-e,t)}function Xd(i,e){return Ed(Ae(e?.in||i,i),Kd(wd(e?.in||i),1))}function Jd(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=ms(i,"HH:mm:ss"),n=e.getTime()-i.getTime(),r=Math.floor(n/(1e3*60));if(r<1)return`just now (${t})`;if(r<60)return`${r} min ago (${t})`;let o=Math.floor(n/(1e3*60*60));if(o<24)return`${o}h ago (${t})`;if(Xd(i))return`yesterday ${t}`;let a=Od(e,i);return a<7?`${a}d ago ${t}`:`${ms(i,"dd/MM/yyyy")} ${t}`}var _g=(i,e)=>e.filename;function bg(i,e){if(i&1){let t=O();l(0,"button",11),v("click",function(){x(t);let r=h(2);return T(r.downloadAll())}),l(1,"mat-icon"),u(2,"download_for_offline"),c()()}}function vg(i,e){i&1&&(l(0,"div",10),R(1,"span",12),l(2,"span",13),u(3,"Loading files..."),c()())}function yg(i,e){i&1&&(l(0,"div",14)(1,"mat-icon",15),u(2,"folder_open"),c(),l(3,"p",16),u(4,"No files in exchange space"),c(),l(5,"p",17),u(6,"Upload files to share with the agent"),c()())}function Cg(i,e){if(i&1){let t=O();l(0,"button",28),v("click",function(){x(t);let r=h().$implicit,o=h(4);return T(o.viewFile(r))}),l(1,"mat-icon"),u(2,"visibility"),c()()}}function Sg(i,e){if(i&1){let t=O();l(0,"div",18)(1,"div",19)(2,"mat-icon",20),u(3),c(),l(4,"div",21)(5,"span",22),u(6),c(),l(7,"span",23),u(8),c()()(),l(9,"div",24),C(10,Cg,3,0,"button",25),l(11,"button",26),v("click",function(){let r=x(t).$implicit,o=h(4);return T(o.download(r))}),l(12,"mat-icon"),u(13,"download"),c()(),l(14,"button",27),v("click",function(){let r=x(t).$implicit,o=h(4);return T(o.delete(r))}),l(15,"mat-icon"),u(16,"delete"),c()()()()}if(i&2){let t=e.$implicit,n=h(4);p(3),F(n.getFileIcon(t.filename)),p(2),w("title",t.filename),p(),F(t.filename),p(2),Jn("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),p(2),S(n.canViewFile(t)?10:-1)}}function xg(i,e){if(i&1&&Ce(0,Sg,17,6,"div",18,_g),i&2){let t=h(3);Se(t.files())}}function Tg(i,e){if(i&1&&C(0,yg,7,0,"div",14)(1,xg,2,0),i&2){let t=h(2);S(t.files().length===0?0:1)}}function wg(i,e){if(i&1){let t=O();l(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),u(4,"Exchange"),c(),l(5,"span",5),u(6),c()(),l(7,"div",6),C(8,bg,3,0,"button",7),l(9,"button",8),v("click",function(){x(t);let r=h();return T(r.close())}),l(10,"mat-icon"),u(11,"chevron_right"),c()()()(),l(12,"div",9),C(13,vg,4,0,"div",10)(14,Tg,2,1),c()()}if(i&2){let t=h();p(6),Oe("(",t.files().length,")"),p(2),S(t.files().length>0?8:-1),p(5),S(t.isLoading()?13:14)}}function Eg(i,e){if(i&1){let t=O();l(0,"app-content-viewer",29),v("closeViewer",function(){x(t);let r=h();return T(r.backToList())}),c()}if(i&2){let t=h();w("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var Oo=class i{projectName;threadId;closeDrawer=new ie;fileExchangeState=f(yi);contentViewerService=f(Ci);files=this.fileExchangeState.files;isLoading=this.fileExchangeState.isLoading;viewerState="list";currentFile=null;close(){this.viewerState==="content"?this.backToList():this.closeDrawer.emit()}viewFile(e){this.currentFile=e,this.viewerState="content"}backToList(){this.viewerState="list",this.currentFile=null}downloadAll(){this.fileExchangeState.downloadAllFiles()}download(e){this.fileExchangeState.downloadFile(e.filename)}delete(e){return H(this,null,function*(){if(!confirm(`Delete file "${e.filename}"?`))return;let n=yield this.fileExchangeState.deleteFile(e.filename);n.success||alert(`Failed to delete file: ${n.error}`)})}getFileIcon(e){switch(e.split(".").pop()?.toLowerCase()){case"pdf":return"picture_as_pdf";case"csv":case"xlsx":case"xls":return"table_chart";case"txt":case"md":return"description";case"jpg":case"jpeg":case"png":case"gif":case"webp":return"image";case"zip":case"tar":case"gz":return"folder_zip";default:return"insert_drive_file"}}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}formatDate(e){return Jd(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-file-exchange-drawer"]],inputs:{projectName:"projectName",threadId:"threadId"},outputs:{closeDrawer:"closeDrawer"},decls:2,vars:2,consts:[[1,"file-drawer-container"],[3,"file","projectName","threadId"],[1,"drawer-header"],[1,"header-left"],[1,"drawer-title"],[1,"file-count"],[1,"header-actions"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"file-list"],[1,"file-loading"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn",3,"click"],[1,"loading-spinner"],[1,"loading-text"],[1,"file-empty"],[1,"empty-icon"],[1,"empty-text"],[1,"empty-hint"],[1,"file-item"],[1,"file-info"],[1,"file-icon"],[1,"file-details"],[1,"file-name",3,"title"],[1,"file-meta"],[1,"file-actions"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn"],["mat-icon-button","","title","Download","type","button",1,"action-btn","download-btn",3,"click"],["mat-icon-button","","title","Delete","type","button",1,"action-btn","delete-btn",3,"click"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn",3,"click"],[3,"closeViewer","file","projectName","threadId"]],template:function(t,n){t&1&&(C(0,wg,15,3,"div",0),C(1,Eg,1,3,"app-content-viewer",1)),t&2&&(S(n.viewerState==="list"?0:-1),p(),S(n.viewerState==="content"&&n.currentFile?1:-1))},dependencies:[nt,Te,ae,qe,ze,To],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.file-drawer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.drawer-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--color-border);flex-shrink:0}.header-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.5rem}.header-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem}.drawer-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text)}.file-count[_ngcontent-%COMP%]{font-size:.9rem;color:var(--color-text-secondary)}.download-all-btn[_ngcontent-%COMP%]{color:var(--color-primary)}.download-all-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.file-list[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:.5rem}.file-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;gap:1rem;color:var(--color-text-secondary)}.loading-spinner[_ngcontent-%COMP%]{display:inline-block;width:32px;height:32px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.loading-text[_ngcontent-%COMP%]{font-size:.9rem}.file-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;text-align:center;color:var(--color-text-secondary)}.empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:1rem;opacity:.5}.empty-text[_ngcontent-%COMP%]{margin:0 0 .5rem;font-size:1rem;font-weight:500}.empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;opacity:.7}.file-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-radius:8px;transition:background .2s;gap:1rem}.file-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.file-item[_ngcontent-%COMP%]:hover .file-actions[_ngcontent-%COMP%]{opacity:1}.file-info[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-icon[_ngcontent-%COMP%]{flex-shrink:0;color:var(--color-primary);font-size:28px;width:28px;height:28px}.file-details[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;min-width:0}.file-name[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.file-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .2s}.action-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.action-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.action-btn.view-btn[_ngcontent-%COMP%]:hover, .action-btn.download-btn[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.action-btn.delete-btn[_ngcontent-%COMP%]:hover{color:var(--color-error)}@media(max-width:768px){.file-actions[_ngcontent-%COMP%]{opacity:1}.file-item[_ngcontent-%COMP%]{padding:1rem .75rem}.drawer-header[_ngcontent-%COMP%]{padding:.75rem;padding-top:calc(.75rem + env(safe-area-inset-top,0px))}}"]})};var Ao=class i{http=f(it);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Io=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new ie;userApi=f(Ao);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(Le(n=>n.filter(r=>!this.excludedUserIds.includes(r.username)).filter(r=>r.username.toLowerCase().includes(t)).map(r=>({id:r.username,name:r.username}))))}onItemSelected(e){this.userSelected.emit(e.id)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-user-autocomplete"]],inputs:{excludedUserIds:"excludedUserIds",placeholder:"placeholder",disabled:"disabled"},outputs:{userSelected:"userSelected"},decls:1,vars:3,consts:[[3,"itemSelected","dataSource","placeholder","disabled"]],template:function(t,n){t&1&&(l(0,"ds-autocomplete-input",0),v("itemSelected",function(o){return n.onItemSelected(o)}),c()),t&2&&w("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[Dl],styles:["[_nghost-%COMP%]{display:block}"]})};var Mg=(i,e)=>e.userId;function Pg(i,e){if(i&1&&(l(0,"div",7),u(1),c()),i&2){let t=h();p(),F(t.errorMessage())}}function kg(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){x(t);let r=h().$implicit,o=h();return T(o.removeUser(r.userId))}),l(1,"mat-icon"),u(2,"close"),c()()}}function Og(i,e){if(i&1&&(l(0,"div",9)(1,"mat-icon",10),u(2,"person"),c(),l(3,"span",11),u(4),c(),C(5,kg,3,0,"button",12),c()),i&2){let t=e.$implicit,n=h();p(4),F(t.userId),p(),S(n.users.length>1?5:-1)}}var er=class i{threadId;users=[];currentUsername;userAdded=new ie;userRemoved=new ie;closed=new ie;isAdding=et(!1);errorMessage=et("");get excludedUserIds(){return[this.currentUsername,...this.users.map(e=>e.userId)]}setAdding(e){this.isAdding.set(e)}setError(e){this.errorMessage.set(e),this.isAdding.set(!1)}onUserSelected(e){this.errorMessage.set(""),this.userAdded.emit(e)}removeUser(e){this.userRemoved.emit(e)}close(){this.closed.emit()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-thread-share"]],inputs:{threadId:"threadId",users:"users",currentUsername:"currentUsername"},outputs:{userAdded:"userAdded",userRemoved:"userRemoved",closed:"closed"},decls:19,vars:3,consts:[[1,"thread-share"],[1,"share-header"],[1,"header-left"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"share-subheader"],[1,"add-user-section"],[3,"userSelected","excludedUserIds","disabled"],[1,"error-message"],[1,"users-list"],[1,"user-item"],[1,"user-icon"],[1,"user-name"],["mat-icon-button","","title","Remove user",1,"remove-button"],["mat-icon-button","","title","Remove user",1,"remove-button",3,"click"]],template:function(t,n){t&1&&(l(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),u(4,"group"),c(),l(5,"span"),u(6,"Share"),c()(),l(7,"button",3),v("click",function(){return n.close()}),l(8,"mat-icon"),u(9,"chevron_right"),c()()(),l(10,"div",4)(11,"span"),u(12,"Participants"),c()(),l(13,"div",5)(14,"app-user-autocomplete",6),v("userSelected",function(o){return n.onUserSelected(o)}),c()(),C(15,Pg,2,1,"div",7),l(16,"div",8),Ce(17,Og,6,2,"div",9,Mg),c()()),t&2&&(p(14),w("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),p(),S(n.errorMessage()?15:-1),p(2),Se(n.users))},dependencies:[Te,ae,qe,ze,Dr,Io],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;height:100%}.thread-share[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.share-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;padding-top:calc(1rem + env(safe-area-inset-top,0px));border-bottom:1px solid var(--color-border);flex-shrink:0}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;font-weight:600;font-size:1.1rem;color:var(--color-text)}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.share-subheader[_ngcontent-%COMP%]{padding:.75rem 1rem .25rem;font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-secondary)}.add-user-section[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 1rem .75rem;width:50%}.error-message[_ngcontent-%COMP%]{color:var(--color-error);font-size:.75rem;margin-top:-.5rem;padding:0 1rem}.users-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.user-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;border-radius:6px;transition:background .15s ease}.user-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.user-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-text-secondary);flex-shrink:0}.user-name[_ngcontent-%COMP%]{flex:1;font-size:.875rem;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.remove-button[_ngcontent-%COMP%]{flex-shrink:0;width:28px!important;height:28px!important;padding:0!important}.remove-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px;color:var(--color-text-secondary)}.remove-button[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{color:var(--color-error, #ef4444)}"]})};var Zd="mat-badge-content",Ag=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=N({type:i,selectors:[["ng-component"]],decls:0,vars:0,template:function(n,r){},styles:[`.mat-badge{position:relative}.mat-badge.mat-badge{overflow:visible}.mat-badge-content{position:absolute;text-align:center;display:inline-block;transition:transform 200ms ease-in-out;transform:scale(0.6);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;box-sizing:border-box;pointer-events:none;background-color:var(--mat-badge-background-color, var(--mat-sys-error));color:var(--mat-badge-text-color, var(--mat-sys-on-error));font-family:var(--mat-badge-text-font, var(--mat-sys-label-small-font));font-weight:var(--mat-badge-text-weight, var(--mat-sys-label-small-weight));border-radius:var(--mat-badge-container-shape, var(--mat-sys-corner-full))}.mat-badge-above .mat-badge-content{bottom:100%}.mat-badge-below .mat-badge-content{top:100%}.mat-badge-before .mat-badge-content{right:100%}[dir=rtl] .mat-badge-before .mat-badge-content{right:auto;left:100%}.mat-badge-after .mat-badge-content{left:100%}[dir=rtl] .mat-badge-after .mat-badge-content{left:auto;right:100%}@media(forced-colors: active){.mat-badge-content{outline:solid 1px;border-radius:0}}.mat-badge-disabled .mat-badge-content{background-color:var(--mat-badge-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-error) 38%, transparent));color:var(--mat-badge-disabled-state-text-color, var(--mat-sys-on-error))}.mat-badge-hidden .mat-badge-content{display:none}.ng-animate-disabled .mat-badge-content,.mat-badge-content._mat-animation-noopable{transition:none}.mat-badge-content.mat-badge-active{transform:none}.mat-badge-small .mat-badge-content{width:var(--mat-badge-legacy-small-size-container-size, unset);height:var(--mat-badge-legacy-small-size-container-size, unset);min-width:var(--mat-badge-small-size-container-size, 6px);min-height:var(--mat-badge-small-size-container-size, 6px);line-height:var(--mat-badge-small-size-line-height, 6px);padding:var(--mat-badge-small-size-container-padding, 0);font-size:var(--mat-badge-small-size-text-size, 0);margin:var(--mat-badge-small-size-container-offset, -6px 0)}.mat-badge-small.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-small-size-container-overlap-offset, -6px)}.mat-badge-medium .mat-badge-content{width:var(--mat-badge-legacy-container-size, unset);height:var(--mat-badge-legacy-container-size, unset);min-width:var(--mat-badge-container-size, 16px);min-height:var(--mat-badge-container-size, 16px);line-height:var(--mat-badge-line-height, 16px);padding:var(--mat-badge-container-padding, 0 4px);font-size:var(--mat-badge-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-container-offset, -12px 0)}.mat-badge-medium.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-container-overlap-offset, -12px)}.mat-badge-large .mat-badge-content{width:var(--mat-badge-legacy-large-size-container-size, unset);height:var(--mat-badge-legacy-large-size-container-size, unset);min-width:var(--mat-badge-large-size-container-size, 16px);min-height:var(--mat-badge-large-size-container-size, 16px);line-height:var(--mat-badge-large-size-line-height, 16px);padding:var(--mat-badge-large-size-container-padding, 0 4px);font-size:var(--mat-badge-large-size-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-large-size-container-offset, -12px 0)}.mat-badge-large.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-large-size-container-overlap-offset, -12px)}
357
+ `],encapsulation:2,changeDetection:0})}return i})(),ep=(()=>{class i{_ngZone=f(Xn);_elementRef=f(ln);_ariaDescriber=f(ml);_renderer=f(Us);_animationsDisabled=hl();_idGenerator=f(pl);get color(){return this._color}set color(t){this._setColor(t),this._color=t}_color="primary";overlap=!0;disabled=!1;position="above after";get content(){return this._content}set content(t){this._updateRenderedContent(t)}_content;get description(){return this._description}set description(t){this._updateDescription(t)}_description;size="medium";hidden=!1;_badgeElement;_inlineBadgeDescription;_isInitialized=!1;_interactivityChecker=f(cl);_document=f(fr);constructor(){let t=f(al);t.load(Ag),t.load(sl)}isAbove(){return this.position.indexOf("below")===-1}isAfter(){return this.position.indexOf("before")===-1}getBadgeElement(){return this._badgeElement}ngOnInit(){this._clearExistingBadges(),this.content&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement(),this._updateRenderedContent(this.content)),this._isInitialized=!0}ngAfterViewInit(){}ngOnDestroy(){this._renderer.destroyNode&&(this._renderer.destroyNode(this._badgeElement),this._inlineBadgeDescription?.remove()),this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description)}_isHostInteractive(){return this._interactivityChecker.isFocusable(this._elementRef.nativeElement,{ignoreVisibility:!0})}_createBadgeElement(){let t=this._renderer.createElement("span"),n="mat-badge-active";return t.setAttribute("id",this._idGenerator.getId("mat-badge-content-")),t.setAttribute("aria-hidden","true"),t.classList.add(Zd),this._animationsDisabled&&t.classList.add("_mat-animation-noopable"),this._elementRef.nativeElement.appendChild(t),typeof requestAnimationFrame=="function"&&!this._animationsDisabled?this._ngZone.runOutsideAngular(()=>{requestAnimationFrame(()=>{t.classList.add(n)})}):t.classList.add(n),t}_updateRenderedContent(t){let n=`${t??""}`.trim();this._isInitialized&&n&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement()),this._badgeElement&&(this._badgeElement.textContent=n),this._content=n}_updateDescription(t){this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description),(!t||this._isHostInteractive())&&this._removeInlineDescription(),this._description=t,this._isHostInteractive()?this._ariaDescriber.describe(this._elementRef.nativeElement,t):this._updateInlineDescription()}_updateInlineDescription(){this._inlineBadgeDescription||(this._inlineBadgeDescription=this._document.createElement("span"),this._inlineBadgeDescription.classList.add("cdk-visually-hidden")),this._inlineBadgeDescription.textContent=this.description,this._badgeElement?.appendChild(this._inlineBadgeDescription)}_removeInlineDescription(){this._inlineBadgeDescription?.remove(),this._inlineBadgeDescription=void 0}_setColor(t){let n=this._elementRef.nativeElement.classList;n.remove(`mat-badge-${this._color}`),t&&n.add(`mat-badge-${t}`)}_clearExistingBadges(){let t=this._elementRef.nativeElement.querySelectorAll(`:scope > .${Zd}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=Bs({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,r){n&2&&J("mat-badge-overlap",r.overlap)("mat-badge-above",r.isAbove())("mat-badge-below",!r.isAbove())("mat-badge-before",!r.isAfter())("mat-badge-after",r.isAfter())("mat-badge-small",r.size==="small")("mat-badge-medium",r.size==="medium")("mat-badge-large",r.size==="large")("mat-badge-hidden",r.hidden||!r.content)("mat-badge-disabled",r.disabled)},inputs:{color:[0,"matBadgeColor","color"],overlap:[2,"matBadgeOverlap","overlap",yr],disabled:[2,"matBadgeDisabled","disabled",yr],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",yr]}})}return i})(),tp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Jt({type:i});static \u0275inj=Xt({imports:[dl,mn]})}return i})();var Mi=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=f(_i);project=f(_e);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){wn([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=!0,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=!1,this.forceUpdateTitle()},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle()}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=!1,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=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Do=class i{http=f(it);maxFileSize=5*1024*1024;supportedTypes=["image/png","image/jpeg","image/gif","image/webp"];validateFile(e){if(!this.supportedTypes.includes(e.type))throw new Error(`Unsupported file type: ${e.type}`);if(e.size>this.maxFileSize)throw new Error(`File too large: ${(e.size/1024/1024).toFixed(1)}MB exceeds 5MB limit`)}fileToBase64(e){return H(this,null,function*(){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let o=r.result;if(!o){n(new Error("Failed to read file"));return}let a=o.split(",")[1];if(!a){n(new Error("Invalid file format"));return}t(a)},r.onerror=n,r.readAsDataURL(e)})})}getUploadUrl(e,t){return`/api/projects/${e}/threads/${t}/upload`}uploadImage(e,t,n){console.log("[IMAGE-UPLOAD] uploadImage - file:",e.name,e.type,e.size),console.log("[IMAGE-UPLOAD] uploadImage - project:",t,"thread:",n);try{console.log("[IMAGE-UPLOAD] Validating file..."),this.validateFile(e)}catch(r){return console.log("[IMAGE-UPLOAD] Validation failed:",r),Tn({success:!1,error:r instanceof Error?r.message:"Validation failed"})}return new ur(r=>{console.log("[IMAGE-UPLOAD] Converting to base64..."),this.fileToBase64(e).then(o=>{console.log("[IMAGE-UPLOAD] Base64 length:",o.length),console.log("[IMAGE-UPLOAD] Sending upload request..."),this.http.post(this.getUploadUrl(t,n),{content:o,mimeType:e.type,filename:e.name}).pipe(Le(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),sn(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let s=a.error?.error||a.message||"Upload failed";return Tn({success:!1,error:s})})).subscribe({next:a=>{r.next(a),r.complete()},error:a=>r.error(a)})}).catch(o=>{console.log("[IMAGE-UPLOAD] Base64 conversion failed:",o),r.next({success:!1,error:o instanceof Error?o.message:"Failed to read file"}),r.complete()})})}hasImageFiles(e){if(console.log("[IMAGE-UPLOAD] hasImageFiles - dataTransfer:",e),!e)return console.log("[IMAGE-UPLOAD] hasImageFiles - no dataTransfer"),!1;if(console.log("[IMAGE-UPLOAD] hasImageFiles - types:",Array.from(e.types)),!Array.from(e.types).includes("Files"))return console.log("[IMAGE-UPLOAD] hasImageFiles - no Files type"),!1;let t=Array.from(e.files||[]);console.log("[IMAGE-UPLOAD] hasImageFiles - files:",t.map(r=>({name:r.name,type:r.type})));let n=t.some(r=>this.supportedTypes.includes(r.type));return console.log("[IMAGE-UPLOAD] hasImageFiles - result:",n),n}filterImageFiles(e){return Array.from(e).filter(n=>this.supportedTypes.includes(n.type))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Pi=class i{pendingFirstMessage=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}hasPendingFirstMessage(){return this.pendingFirstMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Rg=["inputSection"],Ng=()=>[];function Fg(i,e){if(i&1){let t=O();l(0,"button",20),v("click",function(){x(t);let r=h();return T(r.toggleFileDrawer())}),l(1,"mat-icon"),u(2,"folder_open"),c()()}if(i&2){let t=h();J("has-files",t.fileCount>0),w("title",Ys("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function Lg(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){x(t);let r=h();return T(r.toggleSharePanel())}),l(1,"mat-icon"),u(2,"group"),c()()}if(i&2){let t=h();J("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function jg(i,e){if(i&1&&(l(0,"div",6),u(1),c()),i&2){let t=h();p(),Jn(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function Vg(i,e){if(i&1&&(l(0,"div",22),u(1),c()),i&2){let t=h();J("error",t.uploadStatus.isError),p(),Oe(" ",t.uploadStatus.message," ")}}function zg(i,e){if(i&1){let t=O();l(0,"app-chat-textarea",23),v("messageSubmitted",function(r){x(t);let o=h();return T(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){x(t);let o=h();return T(o.onVoiceToggled(r))})("heightChanged",function(r){x(t);let o=h();return T(o.onInputHeightChanged(r))})("stopRequested",function(){x(t);let r=h();return T(r.onStopRequested())})("filesPasted",function(r){x(t);let o=h();return T(o.onFilesPasted(r))}),c()}if(i&2){let t=h();w("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function $g(i,e){if(i&1){let t=O();l(0,"app-choice-select",24),v("choiceSelected",function(r){x(t);let o=h();return T(o.onChoiceSelected(r))}),c()}if(i&2){let t=h();w("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function Hg(i,e){i&1&&R(0,"app-oauth-request-panel")}function Ug(i,e){if(i&1){let t=O();l(0,"app-file-exchange-drawer",25),v("closeDrawer",function(){x(t);let r=h();return T(r.closeDrawer())}),c()}if(i&2){let t=h();w("projectName",t.projectName)("threadId",t.threadId)}}function Bg(i,e){if(i&1){let t=O();l(0,"app-thread-share",26),v("userAdded",function(r){x(t);let o=h();return T(o.onUserAdded(r))})("userRemoved",function(r){x(t);let o=h();return T(o.onUserRemoved(r))})("closed",function(){x(t);let r=h();return T(r.closeDrawer())}),c()}if(i&2){let t=h();w("threadId",t.threadId)("users",t.threadDetails.users||_r(3,Ng))("currentUsername",t.currentUsername)}}function qg(i,e){i&1&&(l(0,"div",19)(1,"div",27)(2,"div",28),u(3,"\u{1F4CE}"),c(),l(4,"div",29),u(5,"Drop files here to upload"),c(),l(6,"div",30),u(7,"Images will be added to conversation, other files to exchange space"),c()()())}var Ro=class i{projectName;threadId;chatFocused=new ie;drawerStateChange=new ie;destroy$=new ce;connectionDestroy$=new ce;inputSection;messages=[];streamingText="";isThinking=!1;currentChoice=null;connectionStatus=null;isConnected=!1;showConnectionStatus=!1;hasEverConnected=!1;inputSectionHeight=80;uploadStatus={message:"",isError:!1};isDragOver=!1;drawerMode="none";get isDrawerOpen(){return this.drawerMode!=="none"}threadDetails=null;threadShareRef;get fileCount(){return this.fileExchangeState.fileCount()}currentUsername="";authEnabled=!1;pendingFirstMessage=null;subscriptions=[];codayService=f(pt);oauthService=f(bn);pendingOAuthRequest=Me(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=f(we);titleService=f(Mi);elementRef=f(ln);threadState=f(We);userService=f(Ut);router=f(Nt);imageUploadService=f(Do);fileExchangeState=f(yi);firstMessageState=f(Pi);ngOnInit(){if(console.log("[THREAD] Initializing with project:",this.projectName,"thread:",this.threadId),!this.projectName||!this.threadId){console.error("[THREAD] Missing required inputs: projectName or threadId");return}this.setupPrintHandlers(),this.userService.authEnabled$.pipe(z(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(z(this.destroy$)).subscribe(e=>{this.currentUsername=e??"",this.messages.length>0&&(this.messages=[...this.messages])}),this.initializeThreadConnection()}ngOnChanges(e){console.log("[THREAD] ngOnChanges called",e),e.threadId&&(console.log("[THREAD] threadId changed:",{firstChange:e.threadId.firstChange,previousValue:e.threadId.previousValue,currentValue:e.threadId.currentValue}),e.threadId.firstChange||(console.log("[THREAD] Reconnecting to new thread"),this.initializeThreadConnection()))}initializeThreadConnection(){console.log("[THREAD] Initializing connection for thread:",this.threadId),this.fileExchangeState.initializeForThread(this.projectName,this.threadId),this.connectionDestroy$.next(),this.codayService.messages$.pipe(z(this.connectionDestroy$)).subscribe(t=>{console.log("[THREAD] Messages updated:",t.length),this.messages=t}),this.codayService.streamingText$.pipe(z(this.connectionDestroy$)).subscribe(t=>{this.streamingText=t}),this.codayService.isThinking$.pipe(z(this.connectionDestroy$)).subscribe(t=>{this.isThinking=t}),this.codayService.currentChoice$.pipe(z(this.connectionDestroy$)).subscribe(t=>{this.currentChoice=t}),this.codayService.connectionStatus$.pipe(z(this.connectionDestroy$)).subscribe(t=>{this.connectionStatus=t,this.isConnected=t.connected,t.connected&&!this.hasEverConnected&&(this.hasEverConnected=!0,this.showConnectionStatus=!0),!t.connected&&!this.hasEverConnected?setTimeout(()=>{!this.isConnected&&!this.hasEverConnected&&(this.showConnectionStatus=!0)},2e3):!t.connected&&this.hasEverConnected?this.showConnectionStatus=!0:t.connected&&(this.showConnectionStatus=!0)}),this.codayService.threadUpdateEvent$.pipe(z(this.connectionDestroy$)).subscribe(t=>{t&&(console.log("[THREAD] Thread update event received:",t),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(z(this.connectionDestroy$)).subscribe(t=>{this.threadDetails=t}),this.codayService.resetMessages(),this.codayService.setTabTitleService(this.titleService),console.log("[THREAD] Connecting to thread event stream"),this.codayService.connectToThread(this.projectName,this.threadId);let e=this.firstMessageState.consumePendingFirstMessage();e?(console.log("[THREAD] First message pending:",e.substring(0,50)+"..."),this.pendingFirstMessage=e,this.codayService.setThinkingForPendingMessage(),this.subscribeToFirstInvite()):console.log("[THREAD] No first message found in state service")}ngAfterViewChecked(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&e>0&&(this.inputSectionHeight=e)}}ngOnDestroy(){console.log("[THREAD] Destroying component"),this.connectionDestroy$.next(),this.connectionDestroy$.complete(),this.destroy$.next(),this.destroy$.complete(),this.fileExchangeState.clear(),this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[THREAD] Sending message:",e),this.codayService.sendMessage(e)}onVoiceToggled(e){console.log("[VOICE] Recording:",e)}onChoiceSelected(e){console.log("[THREAD] Choice selected:",e),this.codayService.sendChoice(e)}onCopyMessage(e){console.log("[COPY] Message copied:",e.id)}onStopRequested(){this.threadState.stop()}onInputHeightChanged(e){console.log("[THREAD] Input height changed:",e),this.inputSectionHeight=e}onFilesPasted(e){console.log("[THREAD] File(s) pasted:",e.length);let t=this.imageUploadService.filterImageFiles(e),n=e.filter(r=>!r.type.startsWith("image/"));t.length&&this.uploadFilesSequentially(t,0),n.length&&this.uploadFilesToExchangeSpace(n),!t.length&&!n.length&&this.showUploadError("No supported files found")}emitDrawerState(){this.drawerStateChange.emit(this.isDrawerOpen)}toggleFileDrawer(){this.drawerMode=this.drawerMode==="files"?"none":"files",this.emitDrawerState()}toggleSharePanel(){this.drawerMode=this.drawerMode==="share"?"none":"share",this.emitDrawerState()}closeDrawer(){this.drawerMode="none",this.emitDrawerState()}onUserAdded(e){if(console.log("[THREAD] Adding user to thread:",e),!this.threadDetails)return;let t=this.threadDetails.users||[];if(t.some(r=>r.userId===e)){this.threadShareRef?.setError("User already has access to this thread");return}this.threadShareRef?.setAdding(!0);let n=[...t,{userId:e}];this.threadState.updateThreadUsers(this.threadId,n).pipe(z(this.destroy$)).subscribe({next:()=>{console.log("[THREAD] User added successfully"),this.threadShareRef?.setAdding(!1),this.threadState.refreshSelectedThread()},error:r=>{console.error("[THREAD] Error adding user:",r),this.threadShareRef?.setError(r?.error?.error||"Failed to add user")}})}onUserRemoved(e){if(console.log("[THREAD] Removing user from thread:",e),!this.threadDetails)return;let t=e===this.currentUsername,n=(this.threadDetails.users||[]).filter(r=>r.userId!==e);this.threadState.updateThreadUsers(this.threadId,n).pipe(z(this.destroy$)).subscribe({next:()=>{console.log("[THREAD] User removed successfully"),t?(this.threadState.clearSelection(),this.threadState.refreshThreadList(),this.router.navigate(["project",this.projectName])):this.threadState.refreshSelectedThread()},error:r=>{console.error("[THREAD] Error removing user:",r)}})}onDragEnter(e){e.preventDefault(),e.dataTransfer?.types.includes("Files")&&(console.log("[THREAD] Image files detected - showing drag overlay"),this.isDragOver=!0)}onDragOver(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")}onDragLeave(e){this.elementRef.nativeElement.contains(e.relatedTarget)||(console.log("[THREAD] Leaving component area - hiding drag overlay"),this.isDragOver=!1)}onDrop(e){e.preventDefault(),this.isDragOver=!1,console.log("[THREAD] Files dropped:",e.dataTransfer?.files?.length||0);let t=e.dataTransfer?.files;if(!t||t.length===0){console.log("[THREAD] No files in drop event");return}let n=this.imageUploadService.filterImageFiles(t),r=Array.from(t).filter(o=>!o.type.startsWith("image/"));console.log("[THREAD] Image files:",n.length,"Other files:",r.length),n.length>0&&this.uploadFilesSequentially(n,0),r.length>0&&this.uploadFilesToExchangeSpace(r),n.length===0&&r.length===0&&this.showUploadError("No supported files found")}uploadFilesSequentially(e,t){if(t>=e.length)return;let n=e[t];if(!n){console.error("[THREAD] File at index",t,"is undefined");return}console.log("[THREAD] Uploading file:",n.name),this.uploadStatus={message:`Uploading ${n.name}...`,isError:!1},this.imageUploadService.uploadImage(n,this.projectName,this.threadId).subscribe({next:r=>{r.success?(console.log("[THREAD] Upload successful:",n.name),this.uploadStatus={message:`\u2713 ${n.name} uploaded (${(r.processedSize/1024).toFixed(1)} KB)`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3),this.uploadFilesSequentially(e,t+1)):(console.error("[THREAD] Upload failed:",n.name,r.error),this.showUploadError(`Failed to upload ${n.name}: ${r.error}`))},error:r=>{console.error("[THREAD] Upload error:",n.name,r),this.showUploadError(`Failed to upload ${n.name}: ${r.message||"Unknown error"}`)}})}showUploadError(e){this.uploadStatus={message:e,isError:!0},setTimeout(()=>{this.uploadStatus={message:"",isError:!1}},5e3)}uploadFilesToExchangeSpace(e){return H(this,null,function*(){for(let t of e){console.log("[THREAD] Uploading to exchange space:",t.name),this.uploadStatus={message:`Uploading ${t.name}...`,isError:!1};let n=yield this.fileExchangeState.uploadFile(t);if(n.success)console.log("[THREAD] Upload to exchange space successful:",t.name),this.uploadStatus={message:`\u2713 ${t.name} uploaded to exchange space`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3);else{console.error("[THREAD] Upload to exchange space failed:",t.name,n.error),this.showUploadError(`Failed to upload ${t.name}: ${n.error}`);break}}})}subscribeToFirstInvite(){console.log("[THREAD] Subscribing to wait for InviteEvent"),this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{if(e&&this.pendingFirstMessage){console.log("[THREAD] Received InviteEvent, sending pending message");let t=this.pendingFirstMessage;this.pendingFirstMessage=null,this.codayService.sendMessage(t)}}))}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&tt(Rg,5)(er,5),t&2){let r;je(r=Ve())&&(n.inputSection=r.first),je(r=Ve())&&(n.threadShareRef=r.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[Dt],decls:22,vars:16,consts:[["inputSection",""],[1,"drag-drop-wrapper",3,"dragenter","dragover","dragleave","drop"],[1,"file-drawer-container",3,"hasBackdrop"],[1,"thread-container"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"has-files","matBadge","title"],["matFab","","title","Share thread","type","button",1,"share-toggle-btn",3,"has-shared-users"],[1,"connection-status"],[1,"chat-wrapper",3,"mousedown","touchstart"],[1,"chat-center"],[3,"copyRequested","stopRequested","messages","streamingText","isThinking","currentUsername"],[1,"upload-status",3,"error"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"options","labelHtml","isVisible","allowFreeText"],["mode","side","position","end",3,"closed","opened"],[3,"projectName","threadId"],[3,"threadId","users","currentUsername"],[1,"drag-overlay"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"click","matBadge","title"],["matFab","","title","Share thread","type","button",1,"share-toggle-btn",3,"click"],[1,"upload-status"],[3,"messageSubmitted","voiceRecordingToggled","heightChanged","stopRequested","filesPasted","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"choiceSelected","options","labelHtml","isVisible","allowFreeText"],[3,"closeDrawer","projectName","threadId"],[3,"userAdded","userRemoved","closed","threadId","users","currentUsername"],[1,"drag-overlay-content"],[1,"drag-icon"],[1,"drag-text"],[1,"drag-hint"]],template:function(t,n){t&1&&(l(0,"div",1),v("dragenter",function(o){return n.onDragEnter(o)})("dragover",function(o){return n.onDragOver(o)})("dragleave",function(o){return n.onDragLeave(o)})("drop",function(o){return n.onDrop(o)}),l(1,"mat-drawer-container",2)(2,"mat-drawer-content")(3,"div",3),C(4,Fg,3,5,"button",4),C(5,Lg,3,2,"button",5),C(6,jg,2,2,"div",6),l(7,"div",7),v("mousedown",function(){return n.chatFocused.emit()})("touchstart",function(){return n.chatFocused.emit()}),l(8,"div",8)(9,"app-chat-history",9),v("copyRequested",function(o){return n.onCopyMessage(o)})("stopRequested",function(){return n.onStopRequested()}),c(),C(10,Vg,2,3,"div",10),c()(),l(11,"div",11,0)(13,"div",12)(14,"div",13),C(15,zg,1,5,"app-chat-textarea",14),C(16,$g,1,4,"app-choice-select",15),C(17,Hg,1,0,"app-oauth-request-panel"),c()()()()(),l(18,"mat-drawer",16),v("closed",function(){return n.closeDrawer()}),C(19,Ug,1,2,"app-file-exchange-drawer",17),C(20,Bg,1,4,"app-thread-share",18),c()(),C(21,qg,8,0,"div",19),c()),t&2&&(p(),w("hasBackdrop",!1),p(3),S(n.drawerMode!=="files"?4:-1),p(),S(n.authEnabled&&n.drawerMode!=="share"?5:-1),p(),S(n.showConnectionStatus&&n.connectionStatus&&!n.connectionStatus.connected?6:-1),p(3),w("messages",n.messages)("streamingText",n.streamingText)("isThinking",n.isThinking)("currentUsername",n.currentUsername),p(),S(n.uploadStatus.message?10:-1),p(5),S(!n.currentChoice&&!n.pendingOAuthRequest()?15:-1),p(),S(n.currentChoice?16:-1),p(),S(n.pendingOAuthRequest()?17:-1),p(),w("opened",n.isDrawerOpen),p(),S(n.drawerMode==="files"?19:-1),p(),S(n.drawerMode==="share"&&n.threadDetails?20:-1),p(),S(n.isDragOver?21:-1))},dependencies:[bo,mi,vo,Co,Oo,er,Ir,Cl,Sl,yl,Te,ae,qe,wr,tp,ep],styles:[".drag-drop-wrapper[_ngcontent-%COMP%]{height:100vh;height:100dvh;width:100%;position:relative}.thread-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;width:100%;position:relative;background:transparent}.file-drawer-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;top:1rem!important;right:1rem!important;z-index:100!important}.file-drawer-toggle-btn.has-files[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse-subtle 3s infinite}@media(max-width:768px){.file-drawer-toggle-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;top:.75rem!important;right:.75rem!important}.file-drawer-toggle-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}.share-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;top:5rem!important;right:1rem!important;z-index:100!important}.share-toggle-btn.has-shared-users[_ngcontent-%COMP%]{color:var(--color-primary)!important}@media(max-width:768px){.share-toggle-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;top:calc(1.25rem + 40px)!important;right:.75rem!important}.share-toggle-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}@keyframes _ngcontent-%COMP%_pulse-subtle{0%,to{box-shadow:0 2px 8px #00000026}50%{box-shadow:0 4px 16px rgba(var(--color-primary-rgb, 25, 118, 210),.3)}}.file-drawer-container[_ngcontent-%COMP%]{height:100dvh;width:100%;background:var(--color-bg)}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-content{display:flex;flex-direction:column;height:100%;overflow:hidden;background:transparent}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:35%;min-width:280px;max-width:480px;box-shadow:-2px 0 8px #0000001a}@media(max-width:768px){.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:100%;max-width:100%;padding-bottom:env(safe-area-inset-bottom,0px)}}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-backdrop{display:none}.connection-status[_ngcontent-%COMP%]{position:fixed;top:0;left:0;right:0;z-index:1000;background:var(--color-warning);color:var(--color-text);padding:.5rem 1rem;text-align:center;font-size:.9rem;box-shadow:0 2px 4px #0000001a}.chat-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;width:100%;padding:1rem 0}.chat-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 2rem;display:flex;flex-direction:column;gap:1rem}@media(max-width:768px){.chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-section[_ngcontent-%COMP%]{width:100%;padding:1rem 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom,0px));background:transparent;position:relative}.input-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 2rem}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.choice-overlay[_ngcontent-%COMP%]{display:block;width:100%}.upload-status[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:8px;background:var(--color-success-light);color:var(--color-text);font-size:.9rem;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:var(--color-error-light)}@media print{.file-drawer-toggle-btn[_ngcontent-%COMP%], .share-toggle-btn[_ngcontent-%COMP%], .connection-status[_ngcontent-%COMP%]{display:none}.thread-container[_ngcontent-%COMP%]{background:#fff}.input-section[_ngcontent-%COMP%]{display:none}}"]})};var No=class i{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,n){t&1&&(dn(0,"h1",0),u(1),pn()),t&2&&(p(),F(n.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var np=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Jt({type:i});static \u0275inj=Xt({imports:[mn]})}return i})();var ip=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Jt({type:i});static \u0275inj=Xt({imports:[mn]})}return i})();var ki=class i{currentThemeSubject=new q("light");currentTheme$=this.currentThemeSubject.asObservable();preferences=f(we);subscription=null;constructor(){console.log("[THEME] Initializing theme service"),this.initializeTheme(),this.setupSystemThemeListener()}ngOnDestroy(){this.subscription?.unsubscribe()}initializeTheme(){this.subscription=this.preferences.theme$.subscribe(e=>{console.log("[THEME] Theme preference changed to:",e),this.applyTheme(e)})}setTheme(e){this.preferences.setPreference("theme",e),this.applyTheme(e)}getCurrentTheme(){return this.currentThemeSubject.value}applyTheme(e){if(console.log("[THEME] Applying theme:",e),this.currentThemeSubject.next(e),e==="system")if(typeof window<"u"&&window.matchMedia){let n=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";console.log("[THEME] System theme resolved to:",n),this.setDocumentTheme(n)}else console.log("[THEME] matchMedia not available, defaulting to light theme"),this.setDocumentTheme("light");else this.setDocumentTheme(e)}setDocumentTheme(e){console.log("[THEME] Setting document theme to:",e),typeof document<"u"&&document.documentElement&&(e==="dark"?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.removeAttribute("data-theme"))}setupSystemThemeListener(){typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{this.getCurrentTheme()==="system"&&this.setDocumentTheme(e.matches?"dark":"light")})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var Wg=(i,e)=>e.code,Gg=(i,e)=>e.name+e.lang;function Yg(i,e){i&1&&(l(0,"div",15)(1,"mat-icon",32),u(2,"warning"),c(),l(3,"span",33),u(4," Browser notifications have been blocked. To enable them, please reset the site permissions in your browser settings. "),c()())}function Qg(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;w("value",t.code),p(),Jn("",t.flag," ",t.label)}}function Kg(i,e){i&1&&(l(0,"option",25),u(1,"Loading voices..."),c())}function Xg(i,e){i&1&&(l(0,"option",25),u(1,"No voice available"),c())}function Jg(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;w("value",t.name+"|"+t.lang),p(),Oe(" ",t.displayName," ")}}var tr=class i{destroy$=new ce;selectedTheme="light";selectedVoiceLanguage="en-US";useEnterToSend=!1;printTechnicalMessages=!1;showTechnicalMessages=!0;showWarningMessages=!0;voiceAnnounceEnabled=!1;voiceMode="speech";voiceReadFullText=!1;voiceVolume=80;voiceRate=120;agentNotificationEnabled=!1;notificationSoundEnabled=!0;browserNotificationEnabled=!1;browserNotificationDenied=!1;availableVoices=[];selectedVoiceId=null;loadingVoices=!1;voiceLanguageOptions=[{code:"fr-FR",label:"Fran\xE7ais",flag:"\u{1F1EB}\u{1F1F7}"},{code:"en-US",label:"English (US)",flag:"\u{1F1FA}\u{1F1F8}"},{code:"en-GB",label:"English (UK)",flag:"\u{1F1EC}\u{1F1E7}"},{code:"es-ES",label:"Espa\xF1ol",flag:"\u{1F1EA}\u{1F1F8}"},{code:"de-DE",label:"Deutsch",flag:"\u{1F1E9}\u{1F1EA}"},{code:"it-IT",label:"Italiano",flag:"\u{1F1EE}\u{1F1F9}"},{code:"pt-BR",label:"Portugu\xEAs",flag:"\u{1F1E7}\u{1F1F7}"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E",flag:"\u{1F1EF}\u{1F1F5}"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4",flag:"\u{1F1F0}\u{1F1F7}"},{code:"zh-CN",label:"\u4E2D\u6587 (\u7B80\u4F53)",flag:"\u{1F1E8}\u{1F1F3}"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",flag:"\u{1F1F7}\u{1F1FA}"},{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",flag:"\u{1F1F8}\u{1F1E6}"}];preferencesService=f(we);voiceSynthesisService=f(bi);themeService=f(ki);ngOnInit(){this.selectedTheme=this.themeService.getCurrentTheme(),this.selectedVoiceLanguage=this.preferencesService.getVoiceLanguage(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.printTechnicalMessages=this.preferencesService.getPrintTechnicalMessages(),this.showTechnicalMessages=!this.preferencesService.getHideTechnicalMessages(),this.showWarningMessages=!this.preferencesService.getHideWarningMessages(),this.voiceAnnounceEnabled=this.preferencesService.getVoiceAnnounceEnabled(),this.voiceMode=this.preferencesService.getVoiceMode(),this.voiceReadFullText=this.preferencesService.getVoiceReadFullText(),this.voiceVolume=Math.round(this.preferencesService.getVoiceVolume()*100),this.voiceRate=Math.round(this.preferencesService.getVoiceRate()*100),this.selectedVoiceId=this.preferencesService.getSelectedVoice(),this.agentNotificationEnabled=this.preferencesService.getAgentNotificationEnabled(),this.notificationSoundEnabled=this.preferencesService.getNotificationSoundEnabled(),this.browserNotificationEnabled=this.preferencesService.getBrowserNotificationEnabled(),this.loadAvailableVoices(),this.themeService.currentTheme$.pipe(z(this.destroy$)).subscribe(e=>{this.selectedTheme=e}),this.preferencesService.voiceLanguage$.pipe(z(this.destroy$)).subscribe(e=>{this.selectedVoiceLanguage=e}),this.preferencesService.enterToSend$.pipe(z(this.destroy$)).subscribe(e=>{this.useEnterToSend=e}),this.preferencesService.printTechnicalMessages$.pipe(z(this.destroy$)).subscribe(e=>{this.printTechnicalMessages=e}),this.preferencesService.hideTechnicalMessages$.pipe(z(this.destroy$)).subscribe(e=>{this.showTechnicalMessages=!e}),this.preferencesService.hideWarningMessages$.pipe(z(this.destroy$)).subscribe(e=>{this.showWarningMessages=!e}),this.preferencesService.voiceAnnounceEnabled$.pipe(z(this.destroy$)).subscribe(e=>{this.voiceAnnounceEnabled=e}),this.preferencesService.voiceMode$.pipe(z(this.destroy$)).subscribe(e=>{this.voiceMode=e}),this.preferencesService.voiceReadFullText$.pipe(z(this.destroy$)).subscribe(e=>{this.voiceReadFullText=e}),this.preferencesService.voiceVolume$.pipe(z(this.destroy$)).subscribe(e=>{this.voiceVolume=Math.round(e*100)}),this.preferencesService.voiceRate$.pipe(z(this.destroy$)).subscribe(e=>{this.voiceRate=Math.round(e*100)}),this.preferencesService.selectedVoice$.pipe(z(this.destroy$)).subscribe(e=>{this.selectedVoiceId=e}),this.preferencesService.voiceLanguage$.pipe(z(this.destroy$)).subscribe(()=>{this.loadAvailableVoices()}),this.preferencesService.agentNotificationEnabled$.pipe(z(this.destroy$)).subscribe(e=>{this.agentNotificationEnabled=e}),this.preferencesService.notificationSoundEnabled$.pipe(z(this.destroy$)).subscribe(e=>{this.notificationSoundEnabled=e}),this.preferencesService.browserNotificationEnabled$.pipe(z(this.destroy$)).subscribe(e=>{this.browserNotificationEnabled=e,this.checkNotificationPermission()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}onThemeChange(){console.log("[OPTIONS] Theme changed to:",this.selectedTheme),this.themeService.setTheme(this.selectedTheme)}onVoiceLanguageChange(){console.log("[OPTIONS] Voice language changed to:",this.selectedVoiceLanguage),this.preferencesService.setVoiceLanguage(this.selectedVoiceLanguage)}onEnterToSendChange(){console.log("[OPTIONS] Enter to send changed to:",this.useEnterToSend),this.preferencesService.setEnterToSend(this.useEnterToSend)}onPrintTechnicalMessagesChange(){console.log("[OPTIONS] Print technical messages changed to:",this.printTechnicalMessages),this.preferencesService.setPrintTechnicalMessages(this.printTechnicalMessages)}onShowTechnicalMessagesChange(){let e=!this.showTechnicalMessages;console.log("[OPTIONS] Show technical messages changed to:",this.showTechnicalMessages,"(hide:",e,")"),this.preferencesService.setHideTechnicalMessages(e)}onShowWarningMessagesChange(){let e=!this.showWarningMessages;console.log("[OPTIONS] Show warning messages changed to:",this.showWarningMessages,"(hide:",e,")"),this.preferencesService.setHideWarningMessages(e)}onVoiceAnnounceEnabledChange(){console.log("[OPTIONS] Voice announce enabled changed to:",this.voiceAnnounceEnabled),this.preferencesService.setVoiceAnnounceEnabled(this.voiceAnnounceEnabled)}onVoiceModeChange(){console.log("[OPTIONS] Voice mode changed to:",this.voiceMode),this.preferencesService.setVoiceMode(this.voiceMode)}onVoiceReadFullTextChange(){console.log("[OPTIONS] Voice read full text changed to:",this.voiceReadFullText),this.preferencesService.setVoiceReadFullText(this.voiceReadFullText)}onVoiceVolumeChange(){let e=this.voiceVolume/100;console.log("[OPTIONS] Voice volume changed to:",e),this.preferencesService.setVoiceVolume(e)}onVoiceRateChange(){let e=this.voiceRate/100;console.log("[OPTIONS] Voice rate changed to:",e),this.preferencesService.setVoiceRate(e)}loadAvailableVoices(){return H(this,null,function*(){this.loadingVoices=!0;try{this.availableVoices=yield this.voiceSynthesisService.getVoicesForLanguage(),console.log("[OPTIONS] Loaded",this.availableVoices.length,"voices for current language")}catch(e){console.error("[OPTIONS] Error loading voices:",e),this.availableVoices=[]}finally{this.loadingVoices=!1}})}onSelectedVoiceChange(){console.log("[OPTIONS] Selected voice changed to:",this.selectedVoiceId),this.preferencesService.setSelectedVoice(this.selectedVoiceId)}testVoice(){console.log("[OPTIONS] Testing voice with current settings"),this.voiceSynthesisService.testSelectedVoice()}onAgentNotificationEnabledChange(){console.log("[OPTIONS] Agent notification enabled changed to:",this.agentNotificationEnabled),this.preferencesService.setAgentNotificationEnabled(this.agentNotificationEnabled)}onNotificationSoundEnabledChange(){console.log("[OPTIONS] Notification sound enabled changed to:",this.notificationSoundEnabled),this.preferencesService.setNotificationSoundEnabled(this.notificationSoundEnabled)}onBrowserNotificationEnabledChange(){console.log("[OPTIONS] Browser notification enabled changed to:",this.browserNotificationEnabled),this.preferencesService.setBrowserNotificationEnabled(this.browserNotificationEnabled)}checkNotificationPermission(){"Notification"in window&&(this.browserNotificationDenied=Notification.permission==="denied",console.log("[OPTIONS] Notification permission status:",Notification.permission))}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-options-panel"]],decls:144,vars:35,consts:[[1,"options-content"],[1,"option-section"],[1,"section-title"],[1,"option-group"],[1,"radio-group"],[1,"option-radio"],["type","radio","name","theme","value","light",3,"ngModelChange","change","ngModel"],[1,"radio-mark"],["type","radio","name","theme","value","dark",3,"ngModelChange","change","ngModel"],["type","radio","name","theme","value","system",3,"ngModelChange","change","ngModel"],[1,"option-label"],["type","radio","name","enterBehavior",3,"ngModelChange","change","value","ngModel"],[1,"toggle-option"],["color","primary",3,"ngModelChange","change","ngModel"],["color","primary",3,"ngModelChange","change","ngModel","disabled"],[1,"notification-error"],["for","voice-language-select",1,"option-label"],["id","voice-language-select",1,"option-select",3,"ngModelChange","change","ngModel"],[3,"value"],["type","radio","name","voiceAnnounce",3,"ngModelChange","change","value","ngModel"],["type","radio","name","voiceMode","value","speech",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceMode","value","notification",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceReadFull",3,"ngModelChange","change","value","ngModel"],["for","voice-select",1,"option-label"],["id","voice-select",1,"option-select",3,"ngModelChange","change","ngModel","disabled"],["value",""],["role","button","tabindex","0","title","Test voice with current settings",1,"test-voice-link",3,"click"],[1,"thread-name"],["for","voice-volume-slider",1,"option-label"],["id","voice-volume-slider","type","range","min","0","max","100","step","5",1,"option-slider",3,"ngModelChange","input","ngModel"],["for","voice-rate-slider",1,"option-label"],["id","voice-rate-slider","type","range","min","50","max","200","step","10",1,"option-slider",3,"ngModelChange","input","ngModel"],[1,"error-icon"],[1,"error-message"]],template:function(t,n){t&1&&(l(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),u(4,"palette"),c(),l(5,"span"),u(6,"Appearance"),c()(),l(7,"div",3)(8,"div",4)(9,"label",5)(10,"input",6),te("ngModelChange",function(o){return ee(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),R(11,"span",7),u(12," Light "),c(),l(13,"label",5)(14,"input",8),te("ngModelChange",function(o){return ee(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),R(15,"span",7),u(16," Dark "),c(),l(17,"label",5)(18,"input",9),te("ngModelChange",function(o){return ee(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),R(19,"span",7),u(20," System "),c()()()(),l(21,"div",1)(22,"div",2)(23,"mat-icon"),u(24,"chat_bubble_outline"),c(),l(25,"span"),u(26,"Messaging"),c()(),l(27,"div",3)(28,"span",10),u(29,"Send message behavior:"),c(),l(30,"div",4)(31,"label",5)(32,"input",11),te("ngModelChange",function(o){return ee(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),R(33,"span",7),u(34," Enter to send "),c(),l(35,"label",5)(36,"input",11),te("ngModelChange",function(o){return ee(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),R(37,"span",7),u(38," Enter for new line "),c()()(),l(39,"div",3)(40,"div",12)(41,"span",10),u(42,"Show technical messages"),c(),l(43,"mat-slide-toggle",13),te("ngModelChange",function(o){return ee(n.showTechnicalMessages,o)||(n.showTechnicalMessages=o),o}),v("change",function(){return n.onShowTechnicalMessagesChange()}),c()()(),l(44,"div",3)(45,"div",12)(46,"span",10),u(47,"Show warning messages"),c(),l(48,"mat-slide-toggle",13),te("ngModelChange",function(o){return ee(n.showWarningMessages,o)||(n.showWarningMessages=o),o}),v("change",function(){return n.onShowWarningMessagesChange()}),c()()(),l(49,"div",3)(50,"div",12)(51,"span",10),u(52,"Include technical messages in print"),c(),l(53,"mat-slide-toggle",13),te("ngModelChange",function(o){return ee(n.printTechnicalMessages,o)||(n.printTechnicalMessages=o),o}),v("change",function(){return n.onPrintTechnicalMessagesChange()}),c()()()(),l(54,"div",1)(55,"div",2)(56,"mat-icon"),u(57,"notifications"),c(),l(58,"span"),u(59,"Notifications"),c()(),l(60,"div",3)(61,"div",12)(62,"span",10),u(63,"Notify when the agent answers or requests input"),c(),l(64,"mat-slide-toggle",13),te("ngModelChange",function(o){return ee(n.agentNotificationEnabled,o)||(n.agentNotificationEnabled=o),o}),v("change",function(){return n.onAgentNotificationEnabledChange()}),c()()(),l(65,"div",3)(66,"div",12)(67,"span",10),u(68,"Notification sound"),c(),l(69,"mat-slide-toggle",14),te("ngModelChange",function(o){return ee(n.notificationSoundEnabled,o)||(n.notificationSoundEnabled=o),o}),v("change",function(){return n.onNotificationSoundEnabledChange()}),c()()(),l(70,"div",3)(71,"div",12)(72,"span",10),u(73,"Browser notification"),c(),l(74,"mat-slide-toggle",14),te("ngModelChange",function(o){return ee(n.browserNotificationEnabled,o)||(n.browserNotificationEnabled=o),o}),v("change",function(){return n.onBrowserNotificationEnabledChange()}),c()(),C(75,Yg,5,0,"div",15),c()(),l(76,"div",1)(77,"div",2)(78,"mat-icon"),u(79,"record_voice_over"),c(),l(80,"span"),u(81,"Voice & Speech"),c()(),l(82,"div",3)(83,"label",16),u(84,"Voice recognition language:"),c(),l(85,"select",17),te("ngModelChange",function(o){return ee(n.selectedVoiceLanguage,o)||(n.selectedVoiceLanguage=o),o}),v("change",function(){return n.onVoiceLanguageChange()}),Ce(86,Qg,2,3,"option",18,Wg),c()(),l(88,"div",3)(89,"span",10),u(90,"Automatic announcement:"),c(),l(91,"div",4)(92,"label",5)(93,"input",19),te("ngModelChange",function(o){return ee(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),R(94,"span",7),u(95," Enabled "),c(),l(96,"label",5)(97,"input",19),te("ngModelChange",function(o){return ee(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),R(98,"span",7),u(99," Disabled "),c()()(),l(100,"div",3)(101,"span",10),u(102,"Voice mode:"),c(),l(103,"div",4)(104,"label",5)(105,"input",20),te("ngModelChange",function(o){return ee(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),R(106,"span",7),u(107," Voice synthesis "),c(),l(108,"label",5)(109,"input",21),te("ngModelChange",function(o){return ee(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),R(110,"span",7),u(111," Sound notification "),c()()(),l(112,"div",3)(113,"span",10),u(114,"Message reading:"),c(),l(115,"div",4)(116,"label",5)(117,"input",22),te("ngModelChange",function(o){return ee(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),R(118,"span",7),u(119," Full message "),c(),l(120,"label",5)(121,"input",22),te("ngModelChange",function(o){return ee(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),R(122,"span",7),u(123," First paragraphs only "),c()()(),l(124,"div",3)(125,"label",23),u(126,"Selected voice:"),c(),l(127,"select",24),te("ngModelChange",function(o){return ee(n.selectedVoiceId,o)||(n.selectedVoiceId=o),o}),v("change",function(){return n.onSelectedVoiceChange()}),C(128,Kg,2,0,"option",25),C(129,Xg,2,0,"option",25),Ce(130,Jg,2,2,"option",18,Gg),c(),R(132,"div",10),l(133,"a",26),v("click",function(){return n.testVoice()}),l(134,"span",27),u(135,"Test voice"),c()()(),l(136,"div",3)(137,"label",28),u(138),c(),l(139,"input",29),te("ngModelChange",function(o){return ee(n.voiceVolume,o)||(n.voiceVolume=o),o}),v("input",function(){return n.onVoiceVolumeChange()}),c()(),l(140,"div",3)(141,"label",30),u(142),c(),l(143,"input",31),te("ngModelChange",function(o){return ee(n.voiceRate,o)||(n.voiceRate=o),o}),v("input",function(){return n.onVoiceRateChange()}),c()()()()),t&2&&(p(10),Z("ngModel",n.selectedTheme),p(4),Z("ngModel",n.selectedTheme),p(4),Z("ngModel",n.selectedTheme),p(14),w("value",!0),Z("ngModel",n.useEnterToSend),p(4),w("value",!1),Z("ngModel",n.useEnterToSend),p(7),Z("ngModel",n.showTechnicalMessages),p(5),Z("ngModel",n.showWarningMessages),p(5),Z("ngModel",n.printTechnicalMessages),p(11),Z("ngModel",n.agentNotificationEnabled),p(5),Z("ngModel",n.notificationSoundEnabled),w("disabled",!n.agentNotificationEnabled),p(5),Z("ngModel",n.browserNotificationEnabled),w("disabled",!n.agentNotificationEnabled||n.browserNotificationDenied),p(),S(n.browserNotificationDenied?75:-1),p(10),Z("ngModel",n.selectedVoiceLanguage),p(),Se(n.voiceLanguageOptions),p(7),w("value",!0),Z("ngModel",n.voiceAnnounceEnabled),p(4),w("value",!1),Z("ngModel",n.voiceAnnounceEnabled),p(8),Z("ngModel",n.voiceMode),p(4),Z("ngModel",n.voiceMode),p(8),w("value",!0),Z("ngModel",n.voiceReadFullText),p(4),w("value",!1),Z("ngModel",n.voiceReadFullText),p(6),Z("ngModel",n.selectedVoiceId),w("disabled",n.loadingVoices||n.availableVoices.length===0),p(),S(n.loadingVoices?128:-1),p(),S(!n.loadingVoices&&n.availableVoices.length===0?129:-1),p(),Se(n.availableVoices),p(8),Oe("Volume: ",n.voiceVolume,"%"),p(),Z("ngModel",n.voiceVolume),p(3),Oe("Speed: ",n.voiceRate,"%"),p(),Z("ngModel",n.voiceRate))},dependencies:[st,Ol,Al,ht,Pl,kl,Ml,ot,at,ae,Bl],styles:['.options-content[_ngcontent-%COMP%]{padding:0;width:100%}.option-group[_ngcontent-%COMP%]{padding:0 1rem 1rem;margin-bottom:1rem;border-bottom:1px solid var(--color-border-light)}.option-group[_ngcontent-%COMP%]:last-child{margin-bottom:0;padding-bottom:0;border-bottom:none}.option-label[_ngcontent-%COMP%]{display:block;margin-bottom:.5rem;font-weight:500;color:var(--color-text);font-size:.875rem}.toggle-option[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:1rem}.toggle-option[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0;flex:1}.toggle-option[_ngcontent-%COMP%] mat-slide-toggle[_ngcontent-%COMP%]{flex-shrink:0}.option-select[_ngcontent-%COMP%]{width:100%;padding:.5rem;border:1px solid var(--color-border);border-radius:4px;background:var(--color-input-bg);color:var(--color-text);font-size:.875rem;cursor:pointer}.option-select[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #7064fb1a}.option-select[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.option-select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]{padding:.5rem}.option-checkbox[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{display:none}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]{width:18px;height:18px;border:2px solid var(--color-border);border-radius:3px;margin-right:.75rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]:after{content:"";width:10px;height:6px;border-left:2px solid transparent;border-bottom:2px solid transparent;transform:rotate(-45deg);transition:all .2s ease;opacity:0}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]{background-color:var(--color-primary);border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]:after{border-left-color:#fff;border-bottom-color:#fff;opacity:1}.option-checkbox[_ngcontent-%COMP%]:hover .checkmark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%]:focus-within .checkmark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-section[_ngcontent-%COMP%]{padding-top:1rem;margin-top:1rem;border-top:2px solid var(--color-border)}.option-section[_ngcontent-%COMP%]:first-child{border-top:none;padding-top:0;margin-top:0}.section-title[_ngcontent-%COMP%]{margin:0 0 1rem;padding:0 1rem;font-size:.9rem;font-weight:600;color:var(--color-text);display:flex;align-items:center;gap:.5rem}.section-title[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.option-radio[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{display:none}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]{width:16px;height:16px;border:2px solid var(--color-border);border-radius:50%;margin-right:.5rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0;position:relative}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;border-radius:50%;background-color:var(--color-primary);transition:all .2s ease;opacity:0;transform:scale(0)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]:after{opacity:1;transform:scale(1)}.option-radio[_ngcontent-%COMP%]:hover .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%]:focus-within .radio-mark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-slider[_ngcontent-%COMP%]{width:100%;height:6px;border-radius:3px;background:var(--color-bg-solid);outline:none;cursor:pointer;-webkit-appearance:none;appearance:none}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-webkit-slider-track{height:6px;border-radius:3px;background:var(--color-bg-secondary)}.option-slider[_ngcontent-%COMP%]::-moz-range-track{height:6px;border-radius:3px;background:var(--color-bg-secondary);border:none}.option-slider[_ngcontent-%COMP%]:focus{outline:none}.option-slider[_ngcontent-%COMP%]:focus::-webkit-slider-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.option-slider[_ngcontent-%COMP%]:focus::-moz-range-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.test-voice-btn[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;background:var(--color-primary);color:#fff;border:none;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;gap:.5rem}.test-voice-btn[_ngcontent-%COMP%]:hover{background:var(--color-primary-hover);transform:translateY(-1px);box-shadow:0 2px 8px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:active{transform:translateY(0);box-shadow:0 1px 4px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:focus{outline:none;box-shadow:0 0 0 3px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:disabled{background:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;transform:none;box-shadow:none}.test-voice-link[_ngcontent-%COMP%]{text-decoration-thickness:1.5px;text-underline-offset:3px;background:transparent;border:none;padding:0;font-size:.775rem;font-weight:400;cursor:pointer;transition:all .2s ease;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;text-decoration:underline}.test-voice-link[_ngcontent-%COMP%]:hover{color:var(--color-primary-hover, var(--color-primary));text-decoration-thickness:2px}.test-voice-link[_ngcontent-%COMP%]:active{opacity:.8}.test-voice-link[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.test-voice-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.notification-error[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;padding:.75rem;margin-top:.75rem;background-color:#d32f2f1a;border:1px solid rgba(211,47,47,.3);border-radius:6px;font-size:.8125rem;line-height:1.5}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#d32f2f;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{color:var(--color-text);flex:1}.notification-error[_ngcontent-%COMP%]{margin-top:.75rem;padding:.75rem;background-color:#f443361a;border:1px solid rgba(244,67,54,.3);border-radius:6px;display:flex;align-items:flex-start;gap:.5rem}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#f44336;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-text);line-height:1.5;flex:1}']})};var Zg=(i,e)=>({subThreads:i,depth:e}),ef=i=>({subThreads:i,depth:1}),rp=(i,e)=>e.id,tf=(i,e)=>e.label;function nf(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){x(t);let o=h().$implicit,a=h(3);return T(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=h().$implicit,n=h(3);p(),F(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function rf(i,e){i&1&&Mn(0)}function of(i,e){if(i&1&&cn(0,rf,1,0,"ng-container",11),i&2){let t=h().$implicit,n=h().depth;h();let r=Pn(1);w("ngTemplateOutlet",r)("ngTemplateOutletContext",Ks(2,Zg,t.subThreads,n+1))}}function af(i,e){if(i&1){let t=O();l(0,"div",5)(1,"a",6),v("click",function(r){let o=x(t).$implicit;return h(3).selectThread(o.id),T(r.preventDefault())})("keydown.enter",function(r){let o=x(t).$implicit;return h(3).selectThread(o.id),T(r.preventDefault())})("keydown.space",function(r){let o=x(t).$implicit;return h(3).selectThread(o.id),T(r.preventDefault())}),C(2,nf,2,1,"mat-icon",7),l(3,"span",8),u(4),c(),l(5,"span",9),u(6),c()()(),C(7,of,1,5,"ng-container")}if(i&2){let t,n=e.$implicit,r=h().depth,o=h(2);yt("--sub-depth",r),J("current",n.id===((t=o.currentThread())==null?null:t.id)),p(2),S(n.subThreads!=null&&n.subThreads.length?2:-1),p(2),F(n.delegatedAgentName||"Agent"),p(2),F(n.delegatedTask||n.name),p(),S(o.isParentExpanded(n.id)&&(n.subThreads!=null&&n.subThreads.length)?7:-1)}}function sf(i,e){if(i&1&&Ce(0,af,8,8,null,null,rp),i&2){let t=e.subThreads;Se(t)}}function lf(i,e){i&1&&(l(0,"div",4),R(1,"span",12),l(2,"span",13),u(3,"Loading threads..."),c()())}function cf(i,e){if(i&1&&(l(0,"div",25),u(1),c()),i&2){let t=h(6);p(),F(t.renameErrorMessage)}}function df(i,e){if(i&1){let t=O();l(0,"div",18)(1,"input",24),te("ngModelChange",function(r){x(t);let o=h(5);return ee(o.editingThreadName,r)||(o.editingThreadName=r),T(r)}),v("keydown",function(r){x(t);let o=h(5);return T(o.onEditKeydown(r))})("blur",function(){x(t);let r=h(5);return T(r.onEditBlur())})("click",function(r){return r.stopPropagation()}),c(),C(2,cf,2,1,"div",25),c()}if(i&2){let t=h(5);p(),Z("ngModel",t.editingThreadName),w("disabled",t.isRenamingThread),p(),S(t.renameErrorMessage?2:-1)}}function pf(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){x(t);let o=h(2).$implicit,a=h(4);return T(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=h(2).$implicit,n=h(4);p(),F(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function mf(i,e){if(i&1&&(l(0,"span",27),u(1),c()),i&2){let t=h(2).$implicit;p(),F(t.name)}}function uf(i,e){i&1&&(R(0,"mat-spinner",29),l(1,"span",30),u(2,"Generating name..."),c()),i&2&&w("diameter",16)}function hf(i,e){i&1&&(l(0,"mat-icon",28),u(1,"group"),c())}function gf(i,e){if(i&1){let t=O();l(0,"a",26),v("click",function(r){x(t);let o=h().$implicit;return h(4).selectThread(o.id),T(r.preventDefault())})("keydown.enter",function(r){x(t);let o=h().$implicit;return h(4).selectThread(o.id),T(r.preventDefault())})("keydown.space",function(r){x(t);let o=h().$implicit;return h(4).selectThread(o.id),T(r.preventDefault())}),C(1,pf,2,1,"mat-icon",7),C(2,mf,2,1,"span",27)(3,uf,3,1),C(4,hf,2,0,"mat-icon",28),c()}if(i&2){let t=h().$implicit,n=h(4);w("matTooltip",t.name?t.name+`
358
+
359
+ `+(t.summary||""):t.summary||"")("matTooltipDisabled",!t.summary),p(),S(t.subThreads!=null&&t.subThreads.length?1:-1),p(),S(t.name?2:3),p(2),S(n.isSharedThread(t)?4:-1)}}function ff(i,e){if(i&1){let t=O();l(0,"button",31),v("click",function(r){x(t);let o=h().$implicit,a=h(4);return T(a.startEditingThreadName(r,o))}),l(1,"mat-icon"),u(2,"edit"),c()()}}function _f(i,e){i&1&&Mn(0)}function bf(i,e){if(i&1&&cn(0,_f,1,0,"ng-container",11),i&2){let t=h().$implicit;h(3);let n=Pn(1);w("ngTemplateOutlet",n)("ngTemplateOutletContext",br(2,ef,t.subThreads))}}function vf(i,e){if(i&1){let t=O();l(0,"div",17),C(1,df,3,3,"div",18)(2,gf,5,5,"a",19),l(3,"div",20),C(4,ff,3,0,"button",21),l(5,"button",22),v("click",function(r){let o=x(t).$implicit,a=h(4);return T(a.toggleStar(r,o))}),l(6,"mat-icon"),u(7),c()(),l(8,"button",23),v("click",function(r){let o=x(t).$implicit,a=h(4);return T(a.deleteThread(r,o))}),l(9,"mat-icon"),u(10,"delete"),c()()()(),C(11,bf,1,4,"ng-container")}if(i&2){let t,n=e.$implicit,r=h(4);J("current",n.id===((t=r.currentThread())==null?null:t.id)),p(),S(r.editingThreadId===n.id?1:2),p(3),S(r.editingThreadId!==n.id&&n.name?4:-1),p(),J("starred",r.isStarred(n)),w("title",r.isStarred(n)?"Unstar thread":"Star thread"),p(2),F(r.isStarred(n)?"star":"star_outline"),p(4),S(r.isParentExpanded(n.id)&&(n.subThreads!=null&&n.subThreads.length)?11:-1)}}function yf(i,e){if(i&1&&(l(0,"div",14)(1,"div",16),u(2),c(),Ce(3,vf,12,9,null,null,rp),c()),i&2){let t=e.$implicit;p(2),F(t.label),p(),Se(t.threads)}}function Cf(i,e){i&1&&(l(0,"div",15),u(1,"No existing threads"),c())}function Sf(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=h(3);p(),Oe('No threads matching "',t.searchQuery(),'"')}}function xf(i,e){if(i&1&&(Ce(0,yf,5,1,"div",14,tf),C(2,Cf,2,0,"div",15)(3,Sf,2,1,"div",15)),i&2){let t,n=h(2);Se(n.getGroupedThreads()),p(2),S(!((t=n.threads())!=null&&t.length)&&!n.searchQuery()?2:n.searchQuery()&&n.getGroupedThreads().length===0?3:-1)}}function Tf(i,e){if(i&1&&(cn(0,sf,2,0,"ng-template",null,0,Zn),l(2,"div",3),C(3,lf,4,0,"div",4)(4,xf,4,1),c()),i&2){let t=h();p(3),S(t.isLoadingThreadList()?3:4)}}function wf(i,e){i&1&&(l(0,"span",32),u(1,"No project selected"),c())}function Ef(i,e){i&1&&(l(0,"span",32),u(1,"Loading..."),c())}function Mf(i,e){if(i&1&&(l(0,"div",2),C(1,wf,2,0,"span",32)(2,Ef,2,0,"span",32),c()),i&2){let t,n=h();p(),S((t=n.currentProject())!=null&&t.name?2:1)}}var Fo=class i{projects=null;searchMode=!1;searchQuery=vr("");searchModeChange=new ie;threadSelected=new ie;projectStateService=f(_e);threadStateService=f(We);threadApiService=f(Ht);userService=f(Ut);router=f(Nt);destroyRef=f(Kn);currentThread=Me(this.threadStateService.selectedThread$);currentProject=Me(this.projectStateService.selectedProject$);threads=Me(this.threadStateService.threadList$);isLoadingThreadList=Me(this.threadStateService.isLoadingThreadList$);username=Me(this.userService.username$);isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0;editingThreadId=null;editingThreadName="";isRenamingThread=!1;renameErrorMessage="";expandedParents=new Set;constructor(){Di(()=>{let e=this.currentThread()?.id,t=this.threads();if(!e||!t?.length)return;let n=new Map;for(let o of t)o.parentThreadId&&n.set(o.id,o.parentThreadId);let r=e;for(;r;){let o=n.get(r);o&&this.expandedParents.add(o),r=o}})}ngOnInit(){this.userService.fetchCurrentUser().subscribe({error:e=>{console.error("[THREAD-SELECTOR] Failed to load current user:",e)}})}selectThread(e){this.threadStateService.selectThread(e),this.threadSelected.emit(),this.router.navigate(["project",this.currentProject()?.name,"thread",e])}getGroupedThreads(){let e=this.threads();if(!e?.length)return[];let t=new Set(e.map(D=>D.id)),n=e.filter(D=>!D.parentThreadId),r=e.filter(D=>!!D.parentThreadId),o=r.filter(D=>!t.has(D.parentThreadId)),a=r.filter(D=>t.has(D.parentThreadId)),s=new Map;for(let D of a){let K=D.parentThreadId;s.has(K)||s.set(K,[]),s.get(K).push(D)}let d=D=>(s.get(D)||[]).sort((B,xe)=>B.modifiedDate>xe.modifiedDate?-1:1).map(B=>he(G({},B),{subThreads:d(B.id)})),m=[...n,...o];if(this.searchQuery()&&this.searchQuery().trim()){let D=this.searchQuery().toLowerCase().trim();m=m.filter(K=>K.name.toLowerCase().includes(D)||K.summary&&K.summary.toLowerCase().includes(D))}if(!m.length)return[];let _=this.username();if(!_)return[];let b=m.map(D=>he(G({},D),{subThreads:d(D.id)})),y=b.filter(D=>D.starring&&D.starring.includes(_)),P=b.filter(D=>!D.starring||!D.starring.includes(_)),E=new Map,k=new Date;k.setHours(0,0,0,0);for(let D of P){let K=new Date(D.modifiedDate);K.setHours(0,0,0,0);let B=k.getTime()-K.getTime(),xe=Math.floor(B/(1e3*60*60*24)),de;xe===0?de="Today":xe===1?de="Yesterday":xe<7?de="This Week":xe<30?de="This Month":xe<90?de="Last 3 Months":de="Older",E.has(de)||E.set(de,[]),E.get(de).push(D)}let Q=[];if(y.length>0){let D=[...y].sort((K,B)=>K.modifiedDate>B.modifiedDate?-1:1);Q.push({label:"Starred",threads:D})}return["Today","Yesterday","This Week","This Month","Last 3 Months","Older"].filter(D=>E.has(D)).forEach(D=>{Q.push({label:D,threads:E.get(D)})}),Q}isParentExpanded(e){return this.expandedParents.has(e)}toggleSubThreads(e,t){e.stopPropagation(),this.expandedParents.has(t)?this.expandedParents.delete(t):this.expandedParents.add(t)}isSubThread(e){return!!e.parentThreadId}isSharedThread(e){return e.users&&e.users.length>1}isStarred(e){let t=this.username();return!!t&&e.starring&&e.starring.includes(t)}toggleStar(e,t){e.stopPropagation();let n=this.username();if(!n)return;let r=t.starring&&t.starring.includes(n),o=r?this.threadApiService.unstarThread(t.id):this.threadApiService.starThread(t.id);this.threadStateService.updateStarLocal(t.id,!r,n),o.pipe(rt(this.destroyRef)).subscribe({next:()=>{},error:a=>{console.error("Error toggling star:",a),this.threadStateService.refreshThreadList()}})}deleteThread(e,t){e.stopPropagation();let n=this.currentProject()?.name;!n||!confirm(`Are you sure you want to delete the thread "${t.name}"?`)||this.threadApiService.deleteThread(t.id).subscribe({next:()=>{this.currentThread()?.id===t.id&&(this.threadStateService.clearSelection(),this.router.navigate(["project",n])),this.threadStateService.refreshThreadList()},error:o=>{console.error("Error deleting thread:",o),alert("Failed to delete thread. Please try again.")}})}formatDate(e){try{let t=new Date(e),r=new Date().getTime()-t.getTime(),o=Math.floor(r/(1e3*60*60*24));return o===0?"Today":o===1?"Yesterday":o<7?`${o} days ago`:t.toLocaleDateString("en-EN",{day:"numeric",month:"short"})}catch(t){return"No date"}}startEditingThreadName(e,t){e.stopPropagation(),this.editingThreadId=t.id,this.editingThreadName=t.name||"",this.renameErrorMessage="",setTimeout(()=>{let n=document.querySelector(".thread-name-input");n&&(n.focus(),n.select())},0)}cancelEditingThreadName(){this.editingThreadId=null,this.editingThreadName="",this.renameErrorMessage=""}saveThreadName(e){if(e&&e.stopPropagation(),!this.editingThreadId)return;let t=this.editingThreadName.trim();if(!t){this.renameErrorMessage="Thread name cannot be empty";return}if(t.length>200){this.renameErrorMessage="Thread name is too long (max 200 characters)";return}let n=this.editingThreadId;this.isRenamingThread=!0,this.renameErrorMessage="",this.threadStateService.renameThread(n,t).subscribe({next:()=>{console.log("[THREAD-SELECTOR] Thread renamed successfully"),this.cancelEditingThreadName(),this.isRenamingThread=!1},error:r=>{console.error("[THREAD-SELECTOR] Error renaming thread:",r),this.renameErrorMessage=r.message||"Failed to rename thread",this.isRenamingThread=!1}})}onEditKeydown(e){e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.saveThreadName()):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.cancelEditingThreadName())}onEditBlur(){setTimeout(()=>{this.editingThreadId&&!this.isRenamingThread&&this.saveThreadName()},200)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-thread-selector"]],inputs:{searchMode:"searchMode",searchQuery:[1,"searchQuery"]},outputs:{searchModeChange:"searchModeChange",threadSelected:"threadSelected"},decls:3,vars:1,consts:[["subThreadTemplate",""],["tabindex","0","role","application","aria-label","Thread selector",1,"thread-selector",3,"click","keydown"],[1,"thread-disabled"],["role","menu","aria-label","Thread selection",1,"thread-list"],[1,"thread-loading"],[1,"thread-item-wrapper","sub-thread"],["role","menuitem","tabindex","0",1,"thread-item","sub-thread-item",3,"click","keydown.enter","keydown.space"],[1,"sub-thread-toggle"],[1,"sub-thread-agent"],[1,"sub-thread-task"],[1,"sub-thread-toggle",3,"click"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"loading-spinner"],[1,"loading-text"],[1,"thread-group"],[1,"thread-empty"],[1,"thread-group-header"],[1,"thread-item-wrapper"],[1,"thread-name-edit-wrapper"],["matTooltipShowDelay","1000","role","menuitem","tabindex","0",1,"thread-item",3,"matTooltip","matTooltipDisabled"],[1,"action-buttons"],["mat-icon-button","","title","Rename thread","type","button",1,"action-button","edit-button"],["mat-icon-button","","type","button",1,"action-button","star-button",3,"click","title"],["mat-icon-button","","title","Delete thread","type","button",1,"action-button","delete-button",3,"click"],["type","text","maxlength","200",1,"thread-name-input",3,"ngModelChange","keydown","blur","click","ngModel","disabled"],[1,"rename-error"],["matTooltipShowDelay","1000","role","menuitem","tabindex","0",1,"thread-item",3,"click","keydown.enter","keydown.space","matTooltip","matTooltipDisabled"],[1,"thread-name"],["matTooltip","Shared thread",1,"shared-indicator"],[1,"thread-name-spinner",3,"diameter"],[1,"thread-name","thread-name-generating"],["mat-icon-button","","title","Rename thread","type","button",1,"action-button","edit-button",3,"click"],[1,"disabled-text"]],template:function(t,n){if(t&1&&(l(0,"div",1),v("click",function(o){return o.stopPropagation()})("keydown",function(o){return o.stopPropagation()}),C(1,Tf,5,1)(2,Mf,3,1,"div",2),c()),t&2){let r;p(),S((r=n.currentProject())!=null&&r.name?1:2)}},dependencies:[xr,st,ht,ot,Il,at,Te,ae,qe,ze,Ll,Fl,fi,gi,Dr,Rl],styles:[".thread-selector[_ngcontent-%COMP%]{display:flex;flex-direction:column;width:100%;flex:1;min-height:0;overflow-x:hidden;overflow-y:auto}.thread-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:0;max-height:none;overflow:visible}.thread-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;margin-bottom:.5rem}.thread-group[_ngcontent-%COMP%]:last-child{margin-bottom:0}.thread-group-header[_ngcontent-%COMP%]{padding:.5rem 1rem .25rem;font-size:.75rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.5px;position:sticky;top:0;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);z-index:1}.thread-item-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;position:relative;width:100%;border-radius:0;min-width:0;gap:.25rem}.thread-item-wrapper[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.thread-item-wrapper[_ngcontent-%COMP%]:hover .action-buttons[_ngcontent-%COMP%]{display:flex}.thread-item-wrapper.current[_ngcontent-%COMP%]{background:var(--color-primary-light)}.thread-item-wrapper.current[_ngcontent-%COMP%] .thread-item[_ngcontent-%COMP%]{color:var(--color-primary-text);font-weight:600}.thread-item[_ngcontent-%COMP%]{display:flex;align-items:center;flex:1;min-width:0;padding:.75rem 1rem;text-decoration:none;cursor:pointer;transition:all .2s ease;background:transparent;border:none;border-radius:0;color:var(--color-text);text-align:left;justify-content:flex-start}.thread-item.new-thread-item[_ngcontent-%COMP%]{margin-bottom:.25rem}.thread-item[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.thread-item[_ngcontent-%COMP%]:focus-visible{outline:2px solid var(--color-primary);outline-offset:-2px}.action-buttons[_ngcontent-%COMP%]{display:none;align-items:center;gap:.25rem;flex-shrink:0;margin-right:.5rem}.thread-item-wrapper[_ngcontent-%COMP%]:hover .action-buttons[_ngcontent-%COMP%], .thread-item-wrapper.current[_ngcontent-%COMP%] .action-buttons[_ngcontent-%COMP%]{display:flex}.action-button[_ngcontent-%COMP%]{flex-shrink:0;border-radius:4px!important;width:28px!important;height:28px!important;padding:0!important}.action-button[_ngcontent-%COMP%] .mat-mdc-button-persistent-ripple{border-radius:4px!important}.action-button[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)!important}.action-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px}.action-button.edit-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px}.action-button.edit-button[_ngcontent-%COMP%]:hover{background-color:var(--color-primary-hover)!important}.action-button.edit-button[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.action-button.star-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{transition:color .2s ease}.action-button.star-button.starred[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#fbbf24}.action-button.star-button[_ngcontent-%COMP%]:not(.starred):hover mat-icon[_ngcontent-%COMP%]{color:#fbbf24}.action-button.delete-button[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{color:#ef4444}.thread-link[_ngcontent-%COMP%]{display:inline-flex;align-items:center;background:transparent;border:none;text-decoration:none;cursor:pointer;transition:all .2s ease;gap:.5rem;font-size:.875rem;font-weight:400;padding:0 1rem;min-width:0}.thread-link[_ngcontent-%COMP%]:hover:not(.new-thread-link){color:var(--color-primary-hover, var(--color-primary));text-decoration:underline;text-decoration-thickness:1.5px;text-underline-offset:3px}.thread-link[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.thread-link.new-thread-link[_ngcontent-%COMP%]{margin-bottom:.5rem;font-weight:600;font-size:.95rem}.thread-link.new-thread-link[_ngcontent-%COMP%] .thread-name[_ngcontent-%COMP%]{background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite}.thread-link.new-thread-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:var(--color-primary);animation:_ngcontent-%COMP%_iconPulse 3s ease-in-out infinite}.thread-link.new-thread-link[_ngcontent-%COMP%]:hover{transform:translate(4px)}.thread-link.new-thread-link[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_iconPulse 1.5s ease-in-out infinite}.thread-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0 center}50%{background-position:100% center}to{background-position:0 center}}@keyframes _ngcontent-%COMP%_iconPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.8;transform:scale(1.05)}}.thread-name[_ngcontent-%COMP%]{flex:1;font-size:.875rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left}.thread-name.thread-name-generating[_ngcontent-%COMP%]{color:var(--color-text-muted);font-style:italic}.thread-name-edit-wrapper[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;padding:0 .5rem}.thread-name-input[_ngcontent-%COMP%]{width:100%;padding:.5rem;border:1px solid var(--color-border);border-radius:4px;background:var(--color-bg-secondary);color:var(--color-text-primary);font-size:.9rem;font-family:inherit}.thread-name-input[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 2px #3b82f61a}.thread-name-input[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.rename-error[_ngcontent-%COMP%]{color:var(--color-error);font-size:.75rem;margin-top:.25rem;padding-left:.5rem}.thread-name-spinner[_ngcontent-%COMP%]{flex-shrink:0;margin-right:.5rem}.thread-name-spinner[_ngcontent-%COMP%] .mat-mdc-progress-spinner circle{stroke:var(--color-primary)!important}.current-indicator[_ngcontent-%COMP%]{color:var(--color-success);font-weight:700;flex-shrink:0;font-size:1rem}.thread-separator[_ngcontent-%COMP%]{height:1px;background:var(--color-border);margin:.25rem 0}.thread-empty[_ngcontent-%COMP%]{padding:1.5rem 1rem;text-align:center;color:var(--color-text-muted);font-size:.8rem;font-style:italic}.thread-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2rem 1rem;gap:.75rem}.thread-loading[_ngcontent-%COMP%] .loading-spinner[_ngcontent-%COMP%]{width:24px;height:24px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}.thread-loading[_ngcontent-%COMP%] .loading-text[_ngcontent-%COMP%]{color:var(--color-text-muted);font-size:.8rem}@keyframes _ngcontent-%COMP%_spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.thread-disabled[_ngcontent-%COMP%]{padding:1.5rem 1rem}.thread-disabled[_ngcontent-%COMP%] .disabled-text[_ngcontent-%COMP%]{display:block;color:var(--color-text-muted);font-size:.85rem;font-style:italic;text-align:center}.thread-item-wrapper.sub-thread[_ngcontent-%COMP%]{padding-left:calc(.2rem + var(--sub-depth, 1) * 1.5rem);border-left:2px solid var(--color-primary, #3b82f6);margin-left:.75rem}.thread-item-wrapper.sub-thread[_ngcontent-%COMP%] .sub-thread-item[_ngcontent-%COMP%]{padding:.35rem .5rem .35rem 0;gap:.2rem;font-size:.8rem;color:var(--color-text-secondary)}.thread-item-wrapper.sub-thread[_ngcontent-%COMP%] .sub-thread-item[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.thread-item-wrapper.sub-thread[_ngcontent-%COMP%] .sub-thread-agent[_ngcontent-%COMP%]{font-weight:600;color:var(--color-primary);white-space:nowrap;flex-shrink:0;font-size:.8rem}.thread-item-wrapper.sub-thread[_ngcontent-%COMP%] .sub-thread-task[_ngcontent-%COMP%]{color:var(--color-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.75rem}.sub-thread-toggle[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px;flex-shrink:0;cursor:pointer;color:var(--color-text-secondary);margin-right:.25rem}.sub-thread-toggle[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.shared-indicator[_ngcontent-%COMP%]{font-size:14px;width:14px;height:14px;color:var(--color-text-secondary);flex-shrink:0;margin-left:.25rem}@media(max-width:768px){.thread-item[_ngcontent-%COMP%]{padding:.6rem .8rem}.thread-name[_ngcontent-%COMP%]{font-size:.8rem}}"]})};var Pf=["logsContent"],kf=(i,e)=>e.name;function Of(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){x(t);let r=h().$implicit,o=h();return T(o.start(r.name))}),l(1,"mat-icon"),u(2,"play_arrow"),c()()}if(i&2){let t=h().$implicit;w("disabled",t.isLoading)}}function Af(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){x(t);let r=h().$implicit,o=h();return T(o.stop(r.name))}),l(1,"mat-icon"),u(2,"stop"),c()()}if(i&2){let t=h().$implicit;w("disabled",t.isLoading)}}function If(i,e){if(i&1&&(l(0,"a",8)(1,"mat-icon",14),u(2,"open_in_new"),c()()),i&2){let t=h().$implicit;w("href",t.url,En)("title",t.url)}}function Df(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=h(),n=t.$implicit,r=t.$index;yt("order",r*2),p(),F(n.errorMessage)}}function Rf(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){x(t);let r=h(3);return T(r.onManualRefresh())}),l(1,"mat-icon"),u(2,"refresh"),c()()}}function Nf(i,e){if(i&1&&(l(0,"div",16)(1,"div",17)(2,"span",18),u(3),c(),C(4,Rf,3,0,"button",19),c(),l(5,"pre",20,0),u(7),c()()),i&2){let t=h(),n=t.$implicit,r=t.$index,o=h();yt("order",r*2+1),p(3),Oe("",n.name," logs"),p(),S(n.status==="running"?4:-1),p(3),F(o.logs()||"(empty)")}}function Ff(i,e){if(i&1){let t=O();l(0,"div",2)(1,"span",3),u(2),c(),l(3,"div",4),C(4,Of,3,1,"button",5)(5,Af,3,1,"button",6),l(6,"span",7),u(7),c(),C(8,If,3,2,"a",8),l(9,"button",9),v("click",function(){let r=x(t).$implicit,o=h();return T(o.toggleLogs(r.name))}),l(10,"mat-icon"),u(11),c()()()(),C(12,Df,2,3,"div",10),C(13,Nf,8,5,"div",11)}if(i&2){let t=e.$implicit,n=e.$index,r=h();yt("order",n*2),p(2),F(t.name),p(2),S(t.status==="stopped"?4:5),p(2),J("running",t.status==="running"),p(),Oe(" ",t.status==="running"?"Running":"Stopped"," "),p(),S(t.url?8:-1),p(),w("title",r.logsOpenFor()===t.name?"Hide logs":"Show logs"),p(2),F(r.logsOpenFor()===t.name?"expand_less":"terminal"),p(),S(t.errorMessage?12:-1),p(),S(r.logsOpenFor()===t.name?13:-1)}}var Lo=class i{destroyRef=f(Kn);projectApi=f(Ar);projectName=vr.required();entryStates=et([]);hasPreview=Ct(()=>this.entryStates().length>0);logsOpenFor=et(null);logs=et("");logsContent;logsPollTimer=null;logsTimeoutTimer=null;static LOGS_POLL_MS=5e3;static LOGS_TIMEOUT_MS=1200*1e3;constructor(){Di(()=>{let e=this.projectName();e&&this.onProjectChanged(e)},{allowSignalWrites:!0}),Di(()=>{console.log("entry states",this.entryStates())})}ngOnDestroy(){this.stopLogPolling()}onProjectChanged(e){this.stopLogPolling(),this.entryStates.set([]),this.logsOpenFor.set(null),this.logs.set(""),this.projectApi.getPreviewEntries(e).pipe(rt(this.destroyRef)).subscribe({next:t=>{let n=t.entries;if(n.length===0)return;let r=n.map(a=>({name:a.name,command:a.command,url:a.url,status:"stopped",isLoading:!1,errorMessage:""}));this.entryStates.set(r);let o=n.map(a=>this.projectApi.getPreviewStatus(e,a.name));Ds(o).pipe(rt(this.destroyRef)).subscribe({next:a=>{this.entryStates.update(s=>s.map((d,m)=>{let _=a[m];return _?he(G({},d),{status:_.status}):d}))},error:()=>{}})},error:()=>{}})}start(e){this.updateEntry(e,{isLoading:!0,errorMessage:""}),this.projectApi.startPreview(this.projectName(),e).pipe(rt(this.destroyRef)).subscribe({next:t=>{this.updateEntry(e,{status:t.status,isLoading:!1})},error:t=>{this.updateEntry(e,{errorMessage:t?.error?.error??"Failed to start preview",isLoading:!1})}})}stop(e){this.updateEntry(e,{isLoading:!0,errorMessage:""}),this.projectApi.stopPreview(this.projectName(),e).pipe(rt(this.destroyRef)).subscribe({next:()=>{this.updateEntry(e,{status:"stopped",isLoading:!1}),this.logsOpenFor()===e&&this.stopLogPolling()},error:t=>{this.updateEntry(e,{errorMessage:t?.error?.error??"Failed to stop preview",isLoading:!1})}})}toggleLogs(e){this.logsOpenFor()===e?(this.logsOpenFor.set(null),this.logs.set(""),this.stopLogPolling()):(this.logsOpenFor.set(e),this.refreshLogs(),this.startLogPolling())}onManualRefresh(){this.refreshLogs(),this.logsPollTimer&&this.resetLogsTimeout()}refreshLogs(){let e=this.logsOpenFor();e&&this.projectApi.getPreviewLogs(this.projectName(),e).pipe(rt(this.destroyRef)).subscribe({next:t=>{this.logs.set(t.logs),this.scrollLogsToBottom()},error:()=>this.logs.set("(failed to load logs)")})}updateEntry(e,t){this.entryStates.update(n=>n.map(r=>r.name===e?G(G({},r),t):r))}startLogPolling(){this.stopLogPolling(),this.logsPollTimer=setInterval(()=>{this.logsOpenFor()?this.refreshLogs():this.stopLogPolling()},i.LOGS_POLL_MS),this.resetLogsTimeout()}stopLogPolling(){this.logsPollTimer&&(clearInterval(this.logsPollTimer),this.logsPollTimer=null),this.logsTimeoutTimer&&(clearTimeout(this.logsTimeoutTimer),this.logsTimeoutTimer=null)}resetLogsTimeout(){this.logsTimeoutTimer&&clearTimeout(this.logsTimeoutTimer),this.logsTimeoutTimer=setTimeout(()=>{this.stopLogPolling()},i.LOGS_TIMEOUT_MS)}scrollLogsToBottom(){setTimeout(()=>{let e=this.logsContent?.nativeElement;e&&(e.scrollTop=e.scrollHeight)})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-preview-panel"]],viewQuery:function(t,n){if(t&1&&tt(Pf,5),t&2){let r;je(r=Ve())&&(n.logsContent=r.first)}},inputs:{projectName:[1,"projectName"]},decls:3,vars:0,consts:[["logsContent",""],[1,"preview-panel"],[1,"entry-row"],[1,"entry-name"],[1,"entry-actions"],["mat-icon-button","","title","Start","type","button",1,"entry-btn","start",3,"disabled"],["mat-icon-button","","title","Stop","type","button",1,"entry-btn","stop",3,"disabled"],[1,"status-pill"],["target","_blank","rel","noopener noreferrer",1,"preview-url",3,"href","title"],["mat-icon-button","","type","button",1,"entry-btn","logs",3,"click","title"],[1,"preview-error",3,"order"],[1,"logs-container",3,"order"],["mat-icon-button","","title","Start","type","button",1,"entry-btn","start",3,"click","disabled"],["mat-icon-button","","title","Stop","type","button",1,"entry-btn","stop",3,"click","disabled"],[1,"link-icon"],[1,"preview-error"],[1,"logs-container"],[1,"logs-header"],[1,"logs-title"],["mat-icon-button","","title","Refresh logs","type","button",1,"entry-btn"],[1,"logs-content"],["mat-icon-button","","title","Refresh logs","type","button",1,"entry-btn",3,"click"]],template:function(t,n){t&1&&(l(0,"div",1),Ce(1,Ff,14,12,null,null,kf),c()),t&2&&(p(),Se(n.entryStates()))},dependencies:[qe,ze,Te,ae],styles:["[_nghost-%COMP%]{display:block}.preview-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;padding:.25rem 0}.entry-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;padding:.125rem .5rem;min-height:36px}.entry-name[_ngcontent-%COMP%]{font-size:.82rem;font-weight:500;color:var(--on-surface, #e0e0e0);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1 1 auto;min-width:0}.entry-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem;flex-shrink:0}.entry-btn[_ngcontent-%COMP%]{width:28px!important;height:28px!important;padding:0!important;display:inline-flex!important;align-items:center;justify-content:center;flex-shrink:0}.entry-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;line-height:18px}.entry-btn.start[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:var(--color-primary)}.entry-btn.stop[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#e53935}.entry-btn.logs[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px;line-height:16px;color:var(--color-text-secondary)}.entry-btn[disabled][_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.status-pill[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:1px 6px;border-radius:12px;font-size:.68rem;font-weight:600;letter-spacing:.02em;flex-shrink:0;min-width:52px;text-align:center;background:var(--color-bg-hover);color:var(--color-text-secondary);border:1px solid var(--color-border)}.status-pill.running[_ngcontent-%COMP%]{background:#22c55e26;color:#16a34a;border-color:#22c55e66}.preview-url[_ngcontent-%COMP%]{display:inline-flex;align-items:center;text-decoration:none;color:var(--color-primary);flex-shrink:0}.preview-url[_ngcontent-%COMP%]:hover{text-decoration:underline}.preview-url[_ngcontent-%COMP%] .link-icon[_ngcontent-%COMP%]{font-size:14px;width:14px;height:14px}.preview-error[_ngcontent-%COMP%]{font-size:.75rem;color:#c00;padding:0 .75rem}.logs-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;margin:.125rem .5rem .25rem;background:var(--color-bg-hover);border-radius:8px;overflow:hidden;border:1px solid var(--color-border)}.logs-header[_ngcontent-%COMP%]{display:flex;align-items:center;padding:.25rem .75rem;border-bottom:1px solid var(--color-border)}.logs-header[_ngcontent-%COMP%] .logs-title[_ngcontent-%COMP%]{flex:1;font-size:.72rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.05em}.logs-content[_ngcontent-%COMP%]{margin:0;padding:.5rem .75rem;font-family:Courier New,Courier,monospace;font-size:.72rem;line-height:1.5;color:var(--color-text);white-space:pre-wrap;word-break:break-all;max-height:200px;overflow-y:auto}.logs-content[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.logs-content[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.logs-content[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-text-secondary);border-radius:3px}"]})};function Lf(i,e){if(i&1&&(l(0,"div",3),u(1),c()),i&2){let t=h();p(),Oe("\u274C ",t.errorMessage)}}var nr=class i{dialogRef=f(Er);data=f(Mr);jsonContent;errorMessage="";title;constructor(){this.jsonContent=this.data.initialContent,this.title=this.data.title||this.getDefaultTitle(this.data.configType,this.data.projectName)}getDefaultTitle(e,t){return e==="user"?"User Configuration":`Project Configuration: ${t||"Unknown"}`}onSave(){this.errorMessage="";let e;try{e=JSON.parse(this.jsonContent)}catch(t){this.errorMessage=`Invalid JSON syntax: ${t instanceof Error?t.message:"Unknown error"}`;return}this.dialogRef.close(e)}onCancel(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-json-editor"]],decls:13,vars:3,consts:[["mat-dialog-title",""],["mat-icon-button","","title","Close",1,"close-button",3,"click"],["spellcheck","false","placeholder","Enter JSON configuration...",1,"json-textarea",3,"ngModelChange","ngModel"],[1,"error-message"],["align","end"],["matButton","",3,"click"],["matButton","filled","color","primary",3,"click"]],template:function(t,n){t&1&&(l(0,"div",0),u(1),l(2,"button",1),v("click",function(){return n.onCancel()}),l(3,"mat-icon"),u(4,"close"),c()()(),l(5,"mat-dialog-content")(6,"textarea",2),te("ngModelChange",function(o){return ee(n.jsonContent,o)||(n.jsonContent=o),o}),c(),C(7,Lf,2,1,"div",3),c(),l(8,"mat-dialog-actions",4)(9,"button",5),v("click",function(){return n.onCancel()}),u(10,"Cancel"),c(),l(11,"button",6),v("click",function(){return n.onSave()}),u(12,"Save"),c()()),t&2&&(p(),Oe(" ",n.title," "),p(5),Z("ngModel",n.jsonContent),p(),S(n.errorMessage?7:-1))},dependencies:[nt,st,ht,ot,at,ae,ze,ei,kr,bl,Or],styles:["[mat-dialog-title][_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}[mat-dialog-title][_ngcontent-%COMP%] .close-button[_ngcontent-%COMP%]{margin-left:auto}mat-dialog-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;min-height:400px}.json-textarea[_ngcontent-%COMP%]{flex:1;min-height:300px;max-height:80vh;padding:1rem;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;font-size:.875rem;line-height:1.5;background:var(--color-code-bg);color:var(--color-text);border:1px solid var(--color-border);border-radius:4px;resize:vertical;outline:none;transition:border-color .2s}.json-textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.json-textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.6}.error-message[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:4px;font-size:.875rem;line-height:1.4;background:#dc26261a;color:#dc2626;border:1px solid rgba(220,38,38,.3)}"]})};var jf=["threadSearchInput"],Vf=["*"];function zf(i,e){if(i&1){let t=O();l(0,"button",26),v("click",function(){x(t);let r=h();return T(r.toggle())}),l(1,"mat-icon"),u(2,"menu"),c()(),l(3,"button",27),v("click",function(){x(t);let r=h();return T(r.createNewThread())}),l(4,"mat-icon",10),u(5,"play_circle"),c()()}if(i&2){let t=h();p(3),w("disabled",!t.selectedProjectName())}}function $f(i,e){if(i&1){let t=O();l(0,"div",14)(1,"mat-icon",28),u(2,"search"),c(),l(3,"input",29,0),te("ngModelChange",function(r){x(t);let o=h();return ee(o.threadSearchQuery,r)||(o.threadSearchQuery=r),T(r)}),v("input",function(){x(t);let r=h();return T(r.onThreadSearchInput())}),c(),l(5,"button",30),v("click",function(){x(t);let r=h();return T(r.closeThreadSearch())}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=h();p(3),Z("ngModel",t.threadSearchQuery)}}function Hf(i,e){if(i&1){let t=O();l(0,"div",15)(1,"mat-icon",22),u(2,"forum"),c(),l(3,"span",23),u(4,"Threads"),c(),l(5,"button",31),v("click",function(r){x(t);let o=h();return T(o.toggleThreadSearch(r))}),l(6,"mat-icon"),u(7,"search"),c()()()}}function Uf(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function Bf(i,e){i&1&&(l(0,"mat-icon",22),u(1,"hub"),c())}function qf(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function Wf(i,e){i&1&&(l(0,"mat-icon",22),u(1,"tune"),c())}function Gf(i,e){i&1&&(l(0,"div",33)(1,"div",37),R(2,"app-options-panel",38),c()())}function Yf(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return x(t),h(3).openProjectConfig(),r.preventDefault(),T(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"settings_applications"),c(),l(4,"span",23),u(5,"Project Configuration"),c()()()}}function Qf(i,e){i&1&&(l(0,"div",32)(1,"a",39)(2,"mat-icon",22),u(3,"settings_applications"),c(),l(4,"span",23),u(5,"Project config (No project)"),c()()())}function Kf(i,e){if(i&1&&C(0,Yf,6,0,"div",32)(1,Qf,6,0,"div",32),i&2){let t=h(2);S(t.selectedProjectName()?0:1)}}function Xf(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return x(t),h(2).openAgents(),r.preventDefault(),T(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"smart_toy"),c(),l(4,"span",23),u(5,"Agents"),c()()()}}function Jf(i,e){i&1&&(l(0,"div",32)(1,"a",39)(2,"mat-icon",22),u(3,"smart_toy"),c(),l(4,"span",23),u(5,"Agents (No project)"),c()()())}function Zf(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return x(t),h(2).openPrompts(),r.preventDefault(),T(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"description"),c(),l(4,"span",23),u(5,"Prompts"),c()()()}}function e0(i,e){i&1&&(l(0,"div",32)(1,"a",39)(2,"mat-icon",22),u(3,"description"),c(),l(4,"span",23),u(5,"Prompts (No project)"),c()()())}function t0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return x(t),h(2).openSchedulers(),r.preventDefault(),T(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"schedule"),c(),l(4,"span",23),u(5,"Schedulers"),c()()()}}function n0(i,e){i&1&&(l(0,"div",32)(1,"a",39)(2,"mat-icon",22),u(3,"schedule"),c(),l(4,"span",23),u(5,"Schedulers (No project)"),c()()())}function i0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function r0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"rocket_launch"),c())}function o0(i,e){if(i&1&&(l(0,"div",33),R(1,"app-preview-panel",40),c()),i&2){let t=h(3);p(),w("projectName",t.selectedProjectName())}}function a0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return x(t),h(2).toggleSection("preview"),r.preventDefault(),T(r.stopPropagation())}),C(2,i0,2,0,"mat-icon",21)(3,r0,2,0,"mat-icon",22),l(4,"span",23),u(5,"Preview Server"),c()(),C(6,o0,2,1,"div",33),c()}if(i&2){let t=h(2);J("expanded",t.expandedSections.preview),p(),J("active",t.expandedSections.preview),p(),S(t.expandedSections.preview?2:3),p(4),S(t.expandedSections.preview?6:-1)}}function s0(i,e){if(i&1){let t=O();l(0,"div",24)(1,"div",32)(2,"a",20),v("click",function(r){return x(t),h().toggleSection("config"),T(r.preventDefault())}),C(3,qf,2,0,"mat-icon",21)(4,Wf,2,0,"mat-icon",22),l(5,"span",23),u(6,"Preferences"),c()(),C(7,Gf,3,0,"div",33),c(),l(8,"div",32)(9,"a",20),v("click",function(r){return x(t),h().openTokenUsage(),r.preventDefault(),T(r.stopPropagation())}),l(10,"mat-icon",22),u(11,"data_usage"),c(),l(12,"span",23),u(13,"Token Usage"),c()()(),l(14,"div",32)(15,"a",20),v("click",function(r){return x(t),h().openUserConfig(),r.preventDefault(),T(r.stopPropagation())}),l(16,"mat-icon",22),u(17,"manage_accounts"),c(),l(18,"span",23),u(19,"User Configuration"),c()()(),C(20,Kf,2,1),C(21,Xf,6,0,"div",32)(22,Jf,6,0,"div",32),C(23,Zf,6,0,"div",32)(24,e0,6,0,"div",32),C(25,t0,6,0,"div",32)(26,n0,6,0,"div",32),C(27,a0,7,6,"div",34),l(28,"div",32)(29,"a",35),R(30,"img",36),l(31,"span",23),u(32,"Contribute on GitHub"),c()()()()}if(i&2){let t=h();p(),J("expanded",t.expandedSections.config),p(),J("active",t.expandedSections.config),p(),S(t.expandedSections.config?3:4),p(4),S(t.expandedSections.config?7:-1),p(13),S(t.isAdmin?20:-1),p(),S(t.selectedProjectName()?21:22),p(2),S(t.selectedProjectName()?23:24),p(2),S(t.selectedProjectName()?25:26),p(2),S(t.hasPreviewConfig()?27:-1),p(3),Re("src","CODAY-Logo.png",En)}}function l0(i,e){if(i&1){let t=O();l(0,"div",25)(1,"mat-icon",41),u(2,"warning"),c(),l(3,"span",42),u(4),c(),l(5,"button",43),v("click",function(){x(t);let r=h();return T(r.configErrorMessage="")}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=h();p(4),F(t.configErrorMessage)}}var ir=class i{destroy$=new ce;sidenavStateChange=new ie;drawerOpen=!1;breakpointObserver=f(ll);isDesktop=Me(this.breakpointObserver.observe("(min-width: 1400px)").pipe(Le(e=>e.matches)),{initialValue:!1});userOpenPreference=et(!0);isOpen=Ct(()=>this.userOpenPreference());isAdmin=!1;configErrorMessage="";expandedSections={config:!1,preview:!1,settings:!1};isThreadSearchActive=!1;threadSearchQuery="";threadSearchInput;dialog=f(Pr);configApi=f(Ul);projectStateService=f(_e);projectApi=f(Ar);router=f(Nt);preferences=f(we);threadStateService=f(We);projects=Me(this.projectStateService.projectList$);selectedProject=Me(this.projectStateService.selectedProject$);selectedProjectName=Me(this.projectStateService.selectedProject$.pipe(Le(e=>e?.name)));isProjectVolatile=Me(this.projectStateService.selectedProject$.pipe(Le(e=>e?.config?.volatile||!1)));forcedProject=Me(this.projectStateService.forcedProject$);hasPreviewConfig=Me(this.projectStateService.selectedProject$.pipe(Le(e=>{let t=e?.config?.preview;return Array.isArray(t)&&!!t.length})),{initialValue:!1});ngOnInit(){let e=window.innerWidth>=1024,t=this.preferences.getPreference("sidenavOpen",e);this.userOpenPreference.set(t??e),this.configApi.getUserConfig().pipe(z(this.destroy$)).subscribe({next:n=>{this.isAdmin=n.groups?.includes("CODAY_ADMIN")??!1,console.log("[SIDENAV] User admin status:",this.isAdmin)},error:n=>{console.error("[SIDENAV] Error loading user config for roles:",n),this.isAdmin=!1}})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}toggle(){let e=!this.userOpenPreference();this.userOpenPreference.set(e),this.saveSidenavState(e),this.sidenavStateChange.emit(e)}close(){this.userOpenPreference()&&(this.userOpenPreference.set(!1),this.saveSidenavState(!1),this.sidenavStateChange.emit(!1))}saveSidenavState(e){this.preferences.setPreference("sidenavOpen",e)}openTokenUsage(){this.configErrorMessage="",this.router.navigate(["/token-usage"])}openUserConfig(){console.log("[SIDENAV] openUserConfig called"),this.configErrorMessage="",this.configApi.getUserConfig().pipe(z(this.destroy$)).subscribe({next:e=>{console.log("[SIDENAV] User config loaded, opening dialog"),this.dialog.open(nr,{data:{configType:"user",initialContent:JSON.stringify(e,null,2)}}).afterClosed().subscribe(n=>{n&&this.saveUserConfig(n)})},error:e=>{console.error("[SIDENAV] Error loading user config:",e),this.configErrorMessage=e?.error?.error||"Failed to load user configuration"}})}saveUserConfig(e){this.configApi.updateUserConfig(e).pipe(z(this.destroy$)).subscribe({next:t=>{console.log("[SIDENAV] User config saved successfully")},error:t=>{console.error("[SIDENAV] Error saving user config:",t),this.configErrorMessage=t?.error?.error||"Failed to save user configuration"}})}openProjectConfig(){let e=this.selectedProjectName();if(!e){console.error("[SIDENAV] No project selected"),this.configErrorMessage="No project selected. Please select a project first.";return}this.configErrorMessage="",this.projectApi.getProjectConfig(e).pipe(z(this.destroy$)).subscribe({next:t=>{console.log("[SIDENAV] Project config loaded, opening dialog"),this.dialog.open(nr,{data:{configType:"project",projectName:e,initialContent:JSON.stringify(t,null,2)}}).afterClosed().subscribe(r=>{r&&this.saveProjectConfig(e,r)})},error:t=>{console.error("[SIDENAV] Error loading project config:",t),this.configErrorMessage=t?.error?.error||"Failed to load project configuration"}})}saveProjectConfig(e,t){this.projectApi.updateProjectConfig(e,t).pipe(z(this.destroy$)).subscribe({next:n=>{console.log("[SIDENAV] Project config saved successfully")},error:n=>{console.error("[SIDENAV] Error saving project config:",n),this.configErrorMessage=n?.error?.error||"Failed to save project configuration"}})}requireProjectSelection(e){return this.selectedProjectName()?!0:(console.error(`[SIDENAV] No project selected, cannot ${e}`),this.configErrorMessage="Please select a project first",!1)}openAgents(){if(!this.requireProjectSelection("open agents"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"agents"])}openPrompts(){if(!this.requireProjectSelection("open prompts"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"prompts"])}openSchedulers(){if(!this.requireProjectSelection("open schedulers"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"schedulers"])}toggleSection(e){let t=this.expandedSections[e];e==="settings"?this.expandedSections[e]=!t:(["config","preview"].forEach(r=>{this.expandedSections[r]=!1}),this.expandedSections[e]=!t)}navigateToHome(){if(this.forcedProject()){console.log("[SIDENAV] Cannot navigate to home - forced project active");return}console.log("[SIDENAV] Navigating to home (project selection)"),this.projectStateService.clearSelection(),this.router.navigate(["/"])}createNewThread(){let e=this.selectedProjectName();if(!e){console.error("[SIDENAV] No project selected, cannot create new thread"),this.configErrorMessage="Please select a project first";return}console.log("[SIDENAV] Navigating to welcome view for new thread"),this.threadStateService.clearSelection(),this.router.navigate(["project",e])}onThreadSelectedOnMobile(){this.isDesktop()||this.close()}toggleThreadSearch(e){e.stopPropagation(),this.isThreadSearchActive=!0,this.threadSearchQuery="",setTimeout(()=>{this.threadSearchInput?.nativeElement.focus()},0)}closeThreadSearch(){this.isThreadSearchActive=!1,this.threadSearchQuery=""}onThreadSearchInput(){}onThreadSearchModeChange(e){e||this.closeThreadSearch()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-sidenav"]],viewQuery:function(t,n){if(t&1&&tt(jf,5),t&2){let r;je(r=Ve())&&(n.threadSearchInput=r.first)}},inputs:{drawerOpen:"drawerOpen"},outputs:{sidenavStateChange:"sidenavStateChange"},ngContentSelectors:Vf,decls:34,vars:31,consts:[["threadSearchInput",""],[1,"sidenav-container",3,"hasBackdrop"],["mode","push","position","start",1,"app-sidenav",3,"closed","opened","disableClose"],[1,"sidenav-header"],["mat-icon-button","","title","Close menu",3,"click"],["alt","coday",3,"click","keydown.enter","keydown.space","title"],[1,"header-title-section"],[1,"sidenav-title"],[1,"new-thread-section"],["role","button","tabindex","0",1,"new-thread-link",3,"click"],["fontSet","material-icons-outlined"],[1,"new-thread-text"],[1,"sidenav-sections"],[1,"section-container","expanded"],[1,"search-header"],[1,"section-toggle","active","threads-header"],[1,"section-content","threads"],[1,"sidenav-thread-selector",3,"searchModeChange","threadSelected","searchMode","searchQuery"],[1,"sidenav-nav"],[1,"section-container","settings-group"],["role","button","tabindex","0",1,"section-toggle",3,"click"],[1,"arrow-icon","expanded"],[1,"section-icon"],[1,"section-label"],[1,"section-content","settings-content"],["role","alert",1,"error-notification"],["mat-icon-button","","title","Menu","type","button",1,"sidenav-toggle-btn",3,"click"],["mat-icon-button","","title","Start a new thread","type","button",1,"sidenav-new-thread-btn",3,"click","disabled"],[1,"search-icon"],["type","text","placeholder","Search threads...",1,"search-input",3,"ngModelChange","input","ngModel"],["mat-icon-button","","title","Close search","type","button",1,"close-search-btn",3,"click"],["mat-icon-button","","title","Search threads","type","button",1,"search-button",3,"click"],[1,"section-container"],[1,"section-content"],[1,"section-container",3,"expanded"],["href","https://github.com/whoz-oss/coday","target","_blank","rel","noopener noreferrer","title","Contribute on GitHub",1,"section-toggle","contribute-btn"],["alt","Coday",1,"contribute-logo"],[1,"preference-item"],[1,"inline-panel"],["role","button","tabindex","-1","aria-disabled","true",1,"section-toggle","disabled"],[3,"projectName"],[1,"error-icon"],[1,"error-text"],["mat-icon-button","","aria-label","Close error message",1,"error-close",3,"click"]],template:function(t,n){t&1&&(Ws(),C(0,zf,6,1),l(1,"mat-sidenav-container",1)(2,"mat-sidenav",2),v("closed",function(){return n.close()}),l(3,"div",3)(4,"button",4),v("click",function(){return n.close()}),l(5,"mat-icon"),u(6,"chevron_left"),c()(),l(7,"img",5),v("click",function(o){return n.navigateToHome(),o.stopPropagation()})("keydown.enter",function(o){return n.navigateToHome(),o.preventDefault(),o.stopPropagation()})("keydown.space",function(o){return n.navigateToHome(),o.preventDefault(),o.stopPropagation()}),c(),l(8,"div",6)(9,"h2",7),u(10),c()()(),l(11,"div",8)(12,"a",9),v("click",function(o){return n.createNewThread(),o.preventDefault()}),l(13,"mat-icon",10),u(14,"play_circle"),c(),l(15,"span",11),u(16,"Start a new thread"),c()()(),l(17,"div",12)(18,"div",13),C(19,$f,8,1,"div",14)(20,Hf,8,0,"div",15),l(21,"div",16)(22,"app-thread-selector",17),v("searchModeChange",function(o){return n.onThreadSearchModeChange(o)})("threadSelected",function(){return n.onThreadSelectedOnMobile()}),c()()()(),l(23,"div",18)(24,"div",19)(25,"a",20),v("click",function(o){return n.toggleSection("settings"),o.preventDefault()}),C(26,Uf,2,0,"mat-icon",21)(27,Bf,2,0,"mat-icon",22),l(28,"span",23),u(29,"Control Center"),c()(),C(30,s0,33,12,"div",24),c()()(),l(31,"mat-sidenav-content"),Gs(32),c()(),C(33,l0,8,1,"div",25)),t&2&&(S(!n.isOpen()&&!n.drawerOpen?0:-1),p(),J("sidenav-open",n.isOpen()),w("hasBackdrop",!1),p(),w("opened",n.isOpen())("disableClose",!0),p(5),J("sidenav-logo",!0)("clickable",!n.forcedProject())("disabled",n.forcedProject()),w("title",n.forcedProject()?"Project selection disabled":"Go to project selection"),Re("src","CODAY-Logo.png",En)("role",n.forcedProject()?null:"button")("tabindex",n.forcedProject()?null:"0"),p(3),F(n.selectedProjectName()),p(9),S(n.isThreadSearchActive?19:20),p(3),w("searchMode",n.isThreadSearchActive)("searchQuery",n.threadSearchQuery),p(),J("is-admin",n.isAdmin),p(),J("expanded",n.expandedSections.settings),p(),J("active",n.expandedSections.settings),p(),S(n.expandedSections.settings?26:27),p(4),S(n.expandedSections.settings?30:-1),p(),J("sidenav-closed-offset",!n.isOpen()),p(2),S(n.configErrorMessage?33:-1))},dependencies:[st,ht,ot,at,Ir,Tl,wl,xl,Te,ae,qe,ze,np,ip,tr,Fo,Lo],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;position:relative}.sidenav-container[_ngcontent-%COMP%]{position:fixed;top:0;left:0;right:0;height:100dvh;z-index:1400;transition:width;display:flex}.sidenav-container[_ngcontent-%COMP%] mat-sidenav[_ngcontent-%COMP%]{position:relative!important;transition:width;width:25%;min-width:320px;height:100dvh!important;flex-shrink:0}.sidenav-container[_ngcontent-%COMP%] mat-sidenav[_ngcontent-%COMP%]:not(.mat-drawer-opened){width:0!important;min-width:0;overflow:hidden!important;visibility:hidden!important}.sidenav-container[_ngcontent-%COMP%] mat-sidenav-content[_ngcontent-%COMP%]{width:100%;margin:0!important}@media(min-width:1024px){.sidenav-container[_ngcontent-%COMP%] mat-sidenav-content[_ngcontent-%COMP%]{min-width:0}}[_nghost-%COMP%] .mat-drawer-backdrop{pointer-events:auto}[_nghost-%COMP%] .mat-drawer-content{pointer-events:auto!important;background:transparent!important;overflow:visible!important}[_nghost-%COMP%] .mat-drawer-inner-container{overflow:hidden!important;height:100dvh!important;display:flex!important;flex-direction:column!important}.sidenav-new-thread-btn[_ngcontent-%COMP%], .sidenav-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;z-index:1500!important;width:40px!important;height:40px!important;border-radius:50%!important;background:var(--glass-bg)!important;backdrop-filter:var(--glass-backdrop-blur)!important;-webkit-backdrop-filter:var(--glass-backdrop-blur)!important;border:1px solid var(--glass-border)!important;box-shadow:var(--glass-shadow)!important}.sidenav-toggle-btn[_ngcontent-%COMP%]{top:1rem!important;left:1rem!important}.sidenav-new-thread-btn[_ngcontent-%COMP%]{top:calc(1.5rem + 40px)!important;left:1rem!important}.sidenav-new-thread-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:var(--color-primary)!important}.sidenav-new-thread-btn[_ngcontent-%COMP%]:disabled{opacity:.5!important}.sidenav-logo-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:1rem!important;left:1rem!important;z-index:1500!important;width:56px!important;height:56px!important;border-radius:50%!important;border:1px solid var(--glass-border)!important;padding:4px!important;background:var(--glass-bg)!important;backdrop-filter:var(--glass-backdrop-blur)!important;-webkit-backdrop-filter:var(--glass-backdrop-blur)!important;box-shadow:var(--glass-shadow)!important;transition:all .3s cubic-bezier(.4,0,.2,1)!important;cursor:pointer!important;pointer-events:auto!important;display:flex!important;align-items:center!important;justify-content:center!important;overflow:hidden!important;text-decoration:none!important}.sidenav-logo-btn[_ngcontent-%COMP%]:hover{transform:scale(1.08) translateY(-2px)!important;box-shadow:0 16px 48px #0003!important;border-color:var(--color-primary)!important}.sidenav-logo-btn[_ngcontent-%COMP%]:active{transform:scale(.96)!important}.sidenav-logo-btn[_ngcontent-%COMP%] .logo[_ngcontent-%COMP%]{width:48px;height:48px;border-radius:2px}.app-sidenav[_ngcontent-%COMP%]{width:480px;height:100dvh!important;min-height:0!important;position:relative;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border-radius:0;overflow:hidden;overflow-x:hidden!important;display:flex;flex-direction:column}.sidenav-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:1.5rem 1rem .5rem;flex-shrink:0}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo[_ngcontent-%COMP%]{width:40px;height:40px;border-radius:4px;flex-shrink:0;transition:all .2s ease}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo.clickable[_ngcontent-%COMP%]{cursor:pointer}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo.clickable[_ngcontent-%COMP%]:hover{transform:scale(1.1);filter:drop-shadow(0 4px 12px rgba(0,0,0,.15))}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo.clickable[_ngcontent-%COMP%]:active{transform:scale(.95)}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo.clickable[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.sidenav-header[_ngcontent-%COMP%] .sidenav-logo.disabled[_ngcontent-%COMP%]{opacity:.5;cursor:not-allowed;pointer-events:none}.sidenav-header[_ngcontent-%COMP%] .header-title-section[_ngcontent-%COMP%]{flex:1;display:flex;align-items:center;min-width:0}.sidenav-header[_ngcontent-%COMP%] .header-title-section[_ngcontent-%COMP%] .sidenav-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.loading-section[_ngcontent-%COMP%]{padding:2rem 1rem;display:flex;align-items:center;justify-content:center}.loading-content[_ngcontent-%COMP%]{width:100%;display:flex;flex-direction:column;gap:1rem;align-items:center}.loading-content[_ngcontent-%COMP%] mat-progress-bar[_ngcontent-%COMP%]{width:100%;height:4px;border-radius:2px}.loading-content[_ngcontent-%COMP%] .loading-text[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary);text-align:center}.new-thread-section[_ngcontent-%COMP%]{padding:1rem 1rem .5rem;flex-shrink:0}.new-thread-link[_ngcontent-%COMP%]{display:inline-flex;align-items:center;background:transparent;border:none;text-decoration:none;cursor:pointer;transition:all .2s ease;gap:.5rem;font-size:.95rem;font-weight:600;padding:0}.new-thread-link[_ngcontent-%COMP%] .new-thread-text[_ngcontent-%COMP%]{background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite}.new-thread-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-primary);animation:_ngcontent-%COMP%_iconPulse 3s ease-in-out infinite}.new-thread-link[_ngcontent-%COMP%]:hover{transform:translate(4px)}.new-thread-link[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_iconPulse 1.5s ease-in-out infinite}.new-thread-link[_ngcontent-%COMP%]:focus{transform:scale(1.1)}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}@keyframes _ngcontent-%COMP%_iconPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.8;transform:scale(1.05)}}.sidenav-sections[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:100px;overflow:hidden}.sidenav-sections[_ngcontent-%COMP%] > .section-container[_ngcontent-%COMP%], .sidenav-sections[_ngcontent-%COMP%] > .section-container.expanded[_ngcontent-%COMP%], .sidenav-sections[_ngcontent-%COMP%] > .section-container[_ngcontent-%COMP%] > .section-content.threads[_ngcontent-%COMP%], .sidenav-sections[_ngcontent-%COMP%] > .section-container[_ngcontent-%COMP%] > .section-content.threads[_ngcontent-%COMP%] > app-thread-selector[_ngcontent-%COMP%]{display:flex!important;flex-direction:column!important;flex:1!important;min-height:0!important;overflow:hidden!important}.sidenav-nav[_ngcontent-%COMP%]{flex-shrink:0;display:flex;flex-direction:column;overflow:hidden;max-height:70%;border-top:1px solid var(--color-border)}.sidenav-nav[_ngcontent-%COMP%] > .settings-group[_ngcontent-%COMP%] > .section-toggle.active[_ngcontent-%COMP%]{border-top:none}.sidenav-nav[_ngcontent-%COMP%] .settings-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.sidenav-nav[_ngcontent-%COMP%] .settings-group[_ngcontent-%COMP%] > .section-toggle[_ngcontent-%COMP%]{flex-shrink:0}.sidenav-nav[_ngcontent-%COMP%] .settings-group[_ngcontent-%COMP%] > .section-content.settings-content[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden}.settings-group[_ngcontent-%COMP%] > .section-content.settings-content[_ngcontent-%COMP%]{padding:0;border-bottom:1px solid var(--color-border);overflow:visible}.settings-group[_ngcontent-%COMP%] > .section-content.settings-content[_ngcontent-%COMP%] .section-container.expanded[_ngcontent-%COMP%] .section-content[_ngcontent-%COMP%]{max-height:40vh;overflow-y:auto;overflow-x:hidden}.contribute-btn[_ngcontent-%COMP%] .contribute-logo[_ngcontent-%COMP%]{width:20px;height:20px;border-radius:2px;flex-shrink:0}.section-container[_ngcontent-%COMP%]{flex-shrink:0;display:flex;flex-direction:column}.section-container.expanded[_ngcontent-%COMP%]{display:flex;flex-direction:column}.section-container.expanded[_ngcontent-%COMP%] .section-content[_ngcontent-%COMP%]{border-bottom:none}.section-toggle[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;width:100%;padding:.5rem 1rem;height:50px;text-decoration:none;cursor:pointer;transition:all .2s ease;background:transparent;border:none;border-radius:0;color:var(--color-text);flex-shrink:0}.section-toggle.active[_ngcontent-%COMP%]{border-top:1px solid var(--color-border)}.section-toggle.disabled[_ngcontent-%COMP%]{opacity:.5;cursor:not-allowed;pointer-events:none}.section-toggle[_ngcontent-%COMP%] .arrow-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary);transition:transform .2s ease;transform:rotate(0);flex-shrink:0}.section-toggle[_ngcontent-%COMP%] .section-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary);flex-shrink:0}.section-toggle[_ngcontent-%COMP%] .section-label[_ngcontent-%COMP%]{flex:1;font-size:.9rem;color:var(--color-text);text-align:left}.section-toggle[_ngcontent-%COMP%] .search-button[_ngcontent-%COMP%]{margin-left:auto;flex-shrink:0}.section-toggle[_ngcontent-%COMP%] .search-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px}.section-toggle[_ngcontent-%COMP%]:hover:not(.disabled){background:var(--color-bg-hover)}.section-toggle[_ngcontent-%COMP%]:active:not(.disabled){transform:scale(.98)}.section-toggle[_ngcontent-%COMP%]:focus-visible{outline:2px solid var(--color-primary);outline-offset:-2px}.search-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;height:50px;background:var(--color-bg-hover);border-top:1px solid var(--color-border);transition:all .2s ease}.search-header[_ngcontent-%COMP%] .search-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary);flex-shrink:0}.search-header[_ngcontent-%COMP%] .search-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent;color:var(--color-text);font-size:.9rem;padding:0;min-width:0}.search-header[_ngcontent-%COMP%] .search-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-muted)}.search-header[_ngcontent-%COMP%] .close-search-btn[_ngcontent-%COMP%]{flex-shrink:0}.search-header[_ngcontent-%COMP%] .close-search-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px}.section-content[_ngcontent-%COMP%]{padding:.5rem 0 0;animation:_ngcontent-%COMP%_slideDown .2s ease;border-bottom:1px solid var(--color-border);display:flex;flex-direction:column}.section-content.threads[_ngcontent-%COMP%]{padding:0;border-bottom:none;flex:1!important;min-height:0!important;overflow:hidden!important}.section-content.threads[_ngcontent-%COMP%] app-thread-selector[_ngcontent-%COMP%]{flex:1!important;min-height:0!important;overflow:hidden!important;display:flex!important;flex-direction:column!important}@keyframes _ngcontent-%COMP%_slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.config-links[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem;padding:.5rem 1rem;margin-bottom:1rem}.sidenav-item[_ngcontent-%COMP%]{width:100%}.sidenav-item[_ngcontent-%COMP%] .item-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary)}.sidenav-item[_ngcontent-%COMP%] .item-text[_ngcontent-%COMP%]{flex:1;font-size:.9rem}.sidenav-item[_ngcontent-%COMP%] .disabled-hint[_ngcontent-%COMP%]{font-size:.7rem;color:var(--color-text-secondary);font-style:italic}.sidenav-link.disabled[_ngcontent-%COMP%]{opacity:.5;cursor:not-allowed;color:var(--color-text-secondary)}.sidenav-link.disabled[_ngcontent-%COMP%] .item-icon[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.sidenav-link[_ngcontent-%COMP%] .item-icon[_ngcontent-%COMP%], .sidenav-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-primary)}.sidenav-link[_ngcontent-%COMP%] .item-text[_ngcontent-%COMP%]{font-size:.875rem}.preference-item[_ngcontent-%COMP%]{padding-bottom:1rem;margin-bottom:1rem;border-bottom:1px solid var(--color-border)}.preference-item[_ngcontent-%COMP%]:last-child{margin-bottom:0;padding-bottom:0;border-bottom:none}.preference-item[_ngcontent-%COMP%] .preference-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;margin-bottom:.75rem;padding:0 1rem}.preference-item[_ngcontent-%COMP%] .preference-header[_ngcontent-%COMP%] .item-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.preference-item[_ngcontent-%COMP%] .preference-header[_ngcontent-%COMP%] .item-text[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.preference-item[_ngcontent-%COMP%] .preference-content[_ngcontent-%COMP%]{padding:0 1rem}.error-notification[_ngcontent-%COMP%]{position:fixed;top:5rem;left:50%;transform:translate(-50%);z-index:2000;display:flex;align-items:center;gap:.75rem;background:#ff3b3026;backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid rgba(255,59,48,.3);border-radius:16px;padding:1rem 1.5rem;box-shadow:var(--glass-shadow);animation:_ngcontent-%COMP%_errorSlideDown .3s cubic-bezier(.4,0,.2,1)}.error-notification[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{font-size:1.2rem;flex-shrink:0;color:#c00}.error-notification[_ngcontent-%COMP%] .error-text[_ngcontent-%COMP%]{flex:1;color:#c00;font-size:.9rem;font-weight:500}@keyframes _ngcontent-%COMP%_errorSlideDown{0%{opacity:0;transform:translate(-50%,-10px)}to{opacity:1;transform:translate(-50%)}}@media(max-width:480px){.app-sidenav[_ngcontent-%COMP%]{width:320px}.sidenav-toggle-btn[_ngcontent-%COMP%]{top:.75rem!important;left:.75rem!important}.sidenav-new-thread-btn[_ngcontent-%COMP%]{top:calc(1.25rem + 40px)!important;left:.75rem!important}.error-notification[_ngcontent-%COMP%]{left:1rem;right:1rem;transform:none;max-width:calc(100vw - 2rem)}}body.dark[_nghost-%COMP%] .app-sidenav[_ngcontent-%COMP%], body.dark [_nghost-%COMP%] .app-sidenav[_ngcontent-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .app-sidenav[_ngcontent-%COMP%]{background:#242830f2;border-right-color:#b4c8ff17}body.dark[_nghost-%COMP%] .sidenav-header[_ngcontent-%COMP%], body.dark [_nghost-%COMP%] .sidenav-header[_ngcontent-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .sidenav-header[_ngcontent-%COMP%]{background:#242830b3}"]})};var jo=class i{destroy$=new ce;isSetup=!1;codayService=f(pt);preferencesService=f(we);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(z(this.destroy$),Jo(),De(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(z(this.destroy$),Jo(),De(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let r=e.createOscillator(),o=e.createGain();r.connect(o),o.connect(e.destination);let a=e.currentTime+.11;r.frequency.setValueAtTime(950,a),o.gain.setValueAtTime(.1,a),o.gain.exponentialRampToValueAtTime(.01,a+.09),r.start(a),r.stop(a+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return H(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=U({token:i,factory:i.\u0275fac,providedIn:"root"})};var c0=["inputSection"];function d0(i,e){if(i&1){let t=O();l(0,"app-thread",4),v("chatFocused",function(){x(t);let r=h();return T(r.onChatFocusedOnMobile())})("drawerStateChange",function(r){x(t);let o=h();return T(o.onDrawerStateChange(r))}),c()}if(i&2){let t=h();w("projectName",t.projectName)("threadId",t.threadId)}}function p0(i,e){if(i&1){let t=O();l(0,"div",5),R(1,"app-welcome-message"),c(),l(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),v("messageSubmitted",function(r){x(t);let o=h();return T(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){x(t);let o=h();return T(o.onVoiceToggled(r))})("heightChanged",function(r){x(t);let o=h();return T(o.onInputHeightChanged(r))})("textareaFocused",function(){x(t);let r=h();return T(r.onChatFocusedOnMobile())}),c()()()()}if(i&2){let t=h();p(6),w("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var rr=class i{destroy$=new ce;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=f(pt);titleService=f(Mi);preferencesService=f(we);route=f(Tr);router=f(Nt);threadApiService=f(Ht);agentNotificationService=f(jo);firstMessageState=f(Pi);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(z(this.destroy$)).subscribe(e=>{let t=e.projectName,n=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:n,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=n,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-main"]],viewQuery:function(t,n){if(t&1&&tt(c0,5)(ir,5),t&2){let r;je(r=Ve())&&(n.inputSection=r.first),je(r=Ve())&&(n.sidenav=r.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,n){t&1&&(l(0,"app-sidenav",1)(1,"div",2),v("mousedown",function(){return n.onChatFocusedOnMobile()})("touchstart",function(){return n.onChatFocusedOnMobile()}),C(2,d0,1,2,"app-thread",3)(3,p0,7,5),c()()),t&2&&(w("drawerOpen",n.isDrawerOpen),p(2),S(n.threadId?2:3))},dependencies:[mi,Ro,No,ir],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[la("slideIn",[Nr(":enter",[un({transform:"translateY(100%)",opacity:0}),Rr("300ms ease-out",un({transform:"translateY(0)",opacity:1}))]),Nr(":leave",[Rr("200ms ease-in",un({transform:"translateY(100%)",opacity:0}))])])]}})};var Oi=i=>H(null,null,function*(){let e=f(_e),t=i.params.projectName;return t?e.getSelectedProjectId()===t?!0:(e.selectProject(t),(yield Is(e.selectedProject$.pipe(Rs(r=>r?.name===t))))?.name===t):(console.log("[PROJECT GUARD] no project id in route"),!1)});var op=i=>H(null,null,function*(){let e=f(We),t=f(Ut),n=i.params.threadId;if(!t.getUsername())try{yield Ko(t.fetchCurrentUser())}catch(r){console.error("[THREAD GUARD] Failed to load current user:",r)}if(!n)return console.log("[THREAD GUARD] no threadId in route"),!1;if(console.log("[THREAD GUARD] Checking thread:",n),console.log("[THREAD GUARD] Current selected thread:",e.getSelectedThreadId()),e.getSelectedThreadId()===n)return console.log("[THREAD GUARD] Thread already selected, allowing navigation"),!0;console.log("[THREAD GUARD] Selecting thread:",n),e.selectThread(n);try{let r=yield Ko(wn([e.isLoading$,e.selectedThread$]).pipe(ut(([a,s])=>console.log(`\u{1F43C} [${a?"loading":"loaded"}]`,s?.id)),De(([a,s])=>!a&&!!s),hr(1),Le(([a,s])=>s?.id))),o=r===n;return o?console.log("[THREAD GUARD] Thread validated, allowing navigation"):console.error("[THREAD GUARD] Thread ID mismatch - route:",n,"loaded:",r),o}catch(r){return console.error("[THREAD GUARD] Error loading thread:",r),!1}});var ap=[{path:"",component:io},{path:"oauth/callback",component:yo},{path:"project/new",loadComponent:()=>import("./chunk-PWW4FOUT.js").then(i=>i.ProjectNewComponent)},{path:"project/:projectName",component:rr,canActivate:[Oi]},{path:"project/:projectName/prompts",loadComponent:()=>import("./chunk-RIKUGKVO.js").then(i=>i.PromptListComponent),canActivate:[Oi]},{path:"project/:projectName/schedulers",loadComponent:()=>import("./chunk-HIRSL5MY.js").then(i=>i.SchedulerListComponent),canActivate:[Oi]},{path:"project/:projectName/agents",loadComponent:()=>import("./chunk-LEUHLZHG.js").then(i=>i.AgentListComponent),canActivate:[Oi]},{path:"project/:projectName/thread/:threadId",component:rr,canActivate:[Oi,op]},{path:"token-usage",loadComponent:()=>import("./chunk-AVD3CUGR.js").then(i=>i.TokenUsageComponent)},{path:"agentos",loadChildren:()=>import("./chunk-LPT4NEYN.js").then(i=>i.AGENTOS_ROUTES)},{path:"**",redirectTo:""}];function m0(i){return()=>i.initializeDefaultProject()}function u0(i){return()=>{console.log("[APP_INIT] OAuthService initialized")}}var sp={providers:[Vs(),Js({eventCoalescing:!0}),rl(ap),nl(),Hc(),Ls(fl),{provide:ia,useFactory:m0,deps:[_e],multi:!0},{provide:ia,useFactory:u0,deps:[bn],multi:!0},vl({basePath:"/api/agentos"}),{provide:_l,useValue:{width:"80vw",maxWidth:"80vw",maxHeight:"80vh"}}]};var Vo=class i{title="client";themeService=f(ki);ngOnInit(){console.log("[APP] Application initialized with theme:",this.themeService.getCurrentTheme())}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=N({type:i,selectors:[["app-root"]],decls:1,vars:0,template:function(t,n){t&1&&R(0,"router-outlet")},dependencies:[ol,il],encapsulation:2})};tl(Vo,sp).catch(i=>console.error(i));