@whoz-oss/coday-client 0.114.2 → 0.115.3

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 (51) hide show
  1. package/browser/chunk-2DVVHRX4.js +1 -0
  2. package/browser/chunk-2NHY3763.js +1 -0
  3. package/browser/{chunk-7V75AFNU.js → chunk-3QJA3PD3.js} +1 -1
  4. package/browser/chunk-4NNLWDVJ.js +10 -0
  5. package/browser/chunk-4SMKZ2HA.js +1 -0
  6. package/browser/{chunk-Q6VCYSB2.js → chunk-4TOD23CW.js} +1 -1
  7. package/browser/{chunk-QK4YUPJ4.js → chunk-55ETGHKC.js} +1 -1
  8. package/browser/chunk-5JA4YMVL.js +1 -0
  9. package/browser/{chunk-P25I3C22.js → chunk-5MXEOOQM.js} +1 -1
  10. package/browser/{chunk-HX6IQXOO.js → chunk-6LHAGXIC.js} +1 -1
  11. package/browser/{chunk-OX6WF3Z4.js → chunk-6WUBJOTP.js} +1 -1
  12. package/browser/chunk-6XQBGSR4.js +1 -0
  13. package/browser/chunk-AE24ERN3.js +1 -0
  14. package/browser/{chunk-DSEAUPTG.js → chunk-AE2AQO4B.js} +1 -1
  15. package/browser/chunk-AWTXRCO7.js +1 -0
  16. package/browser/chunk-B2QVH3K3.js +1 -0
  17. package/browser/chunk-FMBLR6NH.js +1 -0
  18. package/browser/chunk-FZVCANBC.js +1 -0
  19. package/browser/chunk-H5JAF7XP.js +1 -0
  20. package/browser/{chunk-227SHMWS.js → chunk-H72Z2LX3.js} +1 -1
  21. package/browser/chunk-HGEXTRZ7.js +1 -0
  22. package/browser/{chunk-FL6JPD3W.js → chunk-JCQFYRAF.js} +1 -1
  23. package/browser/chunk-MN73E3JO.js +1 -0
  24. package/browser/{chunk-H34KEEJ5.js → chunk-NSSFL3WG.js} +1 -1
  25. package/browser/{chunk-TIR2HD4O.js → chunk-ORNGVCRW.js} +1 -1
  26. package/browser/{chunk-2M2BOWAG.js → chunk-OUZFS4TC.js} +1 -1
  27. package/browser/chunk-SPAN622B.js +1 -0
  28. package/browser/chunk-TRUXCA4C.js +5 -0
  29. package/browser/{chunk-OFSMISUU.js → chunk-VVZKXHDD.js} +1 -1
  30. package/browser/{chunk-KTV6E2MT.js → chunk-WZJ3UIRS.js} +1 -1
  31. package/browser/{chunk-YF5TCNFL.js → chunk-X6TFXJKZ.js} +1 -1
  32. package/browser/{chunk-OEWE7VBT.js → chunk-YKARRAPE.js} +1 -1
  33. package/browser/{chunk-DOKGAGLU.js → chunk-YRNTZU7L.js} +1 -1
  34. package/browser/{chunk-OIIJPQ2M.js → chunk-ZP4X376S.js} +3 -3
  35. package/browser/index.html +1 -1
  36. package/browser/{main-D75VEKMS.js → main-C4MZGYXT.js} +25 -25
  37. package/package.json +1 -1
  38. package/browser/chunk-6JCVDUKO.js +0 -10
  39. package/browser/chunk-APZFPOUA.js +0 -1
  40. package/browser/chunk-ASYMPPFD.js +0 -1
  41. package/browser/chunk-DIARVKX4.js +0 -1
  42. package/browser/chunk-OTLZ4X7Y.js +0 -1
  43. package/browser/chunk-PC73MTF7.js +0 -1
  44. package/browser/chunk-PO4TEPXT.js +0 -1
  45. package/browser/chunk-RS3TLRZ3.js +0 -1
  46. package/browser/chunk-SLXXGWVF.js +0 -1
  47. package/browser/chunk-SNDFCTPS.js +0 -1
  48. package/browser/chunk-TN2PAWIS.js +0 -5
  49. package/browser/chunk-UVKQUFKA.js +0 -1
  50. package/browser/chunk-XKPYE4VF.js +0 -1
  51. package/browser/chunk-ZYBKXGLA.js +0 -1
@@ -1,5 +1,5 @@
1
- import{a as oc,b as ac,c as sc}from"./chunk-YF5TCNFL.js";import{a as rc}from"./chunk-7V75AFNU.js";import{a as Fl,b as Ll}from"./chunk-227SHMWS.js";import{a as jl,b as Vl,c as zl,d as $l,e as Bl,f as Hl,g as Ul}from"./chunk-2M2BOWAG.js";import{J as Yl,K as zr,S as tc,U as nc,V as ic,g as Rl,h as ii,i as Nl,j as wa,w as ql,x as Gl}from"./chunk-6JCVDUKO.js";import{F as Il,G as Fr,I as An,L as qe,M as Dl,N as $t,P as Lr,Q as jr,R as rt,S as de,T as Re,e as Rr,f as Sa,h as wl,i as xl,j as Tl,m as El,o as Nr,p as Ml,r as kl,s as Pl,t as Ol,y as Al}from"./chunk-P25I3C22.js";import{a as Vr,b as ve}from"./chunk-KTV6E2MT.js";import{A as _t,c as ht,g as gt,l as ft,o as Ql,p as Kl,t as Xl,u as Zl,v as Jl,z as ec}from"./chunk-SLXXGWVF.js";import{f as Wl}from"./chunk-OTLZ4X7Y.js";import{a as ut,b as Ae}from"./chunk-OFSMISUU.js";import{$ as ua,$a as F,A as la,Ab as Ve,B as ca,Bb as ni,Cb as ne,D as el,Db as ie,E as da,Ea as R,Eb as re,Fa as xt,Fb as pl,G as tl,Ga as cl,Gb as gn,Ha as dl,Hb as ml,I as Jn,Ib as Tr,J as pa,Ja as Li,Jb as ul,K as I,Ka as ti,Kb as Vi,Lb as hl,M as pt,Mb as ya,N as te,Oa as fa,Ob as Er,P as H,Q as wt,Qa as Me,Qb as Tt,R as Ni,S as Cr,Sa as C,Sb as Mr,T as f,Ta as S,V as nl,Vb as gl,Wa as we,Wb as kr,X as w,Xa as xe,Xb as Pr,Y as x,Ya as E,Yb as Or,Z as ma,Za as l,_ as il,_a as c,a as Y,aa as ei,ab as un,b as he,ba as Sr,bb as hn,bc as Ar,c as Qs,ca as J,cb as _a,cc as Ir,d as $,da as Lt,dc as fl,ec as Ca,f as yr,fa as rl,fb as On,g as Z,ga as We,gb as O,gc as nt,h as W,ha as Fi,ia as jt,ib as v,ic as _l,ja as wr,jc as bl,ka as mt,kb as g,l as Mn,la as ol,lb as nn,m as Xn,mb as dt,n as sa,nb as ba,nc as it,o as Ks,oa as ha,ob as $e,oc as vl,p as Oe,pb as ge,pc as Vt,q as kn,qb as fe,qc as Dr,ra as ct,rc as yl,sa as Pn,sc as zt,t as Xs,ta as al,tc as Cl,u as Zs,ua as p,ub as ji,uc as Sl,v as Se,va as sl,vb as Qe,wa as ga,wb as G,x as mn,xb as va,y as Js,ya as ll,yb as u,z as Zn,za as xr,zb as B}from"./chunk-TN2PAWIS.js";var q=(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})(q||{}),bt="*";function xa(i,e){return{type:q.Trigger,name:i,definitions:e,options:{}}}function $r(i,e=null){return{type:q.Animate,styles:e,timings:i}}function lc(i,e=null){return{type:q.Sequence,steps:i,options:e}}function fn(i){return{type:q.Style,styles:i,offset:null}}function Br(i,e,t=null){return{type:q.Transition,expr:i,animation:e,options:t}}var Bt=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}},In=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}},ri="!";function cc(i){return new te(3e3,!1)}function Np(){return new te(3100,!1)}function Fp(){return new te(3101,!1)}function Lp(i){return new te(3001,!1)}function jp(i){return new te(3003,!1)}function Vp(i){return new te(3004,!1)}function pc(i,e){return new te(3005,!1)}function mc(){return new te(3006,!1)}function uc(){return new te(3007,!1)}function hc(i,e){return new te(3008,!1)}function gc(i){return new te(3002,!1)}function fc(i,e,t,n,r){return new te(3010,!1)}function _c(){return new te(3011,!1)}function bc(){return new te(3012,!1)}function vc(){return new te(3200,!1)}function yc(){return new te(3202,!1)}function Cc(){return new te(3013,!1)}function Sc(i){return new te(3014,!1)}function wc(i){return new te(3015,!1)}function xc(i){return new te(3016,!1)}function Tc(i,e){return new te(3404,!1)}function zp(i){return new te(3502,!1)}function Ec(i){return new te(3503,!1)}function Mc(){return new te(3300,!1)}function kc(i){return new te(3504,!1)}function Pc(i){return new te(3301,!1)}function Oc(i,e){return new te(3302,!1)}function Ac(i){return new te(3303,!1)}function Ic(i,e){return new te(3400,!1)}function Dc(i){return new te(3401,!1)}function Rc(i){return new te(3402,!1)}function Nc(i,e){return new te(3505,!1)}function rn(i){switch(i.length){case 0:return new Bt;case 1:return i[0];default:return new In(i)}}function ka(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,k)=>{let T=k,P=y;if(k!=="offset")switch(T=i.normalizePropertyName(T,r),P){case ri:P=t.get(k);break;case bt:P=n.get(k);break;default:P=i.normalizeStyleValue(k,T,P,r);break}b.set(T,P)}),_||o.push(b),s=b,a=m}),r.length)throw zp(r);return o}function Hr(i,e,t,n){switch(e){case"start":i.onStart(()=>n(t&&Ta(t,"start",i)));break;case"done":i.onDone(()=>n(t&&Ta(t,"done",i)));break;case"destroy":i.onDestroy(()=>n(t&&Ta(t,"destroy",i)));break}}function Ta(i,e,t){let n=t.totalTime,r=!!t.disabled,o=Ur(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 Ur(i,e,t,n,r="",o=0,a){return{element:i,triggerName:e,fromState:t,toState:n,phaseName:r,totalTime:o,disabled:!!a}}function ot(i,e,t){let n=i.get(e);return n||i.set(e,n=t),n}function Pa(i){let e=i.indexOf(":"),t=i.substring(1,e),n=i.slice(e+1);return[t,n]}var $p=typeof document>"u"?null:document.documentElement;function Wr(i){let e=i.parentNode||i.host||null;return e===$p?null:e}function Bp(i){return i.substring(1,6)=="ebkit"}var Dn=null,dc=!1;function Fc(i){Dn||(Dn=Hp()||{},dc=Dn.style?"WebkitAppearance"in Dn.style:!1);let e=!0;return Dn.style&&!Bp(i)&&(e=i in Dn.style,!e&&dc&&(e="Webkit"+i.charAt(0).toUpperCase()+i.slice(1)in Dn.style)),e}function Hp(){return typeof document<"u"?document.body:null}function Oa(i,e){for(;e;){if(e===i)return!0;e=Wr(e)}return!1}function Aa(i,e,t){if(t)return Array.from(i.querySelectorAll(e));let n=i.querySelector(e);return n?[n]:[]}var Up=1e3,Ia="{{",Wp="}}",Da="ng-enter",qr="ng-leave",zi="ng-trigger",$i=".ng-trigger",Ra="ng-animating",Gr=".ng-animating";function Ht(i){if(typeof i=="number")return i;let e=i.match(/^(-?[\.\d]+)(m?s)/);return!e||e.length<2?0:Ea(parseFloat(e[1]),e[2])}function Ea(i,e){return e==="s"?i*Up:i}function Bi(i,e,t){return i.hasOwnProperty("duration")?i:Gp(i,e,t)}var qp=/^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;function Gp(i,e,t){let n,r=0,o="";if(typeof i=="string"){let a=i.match(qp);if(a===null)return e.push(cc(i)),{duration:0,delay:0,easing:""};n=Ea(parseFloat(a[1]),a[2]);let s=a[3];s!=null&&(r=Ea(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(Np()),a=!0),r<0&&(e.push(Fp()),a=!0),a&&e.splice(s,0,cc(i))}return{duration:n,delay:r,easing:o}}function Lc(i){return i.length?i[0]instanceof Map?i:i.map(e=>new Map(Object.entries(e))):[]}function Et(i,e,t){e.forEach((n,r)=>{let o=Yr(r);t&&!t.has(r)&&t.set(r,i.style[o]),i.style[o]=n})}function _n(i,e){e.forEach((t,n)=>{let r=Yr(n);i.style[r]=""})}function oi(i){return Array.isArray(i)?i.length==1?i[0]:lc(i):i}function jc(i,e,t){let n=e.params||{},r=Na(i);r.length&&r.forEach(o=>{n.hasOwnProperty(o)||t.push(Lp(o))})}var Ma=new RegExp(`${Ia}\\s*(.+?)\\s*${Wp}`,"g");function Na(i){let e=[];if(typeof i=="string"){let t;for(;t=Ma.exec(i);)e.push(t[1]);Ma.lastIndex=0}return e}function ai(i,e,t){let n=`${i}`,r=n.replace(Ma,(o,a)=>{let s=e[a];return s==null&&(t.push(jp(a)),s=""),s.toString()});return r==n?i:r}var Yp=/-+([a-z0-9])/g;function Yr(i){return i.replace(Yp,(...e)=>e[1].toUpperCase())}function Vc(i,e){return i===0||e===0}function zc(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,Qr(i,s)))}}return e}function at(i,e,t){switch(e.type){case q.Trigger:return i.visitTrigger(e,t);case q.State:return i.visitState(e,t);case q.Transition:return i.visitTransition(e,t);case q.Sequence:return i.visitSequence(e,t);case q.Group:return i.visitGroup(e,t);case q.Animate:return i.visitAnimate(e,t);case q.Keyframes:return i.visitKeyframes(e,t);case q.Style:return i.visitStyle(e,t);case q.Reference:return i.visitReference(e,t);case q.AnimateChild:return i.visitAnimateChild(e,t);case q.AnimateRef:return i.visitAnimateRef(e,t);case q.Query:return i.visitQuery(e,t);case q.Stagger:return i.visitStagger(e,t);default:throw Vp(e.type)}}function Qr(i,e){return window.getComputedStyle(i)[e]}var Za=(()=>{class i{validateStyleProperty(t){return Fc(t)}containsElement(t,n){return Oa(t,n)}getParentElement(t){return Wr(t)}query(t,n,r){return Aa(t,n,r)}computeStyle(t,n,r){return r||""}animate(t,n,r,o,a,s=[],d){return new Bt(r,o)}static \u0275fac=function(n){return new(n||i)};static \u0275prov=H({token:i,factory:i.\u0275fac})}return i})(),Nn=class{static NOOP=new Za},Fn=class{};var Qp=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"]),eo=class extends Fn{normalizePropertyName(e,t){return Yr(e)}normalizeStyleValue(e,t,n,r){let o="",a=n.toString().trim();if(Qp.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(pc(e,n))}return a+o}};var to="*";function Kp(i,e){let t=[];return typeof i=="string"?i.split(/\s*,\s*/).forEach(n=>Xp(n,t,e)):t.push(i),t}function Xp(i,e,t){if(i[0]==":"){let d=Zp(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(wc(i)),e;let r=n[1],o=n[2],a=n[3];e.push($c(r,a));let s=r==to&&a==to;o[0]=="<"&&!s&&e.push($c(a,r))}function Zp(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(xc(i)),"* => *"}}var Kr=new Set(["true","1"]),Xr=new Set(["false","0"]);function $c(i,e){let t=Kr.has(i)||Xr.has(i),n=Kr.has(e)||Xr.has(e);return(r,o)=>{let a=i==to||i==r,s=e==to||e==o;return!a&&t&&typeof r=="boolean"&&(a=r?Kr.has(i):Xr.has(i)),!s&&n&&typeof o=="boolean"&&(s=o?Kr.has(e):Xr.has(e)),a&&s}}var Xc=":self",Jp=new RegExp(`s*${Xc}s*,?`,"g");function Zc(i,e,t,n){return new $a(i).build(e,t,n)}var Bc="",$a=class{_driver;constructor(e){this._driver=e}build(e,t,n){let r=new Ba(t);return this._resetContextStyleTimingState(r),at(this,oi(e),r)}_resetContextStyleTimingState(e){e.currentQuerySelector=Bc,e.collectedStyles=new Map,e.collectedStyles.set(Bc,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(mc()),e.definitions.forEach(s=>{if(this._resetContextStyleTimingState(t),s.type==q.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==q.Transition){let d=this.visitTransition(s,t);n+=d.queryCount,r+=d.depCount,a.push(d)}else t.errors.push(uc())}),{type:q.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=>{Na(d).forEach(m=>{a.hasOwnProperty(m)||o.add(m)})})}),o.size&&t.errors.push(hc(e.name,[...o.values()]))}return{type:q.State,name:e.name,style:n,options:r?{params:r}:null}}visitTransition(e,t){t.queryCount=0,t.depCount=0;let n=at(this,oi(e.animation),t),r=Kp(e.expr,t.errors);return{type:q.Transition,matchers:r,animation:n,queryCount:t.queryCount,depCount:t.depCount,options:Rn(e.options)}}visitSequence(e,t){return{type:q.Sequence,steps:e.steps.map(n=>at(this,n,t)),options:Rn(e.options)}}visitGroup(e,t){let n=t.currentTime,r=0,o=e.steps.map(a=>{t.currentTime=n;let s=at(this,a,t);return r=Math.max(r,t.currentTime),s});return t.currentTime=r,{type:q.Group,steps:o,options:Rn(e.options)}}visitAnimate(e,t){let n=im(e.timings,t.errors);t.currentAnimateTimings=n;let r,o=e.styles?e.styles:fn({});if(o.type==q.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=fn(m)}t.currentTime+=n.duration+n.delay;let d=this.visitStyle(a,t);d.isEmptyStep=s,r=d}return t.currentAnimateTimings=null,{type:q.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===bt?n.push(s):t.errors.push(gc(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(Ia)>=0){o=!0;break}}}),{type:q.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(fc(d,_.startTime,_.endTime,o,r)),b=!1),o=_.startTime),b&&m.set(d,{startTime:o,endTime:r}),t.options&&jc(s,t.options,t.errors)})})}visitKeyframes(e,t){let n={type:q.Keyframes,styles:[],options:null};if(!t.currentAnimateTimings)return t.errors.push(_c()),n;let r=1,o=0,a=[],s=!1,d=!1,m=0,_=e.steps.map(pe=>{let N=this._makeStyleAst(pe,t),X=N.offset!=null?N.offset:nm(N.styles),U=0;return X!=null&&(o++,U=N.offset=X),d=d||U<0||U>1,s=s||U<m,m=U,a.push(U),N});d&&t.errors.push(bc()),s&&t.errors.push(vc());let b=e.steps.length,y=0;o>0&&o<b?t.errors.push(yc()):o==0&&(y=r/(b-1));let k=b-1,T=t.currentTime,P=t.currentAnimateTimings,K=P.duration;return _.forEach((pe,N)=>{let X=y>0?N==k?1:y*N:a[N],U=X*K;t.currentTime=T+P.delay+U,P.duration=U,this._validateStyleAst(pe,t),pe.offset=X,n.styles.push(pe)}),n}visitReference(e,t){return{type:q.Reference,animation:at(this,oi(e.animation),t),options:Rn(e.options)}}visitAnimateChild(e,t){return t.depCount++,{type:q.AnimateChild,options:Rn(e.options)}}visitAnimateRef(e,t){return{type:q.AnimateRef,animation:this.visitReference(e.animation,t),options:Rn(e.options)}}visitQuery(e,t){let n=t.currentQuerySelector,r=e.options||{};t.queryCount++,t.currentQuery=e;let[o,a]=em(e.selector);t.currentQuerySelector=n.length?n+" "+o:o,ot(t.collectedStyles,t.currentQuerySelector,new Map);let s=at(this,oi(e.animation),t);return t.currentQuery=null,t.currentQuerySelector=n,{type:q.Query,selector:o,limit:r.limit||0,optional:!!r.optional,includeSelf:a,animation:s,originalSelector:e.selector,options:Rn(e.options)}}visitStagger(e,t){t.currentQuery||t.errors.push(Cc());let n=e.timings==="full"?{duration:0,delay:0,easing:"full"}:Bi(e.timings,t.errors,!0);return{type:q.Stagger,animation:at(this,oi(e.animation),t),timings:n,options:null}}};function em(i){let e=!!i.split(/\s*,\s*/).find(t=>t==Xc);return e&&(i=i.replace(Jp,"")),i=i.replace(/@\*/g,$i).replace(/@\w+/g,t=>$i+"-"+t.slice(1)).replace(/:animating/g,Gr),[i,e]}function tm(i){return i?Y({},i):null}var Ba=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 nm(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 im(i,e){if(i.hasOwnProperty("duration"))return i;if(typeof i=="number"){let o=Bi(i,e).duration;return Fa(o,0,"")}let t=i;if(t.split(/\s+/).some(o=>o.charAt(0)=="{"&&o.charAt(1)=="{")){let o=Fa(0,0,"");return o.dynamic=!0,o.strValue=t,o}let r=Bi(t,e);return Fa(r.duration,r.delay,r.easing)}function Rn(i){return i?(i=Y({},i),i.params&&(i.params=tm(i.params))):i={},i}function Fa(i,e,t){return{duration:i,delay:e,easing:t}}function Ja(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 Ui=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()}},rm=1,om=":enter",am=new RegExp(om,"g"),sm=":leave",lm=new RegExp(sm,"g");function Jc(i,e,t,n,r,o=new Map,a=new Map,s,d,m=[]){return new Ha().buildKeyframes(i,e,t,n,r,o,a,s,d,m)}var Ha=class{buildKeyframes(e,t,n,r,o,a,s,d,m,_=[]){m=m||new Ui;let b=new Ua(e,t,m,r,o,_,[]);b.options=d;let y=d.delay?Ht(d.delay):0;b.currentTimeline.delayNextStep(y),b.currentTimeline.setStyles([a],null,b.errors,d),at(this,n,b);let k=b.timelines.filter(T=>T.containsAnimation());if(k.length&&s.size){let T;for(let P=k.length-1;P>=0;P--){let K=k[P];if(K.element===t){T=K;break}}T&&!T.allowOnlyTimelineStyles()&&T.setStyles([s],null,b.errors,d)}return k.length?k.map(T=>T.buildKeyframes()):[Ja(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:Ht(ai(o,r?.params??{},t.errors));n.delayNextStep(a)}}}_visitSubInstructions(e,t,n){let o=t.currentTimeline.currentTime,a=n.duration!=null?Ht(n.duration):null,s=n.delay!=null?Ht(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),at(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==q.Style&&(r.currentTimeline.snapshotCurrentStyles(),r.previousNode=no);let a=Ht(o.delay);r.delayNextStep(a)}e.steps.length&&(e.steps.forEach(a=>at(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?Ht(e.options.delay):0;e.steps.forEach(a=>{let s=t.createSubContext(e.options);o&&s.delayNextStep(o),at(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?ai(n,t.params,t.errors):n;return Bi(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==q.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?Ht(r.delay):0;o&&(t.previousNode.type===q.Style||n==0&&t.currentTimeline.hasCurrentStyleProperties())&&(t.currentTimeline.snapshotCurrentStyles(),t.previousNode=no);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),at(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;at(this,e.animation,t),t.previousNode=e,n.currentStaggerTime=r.currentTime-b+(r.startTime-n.currentTimeline.startTime)}},no={},Ua=class i{_driver;element;subInstructions;_enterClassName;_leaveClassName;errors;timelines;parentContext=null;currentTimeline;currentAnimateTimings=null;previousNode=no;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 io(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=Ht(n.duration)),n.delay!=null&&(r.delay=Ht(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]=ai(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=no,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 Wa(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(am,"."+this._enterClassName),e=e.replace(lm,"."+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(Sc(t)),s}},io=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+=rm,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||bt),this._currentKeyframe.set(t,bt);this._currentEmptyStepKeyframe=this._currentKeyframe}setStyles(e,t,n,r){t&&this._previousKeyframe.set("easing",t);let o=r&&r.params||{},a=cm(e,this._globalTimelineStyles);for(let[s,d]of a){let m=ai(d,o,n);this._pendingStyles.set(s,m),this._localTimelineStyles.has(s)||this._backFill.set(s,this._globalTimelineStyles.get(s)??bt),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)=>{_===ri?e.add(b):_===bt&&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 Ja(this.element,r,o,a,this.duration,this.startTime,this.easing,!1)}},Wa=class extends io{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",Hc(s)),o.push(m);let _=e.length-1;for(let b=1;b<=_;b++){let y=new Map(e[b]),k=y.get("offset"),T=t+k*n;y.set("offset",Hc(T/a)),o.push(y)}n=a,t=0,r="",e=o}return Ja(this.element,e,this.preStyleProps,this.postStyleProps,n,t,r,!0)}};function Hc(i,e=3){let t=Math.pow(10,e-1);return Math.round(i*t)/t}function cm(i,e){let t=new Map,n;return i.forEach(r=>{if(r==="*"){n??=e.keys();for(let o of n)t.set(o,bt)}else for(let[o,a]of r)t.set(o,a)}),t}function Uc(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 La={},ro=class{_triggerName;ast;_stateStyles;constructor(e,t,n){this._triggerName=e,this.ast=t,this._stateStyles=n}match(e,t,n,r){return dm(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||La,k=s&&s.params||La,T=this.buildStyles(n,k,b),P=d&&d.params||La,K=this.buildStyles(r,P,b),pe=new Set,N=new Map,X=new Map,U=r==="void",Ee={params:ed(P,y),delay:this.ast.options?.delay},ce=_?[]:Jc(e,t,this.ast.animation,o,a,T,K,Ee,m,b),Ce=0;return ce.forEach(Be=>{Ce=Math.max(Be.duration+Be.delay,Ce)}),b.length?Uc(t,this._triggerName,n,r,U,T,K,[],[],N,X,Ce,b):(ce.forEach(Be=>{let Zt=Be.element,dn=ot(N,Zt,new Set);Be.preStyleProps.forEach(St=>dn.add(St));let je=ot(X,Zt,new Set);Be.postStyleProps.forEach(St=>je.add(St)),Zt!==t&&pe.add(Zt)}),Uc(t,this._triggerName,n,r,U,T,K,ce,[...pe.values()],N,X,Ce))}};function dm(i,e,t,n,r){return i.some(o=>o(e,t,n,r))}function ed(i,e){let t=Y({},e);return Object.entries(i).forEach(([n,r])=>{r!=null&&(t[n]=r)}),t}var qa=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=ed(e,this.defaultParams);return this.styles.styles.forEach(o=>{typeof o!="string"&&o.forEach((a,s)=>{a&&(a=ai(a,r,t));let d=this.normalizer.normalizePropertyName(s,t);a=this.normalizer.normalizeStyleValue(s,d,a,t),n.set(s,a)})}),n}};function pm(i,e,t){return new Ga(i,e,t)}var Ga=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 qa(r.style,o,n))}),Wc(this.states,"true","1"),Wc(this.states,"false","0"),t.transitions.forEach(r=>{this.transitionFactories.push(new ro(e,r,this.states))}),this.fallbackTransition=mm(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 mm(i,e,t){let n=[(a,s)=>!0],r={type:q.Sequence,steps:[],options:null},o={type:q.Transition,animation:r,matchers:n,options:null,queryCount:0,depCount:0};return new ro(i,o,e)}function Wc(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 um=new Ui,Ya=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=Zc(this._driver,t,n,r);if(n.length)throw Ec(n);this._animations.set(e,o)}_buildPlayer(e,t,n){let r=e.element,o=ka(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=Jc(this._driver,t,o,Da,qr,new Map,new Map,n,um,r),a.forEach(_=>{let b=ot(s,_.element,new Map);_.postStyleProps.forEach(y=>b.set(y,null))})):(r.push(Mc()),a=[]),r.length)throw kc(r);s.forEach((_,b)=>{_.forEach((y,k)=>{_.set(k,this._driver.computeStyle(b,k,bt))})});let d=a.map(_=>{let b=s.get(_.element);return this._buildPlayer(_,new Map,b)}),m=rn(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 Pc(e);return t}listen(e,t,n,r){let o=Ur(t,"","","");return Hr(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}}},qc="ng-animate-queued",hm=".ng-animate-queued",ja="ng-animate-disabled",gm=".ng-animate-disabled",fm="ng-star-inserted",_m=".ng-star-inserted",bm=[],td={namespaceId:"",setForRemoval:!1,setForMove:!1,hasAnimation:!1,removedBeforeQueried:!1},vm={namespaceId:"",setForMove:!1,setForRemoval:!1,hasAnimation:!1,removedBeforeQueried:!0},Mt="__ng_removed",Wi=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=Cm(r),n){let o=e,{value:a}=o,s=Qs(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])})}}},Hi="void",Va=new Wi(Hi),Qa=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,vt(t,this._hostClassName)}listen(e,t,n,r){if(!this._triggers.has(t))throw Oc(n,t);if(n==null||n.length==0)throw Ac(t);if(!Sm(n))throw Ic(n,t);let o=ot(this._elementListeners,e,[]),a={name:t,phase:n,callback:r};o.push(a);let s=ot(this._engine.statesByElement,e,new Map);return s.has(t)||(vt(e,zi),vt(e,zi+"-"+t),s.set(t,Va)),()=>{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 Dc(e);return t}trigger(e,t,n,r=!0){let o=this._getTrigger(t),a=new qi(this.id,t,e),s=this._engine.statesByElement.get(e);s||(vt(e,zi),vt(e,zi+"-"+t),this._engine.statesByElement.set(e,s=new Map));let d=s.get(t),m=new Wi(n,this.id);if(!(n&&n.hasOwnProperty("value"))&&d&&m.absorbOptions(d.options),s.set(t,m),d||(d=Va),!(m.value===Hi)&&d.value===m.value){if(!Tm(d.params,m.params)){let P=[],K=o.matchStyles(d.value,d.params,P),pe=o.matchStyles(m.value,m.params,P);P.length?this._engine.reportError(P):this._engine.afterFlush(()=>{_n(e,K),Et(e,pe)})}return}let y=ot(this._engine.playersByElement,e,[]);y.forEach(P=>{P.namespaceId==this.id&&P.triggerName==t&&P.queued&&P.destroy()});let k=o.matchTransition(d.value,m.value,e,m.params),T=!1;if(!k){if(!r)return;k=o.fallbackTransition,T=!0}return this._engine.totalQueuedPlayers++,this._queue.push({element:e,triggerName:t,transition:k,fromState:d,toState:m,player:a,isFallbackTransition:T}),T||(vt(e,qc),a.onStart(()=>{si(e,qc)})),a.onDone(()=>{let P=this.players.indexOf(a);P>=0&&this.players.splice(P,1);let K=this._engine.playersByElement.get(e);if(K){let pe=K.indexOf(a);pe>=0&&K.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,$i,!0);n.forEach(r=>{if(r[Mt])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,Hi,r);_&&s.push(_)}}),s.length)return this._engine.markElementAsRemoved(this.id,e,!0,t,a),n&&rn(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)||Va,_=new Wi(Hi),b=new qi(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[Mt];(!o||o===td)&&(n.afterFlush(()=>this.clearElementCache(e)),n.destroyInnerAnimations(e),n._onRemovalComplete(e,t))}}insertNode(e,t){vt(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=Ur(o,n.triggerName,n.fromState.value,n.toState.value);d._data=e,Hr(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)}},Ka=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 Qa(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(Zr(t)){let o=this._fetchNamespace(e);if(o)return o.trigger(t,n,r),!0}return!1}insertNode(e,t,n,r){if(!Zr(t))return;let o=t[Mt];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),vt(e,ja)):this.disabledNodes.has(e)&&(this.disabledNodes.delete(e),si(e,ja))}removeNode(e,t,n){if(Zr(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[Mt]={namespaceId:e,setForRemoval:r,hasAnimation:n,removedBeforeQueried:!1,previousTriggersValues:o}}listen(e,t,n,r,o){return Zr(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,$i,!0);t.forEach(n=>this.destroyActiveAnimationsForElement(n)),this.playersByQueriedElement.size!=0&&(t=this.driver.query(e,Gr,!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 rn(this.players).onDone(()=>e());e()})}processLeaveNode(e){let t=e[Mt];if(t&&t.setForRemoval){if(e[Mt]=td,t.namespaceId){this.destroyInnerAnimations(e);let n=this._fetchNamespace(t.namespaceId);n&&n.clearElementCache(e)}this._onRemovalComplete(e,t.setForRemoval)}e.classList?.contains(ja)&&this.markElementAsDisabled(e,!1),this.driver.query(e,gm,!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];vt(r,fm)}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?rn(t).onDone(()=>{n.forEach(r=>r())}):n.forEach(r=>r())}}reportError(e){throw Rc(e)}_flushAnimations(e,t){let n=new Ui,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,hm,!0);for(let V=0;V<L.length;V++)_.add(L[V])});let b=this.bodyNode,y=Array.from(this.statesByElement.keys()),k=Qc(y,this.collectedEnterElements),T=new Map,P=0;k.forEach((A,L)=>{let V=Da+P++;T.set(L,V),A.forEach(ee=>vt(ee,V))});let K=[],pe=new Set,N=new Set;for(let A=0;A<this.collectedLeaveElements.length;A++){let L=this.collectedLeaveElements[A],V=L[Mt];V&&V.setForRemoval&&(K.push(L),pe.add(L),V.hasAnimation?this.driver.query(L,_m,!0).forEach(ee=>pe.add(ee)):N.add(L))}let X=new Map,U=Qc(y,Array.from(pe));U.forEach((A,L)=>{let V=qr+P++;X.set(L,V),A.forEach(ee=>vt(ee,V))}),e.push(()=>{k.forEach((A,L)=>{let V=T.get(L);A.forEach(ee=>si(ee,V))}),U.forEach((A,L)=>{let V=X.get(L);A.forEach(ee=>si(ee,V))}),K.forEach(A=>{this.processLeaveNode(A)})});let Ee=[],ce=[];for(let A=this._namespaceList.length-1;A>=0;A--)this._namespaceList[A].drainQueuedTransitions(t).forEach(V=>{let ee=V.player,Pe=V.element;if(Ee.push(ee),this.collectedEnterElements.length){let Ie=Pe[Mt];if(Ie&&Ie.setForMove){if(Ie.previousTriggersValues&&Ie.previousTriggersValues.has(V.triggerName)){let et=Ie.previousTriggersValues.get(V.triggerName),Ye=this.statesByElement.get(V.element);if(Ye&&Ye.has(V.triggerName)){let pn=Ye.get(V.triggerName);pn.value=et,Ye.set(V.triggerName,pn)}}ee.destroy();return}}let le=!b||!this.driver.containsElement(b,Pe),He=X.get(Pe),me=T.get(Pe),ue=this._buildInstruction(V,n,me,He,le);if(ue.errors&&ue.errors.length){ce.push(ue);return}if(le){ee.onStart(()=>_n(Pe,ue.fromStyles)),ee.onDestroy(()=>Et(Pe,ue.toStyles)),r.push(ee);return}if(V.isFallbackTransition){ee.onStart(()=>_n(Pe,ue.fromStyles)),ee.onDestroy(()=>Et(Pe,ue.toStyles)),r.push(ee);return}let _e=[];ue.timelines.forEach(Ie=>{Ie.stretchStartingKeyframe=!0,this.disabledNodes.has(Ie.element)||_e.push(Ie)}),ue.timelines=_e,n.append(Pe,ue.timelines);let xn={instruction:ue,player:ee,element:Pe};a.push(xn),ue.queriedElements.forEach(Ie=>ot(s,Ie,[]).push(ee)),ue.preStyleProps.forEach((Ie,et)=>{if(Ie.size){let Ye=d.get(et);Ye||d.set(et,Ye=new Set),Ie.forEach((pn,Un)=>Ye.add(Un))}}),ue.postStyleProps.forEach((Ie,et)=>{let Ye=m.get(et);Ye||m.set(et,Ye=new Set),Ie.forEach((pn,Un)=>Ye.add(Un))})});if(ce.length){let A=[];ce.forEach(L=>{A.push(Nc(L.triggerName,L.errors))}),Ee.forEach(L=>L.destroy()),this.reportError(A)}let Ce=new Map,Be=new Map;a.forEach(A=>{let L=A.element;n.has(L)&&(Be.set(L,L),this._beforeAnimationBuild(A.player.namespaceId,A.instruction,Ce))}),r.forEach(A=>{let L=A.element;this._getPreviousPlayers(L,!1,A.namespaceId,A.triggerName,null).forEach(ee=>{ot(Ce,L,[]).push(ee),ee.destroy()})});let Zt=K.filter(A=>Kc(A,d,m)),dn=new Map;Yc(dn,this.driver,N,m,bt).forEach(A=>{Kc(A,d,m)&&Zt.push(A)});let St=new Map;k.forEach((A,L)=>{Yc(St,this.driver,new Set(A),d,ri)}),Zt.forEach(A=>{let L=dn.get(A),V=St.get(A);dn.set(A,new Map([...L?.entries()??[],...V?.entries()??[]]))});let wn=[],Hn=[],mr={};a.forEach(A=>{let{element:L,player:V,instruction:ee}=A;if(n.has(L)){if(_.has(L)){V.onDestroy(()=>Et(L,ee.toStyles)),V.disabled=!0,V.overrideTotalTime(ee.totalTime),r.push(V);return}let Pe=mr;if(Be.size>1){let He=L,me=[];for(;He=He.parentNode;){let ue=Be.get(He);if(ue){Pe=ue;break}me.push(He)}me.forEach(ue=>Be.set(ue,Pe))}let le=this._buildAnimation(V.namespaceId,ee,Ce,o,St,dn);if(V.setRealPlayer(le),Pe===mr)wn.push(V);else{let He=this.playersByElement.get(Pe);He&&He.length&&(V.parentPlayer=rn(He)),r.push(V)}}else _n(L,ee.fromStyles),V.onDestroy(()=>Et(L,ee.toStyles)),Hn.push(V),_.has(L)&&r.push(V)}),Hn.forEach(A=>{let L=o.get(A.element);if(L&&L.length){let V=rn(L);A.setRealPlayer(V)}}),r.forEach(A=>{A.parentPlayer?A.syncPlayerEvents(A.parentPlayer):A.destroy()});for(let A=0;A<K.length;A++){let L=K[A],V=L[Mt];if(si(L,qr),V&&V.hasAnimation)continue;let ee=[];if(s.size){let le=s.get(L);le&&le.length&&ee.push(...le);let He=this.driver.query(L,Gr,!0);for(let me=0;me<He.length;me++){let ue=s.get(He[me]);ue&&ue.length&&ee.push(...ue)}}let Pe=ee.filter(le=>!le.destroyed);Pe.length?wm(this,L,Pe):this.processLeaveNode(L)}return K.length=0,wn.forEach(A=>{this.players.push(A),A.onDone(()=>{A.destroy();let L=this.players.indexOf(A);this.players.splice(L,1)}),A.play()}),wn}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==Hi;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=ot(n,m,[]);this._getPreviousPlayers(m,_,a,s,t.toState).forEach(k=>{let T=k.getRealPlayer();T.beforeDestroy&&T.beforeDestroy(),k.destroy(),b.push(k)})}_n(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(T=>{let P=T.element;_.add(P);let K=P[Mt];if(K&&K.removedBeforeQueried)return new Bt(T.duration,T.delay);let pe=P!==d,N=xm((n.get(P)||bm).map(Ce=>Ce.getRealPlayer())).filter(Ce=>{let Be=Ce;return Be.element?Be.element===P:!1}),X=o.get(P),U=a.get(P),Ee=ka(this._normalizer,T.keyframes,X,U),ce=this._buildPlayer(T,Ee,N);if(T.subTimeline&&r&&b.add(P),pe){let Ce=new qi(e,s,P);Ce.setRealPlayer(ce),m.push(Ce)}return ce});m.forEach(T=>{ot(this.playersByQueriedElement,T.element,[]).push(T),T.onDone(()=>ym(this.playersByQueriedElement,T.element,T))}),_.forEach(T=>vt(T,Ra));let k=rn(y);return k.onDestroy(()=>{_.forEach(T=>si(T,Ra)),Et(d,t.toStyles)}),b.forEach(T=>{ot(r,T,[]).push(k)}),k}_buildPlayer(e,t,n){return t.length>0?this.driver.animate(e.element,t,e.duration,e.delay,e.easing,n):new Bt(e.duration,e.delay)}},qi=class{namespaceId;triggerName;element;_player=new Bt;_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=>Hr(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){ot(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 ym(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 Cm(i){return i??null}function Zr(i){return i&&i.nodeType===1}function Sm(i){return i=="start"||i=="done"}function Gc(i,e){let t=i.style.display;return i.style.display=e??"none",t}function Yc(i,e,t,n,r){let o=[];t.forEach(d=>o.push(Gc(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[Mt]=vm,a.push(m))}),i.set(m,_)});let s=0;return t.forEach(d=>Gc(d,o[s++])),a}function Qc(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 vt(i,e){i.classList?.add(e)}function si(i,e){i.classList?.remove(e)}function wm(i,e,t){rn(t).onDone(()=>i.processLeaveNode(e))}function xm(i){let e=[];return nd(i,e),e}function nd(i,e){for(let t=0;t<i.length;t++){let n=i[t];n instanceof In?nd(n.players,e):e.push(n)}}function Tm(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 Kc(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 li=class{_driver;_normalizer;_transitionEngine;_timelineEngine;_triggerCache={};onRemovalComplete=(e,t)=>{};constructor(e,t,n){this._driver=t,this._normalizer=n,this._transitionEngine=new Ka(e.body,t,n),this._timelineEngine=new Ya(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=[],_=Zc(this._driver,o,d,m);if(d.length)throw Tc(r,d);s=pm(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]=Pa(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]=Pa(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 Em(i,e){let t=null,n=null;return Array.isArray(e)&&e.length?(t=za(e[0]),e.length>1&&(n=za(e[e.length-1]))):e instanceof Map&&(t=za(e)),t||n?new Mm(i,t,n):null}var Mm=(()=>{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&&Et(this._element,this._startStyles,this._initialStyles),this._state=1)}finish(){this.start(),this._state<2&&(Et(this._element,this._initialStyles),this._endStyles&&(Et(this._element,this._endStyles),this._endStyles=null),this._state=1)}destroy(){this.finish(),this._state<3&&(i.initialStylesByElement.delete(this._element),this._startStyles&&(_n(this._element,this._startStyles),this._endStyles=null),this._endStyles&&(_n(this._element,this._endStyles),this._endStyles=null),Et(this._element,this._initialStyles),this._state=3)}}return i})();function za(i){let e=null;return i.forEach((t,n)=>{km(n)&&(e=e||new Map,e.set(n,t))}),e}function km(i){return i==="display"||i==="position"}var oo=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:Qr(this.element,r))}),this.currentSnapshot=e}triggerCallback(e){let t=e==="start"?this._onStartFns:this._onDoneFns;t.forEach(n=>n()),t.length=0}},ao=class{validateStyleProperty(e){return!0}validateAnimatableStyleProperty(e){return!0}containsElement(e,t){return Oa(e,t)}getParentElement(e){return Wr(e)}query(e,t,n){return Aa(e,t,n)}computeStyle(e,t,n){return Qr(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(k=>k instanceof oo);Vc(n,r)&&_.forEach(k=>{k.currentSnapshot.forEach((T,P)=>m.set(P,T))});let b=Lc(t).map(k=>new Map(k));b=zc(e,b,m);let y=Em(e,b);return new oo(e,b,d,y)}};var Jr="@",id="@.disabled",so=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)==Jr&&t==id?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)}},Xa=class extends so{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)==Jr?t.charAt(1)=="."&&t==id?(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)==Jr){let o=Pm(e),a=t.slice(1),s="";return a.charAt(0)!=Jr&&([a,s]=Om(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 Pm(i){switch(i){case"body":return document.body;case"document":return document;case"window":return window;default:return i}}function Om(i){let e=i.indexOf("."),t=i.substring(0,e),n=i.slice(e+1);return[t,n]}var lo=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 so("",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 Xa(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 Im=(()=>{class i extends li{constructor(t,n,r){super(t,n,r)}ngOnDestroy(){this.flush()}static \u0275fac=function(n){return new(n||i)(Cr(ei),Cr(Nn),Cr(Fn))};static \u0275prov=H({token:i,factory:i.\u0275fac})}return i})();function Dm(){return new eo}function Rm(){return new lo(f(_l),f(li),f(Lt))}var rd=[{provide:Fn,useFactory:Dm},{provide:li,useClass:Im},{provide:ll,useFactory:Rm}],a_=[{provide:Nn,useClass:Za},{provide:ha,useValue:"NoopAnimations"},...rd],Nm=[{provide:Nn,useFactory:()=>new ao},{provide:ha,useFactory:()=>"BrowserAnimations"},...rd];function od(){return sl("NgEagerAnimations"),[...Nm]}var co="__",po=class i{router=f(zt);projectStateService=f(ve);projects=Ae(this.projectStateService.projectList$);forcedProject=Ae(this.projectStateService.forcedProject$);projectItems=Tt(()=>{let e=this.projects();if(!e)return[];let t=e.filter(y=>!y.name.includes(co)),n=e.filter(y=>y.name.includes(co)),r=new Set(t.map(y=>y.name)),o=y=>y.split(co)[0]??null,a=new Set(n.map(y=>o(y.name)).filter(y=>y!==null&&r.has(y))),s=[],d=[...a].sort((y,k)=>y.localeCompare(k));for(let y of d){let k=t.find(P=>P.name===y);s.push(he(Y({},this.toEntityListItem(k)),{groupKey:y,groupLabel:y}));let T=n.filter(P=>o(P.name)===y).sort((P,K)=>P.name.localeCompare(K.name));for(let P of T){let K=P.name.slice(y.length+co.length);s.push(he(Y({},this.toEntityListItem(P)),{name:K,description:P.name,groupKey:y,groupLabel:y}))}}let m=[...t].filter(y=>!a.has(y.name)&&!y.volatile).sort((y,k)=>y.name.localeCompare(k.name));for(let y of m)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__standalone__",groupLabel:"Projects"}));let _=[...t].filter(y=>!a.has(y.name)&&y.volatile).sort((y,k)=>y.name.localeCompare(k.name));for(let y of _)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__volatile__",groupLabel:"Temporary"}));let b=n.filter(y=>{let k=o(y.name);return k!==null&&!r.has(k)}).sort((y,k)=>y.name.localeCompare(k.name));for(let y of b)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__orphaned__",groupLabel:"Orphaned worktrees"}));return s});showCreateButton=Tt(()=>!this.forcedProject());constructor(){this.projectStateService.selectedProject$.pipe(ut(),Se(e=>!!e),Se(()=>this.router.url.split("?")[0]==="/"),Zn(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"])}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=R({type:i,selectors:[["app-project-selection"]],decls:2,vars:3,consts:[["title","Projects","contentMaxWidth","1400px","searchPlaceholder","Filter projects\u2026","emptyMessage","No projects found.",3,"itemSelected","createRequested","items","showCreate","autoFocusSearch"],["toolbar-start","","src","CODAY-Logo.png","alt","Coday",1,"project-list__logo"]],template:function(t,n){t&1&&(l(0,"ds-entity-list",0),v("itemSelected",function(o){return n.onItemSelected(o)})("createRequested",function(){return n.onCreateRequested()}),F(1,"img",1),c()),t&2&&E("items",n.projectItems())("showCreate",n.showCreateButton())("autoFocusSearch",!0)},dependencies:[ic],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.project-list__logo[_ngcontent-%COMP%]{width:40px;height:40px;object-fit:contain;flex-shrink:0;border-radius:4px}"]})};var ke=class i{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new W("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();enterToSendSubject=new W(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new W(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new W("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new W(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new W(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new W(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new W(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new W(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new W(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new W(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new W(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new W(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new W(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.asObservable();themeSubject=new W("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 k=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(k);let T=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(T);let P=this.getPreferenceSync("theme","light")??"light";this.themeSubject.next(P),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return $(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 k=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(k);let T=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(T);let P=(yield this.getPreferenceAsync("theme","light"))??"light";this.themeSubject.next(P),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 $(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 $(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function es(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 Le=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)}},mo=class extends Le{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new st({answer:e,parentKey:this.timestamp,invite:this.invite})}},ci=class i extends Le{static type="heartbeat";constructor(e){super(e,i.type)}},on=class i extends mo{defaultValue;static type="invite";constructor(e){super(e,i.type),this.defaultValue=e.defaultValue}},ts="InviteEventDefault",st=class i extends Le{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}},Ut=class i extends Le{speaker;text;static type="text";constructor(e){super(e,i.type),this.speaker=e.speaker,this.text=e.text}},bn=class i extends Le{chunk;static type="text_chunk";constructor(e){super(e,i.type),this.chunk=e.chunk,this.length=this.chunk.length}},Ln=class i extends Le{warning;static type="warn";constructor(e){super(e,i.type),this.warning=e.warning}},kt=class i extends Le{error;static type="error";constructor(e){super(e,i.type),this.error=e.error}},an=class i extends mo{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}},Pt=class i extends Le{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 yt({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=es(this.args,e);return`\u{1F527} ${this.name}(${t})`}},yt=class i extends Le{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=es(t,e),r=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${n}${r}`}},vn=class i extends Le{static type="thinking";static debounce=5e3;constructor(e){super(e,i.type)}},jn=class i extends Le{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: ${es(this.summary,e)}`}},Ot=class i extends Le{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
- `)}},di=class i extends Le{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}},yn=class i extends Le{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}`}},pi=class i extends Le{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}},Wt=class i extends Le{subThreadId;agentName;static type="delegation";constructor(e){super(e,i.type),this.subThreadId=e.subThreadId,this.agentName=e.agentName}},At=class i extends Le{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}},Fm={[Ot.type]:Ot,[st.type]:st,[an.type]:an,[Wt.type]:Wt,[kt.type]:kt,[ci.type]:ci,[on.type]:on,[Pt.type]:Pt,[yt.type]:yt,[Ut.type]:Ut,[bn.type]:bn,[vn.type]:vn,[Ln.type]:Ln,[di.type]:di,[jn.type]:jn,[yn.type]:yn,[pi.type]:pi,[At.type]:At};function Gi(i){let e=Fm[i.type];return e?new e(i):void 0}var L_=[{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:
1
+ import{a as ac,b as sc,c as lc}from"./chunk-X6TFXJKZ.js";import{a as oc}from"./chunk-3QJA3PD3.js";import{a as Ll,b as jl}from"./chunk-H72Z2LX3.js";import{a as Vl,b as zl,c as $l,d as Bl,e as Hl,f as Ul,g as Wl}from"./chunk-OUZFS4TC.js";import{K as tc,L as $r,T as nc,V as ic,W as rc,g as Nl,h as ii,i as Fl,j as xa,w as Gl,y as ec}from"./chunk-4NNLWDVJ.js";import{F as Dl,G as Lr,I as An,L as qe,M as Rl,N as $t,P as jr,Q as Vr,R as rt,S as de,T as Re,e as Nr,f as wa,h as xl,i as Tl,j as El,m as Ml,o as Fr,p as kl,r as Pl,s as Ol,t as Al,y as Il}from"./chunk-5MXEOOQM.js";import{a as zr,b as ve}from"./chunk-WZJ3UIRS.js";import{B as Zl,C as _t,c as ht,g as gt,m as ft,p as Yl,q as Ql,v as Kl,w as Xl,x as Jl}from"./chunk-AE24ERN3.js";import{h as ql}from"./chunk-2DVVHRX4.js";import{a as ut,b as Ae}from"./chunk-VVZKXHDD.js";import{$ as ha,$a as F,A as ca,Ab as Ve,B as da,Bb as ni,Cb as ne,D as tl,Db as ie,E as pa,Ea as R,Eb as re,Fa as xt,Fb as ml,G as nl,Ga as dl,Gb as gn,Ha as pl,Hb as ul,I as Zn,Ib as Er,J as ma,Ja as ji,Jb as hl,K as I,Ka as ti,Kb as zi,Lb as gl,M as pt,Mb as Ca,N as te,Oa as _a,Ob as Mr,P as H,Q as wt,Qa as Me,Qb as Tt,R as Fi,S as Sr,Sa as C,T as f,Ta as S,Tb as kr,V as il,Wa as we,Wb as fl,X as w,Xa as xe,Xb as Pr,Y as x,Ya as E,Yb as Or,Z as ua,Za as l,Zb as Ar,_ as rl,_a as c,a as Y,aa as ei,ab as un,b as he,ba as wr,bb as hn,c as Ks,ca as Z,cb as ba,cc as Ir,d as B,da as Lt,dc as Dr,ec as _l,f as Cr,fa as ol,fb as On,fc as Sa,g as J,ga as We,gb as O,h as W,ha as Li,hc as nt,ia as jt,ib as v,ja as xr,jc as bl,ka as mt,kb as g,kc as vl,l as Mn,la as al,lb as nn,m as Xn,mb as dt,n as la,nb as va,o as Xs,oa as ga,ob as $e,oc as it,p as Oe,pb as ge,pc as yl,q as kn,qb as fe,qc as Vt,ra as ct,rc as Rr,sa as Pn,sc as Cl,t as Js,ta as sl,tc as zt,u as Zs,ua as p,ub as Vi,uc as Sl,v as Se,va as ll,vb as Qe,vc as wl,wa as fa,wb as G,x as mn,xb as ya,y as el,ya as cl,yb as u,z as Jn,za as Tr,zb as $}from"./chunk-TRUXCA4C.js";var q=(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})(q||{}),bt="*";function Ta(i,e){return{type:q.Trigger,name:i,definitions:e,options:{}}}function Br(i,e=null){return{type:q.Animate,styles:e,timings:i}}function cc(i,e=null){return{type:q.Sequence,steps:i,options:e}}function fn(i){return{type:q.Style,styles:i,offset:null}}function Hr(i,e,t=null){return{type:q.Transition,expr:i,animation:e,options:t}}var Bt=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}},In=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}},ri="!";function dc(i){return new te(3e3,!1)}function Fp(){return new te(3100,!1)}function Lp(){return new te(3101,!1)}function jp(i){return new te(3001,!1)}function Vp(i){return new te(3003,!1)}function zp(i){return new te(3004,!1)}function mc(i,e){return new te(3005,!1)}function uc(){return new te(3006,!1)}function hc(){return new te(3007,!1)}function gc(i,e){return new te(3008,!1)}function fc(i){return new te(3002,!1)}function _c(i,e,t,n,r){return new te(3010,!1)}function bc(){return new te(3011,!1)}function vc(){return new te(3012,!1)}function yc(){return new te(3200,!1)}function Cc(){return new te(3202,!1)}function Sc(){return new te(3013,!1)}function wc(i){return new te(3014,!1)}function xc(i){return new te(3015,!1)}function Tc(i){return new te(3016,!1)}function Ec(i,e){return new te(3404,!1)}function $p(i){return new te(3502,!1)}function Mc(i){return new te(3503,!1)}function kc(){return new te(3300,!1)}function Pc(i){return new te(3504,!1)}function Oc(i){return new te(3301,!1)}function Ac(i,e){return new te(3302,!1)}function Ic(i){return new te(3303,!1)}function Dc(i,e){return new te(3400,!1)}function Rc(i){return new te(3401,!1)}function Nc(i){return new te(3402,!1)}function Fc(i,e){return new te(3505,!1)}function rn(i){switch(i.length){case 0:return new Bt;case 1:return i[0];default:return new In(i)}}function Pa(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,k)=>{let T=k,P=y;if(k!=="offset")switch(T=i.normalizePropertyName(T,r),P){case ri:P=t.get(k);break;case bt:P=n.get(k);break;default:P=i.normalizeStyleValue(k,T,P,r);break}b.set(T,P)}),_||o.push(b),s=b,a=m}),r.length)throw $p(r);return o}function Ur(i,e,t,n){switch(e){case"start":i.onStart(()=>n(t&&Ea(t,"start",i)));break;case"done":i.onDone(()=>n(t&&Ea(t,"done",i)));break;case"destroy":i.onDestroy(()=>n(t&&Ea(t,"destroy",i)));break}}function Ea(i,e,t){let n=t.totalTime,r=!!t.disabled,o=Wr(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 Wr(i,e,t,n,r="",o=0,a){return{element:i,triggerName:e,fromState:t,toState:n,phaseName:r,totalTime:o,disabled:!!a}}function ot(i,e,t){let n=i.get(e);return n||i.set(e,n=t),n}function Oa(i){let e=i.indexOf(":"),t=i.substring(1,e),n=i.slice(e+1);return[t,n]}var Bp=typeof document>"u"?null:document.documentElement;function qr(i){let e=i.parentNode||i.host||null;return e===Bp?null:e}function Hp(i){return i.substring(1,6)=="ebkit"}var Dn=null,pc=!1;function Lc(i){Dn||(Dn=Up()||{},pc=Dn.style?"WebkitAppearance"in Dn.style:!1);let e=!0;return Dn.style&&!Hp(i)&&(e=i in Dn.style,!e&&pc&&(e="Webkit"+i.charAt(0).toUpperCase()+i.slice(1)in Dn.style)),e}function Up(){return typeof document<"u"?document.body:null}function Aa(i,e){for(;e;){if(e===i)return!0;e=qr(e)}return!1}function Ia(i,e,t){if(t)return Array.from(i.querySelectorAll(e));let n=i.querySelector(e);return n?[n]:[]}var Wp=1e3,Da="{{",qp="}}",Ra="ng-enter",Gr="ng-leave",$i="ng-trigger",Bi=".ng-trigger",Na="ng-animating",Yr=".ng-animating";function Ht(i){if(typeof i=="number")return i;let e=i.match(/^(-?[\.\d]+)(m?s)/);return!e||e.length<2?0:Ma(parseFloat(e[1]),e[2])}function Ma(i,e){return e==="s"?i*Wp:i}function Hi(i,e,t){return i.hasOwnProperty("duration")?i:Yp(i,e,t)}var Gp=/^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;function Yp(i,e,t){let n,r=0,o="";if(typeof i=="string"){let a=i.match(Gp);if(a===null)return e.push(dc(i)),{duration:0,delay:0,easing:""};n=Ma(parseFloat(a[1]),a[2]);let s=a[3];s!=null&&(r=Ma(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(Lp()),a=!0),a&&e.splice(s,0,dc(i))}return{duration:n,delay:r,easing:o}}function jc(i){return i.length?i[0]instanceof Map?i:i.map(e=>new Map(Object.entries(e))):[]}function Et(i,e,t){e.forEach((n,r)=>{let o=Qr(r);t&&!t.has(r)&&t.set(r,i.style[o]),i.style[o]=n})}function _n(i,e){e.forEach((t,n)=>{let r=Qr(n);i.style[r]=""})}function oi(i){return Array.isArray(i)?i.length==1?i[0]:cc(i):i}function Vc(i,e,t){let n=e.params||{},r=Fa(i);r.length&&r.forEach(o=>{n.hasOwnProperty(o)||t.push(jp(o))})}var ka=new RegExp(`${Da}\\s*(.+?)\\s*${qp}`,"g");function Fa(i){let e=[];if(typeof i=="string"){let t;for(;t=ka.exec(i);)e.push(t[1]);ka.lastIndex=0}return e}function ai(i,e,t){let n=`${i}`,r=n.replace(ka,(o,a)=>{let s=e[a];return s==null&&(t.push(Vp(a)),s=""),s.toString()});return r==n?i:r}var Qp=/-+([a-z0-9])/g;function Qr(i){return i.replace(Qp,(...e)=>e[1].toUpperCase())}function zc(i,e){return i===0||e===0}function $c(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,Kr(i,s)))}}return e}function at(i,e,t){switch(e.type){case q.Trigger:return i.visitTrigger(e,t);case q.State:return i.visitState(e,t);case q.Transition:return i.visitTransition(e,t);case q.Sequence:return i.visitSequence(e,t);case q.Group:return i.visitGroup(e,t);case q.Animate:return i.visitAnimate(e,t);case q.Keyframes:return i.visitKeyframes(e,t);case q.Style:return i.visitStyle(e,t);case q.Reference:return i.visitReference(e,t);case q.AnimateChild:return i.visitAnimateChild(e,t);case q.AnimateRef:return i.visitAnimateRef(e,t);case q.Query:return i.visitQuery(e,t);case q.Stagger:return i.visitStagger(e,t);default:throw zp(e.type)}}function Kr(i,e){return window.getComputedStyle(i)[e]}var Za=(()=>{class i{validateStyleProperty(t){return Lc(t)}containsElement(t,n){return Aa(t,n)}getParentElement(t){return qr(t)}query(t,n,r){return Ia(t,n,r)}computeStyle(t,n,r){return r||""}animate(t,n,r,o,a,s=[],d){return new Bt(r,o)}static \u0275fac=function(n){return new(n||i)};static \u0275prov=H({token:i,factory:i.\u0275fac})}return i})(),Nn=class{static NOOP=new Za},Fn=class{};var Kp=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"]),to=class extends Fn{normalizePropertyName(e,t){return Qr(e)}normalizeStyleValue(e,t,n,r){let o="",a=n.toString().trim();if(Kp.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(mc(e,n))}return a+o}};var no="*";function Xp(i,e){let t=[];return typeof i=="string"?i.split(/\s*,\s*/).forEach(n=>Jp(n,t,e)):t.push(i),t}function Jp(i,e,t){if(i[0]==":"){let d=Zp(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(xc(i)),e;let r=n[1],o=n[2],a=n[3];e.push(Bc(r,a));let s=r==no&&a==no;o[0]=="<"&&!s&&e.push(Bc(a,r))}function Zp(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(Tc(i)),"* => *"}}var Xr=new Set(["true","1"]),Jr=new Set(["false","0"]);function Bc(i,e){let t=Xr.has(i)||Jr.has(i),n=Xr.has(e)||Jr.has(e);return(r,o)=>{let a=i==no||i==r,s=e==no||e==o;return!a&&t&&typeof r=="boolean"&&(a=r?Xr.has(i):Jr.has(i)),!s&&n&&typeof o=="boolean"&&(s=o?Xr.has(e):Jr.has(e)),a&&s}}var Jc=":self",em=new RegExp(`s*${Jc}s*,?`,"g");function Zc(i,e,t,n){return new Ba(i).build(e,t,n)}var Hc="",Ba=class{_driver;constructor(e){this._driver=e}build(e,t,n){let r=new Ha(t);return this._resetContextStyleTimingState(r),at(this,oi(e),r)}_resetContextStyleTimingState(e){e.currentQuerySelector=Hc,e.collectedStyles=new Map,e.collectedStyles.set(Hc,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(uc()),e.definitions.forEach(s=>{if(this._resetContextStyleTimingState(t),s.type==q.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==q.Transition){let d=this.visitTransition(s,t);n+=d.queryCount,r+=d.depCount,a.push(d)}else t.errors.push(hc())}),{type:q.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=>{Fa(d).forEach(m=>{a.hasOwnProperty(m)||o.add(m)})})}),o.size&&t.errors.push(gc(e.name,[...o.values()]))}return{type:q.State,name:e.name,style:n,options:r?{params:r}:null}}visitTransition(e,t){t.queryCount=0,t.depCount=0;let n=at(this,oi(e.animation),t),r=Xp(e.expr,t.errors);return{type:q.Transition,matchers:r,animation:n,queryCount:t.queryCount,depCount:t.depCount,options:Rn(e.options)}}visitSequence(e,t){return{type:q.Sequence,steps:e.steps.map(n=>at(this,n,t)),options:Rn(e.options)}}visitGroup(e,t){let n=t.currentTime,r=0,o=e.steps.map(a=>{t.currentTime=n;let s=at(this,a,t);return r=Math.max(r,t.currentTime),s});return t.currentTime=r,{type:q.Group,steps:o,options:Rn(e.options)}}visitAnimate(e,t){let n=rm(e.timings,t.errors);t.currentAnimateTimings=n;let r,o=e.styles?e.styles:fn({});if(o.type==q.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=fn(m)}t.currentTime+=n.duration+n.delay;let d=this.visitStyle(a,t);d.isEmptyStep=s,r=d}return t.currentAnimateTimings=null,{type:q.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===bt?n.push(s):t.errors.push(fc(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(Da)>=0){o=!0;break}}}),{type:q.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(_c(d,_.startTime,_.endTime,o,r)),b=!1),o=_.startTime),b&&m.set(d,{startTime:o,endTime:r}),t.options&&Vc(s,t.options,t.errors)})})}visitKeyframes(e,t){let n={type:q.Keyframes,styles:[],options:null};if(!t.currentAnimateTimings)return t.errors.push(bc()),n;let r=1,o=0,a=[],s=!1,d=!1,m=0,_=e.steps.map(pe=>{let N=this._makeStyleAst(pe,t),X=N.offset!=null?N.offset:im(N.styles),U=0;return X!=null&&(o++,U=N.offset=X),d=d||U<0||U>1,s=s||U<m,m=U,a.push(U),N});d&&t.errors.push(vc()),s&&t.errors.push(yc());let b=e.steps.length,y=0;o>0&&o<b?t.errors.push(Cc()):o==0&&(y=r/(b-1));let k=b-1,T=t.currentTime,P=t.currentAnimateTimings,K=P.duration;return _.forEach((pe,N)=>{let X=y>0?N==k?1:y*N:a[N],U=X*K;t.currentTime=T+P.delay+U,P.duration=U,this._validateStyleAst(pe,t),pe.offset=X,n.styles.push(pe)}),n}visitReference(e,t){return{type:q.Reference,animation:at(this,oi(e.animation),t),options:Rn(e.options)}}visitAnimateChild(e,t){return t.depCount++,{type:q.AnimateChild,options:Rn(e.options)}}visitAnimateRef(e,t){return{type:q.AnimateRef,animation:this.visitReference(e.animation,t),options:Rn(e.options)}}visitQuery(e,t){let n=t.currentQuerySelector,r=e.options||{};t.queryCount++,t.currentQuery=e;let[o,a]=tm(e.selector);t.currentQuerySelector=n.length?n+" "+o:o,ot(t.collectedStyles,t.currentQuerySelector,new Map);let s=at(this,oi(e.animation),t);return t.currentQuery=null,t.currentQuerySelector=n,{type:q.Query,selector:o,limit:r.limit||0,optional:!!r.optional,includeSelf:a,animation:s,originalSelector:e.selector,options:Rn(e.options)}}visitStagger(e,t){t.currentQuery||t.errors.push(Sc());let n=e.timings==="full"?{duration:0,delay:0,easing:"full"}:Hi(e.timings,t.errors,!0);return{type:q.Stagger,animation:at(this,oi(e.animation),t),timings:n,options:null}}};function tm(i){let e=!!i.split(/\s*,\s*/).find(t=>t==Jc);return e&&(i=i.replace(em,"")),i=i.replace(/@\*/g,Bi).replace(/@\w+/g,t=>Bi+"-"+t.slice(1)).replace(/:animating/g,Yr),[i,e]}function nm(i){return i?Y({},i):null}var Ha=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 im(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 rm(i,e){if(i.hasOwnProperty("duration"))return i;if(typeof i=="number"){let o=Hi(i,e).duration;return La(o,0,"")}let t=i;if(t.split(/\s+/).some(o=>o.charAt(0)=="{"&&o.charAt(1)=="{")){let o=La(0,0,"");return o.dynamic=!0,o.strValue=t,o}let r=Hi(t,e);return La(r.duration,r.delay,r.easing)}function Rn(i){return i?(i=Y({},i),i.params&&(i.params=nm(i.params))):i={},i}function La(i,e,t){return{duration:i,delay:e,easing:t}}function es(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 Wi=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()}},om=1,am=":enter",sm=new RegExp(am,"g"),lm=":leave",cm=new RegExp(lm,"g");function ed(i,e,t,n,r,o=new Map,a=new Map,s,d,m=[]){return new Ua().buildKeyframes(i,e,t,n,r,o,a,s,d,m)}var Ua=class{buildKeyframes(e,t,n,r,o,a,s,d,m,_=[]){m=m||new Wi;let b=new Wa(e,t,m,r,o,_,[]);b.options=d;let y=d.delay?Ht(d.delay):0;b.currentTimeline.delayNextStep(y),b.currentTimeline.setStyles([a],null,b.errors,d),at(this,n,b);let k=b.timelines.filter(T=>T.containsAnimation());if(k.length&&s.size){let T;for(let P=k.length-1;P>=0;P--){let K=k[P];if(K.element===t){T=K;break}}T&&!T.allowOnlyTimelineStyles()&&T.setStyles([s],null,b.errors,d)}return k.length?k.map(T=>T.buildKeyframes()):[es(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:Ht(ai(o,r?.params??{},t.errors));n.delayNextStep(a)}}}_visitSubInstructions(e,t,n){let o=t.currentTimeline.currentTime,a=n.duration!=null?Ht(n.duration):null,s=n.delay!=null?Ht(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),at(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==q.Style&&(r.currentTimeline.snapshotCurrentStyles(),r.previousNode=io);let a=Ht(o.delay);r.delayNextStep(a)}e.steps.length&&(e.steps.forEach(a=>at(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?Ht(e.options.delay):0;e.steps.forEach(a=>{let s=t.createSubContext(e.options);o&&s.delayNextStep(o),at(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?ai(n,t.params,t.errors):n;return Hi(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==q.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?Ht(r.delay):0;o&&(t.previousNode.type===q.Style||n==0&&t.currentTimeline.hasCurrentStyleProperties())&&(t.currentTimeline.snapshotCurrentStyles(),t.previousNode=io);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),at(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;at(this,e.animation,t),t.previousNode=e,n.currentStaggerTime=r.currentTime-b+(r.startTime-n.currentTimeline.startTime)}},io={},Wa=class i{_driver;element;subInstructions;_enterClassName;_leaveClassName;errors;timelines;parentContext=null;currentTimeline;currentAnimateTimings=null;previousNode=io;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 ro(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=Ht(n.duration)),n.delay!=null&&(r.delay=Ht(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]=ai(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=io,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 qa(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(sm,"."+this._enterClassName),e=e.replace(cm,"."+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(wc(t)),s}},ro=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+=om,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||bt),this._currentKeyframe.set(t,bt);this._currentEmptyStepKeyframe=this._currentKeyframe}setStyles(e,t,n,r){t&&this._previousKeyframe.set("easing",t);let o=r&&r.params||{},a=dm(e,this._globalTimelineStyles);for(let[s,d]of a){let m=ai(d,o,n);this._pendingStyles.set(s,m),this._localTimelineStyles.has(s)||this._backFill.set(s,this._globalTimelineStyles.get(s)??bt),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)=>{_===ri?e.add(b):_===bt&&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 es(this.element,r,o,a,this.duration,this.startTime,this.easing,!1)}},qa=class extends ro{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",Uc(s)),o.push(m);let _=e.length-1;for(let b=1;b<=_;b++){let y=new Map(e[b]),k=y.get("offset"),T=t+k*n;y.set("offset",Uc(T/a)),o.push(y)}n=a,t=0,r="",e=o}return es(this.element,e,this.preStyleProps,this.postStyleProps,n,t,r,!0)}};function Uc(i,e=3){let t=Math.pow(10,e-1);return Math.round(i*t)/t}function dm(i,e){let t=new Map,n;return i.forEach(r=>{if(r==="*"){n??=e.keys();for(let o of n)t.set(o,bt)}else for(let[o,a]of r)t.set(o,a)}),t}function Wc(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 ja={},oo=class{_triggerName;ast;_stateStyles;constructor(e,t,n){this._triggerName=e,this.ast=t,this._stateStyles=n}match(e,t,n,r){return pm(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||ja,k=s&&s.params||ja,T=this.buildStyles(n,k,b),P=d&&d.params||ja,K=this.buildStyles(r,P,b),pe=new Set,N=new Map,X=new Map,U=r==="void",Ee={params:td(P,y),delay:this.ast.options?.delay},ce=_?[]:ed(e,t,this.ast.animation,o,a,T,K,Ee,m,b),Ce=0;return ce.forEach(Be=>{Ce=Math.max(Be.duration+Be.delay,Ce)}),b.length?Wc(t,this._triggerName,n,r,U,T,K,[],[],N,X,Ce,b):(ce.forEach(Be=>{let Jt=Be.element,dn=ot(N,Jt,new Set);Be.preStyleProps.forEach(St=>dn.add(St));let je=ot(X,Jt,new Set);Be.postStyleProps.forEach(St=>je.add(St)),Jt!==t&&pe.add(Jt)}),Wc(t,this._triggerName,n,r,U,T,K,ce,[...pe.values()],N,X,Ce))}};function pm(i,e,t,n,r){return i.some(o=>o(e,t,n,r))}function td(i,e){let t=Y({},e);return Object.entries(i).forEach(([n,r])=>{r!=null&&(t[n]=r)}),t}var Ga=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=td(e,this.defaultParams);return this.styles.styles.forEach(o=>{typeof o!="string"&&o.forEach((a,s)=>{a&&(a=ai(a,r,t));let d=this.normalizer.normalizePropertyName(s,t);a=this.normalizer.normalizeStyleValue(s,d,a,t),n.set(s,a)})}),n}};function mm(i,e,t){return new Ya(i,e,t)}var Ya=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 Ga(r.style,o,n))}),qc(this.states,"true","1"),qc(this.states,"false","0"),t.transitions.forEach(r=>{this.transitionFactories.push(new oo(e,r,this.states))}),this.fallbackTransition=um(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 um(i,e,t){let n=[(a,s)=>!0],r={type:q.Sequence,steps:[],options:null},o={type:q.Transition,animation:r,matchers:n,options:null,queryCount:0,depCount:0};return new oo(i,o,e)}function qc(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 hm=new Wi,Qa=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=Zc(this._driver,t,n,r);if(n.length)throw Mc(n);this._animations.set(e,o)}_buildPlayer(e,t,n){let r=e.element,o=Pa(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=ed(this._driver,t,o,Ra,Gr,new Map,new Map,n,hm,r),a.forEach(_=>{let b=ot(s,_.element,new Map);_.postStyleProps.forEach(y=>b.set(y,null))})):(r.push(kc()),a=[]),r.length)throw Pc(r);s.forEach((_,b)=>{_.forEach((y,k)=>{_.set(k,this._driver.computeStyle(b,k,bt))})});let d=a.map(_=>{let b=s.get(_.element);return this._buildPlayer(_,new Map,b)}),m=rn(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 Oc(e);return t}listen(e,t,n,r){let o=Wr(t,"","","");return Ur(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}}},Gc="ng-animate-queued",gm=".ng-animate-queued",Va="ng-animate-disabled",fm=".ng-animate-disabled",_m="ng-star-inserted",bm=".ng-star-inserted",vm=[],nd={namespaceId:"",setForRemoval:!1,setForMove:!1,hasAnimation:!1,removedBeforeQueried:!1},ym={namespaceId:"",setForMove:!1,setForRemoval:!1,hasAnimation:!1,removedBeforeQueried:!0},Mt="__ng_removed",qi=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=Sm(r),n){let o=e,{value:a}=o,s=Ks(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])})}}},Ui="void",za=new qi(Ui),Ka=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,vt(t,this._hostClassName)}listen(e,t,n,r){if(!this._triggers.has(t))throw Ac(n,t);if(n==null||n.length==0)throw Ic(t);if(!wm(n))throw Dc(n,t);let o=ot(this._elementListeners,e,[]),a={name:t,phase:n,callback:r};o.push(a);let s=ot(this._engine.statesByElement,e,new Map);return s.has(t)||(vt(e,$i),vt(e,$i+"-"+t),s.set(t,za)),()=>{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 Rc(e);return t}trigger(e,t,n,r=!0){let o=this._getTrigger(t),a=new Gi(this.id,t,e),s=this._engine.statesByElement.get(e);s||(vt(e,$i),vt(e,$i+"-"+t),this._engine.statesByElement.set(e,s=new Map));let d=s.get(t),m=new qi(n,this.id);if(!(n&&n.hasOwnProperty("value"))&&d&&m.absorbOptions(d.options),s.set(t,m),d||(d=za),!(m.value===Ui)&&d.value===m.value){if(!Em(d.params,m.params)){let P=[],K=o.matchStyles(d.value,d.params,P),pe=o.matchStyles(m.value,m.params,P);P.length?this._engine.reportError(P):this._engine.afterFlush(()=>{_n(e,K),Et(e,pe)})}return}let y=ot(this._engine.playersByElement,e,[]);y.forEach(P=>{P.namespaceId==this.id&&P.triggerName==t&&P.queued&&P.destroy()});let k=o.matchTransition(d.value,m.value,e,m.params),T=!1;if(!k){if(!r)return;k=o.fallbackTransition,T=!0}return this._engine.totalQueuedPlayers++,this._queue.push({element:e,triggerName:t,transition:k,fromState:d,toState:m,player:a,isFallbackTransition:T}),T||(vt(e,Gc),a.onStart(()=>{si(e,Gc)})),a.onDone(()=>{let P=this.players.indexOf(a);P>=0&&this.players.splice(P,1);let K=this._engine.playersByElement.get(e);if(K){let pe=K.indexOf(a);pe>=0&&K.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,Bi,!0);n.forEach(r=>{if(r[Mt])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,Ui,r);_&&s.push(_)}}),s.length)return this._engine.markElementAsRemoved(this.id,e,!0,t,a),n&&rn(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)||za,_=new qi(Ui),b=new Gi(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[Mt];(!o||o===nd)&&(n.afterFlush(()=>this.clearElementCache(e)),n.destroyInnerAnimations(e),n._onRemovalComplete(e,t))}}insertNode(e,t){vt(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=Wr(o,n.triggerName,n.fromState.value,n.toState.value);d._data=e,Ur(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)}},Xa=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 Ka(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(Zr(t)){let o=this._fetchNamespace(e);if(o)return o.trigger(t,n,r),!0}return!1}insertNode(e,t,n,r){if(!Zr(t))return;let o=t[Mt];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),vt(e,Va)):this.disabledNodes.has(e)&&(this.disabledNodes.delete(e),si(e,Va))}removeNode(e,t,n){if(Zr(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[Mt]={namespaceId:e,setForRemoval:r,hasAnimation:n,removedBeforeQueried:!1,previousTriggersValues:o}}listen(e,t,n,r,o){return Zr(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,Bi,!0);t.forEach(n=>this.destroyActiveAnimationsForElement(n)),this.playersByQueriedElement.size!=0&&(t=this.driver.query(e,Yr,!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 rn(this.players).onDone(()=>e());e()})}processLeaveNode(e){let t=e[Mt];if(t&&t.setForRemoval){if(e[Mt]=nd,t.namespaceId){this.destroyInnerAnimations(e);let n=this._fetchNamespace(t.namespaceId);n&&n.clearElementCache(e)}this._onRemovalComplete(e,t.setForRemoval)}e.classList?.contains(Va)&&this.markElementAsDisabled(e,!1),this.driver.query(e,fm,!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];vt(r,_m)}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?rn(t).onDone(()=>{n.forEach(r=>r())}):n.forEach(r=>r())}}reportError(e){throw Nc(e)}_flushAnimations(e,t){let n=new Wi,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,gm,!0);for(let V=0;V<L.length;V++)_.add(L[V])});let b=this.bodyNode,y=Array.from(this.statesByElement.keys()),k=Kc(y,this.collectedEnterElements),T=new Map,P=0;k.forEach((A,L)=>{let V=Ra+P++;T.set(L,V),A.forEach(ee=>vt(ee,V))});let K=[],pe=new Set,N=new Set;for(let A=0;A<this.collectedLeaveElements.length;A++){let L=this.collectedLeaveElements[A],V=L[Mt];V&&V.setForRemoval&&(K.push(L),pe.add(L),V.hasAnimation?this.driver.query(L,bm,!0).forEach(ee=>pe.add(ee)):N.add(L))}let X=new Map,U=Kc(y,Array.from(pe));U.forEach((A,L)=>{let V=Gr+P++;X.set(L,V),A.forEach(ee=>vt(ee,V))}),e.push(()=>{k.forEach((A,L)=>{let V=T.get(L);A.forEach(ee=>si(ee,V))}),U.forEach((A,L)=>{let V=X.get(L);A.forEach(ee=>si(ee,V))}),K.forEach(A=>{this.processLeaveNode(A)})});let Ee=[],ce=[];for(let A=this._namespaceList.length-1;A>=0;A--)this._namespaceList[A].drainQueuedTransitions(t).forEach(V=>{let ee=V.player,Pe=V.element;if(Ee.push(ee),this.collectedEnterElements.length){let Ie=Pe[Mt];if(Ie&&Ie.setForMove){if(Ie.previousTriggersValues&&Ie.previousTriggersValues.has(V.triggerName)){let et=Ie.previousTriggersValues.get(V.triggerName),Ye=this.statesByElement.get(V.element);if(Ye&&Ye.has(V.triggerName)){let pn=Ye.get(V.triggerName);pn.value=et,Ye.set(V.triggerName,pn)}}ee.destroy();return}}let le=!b||!this.driver.containsElement(b,Pe),He=X.get(Pe),me=T.get(Pe),ue=this._buildInstruction(V,n,me,He,le);if(ue.errors&&ue.errors.length){ce.push(ue);return}if(le){ee.onStart(()=>_n(Pe,ue.fromStyles)),ee.onDestroy(()=>Et(Pe,ue.toStyles)),r.push(ee);return}if(V.isFallbackTransition){ee.onStart(()=>_n(Pe,ue.fromStyles)),ee.onDestroy(()=>Et(Pe,ue.toStyles)),r.push(ee);return}let _e=[];ue.timelines.forEach(Ie=>{Ie.stretchStartingKeyframe=!0,this.disabledNodes.has(Ie.element)||_e.push(Ie)}),ue.timelines=_e,n.append(Pe,ue.timelines);let xn={instruction:ue,player:ee,element:Pe};a.push(xn),ue.queriedElements.forEach(Ie=>ot(s,Ie,[]).push(ee)),ue.preStyleProps.forEach((Ie,et)=>{if(Ie.size){let Ye=d.get(et);Ye||d.set(et,Ye=new Set),Ie.forEach((pn,Un)=>Ye.add(Un))}}),ue.postStyleProps.forEach((Ie,et)=>{let Ye=m.get(et);Ye||m.set(et,Ye=new Set),Ie.forEach((pn,Un)=>Ye.add(Un))})});if(ce.length){let A=[];ce.forEach(L=>{A.push(Fc(L.triggerName,L.errors))}),Ee.forEach(L=>L.destroy()),this.reportError(A)}let Ce=new Map,Be=new Map;a.forEach(A=>{let L=A.element;n.has(L)&&(Be.set(L,L),this._beforeAnimationBuild(A.player.namespaceId,A.instruction,Ce))}),r.forEach(A=>{let L=A.element;this._getPreviousPlayers(L,!1,A.namespaceId,A.triggerName,null).forEach(ee=>{ot(Ce,L,[]).push(ee),ee.destroy()})});let Jt=K.filter(A=>Xc(A,d,m)),dn=new Map;Qc(dn,this.driver,N,m,bt).forEach(A=>{Xc(A,d,m)&&Jt.push(A)});let St=new Map;k.forEach((A,L)=>{Qc(St,this.driver,new Set(A),d,ri)}),Jt.forEach(A=>{let L=dn.get(A),V=St.get(A);dn.set(A,new Map([...L?.entries()??[],...V?.entries()??[]]))});let wn=[],Hn=[],ur={};a.forEach(A=>{let{element:L,player:V,instruction:ee}=A;if(n.has(L)){if(_.has(L)){V.onDestroy(()=>Et(L,ee.toStyles)),V.disabled=!0,V.overrideTotalTime(ee.totalTime),r.push(V);return}let Pe=ur;if(Be.size>1){let He=L,me=[];for(;He=He.parentNode;){let ue=Be.get(He);if(ue){Pe=ue;break}me.push(He)}me.forEach(ue=>Be.set(ue,Pe))}let le=this._buildAnimation(V.namespaceId,ee,Ce,o,St,dn);if(V.setRealPlayer(le),Pe===ur)wn.push(V);else{let He=this.playersByElement.get(Pe);He&&He.length&&(V.parentPlayer=rn(He)),r.push(V)}}else _n(L,ee.fromStyles),V.onDestroy(()=>Et(L,ee.toStyles)),Hn.push(V),_.has(L)&&r.push(V)}),Hn.forEach(A=>{let L=o.get(A.element);if(L&&L.length){let V=rn(L);A.setRealPlayer(V)}}),r.forEach(A=>{A.parentPlayer?A.syncPlayerEvents(A.parentPlayer):A.destroy()});for(let A=0;A<K.length;A++){let L=K[A],V=L[Mt];if(si(L,Gr),V&&V.hasAnimation)continue;let ee=[];if(s.size){let le=s.get(L);le&&le.length&&ee.push(...le);let He=this.driver.query(L,Yr,!0);for(let me=0;me<He.length;me++){let ue=s.get(He[me]);ue&&ue.length&&ee.push(...ue)}}let Pe=ee.filter(le=>!le.destroyed);Pe.length?xm(this,L,Pe):this.processLeaveNode(L)}return K.length=0,wn.forEach(A=>{this.players.push(A),A.onDone(()=>{A.destroy();let L=this.players.indexOf(A);this.players.splice(L,1)}),A.play()}),wn}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==Ui;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=ot(n,m,[]);this._getPreviousPlayers(m,_,a,s,t.toState).forEach(k=>{let T=k.getRealPlayer();T.beforeDestroy&&T.beforeDestroy(),k.destroy(),b.push(k)})}_n(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(T=>{let P=T.element;_.add(P);let K=P[Mt];if(K&&K.removedBeforeQueried)return new Bt(T.duration,T.delay);let pe=P!==d,N=Tm((n.get(P)||vm).map(Ce=>Ce.getRealPlayer())).filter(Ce=>{let Be=Ce;return Be.element?Be.element===P:!1}),X=o.get(P),U=a.get(P),Ee=Pa(this._normalizer,T.keyframes,X,U),ce=this._buildPlayer(T,Ee,N);if(T.subTimeline&&r&&b.add(P),pe){let Ce=new Gi(e,s,P);Ce.setRealPlayer(ce),m.push(Ce)}return ce});m.forEach(T=>{ot(this.playersByQueriedElement,T.element,[]).push(T),T.onDone(()=>Cm(this.playersByQueriedElement,T.element,T))}),_.forEach(T=>vt(T,Na));let k=rn(y);return k.onDestroy(()=>{_.forEach(T=>si(T,Na)),Et(d,t.toStyles)}),b.forEach(T=>{ot(r,T,[]).push(k)}),k}_buildPlayer(e,t,n){return t.length>0?this.driver.animate(e.element,t,e.duration,e.delay,e.easing,n):new Bt(e.duration,e.delay)}},Gi=class{namespaceId;triggerName;element;_player=new Bt;_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=>Ur(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){ot(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 Cm(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 Sm(i){return i??null}function Zr(i){return i&&i.nodeType===1}function wm(i){return i=="start"||i=="done"}function Yc(i,e){let t=i.style.display;return i.style.display=e??"none",t}function Qc(i,e,t,n,r){let o=[];t.forEach(d=>o.push(Yc(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[Mt]=ym,a.push(m))}),i.set(m,_)});let s=0;return t.forEach(d=>Yc(d,o[s++])),a}function Kc(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 vt(i,e){i.classList?.add(e)}function si(i,e){i.classList?.remove(e)}function xm(i,e,t){rn(t).onDone(()=>i.processLeaveNode(e))}function Tm(i){let e=[];return id(i,e),e}function id(i,e){for(let t=0;t<i.length;t++){let n=i[t];n instanceof In?id(n.players,e):e.push(n)}}function Em(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 Xc(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 li=class{_driver;_normalizer;_transitionEngine;_timelineEngine;_triggerCache={};onRemovalComplete=(e,t)=>{};constructor(e,t,n){this._driver=t,this._normalizer=n,this._transitionEngine=new Xa(e.body,t,n),this._timelineEngine=new Qa(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=[],_=Zc(this._driver,o,d,m);if(d.length)throw Ec(r,d);s=mm(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]=Oa(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]=Oa(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 Mm(i,e){let t=null,n=null;return Array.isArray(e)&&e.length?(t=$a(e[0]),e.length>1&&(n=$a(e[e.length-1]))):e instanceof Map&&(t=$a(e)),t||n?new km(i,t,n):null}var km=(()=>{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&&Et(this._element,this._startStyles,this._initialStyles),this._state=1)}finish(){this.start(),this._state<2&&(Et(this._element,this._initialStyles),this._endStyles&&(Et(this._element,this._endStyles),this._endStyles=null),this._state=1)}destroy(){this.finish(),this._state<3&&(i.initialStylesByElement.delete(this._element),this._startStyles&&(_n(this._element,this._startStyles),this._endStyles=null),this._endStyles&&(_n(this._element,this._endStyles),this._endStyles=null),Et(this._element,this._initialStyles),this._state=3)}}return i})();function $a(i){let e=null;return i.forEach((t,n)=>{Pm(n)&&(e=e||new Map,e.set(n,t))}),e}function Pm(i){return i==="display"||i==="position"}var ao=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:Kr(this.element,r))}),this.currentSnapshot=e}triggerCallback(e){let t=e==="start"?this._onStartFns:this._onDoneFns;t.forEach(n=>n()),t.length=0}},so=class{validateStyleProperty(e){return!0}validateAnimatableStyleProperty(e){return!0}containsElement(e,t){return Aa(e,t)}getParentElement(e){return qr(e)}query(e,t,n){return Ia(e,t,n)}computeStyle(e,t,n){return Kr(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(k=>k instanceof ao);zc(n,r)&&_.forEach(k=>{k.currentSnapshot.forEach((T,P)=>m.set(P,T))});let b=jc(t).map(k=>new Map(k));b=$c(e,b,m);let y=Mm(e,b);return new ao(e,b,d,y)}};var eo="@",rd="@.disabled",lo=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)==eo&&t==rd?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)}},Ja=class extends lo{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)==eo?t.charAt(1)=="."&&t==rd?(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)==eo){let o=Om(e),a=t.slice(1),s="";return a.charAt(0)!=eo&&([a,s]=Am(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 Om(i){switch(i){case"body":return document.body;case"document":return document;case"window":return window;default:return i}}function Am(i){let e=i.indexOf("."),t=i.substring(0,e),n=i.slice(e+1);return[t,n]}var co=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 lo("",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 Ja(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 Dm=(()=>{class i extends li{constructor(t,n,r){super(t,n,r)}ngOnDestroy(){this.flush()}static \u0275fac=function(n){return new(n||i)(Sr(ei),Sr(Nn),Sr(Fn))};static \u0275prov=H({token:i,factory:i.\u0275fac})}return i})();function Rm(){return new to}function Nm(){return new co(f(bl),f(li),f(Lt))}var od=[{provide:Fn,useFactory:Rm},{provide:li,useClass:Dm},{provide:cl,useFactory:Nm}],s_=[{provide:Nn,useClass:Za},{provide:ga,useValue:"NoopAnimations"},...od],Fm=[{provide:Nn,useFactory:()=>new so},{provide:ga,useFactory:()=>"BrowserAnimations"},...od];function ad(){return ll("NgEagerAnimations"),[...Fm]}var po="__",mo=class i{router=f(zt);projectStateService=f(ve);projects=Ae(this.projectStateService.projectList$);forcedProject=Ae(this.projectStateService.forcedProject$);projectItems=Tt(()=>{let e=this.projects();if(!e)return[];let t=e.filter(y=>!y.name.includes(po)),n=e.filter(y=>y.name.includes(po)),r=new Set(t.map(y=>y.name)),o=y=>y.split(po)[0]??null,a=new Set(n.map(y=>o(y.name)).filter(y=>y!==null&&r.has(y))),s=[],d=[...a].sort((y,k)=>y.localeCompare(k));for(let y of d){let k=t.find(P=>P.name===y);s.push(he(Y({},this.toEntityListItem(k)),{groupKey:y,groupLabel:y}));let T=n.filter(P=>o(P.name)===y).sort((P,K)=>P.name.localeCompare(K.name));for(let P of T){let K=P.name.slice(y.length+po.length);s.push(he(Y({},this.toEntityListItem(P)),{name:K,description:P.name,groupKey:y,groupLabel:y}))}}let m=[...t].filter(y=>!a.has(y.name)&&!y.volatile).sort((y,k)=>y.name.localeCompare(k.name));for(let y of m)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__standalone__",groupLabel:"Projects"}));let _=[...t].filter(y=>!a.has(y.name)&&y.volatile).sort((y,k)=>y.name.localeCompare(k.name));for(let y of _)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__volatile__",groupLabel:"Temporary"}));let b=n.filter(y=>{let k=o(y.name);return k!==null&&!r.has(k)}).sort((y,k)=>y.name.localeCompare(k.name));for(let y of b)s.push(he(Y({},this.toEntityListItem(y)),{groupKey:"__orphaned__",groupLabel:"Orphaned worktrees"}));return s});showCreateButton=Tt(()=>!this.forcedProject());constructor(){this.projectStateService.selectedProject$.pipe(ut(),Se(e=>!!e),Se(()=>this.router.url.split("?")[0]==="/"),Jn(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"])}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=R({type:i,selectors:[["app-project-selection"]],decls:2,vars:3,consts:[["title","Projects","contentMaxWidth","1400px","searchPlaceholder","Filter projects\u2026","emptyMessage","No projects found.",3,"itemSelected","createRequested","items","showCreate","autoFocusSearch"],["toolbar-start","","src","CODAY-Logo.png","alt","Coday",1,"project-list__logo"]],template:function(t,n){t&1&&(l(0,"ds-entity-list",0),v("itemSelected",function(o){return n.onItemSelected(o)})("createRequested",function(){return n.onCreateRequested()}),F(1,"img",1),c()),t&2&&E("items",n.projectItems())("showCreate",n.showCreateButton())("autoFocusSearch",!0)},dependencies:[rc],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.project-list__logo[_ngcontent-%COMP%]{width:40px;height:40px;object-fit:contain;flex-shrink:0;border-radius:4px}"]})};var ke=class i{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new W("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();enterToSendSubject=new W(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new W(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new W("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new W(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new W(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new W(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new W(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new W(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new W(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new W(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new W(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new W(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new W(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.asObservable();themeSubject=new W("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 k=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(k);let T=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(T);let P=this.getPreferenceSync("theme","light")??"light";this.themeSubject.next(P),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return B(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 k=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(k);let T=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(T);let P=(yield this.getPreferenceAsync("theme","light"))??"light";this.themeSubject.next(P),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 B(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 B(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function ts(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 Le=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)}},uo=class extends Le{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new st({answer:e,parentKey:this.timestamp,invite:this.invite})}},ci=class i extends Le{static type="heartbeat";constructor(e){super(e,i.type)}},on=class i extends uo{defaultValue;static type="invite";constructor(e){super(e,i.type),this.defaultValue=e.defaultValue}},ns="InviteEventDefault",st=class i extends Le{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}},Ut=class i extends Le{speaker;text;static type="text";constructor(e){super(e,i.type),this.speaker=e.speaker,this.text=e.text}},bn=class i extends Le{chunk;static type="text_chunk";constructor(e){super(e,i.type),this.chunk=e.chunk,this.length=this.chunk.length}},Ln=class i extends Le{warning;static type="warn";constructor(e){super(e,i.type),this.warning=e.warning}},kt=class i extends Le{error;static type="error";constructor(e){super(e,i.type),this.error=e.error}},an=class i extends uo{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}},Pt=class i extends Le{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 yt({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=ts(this.args,e);return`\u{1F527} ${this.name}(${t})`}},yt=class i extends Le{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=ts(t,e),r=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${n}${r}`}},vn=class i extends Le{static type="thinking";static debounce=5e3;constructor(e){super(e,i.type)}},jn=class i extends Le{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: ${ts(this.summary,e)}`}},Ot=class i extends Le{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
+ `)}},di=class i extends Le{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}},yn=class i extends Le{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}`}},pi=class i extends Le{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}},Wt=class i extends Le{subThreadId;agentName;static type="delegation";constructor(e){super(e,i.type),this.subThreadId=e.subThreadId,this.agentName=e.agentName}},At=class i extends Le{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}},Lm={[Ot.type]:Ot,[st.type]:st,[an.type]:an,[Wt.type]:Wt,[kt.type]:kt,[ci.type]:ci,[on.type]:on,[Pt.type]:Pt,[yt.type]:yt,[Ut.type]:Ut,[bn.type]:bn,[vn.type]:vn,[Ln.type]:Ln,[di.type]:di,[jn.type]:jn,[yn.type]:yn,[pi.type]:pi,[At.type]:At};function Yi(i){let e=Lm[i.type];return e?new e(i):void 0}var j_=[{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
3
 
4
4
  <task>
5
5
  {{PARAMETERS}}
@@ -267,16 +267,16 @@ Verify the memory system's overall health:
267
267
  - List any remaining issues or concerns
268
268
  - Provide recommendations for maintaining memory quality
269
269
 
270
- This ensures the memory system stays efficient and valuable.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""}];var X_=[Ot.type,Pt.type,yt.type,jn.type,on.type,an.type,st.type,Wt.type];var ad={CONFLUENCE:[],GIT:[],GIT_WORKTREE:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},gb=Object.keys(ad).filter(i=>ad[i]?.length===0);var qt=class i{eventSource=null;eventsSubject=new Z;connectionStatusSubject=new W({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(Lt);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=Gi(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 kt({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 kt({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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Gt=class i{http=f(it);projectState=f(ve);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ge=class i{selectedThreadIdSubject=new W(null);isLoadingSubject=new W(!1);isLoadingThreadListSubject=new W(!1);refreshThreadListSubject=new Z;threadListSubject=new W([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=f(Gt);projectStateService=f(ve);projectName$=this.projectStateService.selectedProject$.pipe(Oe(e=>e?.name),ca());constructor(){kn([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(Jn(void 0))]).pipe(pt(([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))}),pa(([e])=>e?(console.log("[THREAD_STATE] Fetching threads for project:",e),this.threadApi.listThreads().pipe(Oe(t=>({threads:t,projectName:e})),mn(t=>(console.error("[THREAD_STATE] Error loading thread list:",t),Mn({threads:[],projectName:e}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),Mn({threads:[],projectName:null}))),pt(({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 Z;selectedThread$=kn([this.projectName$,this.selectedThreadIdSubject.pipe(ca()),this.refreshSelectedThreadSubject.pipe(Jn(void 0))]).pipe(pa(([e,t])=>!e||!t?Mn(null):(this.isLoadingSubject.next(!0),this.threadApi.getThread(t).pipe(tl({bufferSize:1,refCount:!0})))),pt(()=>{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(Y({},a),{starring:[...s,n]}):!t&&s.includes(n)?he(Y({},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(pt(()=>{this.refreshThreadList()}),mn(n=>(console.error("[THREAD_STATE] Error updating thread users:",n),Xn(()=>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"),Xn(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",e,"to:",n),this.threadApi.updateThread(e,n).pipe(pt(r=>{console.log("[THREAD_STATE] Thread renamed successfully:",r),this.refreshThreadList()}),mn(r=>(console.error("[THREAD_STATE] Error renaming thread:",r),Xn(()=>r)))))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var mi=class i{http=f(it);projectState=f(ve);threadState=f(Ge);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Yt=class i{http=f(it);usernameSubject=new W(null);authEnabledSubject=new W(!1);username$=this.usernameSubject.asObservable();authEnabled$=this.authEnabledSubject.asObservable();fetchCurrentUser(){return this.http.get("/api/user/me").pipe(pt(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var lt=class i{destroy$=new Z;currentProject=null;currentThread=null;messagesSubject=new W([]);isThinkingSubject=new W(!1);currentChoiceSubject=new W(null);projectTitleSubject=new W("Coday");currentInviteEventSubject=new W(null);messageToRestoreSubject=new W("");threadUpdateEventSubject=new W(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new W("");subThreadEventsSubject=new Z;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(qt);messageApi=f(mi);userService=f(Yt);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(pt(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(I(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 Ot?this.handleMessageEvent(e):e instanceof bn?this.handleTextChunkEvent(e):e instanceof Ut?this.handleTextEvent(e):e instanceof st?this.handleAnswerEvent(e):e instanceof kt?this.handleErrorEvent(e):e instanceof Ln?this.handleWarnEvent(e):e instanceof vn?this.handleThinkingEvent(e):e instanceof Pt?this.handleToolRequestEvent(e):e instanceof yt?this.handleToolResponseEvent(e):e instanceof an?this.handleChoiceEvent(e):e instanceof ci?this.handleHeartBeatEvent(e):e instanceof on?this.handleInviteEvent(e):e instanceof di?this.handleThreadUpdateEvent(e):e instanceof Wt?this.handleDelegationEvent(e):e instanceof pi||e instanceof At||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()},vn.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===ts)&&n&&n.role==="assistant"&&n.content.some(a=>a.type==="text"&&a.content.includes(e.invite)))&&e.invite!==ts){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(`
270
+ This ensures the memory system stays efficient and valuable.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""}];var J_=[Ot.type,Pt.type,yt.type,jn.type,on.type,an.type,st.type,Wt.type];var sd={CONFLUENCE:[],GIT:[],GIT_WORKTREE:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},fb=Object.keys(sd).filter(i=>sd[i]?.length===0);var qt=class i{eventSource=null;eventsSubject=new J;connectionStatusSubject=new W({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(Lt);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=Yi(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 kt({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 kt({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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Gt=class i{http=f(it);projectState=f(ve);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ge=class i{selectedThreadIdSubject=new W(null);isLoadingSubject=new W(!1);isLoadingThreadListSubject=new W(!1);refreshThreadListSubject=new J;threadListSubject=new W([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=f(Gt);projectStateService=f(ve);projectName$=this.projectStateService.selectedProject$.pipe(Oe(e=>e?.name),da());constructor(){kn([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(Zn(void 0))]).pipe(pt(([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))}),ma(([e])=>e?(console.log("[THREAD_STATE] Fetching threads for project:",e),this.threadApi.listThreads().pipe(Oe(t=>({threads:t,projectName:e})),mn(t=>(console.error("[THREAD_STATE] Error loading thread list:",t),Mn({threads:[],projectName:e}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),Mn({threads:[],projectName:null}))),pt(({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 J;selectedThread$=kn([this.projectName$,this.selectedThreadIdSubject.pipe(da()),this.refreshSelectedThreadSubject.pipe(Zn(void 0))]).pipe(ma(([e,t])=>!e||!t?Mn(null):(this.isLoadingSubject.next(!0),this.threadApi.getThread(t).pipe(nl({bufferSize:1,refCount:!0})))),pt(()=>{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(Y({},a),{starring:[...s,n]}):!t&&s.includes(n)?he(Y({},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(pt(()=>{this.refreshThreadList()}),mn(n=>(console.error("[THREAD_STATE] Error updating thread users:",n),Xn(()=>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"),Xn(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",e,"to:",n),this.threadApi.updateThread(e,n).pipe(pt(r=>{console.log("[THREAD_STATE] Thread renamed successfully:",r),this.refreshThreadList()}),mn(r=>(console.error("[THREAD_STATE] Error renaming thread:",r),Xn(()=>r)))))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var mi=class i{http=f(it);projectState=f(ve);threadState=f(Ge);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Yt=class i{http=f(it);usernameSubject=new W(null);authEnabledSubject=new W(!1);username$=this.usernameSubject.asObservable();authEnabled$=this.authEnabledSubject.asObservable();fetchCurrentUser(){return this.http.get("/api/user/me").pipe(pt(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var lt=class i{destroy$=new J;currentProject=null;currentThread=null;messagesSubject=new W([]);isThinkingSubject=new W(!1);currentChoiceSubject=new W(null);projectTitleSubject=new W("Coday");currentInviteEventSubject=new W(null);messageToRestoreSubject=new W("");threadUpdateEventSubject=new W(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new W("");subThreadEventsSubject=new J;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(qt);messageApi=f(mi);userService=f(Yt);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(pt(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(I(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 Ot?this.handleMessageEvent(e):e instanceof bn?this.handleTextChunkEvent(e):e instanceof Ut?this.handleTextEvent(e):e instanceof st?this.handleAnswerEvent(e):e instanceof kt?this.handleErrorEvent(e):e instanceof Ln?this.handleWarnEvent(e):e instanceof vn?this.handleThinkingEvent(e):e instanceof Pt?this.handleToolRequestEvent(e):e instanceof yt?this.handleToolResponseEvent(e):e instanceof an?this.handleChoiceEvent(e):e instanceof ci?this.handleHeartBeatEvent(e):e instanceof on?this.handleInviteEvent(e):e instanceof di?this.handleThreadUpdateEvent(e):e instanceof Wt?this.handleDelegationEvent(e):e instanceof pi||e instanceof At||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()},vn.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===ns)&&n&&n.role==="assistant"&&n.content.some(a=>a.type==="text"&&a.content.includes(e.invite)))&&e.invite!==ns){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
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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var uo=class i{sanitizer=f(Vt);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=dl({name:"highlight",type:i,pure:!0})};var jm=["messageInput"],Vm=["fileInput"],zm=(i,e)=>e.name;function $m(i,e){i&1&&(l(0,"div",3),F(1,"span",8),u(2," Recording... Click mic to stop "),c())}function Bm(i,e){if(i&1&&(l(0,"span",13),u(1),c()),i&2){let t=g().$implicit,n=g(2);p(),B(" "+(n.getParameterFormat(t)||""))}}function Hm(i,e){if(i&1){let t=O();l(0,"div",10),v("click",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("keydown.enter",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("keydown.space",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("mouseenter",function(){let r=w(t).$index,o=g(2);return x(o.selectedAutocompleteIndex=r)}),l(1,"div",11),F(2,"span",12),Vi(3,"highlight"),C(4,Bm,2,1,"span",13),c(),F(5,"div",14),Vi(6,"highlight"),c()}if(i&2){let t=e.$implicit,n=e.$index,r=g(2);G("selected",n===r.selectedAutocompleteIndex),Me("aria-selected",n===r.selectedAutocompleteIndex),p(2),E("innerHTML",ya(3,6,r.autocompleteTrigger+t.name,r.getAutocompleteQuery()),ct),p(2),S(r.hasParameterFormat(t)?4:-1),p(),E("innerHTML",ya(6,9,t.description,r.getAutocompleteQuery()),ct)}}function Um(i,e){if(i&1&&(l(0,"div",4),we(1,Hm,7,12,"div",9,zm),c()),i&2){let t=g();p(),xe(t.autocompleteItems)}}function Wm(i,e){if(i&1){let t=O();l(0,"ds-icon-button",17),v("action",function(){w(t);let r=g(2);return x(r.onStopClick())}),c()}}function qm(i,e){if(i&1){let t=O();l(0,"ds-icon-button",18),v("action",function(){w(t);let r=g(2);return x(r.sendMessage())}),c()}if(i&2){let t=g(2);G("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),E("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Gm(i,e){if(i&1){let t=O();l(0,"ds-icon-button",20),v("action",function(){w(t);let r=g(3);return x(r.triggerFileUpload())}),c(),l(1,"input",21,1),v("change",function(r){w(t);let o=g(3);return x(o.onFileInputChange(r))}),c()}if(i&2){let t=g(3);E("disabled",t.isDisabled)}}function Ym(i,e){if(i&1){let t=O();C(0,Gm,3,1),l(1,"ds-icon-button",19),v("action",function(){w(t);let r=g(2);return x(r.toggleRecording())}),c()}if(i&2){let t=g(2);S(t.showWelcome?-1:0),p(),G("recording",t.isRecording)("hidden",t.message.trim()),E("icon",t.isRecording?"fiber_manual_record":"mic")("title",t.isRecording?"Click to stop recording":"Click to start recording")}}function Qm(i,e){if(i&1&&(l(0,"div",7),C(1,Wm,1,0,"ds-icon-button",15),C(2,qm,1,6,"ds-icon-button",16),C(3,Ym,2,7),c()),i&2){let t=g();p(),S(t.isThinking?1:-1),p(),S(!t.isThinking||t.message.trim()?2:-1),p(),S(t.isThinking?-1:3)}}var ui=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new J;messageSubmitted=new J;voiceRecordingToggled=new J;heightChanged=new J;stopRequested=new J;textareaFocused=new J;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(ke);codayService=f(lt);agentApiService=f(rc);promptApiService=f(oc);projectStateService=f(ve);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 $(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(`
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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var ho=class i{sanitizer=f(Vt);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=pl({name:"highlight",type:i,pure:!0})};var Vm=["messageInput"],zm=["fileInput"],$m=(i,e)=>e.name;function Bm(i,e){i&1&&(l(0,"div",3),F(1,"span",8),u(2," Recording... Click mic to stop "),c())}function Hm(i,e){if(i&1&&(l(0,"span",13),u(1),c()),i&2){let t=g().$implicit,n=g(2);p(),$(" "+(n.getParameterFormat(t)||""))}}function Um(i,e){if(i&1){let t=O();l(0,"div",10),v("click",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("keydown.enter",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("keydown.space",function(){let r=w(t).$index,o=g(2);return x(o.selectAutocompleteItemByClick(r))})("mouseenter",function(){let r=w(t).$index,o=g(2);return x(o.selectedAutocompleteIndex=r)}),l(1,"div",11),F(2,"span",12),zi(3,"highlight"),C(4,Hm,2,1,"span",13),c(),F(5,"div",14),zi(6,"highlight"),c()}if(i&2){let t=e.$implicit,n=e.$index,r=g(2);G("selected",n===r.selectedAutocompleteIndex),Me("aria-selected",n===r.selectedAutocompleteIndex),p(2),E("innerHTML",Ca(3,6,r.autocompleteTrigger+t.name,r.getAutocompleteQuery()),ct),p(2),S(r.hasParameterFormat(t)?4:-1),p(),E("innerHTML",Ca(6,9,t.description,r.getAutocompleteQuery()),ct)}}function Wm(i,e){if(i&1&&(l(0,"div",4),we(1,Um,7,12,"div",9,$m),c()),i&2){let t=g();p(),xe(t.autocompleteItems)}}function qm(i,e){if(i&1){let t=O();l(0,"ds-icon-button",17),v("action",function(){w(t);let r=g(2);return x(r.onStopClick())}),c()}}function Gm(i,e){if(i&1){let t=O();l(0,"ds-icon-button",18),v("action",function(){w(t);let r=g(2);return x(r.sendMessage())}),c()}if(i&2){let t=g(2);G("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),E("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Ym(i,e){if(i&1){let t=O();l(0,"ds-icon-button",20),v("action",function(){w(t);let r=g(3);return x(r.triggerFileUpload())}),c(),l(1,"input",21,1),v("change",function(r){w(t);let o=g(3);return x(o.onFileInputChange(r))}),c()}if(i&2){let t=g(3);E("disabled",t.isDisabled)}}function Qm(i,e){if(i&1){let t=O();C(0,Ym,3,1),l(1,"ds-icon-button",19),v("action",function(){w(t);let r=g(2);return x(r.toggleRecording())}),c()}if(i&2){let t=g(2);S(t.showWelcome?-1:0),p(),G("recording",t.isRecording)("hidden",t.message.trim()),E("icon",t.isRecording?"fiber_manual_record":"mic")("title",t.isRecording?"Click to stop recording":"Click to start recording")}}function Km(i,e){if(i&1&&(l(0,"div",7),C(1,qm,1,0,"ds-icon-button",15),C(2,Gm,1,6,"ds-icon-button",16),C(3,Qm,2,7),c()),i&2){let t=g();p(),S(t.isThinking?1:-1),p(),S(!t.isThinking||t.message.trim()?2:-1),p(),S(t.isThinking?-1:3)}}var ui=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new Z;messageSubmitted=new Z;voiceRecordingToggled=new Z;heightChanged=new Z;stopRequested=new Z;textareaFocused=new Z;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(ke);codayService=f(lt);agentApiService=f(oc);promptApiService=f(ac);projectStateService=f(ve);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 B(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
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=R({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&$e(jm,7)(Vm,5),t&2){let r;ge(r=fe())&&(n.messageInput=r.first),ge(r=fe())&&(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)},al)},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:[jt],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,$m,3,0,"div",3),C(2,Um,3,0,"div",4),l(3,"div",5)(4,"textarea",6,0),re("ngModelChange",function(a){return w(r),ie(n.message,a)||(n.message=a),x(a)}),v("keydown",function(a){return n.onKeyDown(a)})("input",function(){return n.onInput()})("focus",function(){return w(r),n.isFocused=!0,x(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),c(),C(6,Qm,4,3,"div",7),c()()}t&2&&(p(),S(n.isRecording?1:-1),p(),S(n.autocompleteVisible?2:-1),p(),G("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking),p(),ne("ngModel",n.message),E("placeholder",n.getPlaceholder())("disabled",n.isDisabled),p(2),S(n.isSessionInitializing?-1:6))},dependencies:[_t,ht,gt,ft,ql,uo],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 Km=(i,e)=>e.label;function Xm(i,e){if(i&1){let t=O();l(0,"button",2),v("click",function(r){let o=w(t).$implicit,a=g();return x(a.executeAction(o,r))}),l(1,"mat-icon"),u(2),c()()}if(i&2){let t=e.$implicit;Me("title",t.tooltip||t.label),p(),Me("aria-label",t.label),p(),B(t.icon)}}var ho=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({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),we(1,Xm,3,3,"button",1,Km),c()),t&2&&(p(),xe(n.actions))},dependencies:[nt,qe,de],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var go=class i{snackBar=f(Fl);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function os(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var zn=os();function ud(i){zn=i}var Zi={exec:()=>null};function oe(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(Ke.caret,"$1"),t=t.replace(r,a),n},getRegex:()=>new RegExp(t,e)};return n}var Ke={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")},Zm=/^(?:[ \t]*(?:\n|$))+/,Jm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,eu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ji=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,tu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,as=/(?:[*+-]|\d{1,9}[.)])/,hd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,gd=oe(hd).replace(/bull/g,as).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(),nu=oe(hd).replace(/bull/g,as).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(),ss=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,iu=/^[^\n]+/,ls=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ru=oe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ls).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ou=oe(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,as).getRegex(),vo="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",cs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,au=oe("^ {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",cs).replace("tag",vo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fd=oe(ss).replace("hr",Ji).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",vo).getRegex(),su=oe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fd).getRegex(),ds={blockquote:su,code:Jm,def:ru,fences:eu,heading:tu,hr:Ji,html:au,lheading:gd,list:ou,newline:Zm,paragraph:fd,table:Zi,text:iu},sd=oe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ji).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",vo).getRegex(),lu=he(Y({},ds),{lheading:nu,table:sd,paragraph:oe(ss).replace("hr",Ji).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sd).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",vo).getRegex()}),cu=he(Y({},ds),{html:oe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",cs).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:Zi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:oe(ss).replace("hr",Ji).replace("heading",` *#{1,6} *[^
275
- ]`).replace("lheading",gd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),du=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_d=/^( {2,}|\\)\n(?!\s*$)/,mu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yo=/[\p{P}\p{S}]/u,ps=/[\s\p{P}\p{S}]/u,bd=/[^\s\p{P}\p{S}]/u,uu=oe(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ps).getRegex(),vd=/(?!~)[\p{P}\p{S}]/u,hu=/(?!~)[\s\p{P}\p{S}]/u,gu=/(?:[^\s\p{P}\p{S}]|~)/u,fu=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,yd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_u=oe(yd,"u").replace(/punct/g,yo).getRegex(),bu=oe(yd,"u").replace(/punct/g,vd).getRegex(),Cd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",vu=oe(Cd,"gu").replace(/notPunctSpace/g,bd).replace(/punctSpace/g,ps).replace(/punct/g,yo).getRegex(),yu=oe(Cd,"gu").replace(/notPunctSpace/g,gu).replace(/punctSpace/g,hu).replace(/punct/g,vd).getRegex(),Cu=oe("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,bd).replace(/punctSpace/g,ps).replace(/punct/g,yo).getRegex(),Su=oe(/\\(punct)/,"gu").replace(/punct/g,yo).getRegex(),wu=oe(/^<(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(),xu=oe(cs).replace("(?:-->|$)","-->").getRegex(),Tu=oe("^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",xu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_o=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Eu=oe(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",_o).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Sd=oe(/^!?\[(label)\]\[(ref)\]/).replace("label",_o).replace("ref",ls).getRegex(),wd=oe(/^!?\[(ref)\](?:\[\])?/).replace("ref",ls).getRegex(),Mu=oe("reflink|nolink(?!\\()","g").replace("reflink",Sd).replace("nolink",wd).getRegex(),ld=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ms={_backpedal:Zi,anyPunctuation:Su,autolink:wu,blockSkip:fu,br:_d,code:pu,del:Zi,emStrongLDelim:_u,emStrongRDelimAst:vu,emStrongRDelimUnd:Cu,escape:du,link:Eu,nolink:wd,punctuation:uu,reflink:Sd,reflinkSearch:Mu,tag:Tu,text:mu,url:Zi},ku=he(Y({},ms),{link:oe(/^!?\[(label)\]\((.*?)\)/).replace("label",_o).getRegex(),reflink:oe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_o).getRegex()}),ns=he(Y({},ms),{emStrongRDelimAst:yu,emStrongLDelim:bu,url:oe(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ld).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:oe(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ld).getRegex()}),Pu=he(Y({},ns),{br:oe(_d).replace("{2,}","*").getRegex(),text:oe(ns.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),fo={normal:ds,gfm:lu,pedantic:cu},Qi={normal:ms,gfm:ns,breaks:Pu,pedantic:ku},Ou={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},cd=i=>Ou[i];function Qt(i,e){if(e){if(Ke.escapeTest.test(i))return i.replace(Ke.escapeReplace,cd)}else if(Ke.escapeTestNoEncode.test(i))return i.replace(Ke.escapeReplaceNoEncode,cd);return i}function dd(i){try{i=encodeURI(i).replace(Ke.percentDecode,"%")}catch(e){return null}return i}function pd(i,e){let t=i.replace(Ke.findPipe,(o,a,s)=>{let d=!1,m=a;for(;--m>=0&&s[m]==="\\";)d=!d;return d?"|":" |"}),n=t.split(Ke.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(Ke.slashPipe,"|");return n}function Ki(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 Au(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 md(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 Iu(i,e,t){let n=i.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
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=R({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&$e(Vm,7)(zm,5),t&2){let r;ge(r=fe())&&(n.messageInput=r.first),ge(r=fe())&&(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)},sl)},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:[jt],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,Bm,3,0,"div",3),C(2,Wm,3,0,"div",4),l(3,"div",5)(4,"textarea",6,0),re("ngModelChange",function(a){return w(r),ie(n.message,a)||(n.message=a),x(a)}),v("keydown",function(a){return n.onKeyDown(a)})("input",function(){return n.onInput()})("focus",function(){return w(r),n.isFocused=!0,x(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),c(),C(6,Km,4,3,"div",7),c()()}t&2&&(p(),S(n.isRecording?1:-1),p(),S(n.autocompleteVisible?2:-1),p(),G("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking),p(),ne("ngModel",n.message),E("placeholder",n.getPlaceholder())("disabled",n.isDisabled),p(2),S(n.isSessionInitializing?-1:6))},dependencies:[_t,ht,gt,ft,Gl,ho],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 Xm=(i,e)=>e.label;function Jm(i,e){if(i&1){let t=O();l(0,"button",2),v("click",function(r){let o=w(t).$implicit,a=g();return x(a.executeAction(o,r))}),l(1,"mat-icon"),u(2),c()()}if(i&2){let t=e.$implicit;Me("title",t.tooltip||t.label),p(),Me("aria-label",t.label),p(),$(t.icon)}}var go=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({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),we(1,Jm,3,3,"button",1,Xm),c()),t&2&&(p(),xe(n.actions))},dependencies:[nt,qe,de],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var fo=class i{snackBar=f(Ll);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function as(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var zn=as();function hd(i){zn=i}var Zi={exec:()=>null};function oe(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(Ke.caret,"$1"),t=t.replace(r,a),n},getRegex:()=>new RegExp(t,e)};return n}var Ke={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")},Zm=/^(?:[ \t]*(?:\n|$))+/,eu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,er=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ss=/(?:[*+-]|\d{1,9}[.)])/,gd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fd=oe(gd).replace(/bull/g,ss).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(),iu=oe(gd).replace(/bull/g,ss).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(),ls=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ru=/^[^\n]+/,cs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ou=oe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",cs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),au=oe(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ss).getRegex(),yo="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",ds=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,su=oe("^ {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",ds).replace("tag",yo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_d=oe(ls).replace("hr",er).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",yo).getRegex(),lu=oe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_d).getRegex(),ps={blockquote:lu,code:eu,def:ou,fences:tu,heading:nu,hr:er,html:su,lheading:fd,list:au,newline:Zm,paragraph:_d,table:Zi,text:ru},ld=oe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",er).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",yo).getRegex(),cu=he(Y({},ps),{lheading:iu,table:ld,paragraph:oe(ls).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ld).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",yo).getRegex()}),du=he(Y({},ps),{html:oe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ds).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:Zi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:oe(ls).replace("hr",er).replace("heading",` *#{1,6} *[^
275
+ ]`).replace("lheading",fd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),pu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,mu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bd=/^( {2,}|\\)\n(?!\s*$)/,uu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Co=/[\p{P}\p{S}]/u,ms=/[\s\p{P}\p{S}]/u,vd=/[^\s\p{P}\p{S}]/u,hu=oe(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ms).getRegex(),yd=/(?!~)[\p{P}\p{S}]/u,gu=/(?!~)[\s\p{P}\p{S}]/u,fu=/(?:[^\s\p{P}\p{S}]|~)/u,_u=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,Cd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bu=oe(Cd,"u").replace(/punct/g,Co).getRegex(),vu=oe(Cd,"u").replace(/punct/g,yd).getRegex(),Sd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",yu=oe(Sd,"gu").replace(/notPunctSpace/g,vd).replace(/punctSpace/g,ms).replace(/punct/g,Co).getRegex(),Cu=oe(Sd,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,gu).replace(/punct/g,yd).getRegex(),Su=oe("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,vd).replace(/punctSpace/g,ms).replace(/punct/g,Co).getRegex(),wu=oe(/\\(punct)/,"gu").replace(/punct/g,Co).getRegex(),xu=oe(/^<(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(),Tu=oe(ds).replace("(?:-->|$)","-->").getRegex(),Eu=oe("^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",Tu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Mu=oe(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",bo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wd=oe(/^!?\[(label)\]\[(ref)\]/).replace("label",bo).replace("ref",cs).getRegex(),xd=oe(/^!?\[(ref)\](?:\[\])?/).replace("ref",cs).getRegex(),ku=oe("reflink|nolink(?!\\()","g").replace("reflink",wd).replace("nolink",xd).getRegex(),cd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,us={_backpedal:Zi,anyPunctuation:wu,autolink:xu,blockSkip:_u,br:bd,code:mu,del:Zi,emStrongLDelim:bu,emStrongRDelimAst:yu,emStrongRDelimUnd:Su,escape:pu,link:Mu,nolink:xd,punctuation:hu,reflink:wd,reflinkSearch:ku,tag:Eu,text:uu,url:Zi},Pu=he(Y({},us),{link:oe(/^!?\[(label)\]\((.*?)\)/).replace("label",bo).getRegex(),reflink:oe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bo).getRegex()}),is=he(Y({},us),{emStrongRDelimAst:Cu,emStrongLDelim:vu,url:oe(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",cd).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:oe(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",cd).getRegex()}),Ou=he(Y({},is),{br:oe(bd).replace("{2,}","*").getRegex(),text:oe(is.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),_o={normal:ps,gfm:cu,pedantic:du},Ki={normal:us,gfm:is,breaks:Ou,pedantic:Pu},Au={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},dd=i=>Au[i];function Qt(i,e){if(e){if(Ke.escapeTest.test(i))return i.replace(Ke.escapeReplace,dd)}else if(Ke.escapeTestNoEncode.test(i))return i.replace(Ke.escapeReplaceNoEncode,dd);return i}function pd(i){try{i=encodeURI(i).replace(Ke.percentDecode,"%")}catch(e){return null}return i}function md(i,e){let t=i.replace(Ke.findPipe,(o,a,s)=>{let d=!1,m=a;for(;--m>=0&&s[m]==="\\";)d=!d;return d?"|":" |"}),n=t.split(Ke.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(Ke.slashPipe,"|");return n}function Xi(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 Iu(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 ud(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 Du(i,e,t){let n=i.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
276
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 bo=class{options;rules;lexer;constructor(i){this.options=i||zn}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:Ki(t,`
278
- `)}}}fences(i){let e=this.rules.block.fences.exec(i);if(e){let t=e[0],n=Iu(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=Ki(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:Ki(e[0],`
279
- `)}}blockquote(i){let e=this.rules.block.blockquote.exec(i);if(e){let t=Ki(e[0],`
277
+ `)}var vo=class{options;rules;lexer;constructor(i){this.options=i||zn}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:Xi(t,`
278
+ `)}}}fences(i){let e=this.rules.block.fences.exec(i);if(e){let t=e[0],n=Du(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=Xi(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:Xi(e[0],`
279
+ `)}}blockquote(i){let e=this.rules.block.blockquote.exec(i);if(e){let t=Xi(e[0],`
280
280
  `).split(`
281
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
282
  `),_=m.replace(this.rules.other.blockquoteSetextReplace,`
@@ -294,9 +294,9 @@ ${_}`:_;let b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
294
294
  `,1)[0],Ce;if(y=ce,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Ce=y):Ce=y.replace(this.rules.other.tabCharGlobal," "),X.test(y)||U.test(y)||Ee.test(y)||pe.test(y)||N.test(y))break;if(Ce.search(this.rules.other.nonSpaceChar)>=T||!y.trim())_+=`
295
295
  `+Ce.slice(T);else{if(k||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||X.test(b)||U.test(b)||N.test(b))break;_+=`
296
296
  `+y}!k&&!y.trim()&&(k=!0),m+=ce+`
297
- `,i=i.substring(ce.length+1),b=Ce.slice(T)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(m)&&(a=!0));let P=null,K;this.options.gfm&&(P=this.rules.other.listIsTask.exec(_),P&&(K=P[0]!=="[ ] ",_=_.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:m,task:!!P,checked:K,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=pd(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(pd(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=Ki(t.slice(0,-1),"\\");if((t.length-o.length)%2===0)return}else{let o=Au(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)),md(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 md(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 k=b.slice(1,-1);return{type:"em",raw:b,text:k,tokens:this.lexer.inlineTokens(k)}}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}}}},It=class is{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zn,this.options.tokenizer=this.options.tokenizer||new bo,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:Ke,block:fo.normal,inline:Qi.normal};this.options.pedantic?(t.block=fo.pedantic,t.inline=Qi.pedantic):this.options.gfm&&(t.block=fo.gfm,this.options.breaks?t.inline=Qi.breaks:t.inline=Qi.gfm),this.tokenizer.rules=t}static get rules(){return{block:fo,inline:Qi}}static lex(e,t){return new is(t).lex(e)}static lexInline(e,t){return new is(t).inlineTokens(e)}lex(e){e=e.replace(Ke.carriageReturn,`
297
+ `,i=i.substring(ce.length+1),b=Ce.slice(T)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(m)&&(a=!0));let P=null,K;this.options.gfm&&(P=this.rules.other.listIsTask.exec(_),P&&(K=P[0]!=="[ ] ",_=_.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:m,task:!!P,checked:K,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=md(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(md(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=Xi(t.slice(0,-1),"\\");if((t.length-o.length)%2===0)return}else{let o=Iu(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)),ud(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 ud(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 k=b.slice(1,-1);return{type:"em",raw:b,text:k,tokens:this.lexer.inlineTokens(k)}}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}}}},It=class rs{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zn,this.options.tokenizer=this.options.tokenizer||new vo,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:Ke,block:_o.normal,inline:Ki.normal};this.options.pedantic?(t.block=_o.pedantic,t.inline=Ki.pedantic):this.options.gfm&&(t.block=_o.gfm,this.options.breaks?t.inline=Ki.breaks:t.inline=Ki.gfm),this.tokenizer.rules=t}static get rules(){return{block:_o,inline:Ki}}static lex(e,t){return new rs(t).lex(e)}static lexInline(e,t){return new rs(t).inlineTokens(e)}lex(e){e=e.replace(Ke.carriageReturn,`
300
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(Ke.tabCharGlobal," ").replace(Ke.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
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
302
  `)?"":`
@@ -328,11 +328,11 @@ ${this.parser.parse(i)}</blockquote>
328
328
  `}tablerow({text:i}){return`<tr>
329
329
  ${i}</tr>
330
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>${Qt(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=dd(i);if(r===null)return n;i=r;let o='<a href="'+i+'"';return e&&(o+=' title="'+Qt(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=dd(i);if(r===null)return Qt(t);i=r;let o=`<img src="${i}" alt="${t}"`;return e&&(o+=` title="${Qt(e)}"`),o+=">",o}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:Qt(i.text)}},us=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""}},Dt=class rs{options;renderer;textRenderer;constructor(e){this.options=e||zn,this.options.renderer=this.options.renderer||new hi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new us}static parse(e,t){return new rs(t).parse(e)}static parseInline(e,t){return new rs(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}},Xi=class{options;block;constructor(i){this.options=i||zn}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?It.lex:It.lexInline}provideParser(){return this.block?Dt.parse:Dt.parseInline}},Du=class{defaults=os();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Dt;Renderer=hi;TextRenderer=us;Lexer=It;Tokenizer=bo;Hooks=Xi;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=Y({},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 hi(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 bo(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 Xi;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];Xi.passThroughHooks.has(o)?r[a]=m=>{if(this.defaults.async&&Xi.passThroughHooksRespectAsync.has(o))return $(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 $(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=Y(Y({},this.defaults),n)}),this}setOptions(i){return this.defaults=Y(Y({},this.defaults),i),this}lexer(i,e){return It.lex(i,e??this.defaults)}parser(i,e){return Dt.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{let n=Y({},t),r=Y(Y({},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 $(this,null,function*(){let a=r.hooks?yield r.hooks.preprocess(e):e,s=yield(r.hooks?yield r.hooks.provideLexer():i?It.lex:It.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?Dt.parse:Dt.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?It.lex:It.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?Dt.parse:Dt.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>"+Qt(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},Vn=new Du;function se(i,e){return Vn.parse(i,e)}se.options=se.setOptions=function(i){return Vn.setOptions(i),se.defaults=Vn.defaults,ud(se.defaults),se};se.getDefaults=os;se.defaults=zn;se.use=function(...i){return Vn.use(...i),se.defaults=Vn.defaults,ud(se.defaults),se};se.walkTokens=function(i,e){return Vn.walkTokens(i,e)};se.parseInline=Vn.parseInline;se.Parser=Dt;se.parser=Dt.parse;se.Renderer=hi;se.TextRenderer=us;se.Lexer=It;se.lexer=It.lex;se.Tokenizer=bo;se.Hooks=Xi;se.parse=se;var Qy=se.options,Ky=se.setOptions,Xy=se.use,Zy=se.walkTokens,Jy=se.parseInline;var eC=Dt.parse,tC=It.lex;var{entries:Id,setPrototypeOf:xd,isFrozen:Ru,getPrototypeOf:Nu,getOwnPropertyDescriptor:Fu}=Object,{freeze:Ze,seal:Ct,create:ys}=Object,{apply:Cs,construct:Ss}=typeof Reflect<"u"&&Reflect;Ze||(Ze=function(e){return e});Ct||(Ct=function(e){return e});Cs||(Cs=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)});Ss||(Ss=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 Co=Je(Array.prototype.forEach),Lu=Je(Array.prototype.lastIndexOf),Td=Je(Array.prototype.pop),er=Je(Array.prototype.push),ju=Je(Array.prototype.splice),wo=Je(String.prototype.toLowerCase),hs=Je(String.prototype.toString),gs=Je(String.prototype.match),tr=Je(String.prototype.replace),Vu=Je(String.prototype.indexOf),zu=Je(String.prototype.trim),Rt=Je(Object.prototype.hasOwnProperty),Xe=Je(RegExp.prototype.test),nr=$u(TypeError);function Je(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 Cs(i,e,n)}}function $u(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ss(i,t)}}function Q(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wo;xd&&xd(i,null);let n=e.length;for(;n--;){let r=e[n];if(typeof r=="string"){let o=t(r);o!==r&&(Ru(e)||(e[n]=o),r=o)}i[r]=!0}return i}function Bu(i){for(let e=0;e<i.length;e++)Rt(i,e)||(i[e]=null);return i}function Kt(i){let e=ys(null);for(let[t,n]of Id(i))Rt(i,t)&&(Array.isArray(n)?e[t]=Bu(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Kt(n):e[t]=n);return e}function ir(i,e){for(;i!==null;){let n=Fu(i,e);if(n){if(n.get)return Je(n.get);if(typeof n.value=="function")return Je(n.value)}i=Nu(i)}function t(){return null}return t}var Ed=Ze(["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"]),fs=Ze(["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"]),_s=Ze(["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"]),Hu=Ze(["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"]),bs=Ze(["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"]),Uu=Ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Md=Ze(["#text"]),kd=Ze(["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"]),vs=Ze(["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"]),Pd=Ze(["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"]),So=Ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wu=Ct(/\{\{[\w\W]*|[\w\W]*\}\}/gm),qu=Ct(/<%[\w\W]*|[\w\W]*%>/gm),Gu=Ct(/\$\{[\w\W]*/gm),Yu=Ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qu=Ct(/^aria-[\-\w]+$/),Dd=Ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ku=Ct(/^(?:\w+script|data):/i),Xu=Ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rd=Ct(/^html$/i),Zu=Ct(/^[a-z][.\w]*(-[.\w]+)+$/i),Od=Object.freeze({__proto__:null,ARIA_ATTR:Qu,ATTR_WHITESPACE:Xu,CUSTOM_ELEMENT:Zu,DATA_ATTR:Yu,DOCTYPE_NAME:Rd,ERB_EXPR:qu,IS_ALLOWED_URI:Dd,IS_SCRIPT_OR_DATA:Ku,MUSTACHE_EXPR:Wu,TMPLIT_EXPR:Gu}),rr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ju=function(){return typeof window>"u"?null:window},eh=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}},Ad=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Nd(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ju(),e=j=>Nd(j);if(e.version="3.3.1",e.removed=[],!i||!i.document||i.document.nodeType!==rr.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:k}=i,T=d.prototype,P=ir(T,"cloneNode"),K=ir(T,"remove"),pe=ir(T,"nextSibling"),N=ir(T,"childNodes"),X=ir(T,"parentNode");if(typeof a=="function"){let j=t.createElement("template");j.content&&j.content.ownerDocument&&(t=j.content.ownerDocument)}let U,Ee="",{implementation:ce,createNodeIterator:Ce,createDocumentFragment:Be,getElementsByTagName:Zt}=t,{importNode:dn}=n,je=Ad();e.isSupported=typeof Id=="function"&&typeof X=="function"&&ce&&ce.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:St,ERB_EXPR:wn,TMPLIT_EXPR:Hn,DATA_ATTR:mr,ARIA_ATTR:A,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:ee}=Od,{IS_ALLOWED_URI:Pe}=Od,le=null,He=Q({},[...Ed,...fs,..._s,...bs,...Md]),me=null,ue=Q({},[...kd,...vs,...Pd,...So]),_e=Object.seal(ys(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}})),xn=null,Ie=null,et=Object.seal(ys(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ye=!0,pn=!0,Un=!1,As=!0,Wn=!1,ur=!0,Tn=!1,Xo=!1,Zo=!1,qn=!1,hr=!1,gr=!1,Is=!0,Ds=!1,Mp="user-content-",Jo=!0,Di=!1,Gn={},Nt=null,ea=Q({},["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"]),Rs=null,Ns=Q({},["audio","video","img","source","image","track"]),ta=null,Fs=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fr="http://www.w3.org/1998/Math/MathML",_r="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml",Yn=Jt,na=!1,ia=null,kp=Q({},[fr,_r,Jt],hs),br=Q({},["mi","mo","mn","ms","mtext"]),vr=Q({},["annotation-xml"]),Pp=Q({},["title","style","font","a","script"]),Ri=null,Op=["application/xhtml+xml","text/html"],Ap="text/html",Fe=null,Qn=null,Ip=t.createElement("form"),Ls=function(h){return h instanceof RegExp||h instanceof Function},ra=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qn&&Qn===h)){if((!h||typeof h!="object")&&(h={}),h=Kt(h),Ri=Op.indexOf(h.PARSER_MEDIA_TYPE)===-1?Ap:h.PARSER_MEDIA_TYPE,Fe=Ri==="application/xhtml+xml"?hs:wo,le=Rt(h,"ALLOWED_TAGS")?Q({},h.ALLOWED_TAGS,Fe):He,me=Rt(h,"ALLOWED_ATTR")?Q({},h.ALLOWED_ATTR,Fe):ue,ia=Rt(h,"ALLOWED_NAMESPACES")?Q({},h.ALLOWED_NAMESPACES,hs):kp,ta=Rt(h,"ADD_URI_SAFE_ATTR")?Q(Kt(Fs),h.ADD_URI_SAFE_ATTR,Fe):Fs,Rs=Rt(h,"ADD_DATA_URI_TAGS")?Q(Kt(Ns),h.ADD_DATA_URI_TAGS,Fe):Ns,Nt=Rt(h,"FORBID_CONTENTS")?Q({},h.FORBID_CONTENTS,Fe):ea,xn=Rt(h,"FORBID_TAGS")?Q({},h.FORBID_TAGS,Fe):Kt({}),Ie=Rt(h,"FORBID_ATTR")?Q({},h.FORBID_ATTR,Fe):Kt({}),Gn=Rt(h,"USE_PROFILES")?h.USE_PROFILES:!1,Ye=h.ALLOW_ARIA_ATTR!==!1,pn=h.ALLOW_DATA_ATTR!==!1,Un=h.ALLOW_UNKNOWN_PROTOCOLS||!1,As=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Wn=h.SAFE_FOR_TEMPLATES||!1,ur=h.SAFE_FOR_XML!==!1,Tn=h.WHOLE_DOCUMENT||!1,qn=h.RETURN_DOM||!1,hr=h.RETURN_DOM_FRAGMENT||!1,gr=h.RETURN_TRUSTED_TYPE||!1,Zo=h.FORCE_BODY||!1,Is=h.SANITIZE_DOM!==!1,Ds=h.SANITIZE_NAMED_PROPS||!1,Jo=h.KEEP_CONTENT!==!1,Di=h.IN_PLACE||!1,Pe=h.ALLOWED_URI_REGEXP||Dd,Yn=h.NAMESPACE||Jt,br=h.MATHML_TEXT_INTEGRATION_POINTS||br,vr=h.HTML_INTEGRATION_POINTS||vr,_e=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ls(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_e.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ls(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_e.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(_e.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Wn&&(pn=!1),hr&&(qn=!0),Gn&&(le=Q({},Md),me=[],Gn.html===!0&&(Q(le,Ed),Q(me,kd)),Gn.svg===!0&&(Q(le,fs),Q(me,vs),Q(me,So)),Gn.svgFilters===!0&&(Q(le,_s),Q(me,vs),Q(me,So)),Gn.mathMl===!0&&(Q(le,bs),Q(me,Pd),Q(me,So))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?et.tagCheck=h.ADD_TAGS:(le===He&&(le=Kt(le)),Q(le,h.ADD_TAGS,Fe))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?et.attributeCheck=h.ADD_ATTR:(me===ue&&(me=Kt(me)),Q(me,h.ADD_ATTR,Fe))),h.ADD_URI_SAFE_ATTR&&Q(ta,h.ADD_URI_SAFE_ATTR,Fe),h.FORBID_CONTENTS&&(Nt===ea&&(Nt=Kt(Nt)),Q(Nt,h.FORBID_CONTENTS,Fe)),h.ADD_FORBID_CONTENTS&&(Nt===ea&&(Nt=Kt(Nt)),Q(Nt,h.ADD_FORBID_CONTENTS,Fe)),Jo&&(le["#text"]=!0),Tn&&Q(le,["html","head","body"]),le.table&&(Q(le,["tbody"]),delete xn.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw nr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw nr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');U=h.TRUSTED_TYPES_POLICY,Ee=U.createHTML("")}else U===void 0&&(U=eh(k,r)),U!==null&&typeof Ee=="string"&&(Ee=U.createHTML(""));Ze&&Ze(h),Qn=h}},js=Q({},[...fs,..._s,...Hu]),Vs=Q({},[...bs,...Uu]),Dp=function(h){let M=X(h);(!M||!M.tagName)&&(M={namespaceURI:Yn,tagName:"template"});let D=wo(h.tagName),be=wo(M.tagName);return ia[h.namespaceURI]?h.namespaceURI===_r?M.namespaceURI===Jt?D==="svg":M.namespaceURI===fr?D==="svg"&&(be==="annotation-xml"||br[be]):!!js[D]:h.namespaceURI===fr?M.namespaceURI===Jt?D==="math":M.namespaceURI===_r?D==="math"&&vr[be]:!!Vs[D]:h.namespaceURI===Jt?M.namespaceURI===_r&&!vr[be]||M.namespaceURI===fr&&!br[be]?!1:!Vs[D]&&(Pp[D]||!js[D]):!!(Ri==="application/xhtml+xml"&&ia[h.namespaceURI]):!1},Ft=function(h){er(e.removed,{element:h});try{X(h).removeChild(h)}catch(M){K(h)}},En=function(h,M){try{er(e.removed,{attribute:M.getAttributeNode(h),from:M})}catch(D){er(e.removed,{attribute:null,from:M})}if(M.removeAttribute(h),h==="is")if(qn||hr)try{Ft(M)}catch(D){}else try{M.setAttribute(h,"")}catch(D){}},zs=function(h){let M=null,D=null;if(Zo)h="<remove></remove>"+h;else{let De=gs(h,/^[\r\n\t ]+/);D=De&&De[0]}Ri==="application/xhtml+xml"&&Yn===Jt&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");let be=U?U.createHTML(h):h;if(Yn===Jt)try{M=new y().parseFromString(be,Ri)}catch(De){}if(!M||!M.documentElement){M=ce.createDocument(Yn,"template",null);try{M.documentElement.innerHTML=na?Ee:be}catch(De){}}let Ue=M.body||M.documentElement;return h&&D&&Ue.insertBefore(t.createTextNode(D),Ue.childNodes[0]||null),Yn===Jt?Zt.call(M,Tn?"html":"body")[0]:Tn?M.documentElement:Ue},$s=function(h){return Ce.call(h.ownerDocument||h,h,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},oa=function(h){return h instanceof b&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof _)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Bs=function(h){return typeof s=="function"&&h instanceof s};function en(j,h,M){Co(j,D=>{D.call(e,h,M,Qn)})}let Hs=function(h){let M=null;if(en(je.beforeSanitizeElements,h,null),oa(h))return Ft(h),!0;let D=Fe(h.nodeName);if(en(je.uponSanitizeElement,h,{tagName:D,allowedTags:le}),ur&&h.hasChildNodes()&&!Bs(h.firstElementChild)&&Xe(/<[/\w!]/g,h.innerHTML)&&Xe(/<[/\w!]/g,h.textContent)||h.nodeType===rr.progressingInstruction||ur&&h.nodeType===rr.comment&&Xe(/<[/\w]/g,h.data))return Ft(h),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(D))&&(!le[D]||xn[D])){if(!xn[D]&&Ws(D)&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,D)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(D)))return!1;if(Jo&&!Nt[D]){let be=X(h)||h.parentNode,Ue=N(h)||h.childNodes;if(Ue&&be){let De=Ue.length;for(let tt=De-1;tt>=0;--tt){let tn=P(Ue[tt],!0);tn.__removalCount=(h.__removalCount||0)+1,be.insertBefore(tn,pe(h))}}}return Ft(h),!0}return h instanceof d&&!Dp(h)||(D==="noscript"||D==="noembed"||D==="noframes")&&Xe(/<\/no(script|embed|frames)/i,h.innerHTML)?(Ft(h),!0):(Wn&&h.nodeType===rr.text&&(M=h.textContent,Co([St,wn,Hn],be=>{M=tr(M,be," ")}),h.textContent!==M&&(er(e.removed,{element:h.cloneNode()}),h.textContent=M)),en(je.afterSanitizeElements,h,null),!1)},Us=function(h,M,D){if(Is&&(M==="id"||M==="name")&&(D in t||D in Ip))return!1;if(!(pn&&!Ie[M]&&Xe(mr,M))){if(!(Ye&&Xe(A,M))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(M,h))){if(!me[M]||Ie[M]){if(!(Ws(h)&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,h)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(h))&&(_e.attributeNameCheck instanceof RegExp&&Xe(_e.attributeNameCheck,M)||_e.attributeNameCheck instanceof Function&&_e.attributeNameCheck(M,h))||M==="is"&&_e.allowCustomizedBuiltInElements&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,D)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(D))))return!1}else if(!ta[M]){if(!Xe(Pe,tr(D,V,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&h!=="script"&&Vu(D,"data:")===0&&Rs[h])){if(!(Un&&!Xe(L,tr(D,V,"")))){if(D)return!1}}}}}}}return!0},Ws=function(h){return h!=="annotation-xml"&&gs(h,ee)},qs=function(h){en(je.beforeSanitizeAttributes,h,null);let{attributes:M}=h;if(!M||oa(h))return;let D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:me,forceKeepAttr:void 0},be=M.length;for(;be--;){let Ue=M[be],{name:De,namespaceURI:tt,value:tn}=Ue,Kn=Fe(De),aa=tn,ze=De==="value"?aa:zu(aa);if(D.attrName=Kn,D.attrValue=ze,D.keepAttr=!0,D.forceKeepAttr=void 0,en(je.uponSanitizeAttribute,h,D),ze=D.attrValue,Ds&&(Kn==="id"||Kn==="name")&&(En(De,h),ze=Mp+ze),ur&&Xe(/((--!?|])>)|<\/(style|title|textarea)/i,ze)){En(De,h);continue}if(Kn==="attributename"&&gs(ze,"href")){En(De,h);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){En(De,h);continue}if(!As&&Xe(/\/>/i,ze)){En(De,h);continue}Wn&&Co([St,wn,Hn],Ys=>{ze=tr(ze,Ys," ")});let Gs=Fe(h.nodeName);if(!Us(Gs,Kn,ze)){En(De,h);continue}if(U&&typeof k=="object"&&typeof k.getAttributeType=="function"&&!tt)switch(k.getAttributeType(Gs,Kn)){case"TrustedHTML":{ze=U.createHTML(ze);break}case"TrustedScriptURL":{ze=U.createScriptURL(ze);break}}if(ze!==aa)try{tt?h.setAttributeNS(tt,De,ze):h.setAttribute(De,ze),oa(h)?Ft(h):Td(e.removed)}catch(Ys){En(De,h)}}en(je.afterSanitizeAttributes,h,null)},Rp=function j(h){let M=null,D=$s(h);for(en(je.beforeSanitizeShadowDOM,h,null);M=D.nextNode();)en(je.uponSanitizeShadowNode,M,null),Hs(M),qs(M),M.content instanceof o&&j(M.content);en(je.afterSanitizeShadowDOM,h,null)};return e.sanitize=function(j){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,D=null,be=null,Ue=null;if(na=!j,na&&(j="<!-->"),typeof j!="string"&&!Bs(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw nr("dirty is not a string, aborting")}else throw nr("toString is not a function");if(!e.isSupported)return j;if(Xo||ra(h),e.removed=[],typeof j=="string"&&(Di=!1),Di){if(j.nodeName){let tn=Fe(j.nodeName);if(!le[tn]||xn[tn])throw nr("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof s)M=zs("<!---->"),D=M.ownerDocument.importNode(j,!0),D.nodeType===rr.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?M=D:M.appendChild(D);else{if(!qn&&!Wn&&!Tn&&j.indexOf("<")===-1)return U&&gr?U.createHTML(j):j;if(M=zs(j),!M)return qn?null:gr?Ee:""}M&&Zo&&Ft(M.firstChild);let De=$s(Di?j:M);for(;be=De.nextNode();)Hs(be),qs(be),be.content instanceof o&&Rp(be.content);if(Di)return j;if(qn){if(hr)for(Ue=Be.call(M.ownerDocument);M.firstChild;)Ue.appendChild(M.firstChild);else Ue=M;return(me.shadowroot||me.shadowrootmode)&&(Ue=dn.call(n,Ue,!0)),Ue}let tt=Tn?M.outerHTML:M.innerHTML;return Tn&&le["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&Xe(Rd,M.ownerDocument.doctype.name)&&(tt="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
334
- `+tt),Wn&&Co([St,wn,Hn],tn=>{tt=tr(tt,tn," ")}),U&&gr?U.createHTML(tt):tt},e.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ra(j),Xo=!0},e.clearConfig=function(){Qn=null,Xo=!1},e.isValidAttribute=function(j,h,M){Qn||ra({});let D=Fe(j),be=Fe(h);return Us(D,be,M)},e.addHook=function(j,h){typeof h=="function"&&er(je[j],h)},e.removeHook=function(j,h){if(h!==void 0){let M=Lu(je[j],h);return M===-1?void 0:ju(je[j],M,1)[0]}return Td(je[j])},e.removeHooks=function(j){je[j]=[]},e.removeAllHooks=function(){je=Ad()},e}var Fd=Nd();var Xt=class i{renderer;constructor(){this.renderer=new hi,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 $(this,null,function*(){let t=yield se.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Fd.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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var th=i=>({"user-message-wrapper":i});function nh(i,e){if(i&1&&(l(0,"div",5)(1,"div",9),u(2),c()()),i&2){let t=g(2);p(2),Ve(" ",t.message.speaker," ")}}function ih(i,e){if(i&1&&(l(0,"time",7),u(1),c()),i&2){let t=g(2);p(),B(t.formattedTimestamp)}}function rh(i,e){if(i&1&&(l(0,"div",8),F(1,"app-message-context-menu",10),c()),i&2){let t=g(2);p(),E("actions",t.actions)}}function oh(i,e){if(i&1&&(C(0,nh,3,1,"div",5),F(1,"div",6),C(2,ih,2,1,"time",7),C(3,rh,2,1,"div",8)),i&2){let t=g();S(t.shouldShowSpeaker?0:-1),p(),E("innerHTML",t.renderedContent,ct),p(),S(t.formattedTimestamp?2:-1),p(),S(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function ah(i,e){if(i&1&&(l(0,"a",12),u(1,"view"),c()),i&2){let t=g(2);E("href",t.eventLink,Pn)}}function sh(i,e){if(i&1&&(l(0,"div",2),F(1,"span",11),C(2,ah,2,1,"a",12),c()),i&2){let t=g();p(),E("innerHTML",t.renderedContent,ct),p(),S(t.eventLink?2:-1)}}function lh(i,e){if(i&1&&(l(0,"div",3),F(1,"app-message-context-menu",10),c()),i&2){let t=g();p(),E("actions",t.actions)}}function ch(i,e){if(i&1&&(l(0,"div",4),F(1,"app-message-context-menu",10),c()),i&2){let t=g();p(),E("actions",t.actions)}}var gi=class i{destroy$=new Z;message;canDelete=!0;isOtherUser=!1;copyRequested=new J;deleteRequested=new J;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=f(Vt);notificationService=f(go);preferencesService=f(ke);projectState=f(ve);threadState=f(Ge);markdownService=f(Xt);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 $(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(I(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(Ca);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 $(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 $(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=`
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>${Qt(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=pd(i);if(r===null)return n;i=r;let o='<a href="'+i+'"';return e&&(o+=' title="'+Qt(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=pd(i);if(r===null)return Qt(t);i=r;let o=`<img src="${i}" alt="${t}"`;return e&&(o+=` title="${Qt(e)}"`),o+=">",o}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:Qt(i.text)}},hs=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""}},Dt=class os{options;renderer;textRenderer;constructor(e){this.options=e||zn,this.options.renderer=this.options.renderer||new hi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hs}static parse(e,t){return new os(t).parse(e)}static parseInline(e,t){return new os(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}},Ji=class{options;block;constructor(i){this.options=i||zn}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?It.lex:It.lexInline}provideParser(){return this.block?Dt.parse:Dt.parseInline}},Ru=class{defaults=as();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Dt;Renderer=hi;TextRenderer=hs;Lexer=It;Tokenizer=vo;Hooks=Ji;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=Y({},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 hi(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 vo(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 Ji;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];Ji.passThroughHooks.has(o)?r[a]=m=>{if(this.defaults.async&&Ji.passThroughHooksRespectAsync.has(o))return B(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 B(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=Y(Y({},this.defaults),n)}),this}setOptions(i){return this.defaults=Y(Y({},this.defaults),i),this}lexer(i,e){return It.lex(i,e??this.defaults)}parser(i,e){return Dt.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{let n=Y({},t),r=Y(Y({},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 B(this,null,function*(){let a=r.hooks?yield r.hooks.preprocess(e):e,s=yield(r.hooks?yield r.hooks.provideLexer():i?It.lex:It.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?Dt.parse:Dt.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?It.lex:It.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?Dt.parse:Dt.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>"+Qt(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},Vn=new Ru;function se(i,e){return Vn.parse(i,e)}se.options=se.setOptions=function(i){return Vn.setOptions(i),se.defaults=Vn.defaults,hd(se.defaults),se};se.getDefaults=as;se.defaults=zn;se.use=function(...i){return Vn.use(...i),se.defaults=Vn.defaults,hd(se.defaults),se};se.walkTokens=function(i,e){return Vn.walkTokens(i,e)};se.parseInline=Vn.parseInline;se.Parser=Dt;se.parser=Dt.parse;se.Renderer=hi;se.TextRenderer=hs;se.Lexer=It;se.lexer=It.lex;se.Tokenizer=vo;se.Hooks=Ji;se.parse=se;var Ky=se.options,Xy=se.setOptions,Jy=se.use,Zy=se.walkTokens,eC=se.parseInline;var tC=Dt.parse,nC=It.lex;var{entries:Dd,setPrototypeOf:Td,isFrozen:Nu,getPrototypeOf:Fu,getOwnPropertyDescriptor:Lu}=Object,{freeze:Je,seal:Ct,create:Cs}=Object,{apply:Ss,construct:ws}=typeof Reflect<"u"&&Reflect;Je||(Je=function(e){return e});Ct||(Ct=function(e){return e});Ss||(Ss=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)});ws||(ws=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 So=Ze(Array.prototype.forEach),ju=Ze(Array.prototype.lastIndexOf),Ed=Ze(Array.prototype.pop),tr=Ze(Array.prototype.push),Vu=Ze(Array.prototype.splice),xo=Ze(String.prototype.toLowerCase),gs=Ze(String.prototype.toString),fs=Ze(String.prototype.match),nr=Ze(String.prototype.replace),zu=Ze(String.prototype.indexOf),$u=Ze(String.prototype.trim),Rt=Ze(Object.prototype.hasOwnProperty),Xe=Ze(RegExp.prototype.test),ir=Bu(TypeError);function Ze(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 Ss(i,e,n)}}function Bu(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ws(i,t)}}function Q(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xo;Td&&Td(i,null);let n=e.length;for(;n--;){let r=e[n];if(typeof r=="string"){let o=t(r);o!==r&&(Nu(e)||(e[n]=o),r=o)}i[r]=!0}return i}function Hu(i){for(let e=0;e<i.length;e++)Rt(i,e)||(i[e]=null);return i}function Kt(i){let e=Cs(null);for(let[t,n]of Dd(i))Rt(i,t)&&(Array.isArray(n)?e[t]=Hu(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Kt(n):e[t]=n);return e}function rr(i,e){for(;i!==null;){let n=Lu(i,e);if(n){if(n.get)return Ze(n.get);if(typeof n.value=="function")return Ze(n.value)}i=Fu(i)}function t(){return null}return t}var Md=Je(["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"]),_s=Je(["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"]),bs=Je(["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"]),Uu=Je(["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"]),vs=Je(["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"]),Wu=Je(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),kd=Je(["#text"]),Pd=Je(["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"]),ys=Je(["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"]),Od=Je(["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"]),wo=Je(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qu=Ct(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Gu=Ct(/<%[\w\W]*|[\w\W]*%>/gm),Yu=Ct(/\$\{[\w\W]*/gm),Qu=Ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ku=Ct(/^aria-[\-\w]+$/),Rd=Ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xu=Ct(/^(?:\w+script|data):/i),Ju=Ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nd=Ct(/^html$/i),Zu=Ct(/^[a-z][.\w]*(-[.\w]+)+$/i),Ad=Object.freeze({__proto__:null,ARIA_ATTR:Ku,ATTR_WHITESPACE:Ju,CUSTOM_ELEMENT:Zu,DATA_ATTR:Qu,DOCTYPE_NAME:Nd,ERB_EXPR:Gu,IS_ALLOWED_URI:Rd,IS_SCRIPT_OR_DATA:Xu,MUSTACHE_EXPR:qu,TMPLIT_EXPR:Yu}),or={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},eh=function(){return typeof window>"u"?null:window},th=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}},Id=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Fd(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eh(),e=j=>Fd(j);if(e.version="3.3.1",e.removed=[],!i||!i.document||i.document.nodeType!==or.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:k}=i,T=d.prototype,P=rr(T,"cloneNode"),K=rr(T,"remove"),pe=rr(T,"nextSibling"),N=rr(T,"childNodes"),X=rr(T,"parentNode");if(typeof a=="function"){let j=t.createElement("template");j.content&&j.content.ownerDocument&&(t=j.content.ownerDocument)}let U,Ee="",{implementation:ce,createNodeIterator:Ce,createDocumentFragment:Be,getElementsByTagName:Jt}=t,{importNode:dn}=n,je=Id();e.isSupported=typeof Dd=="function"&&typeof X=="function"&&ce&&ce.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:St,ERB_EXPR:wn,TMPLIT_EXPR:Hn,DATA_ATTR:ur,ARIA_ATTR:A,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:ee}=Ad,{IS_ALLOWED_URI:Pe}=Ad,le=null,He=Q({},[...Md,..._s,...bs,...vs,...kd]),me=null,ue=Q({},[...Pd,...ys,...Od,...wo]),_e=Object.seal(Cs(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}})),xn=null,Ie=null,et=Object.seal(Cs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ye=!0,pn=!0,Un=!1,Is=!0,Wn=!1,hr=!0,Tn=!1,Jo=!1,Zo=!1,qn=!1,gr=!1,fr=!1,Ds=!0,Rs=!1,kp="user-content-",ea=!0,Ri=!1,Gn={},Nt=null,ta=Q({},["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"]),Ns=null,Fs=Q({},["audio","video","img","source","image","track"]),na=null,Ls=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),_r="http://www.w3.org/1998/Math/MathML",br="http://www.w3.org/2000/svg",Zt="http://www.w3.org/1999/xhtml",Yn=Zt,ia=!1,ra=null,Pp=Q({},[_r,br,Zt],gs),vr=Q({},["mi","mo","mn","ms","mtext"]),yr=Q({},["annotation-xml"]),Op=Q({},["title","style","font","a","script"]),Ni=null,Ap=["application/xhtml+xml","text/html"],Ip="text/html",Fe=null,Qn=null,Dp=t.createElement("form"),js=function(h){return h instanceof RegExp||h instanceof Function},oa=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qn&&Qn===h)){if((!h||typeof h!="object")&&(h={}),h=Kt(h),Ni=Ap.indexOf(h.PARSER_MEDIA_TYPE)===-1?Ip:h.PARSER_MEDIA_TYPE,Fe=Ni==="application/xhtml+xml"?gs:xo,le=Rt(h,"ALLOWED_TAGS")?Q({},h.ALLOWED_TAGS,Fe):He,me=Rt(h,"ALLOWED_ATTR")?Q({},h.ALLOWED_ATTR,Fe):ue,ra=Rt(h,"ALLOWED_NAMESPACES")?Q({},h.ALLOWED_NAMESPACES,gs):Pp,na=Rt(h,"ADD_URI_SAFE_ATTR")?Q(Kt(Ls),h.ADD_URI_SAFE_ATTR,Fe):Ls,Ns=Rt(h,"ADD_DATA_URI_TAGS")?Q(Kt(Fs),h.ADD_DATA_URI_TAGS,Fe):Fs,Nt=Rt(h,"FORBID_CONTENTS")?Q({},h.FORBID_CONTENTS,Fe):ta,xn=Rt(h,"FORBID_TAGS")?Q({},h.FORBID_TAGS,Fe):Kt({}),Ie=Rt(h,"FORBID_ATTR")?Q({},h.FORBID_ATTR,Fe):Kt({}),Gn=Rt(h,"USE_PROFILES")?h.USE_PROFILES:!1,Ye=h.ALLOW_ARIA_ATTR!==!1,pn=h.ALLOW_DATA_ATTR!==!1,Un=h.ALLOW_UNKNOWN_PROTOCOLS||!1,Is=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Wn=h.SAFE_FOR_TEMPLATES||!1,hr=h.SAFE_FOR_XML!==!1,Tn=h.WHOLE_DOCUMENT||!1,qn=h.RETURN_DOM||!1,gr=h.RETURN_DOM_FRAGMENT||!1,fr=h.RETURN_TRUSTED_TYPE||!1,Zo=h.FORCE_BODY||!1,Ds=h.SANITIZE_DOM!==!1,Rs=h.SANITIZE_NAMED_PROPS||!1,ea=h.KEEP_CONTENT!==!1,Ri=h.IN_PLACE||!1,Pe=h.ALLOWED_URI_REGEXP||Rd,Yn=h.NAMESPACE||Zt,vr=h.MATHML_TEXT_INTEGRATION_POINTS||vr,yr=h.HTML_INTEGRATION_POINTS||yr,_e=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&js(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_e.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&js(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_e.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(_e.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Wn&&(pn=!1),gr&&(qn=!0),Gn&&(le=Q({},kd),me=[],Gn.html===!0&&(Q(le,Md),Q(me,Pd)),Gn.svg===!0&&(Q(le,_s),Q(me,ys),Q(me,wo)),Gn.svgFilters===!0&&(Q(le,bs),Q(me,ys),Q(me,wo)),Gn.mathMl===!0&&(Q(le,vs),Q(me,Od),Q(me,wo))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?et.tagCheck=h.ADD_TAGS:(le===He&&(le=Kt(le)),Q(le,h.ADD_TAGS,Fe))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?et.attributeCheck=h.ADD_ATTR:(me===ue&&(me=Kt(me)),Q(me,h.ADD_ATTR,Fe))),h.ADD_URI_SAFE_ATTR&&Q(na,h.ADD_URI_SAFE_ATTR,Fe),h.FORBID_CONTENTS&&(Nt===ta&&(Nt=Kt(Nt)),Q(Nt,h.FORBID_CONTENTS,Fe)),h.ADD_FORBID_CONTENTS&&(Nt===ta&&(Nt=Kt(Nt)),Q(Nt,h.ADD_FORBID_CONTENTS,Fe)),ea&&(le["#text"]=!0),Tn&&Q(le,["html","head","body"]),le.table&&(Q(le,["tbody"]),delete xn.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw ir('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ir('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');U=h.TRUSTED_TYPES_POLICY,Ee=U.createHTML("")}else U===void 0&&(U=th(k,r)),U!==null&&typeof Ee=="string"&&(Ee=U.createHTML(""));Je&&Je(h),Qn=h}},Vs=Q({},[..._s,...bs,...Uu]),zs=Q({},[...vs,...Wu]),Rp=function(h){let M=X(h);(!M||!M.tagName)&&(M={namespaceURI:Yn,tagName:"template"});let D=xo(h.tagName),be=xo(M.tagName);return ra[h.namespaceURI]?h.namespaceURI===br?M.namespaceURI===Zt?D==="svg":M.namespaceURI===_r?D==="svg"&&(be==="annotation-xml"||vr[be]):!!Vs[D]:h.namespaceURI===_r?M.namespaceURI===Zt?D==="math":M.namespaceURI===br?D==="math"&&yr[be]:!!zs[D]:h.namespaceURI===Zt?M.namespaceURI===br&&!yr[be]||M.namespaceURI===_r&&!vr[be]?!1:!zs[D]&&(Op[D]||!Vs[D]):!!(Ni==="application/xhtml+xml"&&ra[h.namespaceURI]):!1},Ft=function(h){tr(e.removed,{element:h});try{X(h).removeChild(h)}catch(M){K(h)}},En=function(h,M){try{tr(e.removed,{attribute:M.getAttributeNode(h),from:M})}catch(D){tr(e.removed,{attribute:null,from:M})}if(M.removeAttribute(h),h==="is")if(qn||gr)try{Ft(M)}catch(D){}else try{M.setAttribute(h,"")}catch(D){}},$s=function(h){let M=null,D=null;if(Zo)h="<remove></remove>"+h;else{let De=fs(h,/^[\r\n\t ]+/);D=De&&De[0]}Ni==="application/xhtml+xml"&&Yn===Zt&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");let be=U?U.createHTML(h):h;if(Yn===Zt)try{M=new y().parseFromString(be,Ni)}catch(De){}if(!M||!M.documentElement){M=ce.createDocument(Yn,"template",null);try{M.documentElement.innerHTML=ia?Ee:be}catch(De){}}let Ue=M.body||M.documentElement;return h&&D&&Ue.insertBefore(t.createTextNode(D),Ue.childNodes[0]||null),Yn===Zt?Jt.call(M,Tn?"html":"body")[0]:Tn?M.documentElement:Ue},Bs=function(h){return Ce.call(h.ownerDocument||h,h,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},aa=function(h){return h instanceof b&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof _)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Hs=function(h){return typeof s=="function"&&h instanceof s};function en(j,h,M){So(j,D=>{D.call(e,h,M,Qn)})}let Us=function(h){let M=null;if(en(je.beforeSanitizeElements,h,null),aa(h))return Ft(h),!0;let D=Fe(h.nodeName);if(en(je.uponSanitizeElement,h,{tagName:D,allowedTags:le}),hr&&h.hasChildNodes()&&!Hs(h.firstElementChild)&&Xe(/<[/\w!]/g,h.innerHTML)&&Xe(/<[/\w!]/g,h.textContent)||h.nodeType===or.progressingInstruction||hr&&h.nodeType===or.comment&&Xe(/<[/\w]/g,h.data))return Ft(h),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(D))&&(!le[D]||xn[D])){if(!xn[D]&&qs(D)&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,D)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(D)))return!1;if(ea&&!Nt[D]){let be=X(h)||h.parentNode,Ue=N(h)||h.childNodes;if(Ue&&be){let De=Ue.length;for(let tt=De-1;tt>=0;--tt){let tn=P(Ue[tt],!0);tn.__removalCount=(h.__removalCount||0)+1,be.insertBefore(tn,pe(h))}}}return Ft(h),!0}return h instanceof d&&!Rp(h)||(D==="noscript"||D==="noembed"||D==="noframes")&&Xe(/<\/no(script|embed|frames)/i,h.innerHTML)?(Ft(h),!0):(Wn&&h.nodeType===or.text&&(M=h.textContent,So([St,wn,Hn],be=>{M=nr(M,be," ")}),h.textContent!==M&&(tr(e.removed,{element:h.cloneNode()}),h.textContent=M)),en(je.afterSanitizeElements,h,null),!1)},Ws=function(h,M,D){if(Ds&&(M==="id"||M==="name")&&(D in t||D in Dp))return!1;if(!(pn&&!Ie[M]&&Xe(ur,M))){if(!(Ye&&Xe(A,M))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(M,h))){if(!me[M]||Ie[M]){if(!(qs(h)&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,h)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(h))&&(_e.attributeNameCheck instanceof RegExp&&Xe(_e.attributeNameCheck,M)||_e.attributeNameCheck instanceof Function&&_e.attributeNameCheck(M,h))||M==="is"&&_e.allowCustomizedBuiltInElements&&(_e.tagNameCheck instanceof RegExp&&Xe(_e.tagNameCheck,D)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(D))))return!1}else if(!na[M]){if(!Xe(Pe,nr(D,V,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&h!=="script"&&zu(D,"data:")===0&&Ns[h])){if(!(Un&&!Xe(L,nr(D,V,"")))){if(D)return!1}}}}}}}return!0},qs=function(h){return h!=="annotation-xml"&&fs(h,ee)},Gs=function(h){en(je.beforeSanitizeAttributes,h,null);let{attributes:M}=h;if(!M||aa(h))return;let D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:me,forceKeepAttr:void 0},be=M.length;for(;be--;){let Ue=M[be],{name:De,namespaceURI:tt,value:tn}=Ue,Kn=Fe(De),sa=tn,ze=De==="value"?sa:$u(sa);if(D.attrName=Kn,D.attrValue=ze,D.keepAttr=!0,D.forceKeepAttr=void 0,en(je.uponSanitizeAttribute,h,D),ze=D.attrValue,Rs&&(Kn==="id"||Kn==="name")&&(En(De,h),ze=kp+ze),hr&&Xe(/((--!?|])>)|<\/(style|title|textarea)/i,ze)){En(De,h);continue}if(Kn==="attributename"&&fs(ze,"href")){En(De,h);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){En(De,h);continue}if(!Is&&Xe(/\/>/i,ze)){En(De,h);continue}Wn&&So([St,wn,Hn],Qs=>{ze=nr(ze,Qs," ")});let Ys=Fe(h.nodeName);if(!Ws(Ys,Kn,ze)){En(De,h);continue}if(U&&typeof k=="object"&&typeof k.getAttributeType=="function"&&!tt)switch(k.getAttributeType(Ys,Kn)){case"TrustedHTML":{ze=U.createHTML(ze);break}case"TrustedScriptURL":{ze=U.createScriptURL(ze);break}}if(ze!==sa)try{tt?h.setAttributeNS(tt,De,ze):h.setAttribute(De,ze),aa(h)?Ft(h):Ed(e.removed)}catch(Qs){En(De,h)}}en(je.afterSanitizeAttributes,h,null)},Np=function j(h){let M=null,D=Bs(h);for(en(je.beforeSanitizeShadowDOM,h,null);M=D.nextNode();)en(je.uponSanitizeShadowNode,M,null),Us(M),Gs(M),M.content instanceof o&&j(M.content);en(je.afterSanitizeShadowDOM,h,null)};return e.sanitize=function(j){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,D=null,be=null,Ue=null;if(ia=!j,ia&&(j="<!-->"),typeof j!="string"&&!Hs(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw ir("dirty is not a string, aborting")}else throw ir("toString is not a function");if(!e.isSupported)return j;if(Jo||oa(h),e.removed=[],typeof j=="string"&&(Ri=!1),Ri){if(j.nodeName){let tn=Fe(j.nodeName);if(!le[tn]||xn[tn])throw ir("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof s)M=$s("<!---->"),D=M.ownerDocument.importNode(j,!0),D.nodeType===or.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?M=D:M.appendChild(D);else{if(!qn&&!Wn&&!Tn&&j.indexOf("<")===-1)return U&&fr?U.createHTML(j):j;if(M=$s(j),!M)return qn?null:fr?Ee:""}M&&Zo&&Ft(M.firstChild);let De=Bs(Ri?j:M);for(;be=De.nextNode();)Us(be),Gs(be),be.content instanceof o&&Np(be.content);if(Ri)return j;if(qn){if(gr)for(Ue=Be.call(M.ownerDocument);M.firstChild;)Ue.appendChild(M.firstChild);else Ue=M;return(me.shadowroot||me.shadowrootmode)&&(Ue=dn.call(n,Ue,!0)),Ue}let tt=Tn?M.outerHTML:M.innerHTML;return Tn&&le["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&Xe(Nd,M.ownerDocument.doctype.name)&&(tt="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
334
+ `+tt),Wn&&So([St,wn,Hn],tn=>{tt=nr(tt,tn," ")}),U&&fr?U.createHTML(tt):tt},e.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};oa(j),Jo=!0},e.clearConfig=function(){Qn=null,Jo=!1},e.isValidAttribute=function(j,h,M){Qn||oa({});let D=Fe(j),be=Fe(h);return Ws(D,be,M)},e.addHook=function(j,h){typeof h=="function"&&tr(je[j],h)},e.removeHook=function(j,h){if(h!==void 0){let M=ju(je[j],h);return M===-1?void 0:Vu(je[j],M,1)[0]}return Ed(je[j])},e.removeHooks=function(j){je[j]=[]},e.removeAllHooks=function(){je=Id()},e}var Ld=Fd();var Xt=class i{renderer;constructor(){this.renderer=new hi,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 B(this,null,function*(){let t=yield se.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Ld.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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var nh=i=>({"user-message-wrapper":i});function ih(i,e){if(i&1&&(l(0,"div",5)(1,"div",9),u(2),c()()),i&2){let t=g(2);p(2),Ve(" ",t.message.speaker," ")}}function rh(i,e){if(i&1&&(l(0,"time",7),u(1),c()),i&2){let t=g(2);p(),$(t.formattedTimestamp)}}function oh(i,e){if(i&1&&(l(0,"div",8),F(1,"app-message-context-menu",10),c()),i&2){let t=g(2);p(),E("actions",t.actions)}}function ah(i,e){if(i&1&&(C(0,ih,3,1,"div",5),F(1,"div",6),C(2,rh,2,1,"time",7),C(3,oh,2,1,"div",8)),i&2){let t=g();S(t.shouldShowSpeaker?0:-1),p(),E("innerHTML",t.renderedContent,ct),p(),S(t.formattedTimestamp?2:-1),p(),S(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function sh(i,e){if(i&1&&(l(0,"a",12),u(1,"view"),c()),i&2){let t=g(2);E("href",t.eventLink,Pn)}}function lh(i,e){if(i&1&&(l(0,"div",2),F(1,"span",11),C(2,sh,2,1,"a",12),c()),i&2){let t=g();p(),E("innerHTML",t.renderedContent,ct),p(),S(t.eventLink?2:-1)}}function ch(i,e){if(i&1&&(l(0,"div",3),F(1,"app-message-context-menu",10),c()),i&2){let t=g();p(),E("actions",t.actions)}}function dh(i,e){if(i&1&&(l(0,"div",4),F(1,"app-message-context-menu",10),c()),i&2){let t=g();p(),E("actions",t.actions)}}var gi=class i{destroy$=new J;message;canDelete=!0;isOtherUser=!1;copyRequested=new Z;deleteRequested=new Z;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=f(Vt);notificationService=f(fo);preferencesService=f(ke);projectState=f(ve);threadState=f(Ge);markdownService=f(Xt);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 B(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(I(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 B(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 B(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
336
  <div class="image-content">
337
337
  <img src="${r}"
338
338
  alt="${o}"
@@ -342,10 +342,10 @@ Please report this to https://github.com/markedjs/marked.`,i){let n="<p>An error
342
342
  </div>
343
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
344
 
345
- `)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[gn([Ca])],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,oh,4,4),C(3,sh,3,2,"div",2),c(),C(4,lh,2,1,"div",3),C(5,ch,2,1,"div",4),c()),t&2&&(E("ngClass",Tr(6,th,n.message.role==="user")),p(),E("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:[ho,Ar],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 dh=["determinateSpinner"];function ph(i,e){if(i&1&&(ma(),l(0,"svg",11),F(1,"circle",12),c()),i&2){let t=g();Me("viewBox",t._viewBox()),p(),Qe("stroke-dasharray",t._strokeCircumference(),"px")("stroke-dashoffset",t._strokeCircumference()/2,"px")("stroke-width",t._circleStrokeWidth(),"%"),Me("r",t._circleRadius())}}var mh=new Ni("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:Ld})}),Ld=100,uh=10,fi=(()=>{class i{_elementRef=f(mt);_noopAnimations;get color(){return this._color||this._defaultColor}set color(t){this._color=t}_color;_defaultColor="primary";_determinateCircle;constructor(){let t=f(mh),n=Il(),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=Ld;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(t){this._strokeWidth=t||0}_strokeWidth;_circleRadius(){return(this.diameter-uh)/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=R({type:i,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(n,r){if(n&1&&$e(dh,5),n&2){let o;ge(o=fe())&&(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&&(Me("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",r.mode==="determinate"?r.value:null)("mode",r.mode),va("mat-"+r.color),Qe("width",r.diameter,"px")("height",r.diameter,"px")("--mat-progress-spinner-size",r.diameter+"px")("--mat-progress-spinner-active-indicator-width",r.diameter+"px"),G("_mat-animation-noopable",r._noopAnimations)("mdc-circular-progress--indeterminate",r.mode==="indeterminate"))},inputs:{color:"color",mode:"mode",value:[2,"value","value",Or],diameter:[2,"diameter","diameter",Or],strokeWidth:[2,"strokeWidth","strokeWidth",Or]},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&&(ti(0,ph,2,8,"ng-template",null,0,Er),l(2,"div",2,1),ma(),l(4,"svg",3),F(5,"circle",4),c()(),il(),l(6,"div",5)(7,"div",6)(8,"div",7),On(9,8),c(),l(10,"div",9),On(11,8),c(),l(12,"div",10),On(13,8),c()()()),n&2){let o=ji(1);p(4),Me("viewBox",r._viewBox()),p(),Qe("stroke-dasharray",r._strokeCircumference(),"px")("stroke-dashoffset",r._strokeDashOffset(),"px")("stroke-width",r._circleStrokeWidth(),"%"),Me("r",r._circleRadius()),p(4),E("ngTemplateOutlet",o),p(2),E("ngTemplateOutlet",o),p(2),E("ngTemplateOutlet",o)}},dependencies:[Ir],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 _i=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var hh=(i,e)=>e.id;function gh(i,e){if(i&1&&(l(0,"span",4),u(1),c()),i&2){let t=g();p(),B(t.taskSummary)}}function fh(i,e){i&1&&(l(0,"div",6),F(1,"mat-spinner",8),l(2,"span"),u(3,"Loading..."),c()()),i&2&&(p(),E("diameter",16))}function _h(i,e){if(i&1&&F(0,"app-delegation-inline",9),i&2){let t=g().$implicit;E("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function bh(i,e){if(i&1&&F(0,"app-chat-message",10),i&2){let t=g().$implicit;E("message",t)("canDelete",!1)}}function vh(i,e){if(i&1&&C(0,_h,1,2,"app-delegation-inline",9)(1,bh,1,2,"app-chat-message",10),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function yh(i,e){if(i&1&&(l(0,"div",7)(1,"div",11),u(2),c()()),i&2){let t=g(2);p(2),B(t.streamingText)}}function Ch(i,e){if(i&1&&(l(0,"div",5),C(1,fh,4,1,"div",6),we(2,vh,2,1,null,null,hh),C(4,yh,3,1,"div",7),c()),i&2){let t=g();p(),S(t.isLoading&&t.subMessages.length===0?1:-1),p(),xe(t.subMessages),p(2),S(t.streamingText?4:-1)}}var xo=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=f(lt);threadApi=f(Gt);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(Se(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=Gi(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 st?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof bn?this.streamingText+=e.chunk:e instanceof Ot?(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 Pt?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 yt?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 Wt?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 Ut&&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=R({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,gh,2,1,"span",4),c(),C(7,Ch,5,2,"div",5),c()),t&2&&(p(3),B(n.isExpanded?"expand_more":"chevron_right"),p(2),B(n.agentName),p(),S(n.taskSummary?6:-1),p(),S(n.isExpanded?7:-1))},dependencies:[i,nt,Re,de,_i,fi,gi],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 bi=class i{unreadCountSubject=new W(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var vi=class i{destroy$=new Z;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new W(!1);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=f(ke);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(I(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e)}),this.preferencesService.voiceRate$.pipe(I(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e)}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage()}),this.preferencesService.selectedVoice$.pipe(I(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 $(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 $(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 $(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 $(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,`
345
+ `)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[gn([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,ah,4,4),C(3,lh,3,2,"div",2),c(),C(4,ch,2,1,"div",3),C(5,dh,2,1,"div",4),c()),t&2&&(E("ngClass",Er(6,nh,n.message.role==="user")),p(),E("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:[go,Ir],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 ph=["determinateSpinner"];function mh(i,e){if(i&1&&(ua(),l(0,"svg",11),F(1,"circle",12),c()),i&2){let t=g();Me("viewBox",t._viewBox()),p(),Qe("stroke-dasharray",t._strokeCircumference(),"px")("stroke-dashoffset",t._strokeCircumference()/2,"px")("stroke-width",t._circleStrokeWidth(),"%"),Me("r",t._circleRadius())}}var uh=new Fi("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:jd})}),jd=100,hh=10,fi=(()=>{class i{_elementRef=f(mt);_noopAnimations;get color(){return this._color||this._defaultColor}set color(t){this._color=t}_color;_defaultColor="primary";_determinateCircle;constructor(){let t=f(uh),n=Dl(),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=jd;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(t){this._strokeWidth=t||0}_strokeWidth;_circleRadius(){return(this.diameter-hh)/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=R({type:i,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(n,r){if(n&1&&$e(ph,5),n&2){let o;ge(o=fe())&&(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&&(Me("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",r.mode==="determinate"?r.value:null)("mode",r.mode),ya("mat-"+r.color),Qe("width",r.diameter,"px")("height",r.diameter,"px")("--mat-progress-spinner-size",r.diameter+"px")("--mat-progress-spinner-active-indicator-width",r.diameter+"px"),G("_mat-animation-noopable",r._noopAnimations)("mdc-circular-progress--indeterminate",r.mode==="indeterminate"))},inputs:{color:"color",mode:"mode",value:[2,"value","value",Ar],diameter:[2,"diameter","diameter",Ar],strokeWidth:[2,"strokeWidth","strokeWidth",Ar]},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&&(ti(0,mh,2,8,"ng-template",null,0,Mr),l(2,"div",2,1),ua(),l(4,"svg",3),F(5,"circle",4),c()(),rl(),l(6,"div",5)(7,"div",6)(8,"div",7),On(9,8),c(),l(10,"div",9),On(11,8),c(),l(12,"div",10),On(13,8),c()()()),n&2){let o=Vi(1);p(4),Me("viewBox",r._viewBox()),p(),Qe("stroke-dasharray",r._strokeCircumference(),"px")("stroke-dashoffset",r._strokeDashOffset(),"px")("stroke-width",r._circleStrokeWidth(),"%"),Me("r",r._circleRadius()),p(4),E("ngTemplateOutlet",o),p(2),E("ngTemplateOutlet",o),p(2),E("ngTemplateOutlet",o)}},dependencies:[Dr],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 _i=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var gh=(i,e)=>e.id;function fh(i,e){if(i&1&&(l(0,"span",4),u(1),c()),i&2){let t=g();p(),$(t.taskSummary)}}function _h(i,e){i&1&&(l(0,"div",6),F(1,"mat-spinner",8),l(2,"span"),u(3,"Loading..."),c()()),i&2&&(p(),E("diameter",16))}function bh(i,e){if(i&1&&F(0,"app-delegation-inline",9),i&2){let t=g().$implicit;E("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function vh(i,e){if(i&1&&F(0,"app-chat-message",10),i&2){let t=g().$implicit;E("message",t)("canDelete",!1)}}function yh(i,e){if(i&1&&C(0,bh,1,2,"app-delegation-inline",9)(1,vh,1,2,"app-chat-message",10),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function Ch(i,e){if(i&1&&(l(0,"div",7)(1,"div",11),u(2),c()()),i&2){let t=g(2);p(2),$(t.streamingText)}}function Sh(i,e){if(i&1&&(l(0,"div",5),C(1,_h,4,1,"div",6),we(2,yh,2,1,null,null,gh),C(4,Ch,3,1,"div",7),c()),i&2){let t=g();p(),S(t.isLoading&&t.subMessages.length===0?1:-1),p(),xe(t.subMessages),p(2),S(t.streamingText?4:-1)}}var To=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=f(lt);threadApi=f(Gt);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(Se(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=Yi(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 st?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof bn?this.streamingText+=e.chunk:e instanceof Ot?(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 Pt?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 yt?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 Wt?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 Ut&&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=R({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,fh,2,1,"span",4),c(),C(7,Sh,5,2,"div",5),c()),t&2&&(p(3),$(n.isExpanded?"expand_more":"chevron_right"),p(2),$(n.agentName),p(),S(n.taskSummary?6:-1),p(),S(n.isExpanded?7:-1))},dependencies:[i,nt,Re,de,_i,fi,gi],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 bi=class i{unreadCountSubject=new W(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var vi=class i{destroy$=new J;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new W(!1);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=f(ke);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(I(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e)}),this.preferencesService.voiceRate$.pipe(I(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e)}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage()}),this.preferencesService.selectedVoice$.pipe(I(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 B(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 B(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 B(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 B(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
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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var To=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=R({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&&(un(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),_a(5,"img",5),hn(),un(6,"p",6),u(7),hn()()()()()),t&2&&(p(7),B(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 Sh=(i,e)=>e.id;function wh(i,e){if(i&1&&F(0,"app-delegation-inline",3),i&2){let t=g().$implicit;E("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function xh(i,e){if(i&1){let t=O();l(0,"app-chat-message",5),v("copyRequested",function(r){w(t);let o=g(2);return x(o.onCopyMessage(r))})("deleteRequested",function(r){w(t);let o=g(2);return x(o.onDeleteMessage(r))}),c()}if(i&2){let t=g(),n=t.$implicit,r=t.$index,o=g();E("message",n)("canDelete",o.canDeleteMessage(r))("isOtherUser",n.role==="user"&&!!o.currentUsername&&n.speaker!==o.currentUsername)}}function Th(i,e){if(i&1&&C(0,wh,1,2,"app-delegation-inline",3)(1,xh,1,3,"app-chat-message",4),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function Eh(i,e){if(i&1&&(l(0,"div",1),F(1,"div",6),c()),i&2){let t=g();p(),E("innerHTML",t.renderedStreamingText,ct)}}function Mh(i,e){i&1&&F(0,"app-thinking-loader")}function kh(i,e){if(i&1){let t=O();l(0,"button",7),v("click",function(){w(t);let r=g();return x(r.goToBottom())}),l(1,"mat-icon",8),u(2,"arrow_downward"),c()()}}var Eo=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new J;stopRequested=new J;lastMessageCount=0;destroy$=new Z;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=f(mt);unreadService=f(bi);voiceSynthesisService=f(vi);preferencesService=f(ke);codayService=f(lt);markdownService=f(Xt);sanitizer=f(Vt);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(`
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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Eo=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=R({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&&(un(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),ba(5,"img",5),hn(),un(6,"p",6),u(7),hn()()()()()),t&2&&(p(7),$(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 wh=(i,e)=>e.id;function xh(i,e){if(i&1&&F(0,"app-delegation-inline",3),i&2){let t=g().$implicit;E("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Th(i,e){if(i&1){let t=O();l(0,"app-chat-message",5),v("copyRequested",function(r){w(t);let o=g(2);return x(o.onCopyMessage(r))})("deleteRequested",function(r){w(t);let o=g(2);return x(o.onDeleteMessage(r))}),c()}if(i&2){let t=g(),n=t.$implicit,r=t.$index,o=g();E("message",n)("canDelete",o.canDeleteMessage(r))("isOtherUser",n.role==="user"&&!!o.currentUsername&&n.speaker!==o.currentUsername)}}function Eh(i,e){if(i&1&&C(0,xh,1,2,"app-delegation-inline",3)(1,Th,1,3,"app-chat-message",4),i&2){let t=e.$implicit;S(t.type==="delegation"?0:1)}}function Mh(i,e){if(i&1&&(l(0,"div",1),F(1,"div",6),c()),i&2){let t=g();p(),E("innerHTML",t.renderedStreamingText,ct)}}function kh(i,e){i&1&&F(0,"app-thinking-loader")}function Ph(i,e){if(i&1){let t=O();l(0,"button",7),v("click",function(){w(t);let r=g();return x(r.goToBottom())}),l(1,"mat-icon",8),u(2,"arrow_downward"),c()()}}var Mo=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new Z;stopRequested=new Z;lastMessageCount=0;destroy$=new J;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=f(mt);unreadService=f(bi);voiceSynthesisService=f(vi);preferencesService=f(ke);codayService=f(lt);markdownService=f(Xt);sanitizer=f(Vt);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
349
 
350
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
351
 
@@ -353,9 +353,9 @@ This action cannot be undone once you post another message.`)&&(console.log("[CH
353
353
 
354
354
  `)}extractPartialText(e){return e.split(`
355
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 $(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=R({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:[jt],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),we(1,Th,2,1,null,null,Sh),C(3,Eh,2,1,"div",1),C(4,Mh,1,0,"app-thinking-loader"),C(5,kh,3,0,"button",2),c()),t&2&&(p(),xe(n.messages),p(2),S(n.streamingText?3:-1),p(),S(n.isThinking?4:-1),p(),S(n.showGoToBottom?5:-1))},dependencies:[gi,de,To,jr,xo],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 Ph=["buttonContainer"],Oh=["freeTextInput"],Ah=(i,e)=>e.value;function Ih(i,e){i&1&&(l(0,"mat-icon",10),u(1,"keyboard_return"),c())}function Dh(i,e){if(i&1){let t=O();l(0,"button",8),v("click",function(){let r=w(t).$implicit,o=g(2);return x(o.onOptionClick(r.value))}),l(1,"span",9),u(2),c(),C(3,Ih,2,0,"mat-icon",10),c()}if(i&2){let t=e.$implicit,n=e.$index,r=g(2);G("highlighted",n===r.highlightedIndex),E("disabled",t.disabled)("id","choice-option-"+n),Me("aria-selected",n===r.highlightedIndex),p(2),B(t.label),p(),S(n===r.highlightedIndex?3:-1)}}function Rh(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),re("ngModelChange",function(r){w(t);let o=g(2);return ie(o.freeTextValue,r)||(o.freeTextValue=r),x(r)}),v("keydown",function(r){w(t);let o=g(2);return x(o.onFreeTextKeyDown(r))}),c(),l(6,"button",14),v("click",function(){w(t);let r=g(2);return x(r.onFreeTextSubmit())}),l(7,"mat-icon"),u(8,"send"),c()()()()}if(i&2){let t=g(2);p(4),ne("ngModel",t.freeTextValue),p(2),E("disabled",!t.freeTextValue.trim())}}function Nh(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=g(2);p(4),B(t.searchText)}}function Fh(i,e){if(i&1){let t=O();l(0,"div",2),F(1,"div",3),Vi(2,"async"),l(3,"div",4,0),v("keydown",function(r){w(t);let o=g();return x(o.onKeyDown(r))}),we(5,Dh,4,7,"button",5,Ah),c(),C(7,Rh,9,2,"div",6),C(8,Nh,5,1,"div",7),c()}if(i&2){let t=g();p(),E("innerHTML",hl(2,4,t.renderedLabel$),ct),p(2),Me("aria-activedescendant","choice-option-"+t.highlightedIndex),p(2),xe(t.options),p(2),S(t.allowFreeText?7:-1),p(),S(t.searchText?8:-1)}}var Mo=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new J;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new Z;renderedLabelSubject=new W("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=f(Vt);markdownService=f(Xt);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 $(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=R({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&$e(Ph,5)(Oh,5),t&2){let r;ge(r=fe())&&(n.buttonContainer=r.first),ge(r=fe())&&(n.freeTextInput=r.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[jt],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,Fh,9,6,"div",2),t&2&&S(n.isVisible?0:-1)},dependencies:[Re,de,_t,ht,gt,ft,fl],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 Cn=class i{eventStream=f(qt);messageApi=f(mi);pendingStates=new Map;popupCheckInterval=null;pendingRequest$=new W(null);messageHandler=e=>this.handlePopupMessage(e);constructor(){this.eventStream.events$.pipe(Se(e=>e.type==="oauth_request")).subscribe(e=>this.handleOAuthRequest(e)),window.addEventListener("message",this.messageHandler)}ngOnDestroy(){window.removeEventListener("message",this.messageHandler),this.pendingRequest$.complete(),this.popupCheckInterval&&clearInterval(this.popupCheckInterval)}startPopupMonitoring(e,t){this.popupCheckInterval&&clearInterval(this.popupCheckInterval),this.popupCheckInterval=setInterval(()=>{if(e.closed&&(console.log("[OAuth Service] Popup closed by user"),clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.pendingStates.has(t))){console.warn("[OAuth Service] OAuth cancelled - popup closed without completing authentication");let n=this.pendingStates.get(t);if(this.pendingStates.delete(t),n){let r=new At({state:t,integrationName:n,error:"user_cancelled",errorDescription:"User closed the popup without completing authentication"});this.messageApi.sendMessage(r).subscribe({next:()=>console.log("[OAuth Service] Cancellation sent to backend"),error:o=>console.error("[OAuth Service] Failed to send cancellation:",o)})}}},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 At({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}let{code:t,state:n,error:r,errorDescription:o}=e.data??{};if(r){console.log("[OAuth Service] OAuth error received:",r,o);let d=this.pendingStates.get(n);if(d){this.pendingStates.delete(n),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null);let m=new At({state:n,integrationName:d,error:r,errorDescription:o});this.messageApi.sendMessage(m).subscribe({next:()=>console.log("[OAuth Service] Error callback sent to backend"),error:_=>console.error("[OAuth Service] Failed to send error callback:",_)})}return}if(!t||!n){console.warn("[OAuth Service] Message missing code or state:",e.data);return}console.log("[OAuth Service] Processing callback - code:",t,"state:",n);let a=this.pendingStates.get(n);if(!a){console.warn("[OAuth Service] Unknown state received:",n,"Pending states:",Array.from(this.pendingStates.keys()));return}console.log("[OAuth Service] Found integration:",a),this.pendingStates.delete(n),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null);let s=new At({code:t,state:n,integrationName:a});console.log("[OAuth Service] Sending callback to backend..."),this.messageApi.sendMessage(s).subscribe({next:()=>console.log("[OAuth Service] Callback sent to backend successfully"),error:d=>console.error("[OAuth Service] Failed to send callback:",d)})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function Lh(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=w(t),o=g();return x(o.onCancel(r))}),u(13,"Cancel"),c(),l(14,"button",7),v("click",function(){let r=w(t),o=g();return x(o.onAuthorize(r))}),l(15,"mat-icon"),u(16,"open_in_new"),c(),u(17," Authorize "),c()()()}i&2&&(p(9),B(e.integrationName))}var ko=class i{oauthService=f(Cn);pendingRequest=Ae(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=R({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,Lh,18,1,"div",0),t&2){let r;S((r=n.pendingRequest())?0:-1,r)}},dependencies:[Re,de],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 Po=class i{http=f(it);projectState=f(ve);threadState=f(Ge);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 yr(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(Oe(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var yi=class i{fileApi=f(Po);eventStream=f(qt);filesSignal=We([]);isLoadingSignal=We(!1);currentProjectSignal=We(null);currentThreadSignal=We(null);files=Tt(()=>this.filesSignal());isLoading=Tt(()=>this.isLoadingSignal());fileCount=Tt(()=>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(Y({},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 $(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 $(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(Se(e=>e instanceof yn),ut()).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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function jh(i,e){if(i&1&&F(0,"div",1),i&2){let t=g();E("innerHTML",t.renderedContent,ct)}}function Vh(i,e){if(i&1&&F(0,"iframe",2),i&2){let t=g();E("srcdoc",t.content,ct)}}function zh(i,e){if(i&1&&(l(0,"pre",3),u(1),c()),i&2){let t=g();p(),B(t.content)}}var Oo=class i{content="";format="text";renderedContent="";sanitizer=f(Vt);markdownService=f(Xt);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return $(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=R({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[jt],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,jh,1,1,"div",1)(2,Vh,1,1,"iframe",2)(3,zh,2,1,"pre",3),c()),t&2&&(E("ngClass","format-"+n.format),p(),S(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[nt,Ar],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(Oe(a=>{let s=a.body||"",d=new Blob([s]).size;return{content:s,format:o,filename:n,size:d}}),mn(a=>(console.error("[CONTENT_VIEWER] Error loading file:",n,a),Xn(()=>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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function $h(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){w(t);let r=g();return x(r.download())}),l(1,"mat-icon"),u(2,"download"),c()()}}function Bh(i,e){i&1&&(l(0,"div",9),F(1,"mat-spinner",13),l(2,"p"),u(3,"Loading file content..."),c()())}function Hh(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(){w(t);let r=g();return x(r.download())}),l(6,"mat-icon"),u(7,"download"),c(),u(8," Download instead "),c()()}if(i&2){let t=g();p(4),B(t.error)}}function Uh(i,e){if(i&1&&F(0,"app-content-renderer",11),i&2){let t=g();E("content",t.fileContent.content)("format",t.fileContent.format)}}var Ao=class i{destroy$=new Z;file;projectName;threadId;closeViewer=new J;contentService=f(Ci);eventStream=f(qt);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(Se(e=>e instanceof yn),Se(e=>e.filename===this.file.filename),Se(e=>e.operation==="updated"),I(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=R({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,$h,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,Bh,4,0,"div",9),C(14,Hh,9,1,"div",10),C(15,Uh,1,2,"app-content-renderer",11),c()()),t&2&&(p(4),B(n.file.filename),p(2),B(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,Re,de,rt,Lr,qe,_i,fi,Oo],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 Wh=Math.pow(10,8)*24*60*60*1e3,Mx=-Wh,Io=6048e5,jd=864e5;var qh=3600;var Vd=qh*24,kx=Vd*7,Gh=Vd*365.2425,Yh=Gh/12,Px=Yh*3,xs=Symbol.for("constructDateFrom");function Ne(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&xs in i?i[xs](e):i instanceof Date?new i.constructor(e):new Date(e)}function ye(i,e){return Ne(e||i,i)}function zd(i,e,t){let n=ye(i,t?.in);return isNaN(e)?Ne(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var Qh={};function Sn(){return Qh}function ln(i,e){let t=Sn(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=ye(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 $n(i,e){return ln(i,he(Y({},e),{weekStartsOn:1}))}function Do(i,e){let t=ye(i,e?.in),n=t.getFullYear(),r=Ne(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let o=$n(r),a=Ne(t,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let s=$n(a);return t.getTime()>=o.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function Ts(i){let e=ye(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 wi(i,...e){let t=Ne.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function xi(i,e){let t=ye(i,e?.in);return t.setHours(0,0,0,0),t}function Ro(i,e,t){let[n,r]=wi(t?.in,i,e),o=xi(n),a=xi(r),s=+o-Ts(o),d=+a-Ts(a);return Math.round((s-d)/jd)}function $d(i,e){let t=Do(i,e),n=Ne(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),$n(n)}function Bd(i){return Ne(i,Date.now())}function Hd(i,e,t){let[n,r]=wi(t?.in,i,e);return+xi(n)==+xi(r)}function Ud(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function Wd(i){return!(!Ud(i)&&typeof i!="number"||isNaN(+ye(i)))}function Gd(i,e,t){let[n,r]=wi(t?.in,i,e),o=qd(n,r),a=Math.abs(Ro(n,r));n.setDate(n.getDate()-o*a);let s=+(qd(n,r)===-o),d=o*(a-s);return d===0?0:d}function qd(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 Yd(i,e){let t=ye(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var Kh={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"}},Qd=(i,e,t)=>{let n,r=Kh[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 No(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var Xh={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Zh={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Jh={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kd={date:No({formats:Xh,defaultWidth:"full"}),time:No({formats:Zh,defaultWidth:"full"}),dateTime:No({formats:Jh,defaultWidth:"full"})};var eg={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Xd=(i,e,t,n)=>eg[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 tg={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ng={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ig={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"]},rg={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"]},og={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"}},ag={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"}},sg=(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"},Zd={ordinalNumber:sg,era:Ti({values:tg,defaultWidth:"wide"}),quarter:Ti({values:ng,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Ti({values:ig,defaultWidth:"wide"}),day:Ti({values:rg,defaultWidth:"wide"}),dayPeriod:Ti({values:og,defaultWidth:"wide",formattingValues:ag,defaultFormattingWidth:"wide"})};function Ei(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)?cg(s,b=>b.test(a)):lg(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 lg(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function cg(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function Jd(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 dg=/^(\d+)(th|st|nd|rd)?/i,pg=/\d+/i,mg={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},ug={any:[/^b/i,/^(a|c)/i]},hg={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},gg={any:[/1/i,/2/i,/3/i,/4/i]},fg={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},_g={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]},bg={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},vg={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]},yg={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},Cg={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}},ep={ordinalNumber:Jd({matchPattern:dg,parsePattern:pg,valueCallback:i=>parseInt(i,10)}),era:Ei({matchPatterns:mg,defaultMatchWidth:"wide",parsePatterns:ug,defaultParseWidth:"any"}),quarter:Ei({matchPatterns:hg,defaultMatchWidth:"wide",parsePatterns:gg,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Ei({matchPatterns:fg,defaultMatchWidth:"wide",parsePatterns:_g,defaultParseWidth:"any"}),day:Ei({matchPatterns:bg,defaultMatchWidth:"wide",parsePatterns:vg,defaultParseWidth:"any"}),dayPeriod:Ei({matchPatterns:yg,defaultMatchWidth:"any",parsePatterns:Cg,defaultParseWidth:"any"})};var Es={code:"en-US",formatDistance:Qd,formatLong:Kd,formatRelative:Xd,localize:Zd,match:ep,options:{weekStartsOn:0,firstWeekContainsDate:1}};function tp(i,e){let t=ye(i,e?.in);return Ro(t,Yd(t))+1}function np(i,e){let t=ye(i,e?.in),n=+$n(t)-+$d(t);return Math.round(n/Io)+1}function Fo(i,e){let t=ye(i,e?.in),n=t.getFullYear(),r=Sn(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=Ne(e?.in||i,0);a.setFullYear(n+1,0,o),a.setHours(0,0,0,0);let s=ln(a,e),d=Ne(e?.in||i,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);let m=ln(d,e);return+t>=+s?n+1:+t>=+m?n:n-1}function ip(i,e){let t=Sn(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=Fo(i,e),o=Ne(e?.in||i,0);return o.setFullYear(r,0,n),o.setHours(0,0,0,0),ln(o,e)}function rp(i,e){let t=ye(i,e?.in),n=+ln(t,e)-+ip(t,e);return Math.round(n/Io)+1}function ae(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var cn={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return ae(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):ae(t+1,2)},d(i,e){return ae(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 ae(i.getHours()%12||12,e.length)},H(i,e){return ae(i.getHours(),e.length)},m(i,e){return ae(i.getMinutes(),e.length)},s(i,e){return ae(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),r=Math.trunc(n*Math.pow(10,t-3));return ae(r,e.length)}};var Mi={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ms={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 cn.y(i,e)},Y:function(i,e,t,n){let r=Fo(i,n),o=r>0?r:1-r;if(e==="YY"){let a=o%100;return ae(a,2)}return e==="Yo"?t.ordinalNumber(o,{unit:"year"}):ae(o,e.length)},R:function(i,e){let t=Do(i);return ae(t,e.length)},u:function(i,e){let t=i.getFullYear();return ae(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 ae(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 ae(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 cn.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 ae(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=rp(i,n);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):ae(r,e.length)},I:function(i,e,t){let n=np(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):ae(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):cn.d(i,e)},D:function(i,e,t){let n=tp(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):ae(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 ae(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 ae(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 ae(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=Mi.noon:n===0?r=Mi.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=Mi.evening:n>=12?r=Mi.afternoon:n>=4?r=Mi.morning:r=Mi.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 cn.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):cn.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):ae(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):ae(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):cn.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):cn.s(i,e)},S:function(i,e){return cn.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return ap(n);case"XXXX":case"XX":return Bn(n);default:return Bn(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return ap(n);case"xxxx":case"xx":return Bn(n);default:return Bn(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+op(n,":");default:return"GMT"+Bn(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+op(n,":");default:return"GMT"+Bn(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return ae(n,e.length)},T:function(i,e,t){return ae(+i,e.length)}};function op(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+ae(o,2)}function ap(i,e){return i%60===0?(i>0?"-":"+")+ae(Math.abs(i)/60,2):Bn(i,e)}function Bn(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),r=ae(Math.trunc(n/60),2),o=ae(n%60,2);return t+r+e+o}var sp=(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"})}},lp=(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"})}},Sg=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],r=t[2];if(!r)return sp(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}}",sp(n,e)).replace("{{time}}",lp(r,e))},cp={p:lp,P:Sg};var wg=/^D+$/,xg=/^Y+$/,Tg=["D","DD","YY","YYYY"];function dp(i){return wg.test(i)}function pp(i){return xg.test(i)}function mp(i,e,t){let n=Eg(i,e,t);if(console.warn(n),Tg.includes(i))throw new RangeError(n)}function Eg(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 Mg=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kg=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pg=/^'([^]*?)'?$/,Og=/''/g,Ag=/[a-zA-Z]/;function ks(i,e,t){let n=Sn(),r=t?.locale??n.locale??Es,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=ye(i,t?.in);if(!Wd(s))throw new RangeError("Invalid time value");let d=e.match(kg).map(_=>{let b=_[0];if(b==="p"||b==="P"){let y=cp[b];return y(_,r.formatLong)}return _}).join("").match(Mg).map(_=>{if(_==="''")return{isToken:!1,value:"'"};let b=_[0];if(b==="'")return{isToken:!1,value:Ig(_)};if(Ms[b])return{isToken:!0,value:_};if(b.match(Ag))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&&pp(b)||!t?.useAdditionalDayOfYearTokens&&dp(b))&&mp(b,e,String(i));let y=Ms[b[0]];return y(s,b,r.localize,m)}).join("")}function Ig(i){let e=i.match(Pg);return e?e[1].replace(Og,"'"):i}function up(i,e,t){return zd(i,-e,t)}function hp(i,e){return Hd(Ne(e?.in||i,i),up(Bd(e?.in||i),1))}function gp(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=ks(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(hp(i))return`yesterday ${t}`;let a=Gd(e,i);return a<7?`${a}d ago ${t}`:`${ks(i,"dd/MM/yyyy")} ${t}`}var Dg=(i,e)=>e.filename;function Rg(i,e){if(i&1){let t=O();l(0,"button",11),v("click",function(){w(t);let r=g(2);return x(r.downloadAll())}),l(1,"mat-icon"),u(2,"download_for_offline"),c()()}}function Ng(i,e){i&1&&(l(0,"div",10),F(1,"span",12),l(2,"span",13),u(3,"Loading files..."),c()())}function Fg(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 Lg(i,e){if(i&1){let t=O();l(0,"button",28),v("click",function(){w(t);let r=g().$implicit,o=g(4);return x(o.viewFile(r))}),l(1,"mat-icon"),u(2,"visibility"),c()()}}function jg(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,Lg,3,0,"button",25),l(11,"button",26),v("click",function(){let r=w(t).$implicit,o=g(4);return x(o.download(r))}),l(12,"mat-icon"),u(13,"download"),c()(),l(14,"button",27),v("click",function(){let r=w(t).$implicit,o=g(4);return x(o.delete(r))}),l(15,"mat-icon"),u(16,"delete"),c()()()()}if(i&2){let t=e.$implicit,n=g(4);p(3),B(n.getFileIcon(t.filename)),p(2),E("title",t.filename),p(),B(t.filename),p(2),ni("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),p(2),S(n.canViewFile(t)?10:-1)}}function Vg(i,e){if(i&1&&we(0,jg,17,6,"div",18,Dg),i&2){let t=g(3);xe(t.files())}}function zg(i,e){if(i&1&&C(0,Fg,7,0,"div",14)(1,Vg,2,0),i&2){let t=g(2);S(t.files().length===0?0:1)}}function $g(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,Rg,3,0,"button",7),l(9,"button",8),v("click",function(){w(t);let r=g();return x(r.close())}),l(10,"mat-icon"),u(11,"chevron_right"),c()()()(),l(12,"div",9),C(13,Ng,4,0,"div",10)(14,zg,2,1),c()()}if(i&2){let t=g();p(6),Ve("(",t.files().length,")"),p(2),S(t.files().length>0?8:-1),p(5),S(t.isLoading()?13:14)}}function Bg(i,e){if(i&1){let t=O();l(0,"app-content-viewer",29),v("closeViewer",function(){w(t);let r=g();return x(r.backToList())}),c()}if(i&2){let t=g();E("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var Lo=class i{projectName;threadId;closeDrawer=new J;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 $(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 gp(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({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,$g,15,3,"div",0),C(1,Bg,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,Re,de,rt,qe,Ao],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 jo=class i{http=f(it);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vo=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new J;userApi=f(jo);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(Oe(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=R({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&&E("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[Gl],styles:["[_nghost-%COMP%]{display:block}"]})};var Hg=(i,e)=>e.userId;function Ug(i,e){if(i&1&&(l(0,"div",7),u(1),c()),i&2){let t=g();p(),B(t.errorMessage())}}function Wg(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.removeUser(r.userId))}),l(1,"mat-icon"),u(2,"close"),c()()}}function qg(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,Wg,3,0,"button",12),c()),i&2){let t=e.$implicit,n=g();p(4),B(t.userId),p(),S(n.users.length>1?5:-1)}}var or=class i{threadId;users=[];currentUsername;userAdded=new J;userRemoved=new J;closed=new J;isAdding=We(!1);errorMessage=We("");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=R({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,Ug,2,1,"div",7),l(16,"div",8),we(17,qg,6,2,"div",9,Hg),c()()),t&2&&(p(14),E("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),p(),S(n.errorMessage()?15:-1),p(2),xe(n.users))},dependencies:[Re,de,rt,qe,zr,Vo],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 $o=["*"],Yg=["content"],Qg=[[["mat-drawer"]],[["mat-drawer-content"]],"*"],Kg=["mat-drawer","mat-drawer-content","*"];function Xg(i,e){if(i&1){let t=O();l(0,"div",1),v("click",function(){w(t);let r=g();return x(r._onBackdropClicked())}),c()}if(i&2){let t=g();G("mat-drawer-shown",t._isShowingBackdrop())}}function Zg(i,e){i&1&&(l(0,"mat-drawer-content"),dt(1,2),c())}var Jg=[[["mat-sidenav"]],[["mat-sidenav-content"]],"*"],ef=["mat-sidenav","mat-sidenav-content","*"];function tf(i,e){if(i&1){let t=O();l(0,"div",1),v("click",function(){w(t);let r=g();return x(r._onBackdropClicked())}),c()}if(i&2){let t=g();G("mat-drawer-shown",t._isShowingBackdrop())}}function nf(i,e){i&1&&(l(0,"mat-sidenav-content"),dt(1,2),c())}var rf=`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
357
- `;var of=new Ni("MAT_DRAWER_DEFAULT_AUTOSIZE",{providedIn:"root",factory:()=>!1}),Ps=new Ni("MAT_DRAWER_CONTAINER"),ki=(()=>{class i extends ii{_platform=f(Rr);_changeDetectorRef=f(kr);_container=f(sr);constructor(){let t=f(mt),n=f(Rl),r=f(Lt);super(t,n,r)}ngAfterContentInit(){this._container._contentMarginChanges.subscribe(()=>{this._changeDetectorRef.markForCheck()})}_shouldBeHidden(){if(this._platform.isBrowser)return!1;let{start:t,end:n}=this._container;return t!=null&&t.mode!=="over"&&t.opened||n!=null&&n.mode!=="over"&&n.opened}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer-content"]],hostAttrs:[1,"mat-drawer-content"],hostVars:6,hostBindings:function(n,r){n&2&&(Qe("margin-left",r._container._contentMargins.left,"px")("margin-right",r._container._contentMargins.right,"px"),G("mat-drawer-content-hidden",r._shouldBeHidden()))},features:[gn([{provide:ii,useExisting:i}]),Li],ngContentSelectors:$o,decls:1,vars:0,template:function(n,r){n&1&&(nn(),dt(0))},encapsulation:2,changeDetection:0})}return i})(),ar=(()=>{class i{_elementRef=f(mt);_focusTrapFactory=f(Ml);_focusMonitor=f(wl);_platform=f(Rr);_ngZone=f(Lt);_renderer=f(xr);_interactivityChecker=f(Nr);_doc=f(ei);_container=f(Ps,{optional:!0});_focusTrap=null;_elementFocusedBeforeDrawerWasOpened=null;_eventCleanups;_isAttached=!1;_anchor=null;get position(){return this._position}set position(t){t=t==="end"?"end":"start",t!==this._position&&(this._isAttached&&this._updatePositionInParent(t),this._position=t,this.onPositionChanged.emit())}_position="start";get mode(){return this._mode}set mode(t){this._mode=t,this._updateFocusTrapState(),this._modeChanged.next()}_mode="over";get disableClose(){return this._disableClose}set disableClose(t){this._disableClose=An(t)}_disableClose=!1;get autoFocus(){let t=this._autoFocus;return t??(this.mode==="side"?"dialog":"first-tabbable")}set autoFocus(t){(t==="true"||t==="false"||t==null)&&(t=An(t)),this._autoFocus=t}_autoFocus;get opened(){return this._opened()}set opened(t){this.toggle(An(t))}_opened=We(!1);_openedVia=null;_animationStarted=new Z;_animationEnd=new Z;openedChange=new J(!0);_openedStream=this.openedChange.pipe(Se(t=>t),Oe(()=>{}));openedStart=this._animationStarted.pipe(Se(()=>this.opened),la(void 0));_closedStream=this.openedChange.pipe(Se(t=>!t),Oe(()=>{}));closedStart=this._animationStarted.pipe(Se(()=>!this.opened),la(void 0));_destroyed=new Z;onPositionChanged=new J;_content;_modeChanged=new Z;_injector=f(ua);_changeDetectorRef=f(kr);constructor(){this.openedChange.pipe(I(this._destroyed)).subscribe(t=>{t?(this._elementFocusedBeforeDrawerWasOpened=this._doc.activeElement,this._takeFocus()):this._isFocusWithinDrawer()&&this._restoreFocus(this._openedVia||"program")}),this._eventCleanups=this._ngZone.runOutsideAngular(()=>{let t=this._renderer,n=this._elementRef.nativeElement;return[t.listen(n,"keydown",r=>{r.keyCode===27&&!this.disableClose&&!Ol(r)&&this._ngZone.run(()=>{this.close(),r.stopPropagation(),r.preventDefault()})}),t.listen(n,"transitionrun",this._handleTransitionEvent),t.listen(n,"transitionend",this._handleTransitionEvent),t.listen(n,"transitioncancel",this._handleTransitionEvent)]}),this._animationEnd.subscribe(()=>{this.openedChange.emit(this.opened)})}_forceFocus(t,n){this._interactivityChecker.isFocusable(t)||(t.tabIndex=-1,this._ngZone.runOutsideAngular(()=>{let r=()=>{o(),a(),t.removeAttribute("tabindex")},o=this._renderer.listen(t,"blur",r),a=this._renderer.listen(t,"mousedown",r)})),t.focus(n)}_focusByCssSelector(t,n){let r=this._elementRef.nativeElement.querySelector(t);r&&this._forceFocus(r,n)}_takeFocus(){if(!this._focusTrap)return;let t=this._elementRef.nativeElement;switch(this.autoFocus){case!1:case"dialog":return;case!0:case"first-tabbable":ga(()=>{!this._focusTrap.focusInitialElement()&&typeof t.focus=="function"&&t.focus()},{injector:this._injector});break;case"first-heading":this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');break;default:this._focusByCssSelector(this.autoFocus);break}}_restoreFocus(t){this.autoFocus!=="dialog"&&(this._elementFocusedBeforeDrawerWasOpened?this._focusMonitor.focusVia(this._elementFocusedBeforeDrawerWasOpened,t):this._elementRef.nativeElement.blur(),this._elementFocusedBeforeDrawerWasOpened=null)}_isFocusWithinDrawer(){let t=this._doc.activeElement;return!!t&&this._elementRef.nativeElement.contains(t)}ngAfterViewInit(){this._isAttached=!0,this._position==="end"&&this._updatePositionInParent("end"),this._platform.isBrowser&&(this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement),this._updateFocusTrapState())}ngOnDestroy(){this._eventCleanups.forEach(t=>t()),this._focusTrap?.destroy(),this._anchor?.remove(),this._anchor=null,this._animationStarted.complete(),this._animationEnd.complete(),this._modeChanged.complete(),this._destroyed.next(),this._destroyed.complete()}open(t){return this.toggle(!0,t)}close(){return this.toggle(!1)}_closeViaBackdropClick(){return this._setOpen(!1,!0,"mouse")}toggle(t=!this.opened,n){t&&n&&(this._openedVia=n);let r=this._setOpen(t,!t&&this._isFocusWithinDrawer(),this._openedVia||"program");return t||(this._openedVia=null),r}_setOpen(t,n,r){return t===this.opened?Promise.resolve(t?"open":"close"):(this._opened.set(t),this._container?._transitionsEnabled?this._setIsAnimating(!0):setTimeout(()=>{this._animationStarted.next(),this._animationEnd.next()}),this._elementRef.nativeElement.classList.toggle("mat-drawer-opened",t),!t&&n&&this._restoreFocus(r),this._changeDetectorRef.markForCheck(),this._updateFocusTrapState(),new Promise(o=>{this.openedChange.pipe(Zn(1)).subscribe(a=>o(a?"open":"close"))}))}_setIsAnimating(t){this._elementRef.nativeElement.classList.toggle("mat-drawer-animating",t)}_getWidth(){return this._elementRef.nativeElement.offsetWidth||0}_updateFocusTrapState(){this._focusTrap&&(this._focusTrap.enabled=this.opened&&!!this._container?._isShowingBackdrop())}_updatePositionInParent(t){if(!this._platform.isBrowser)return;let n=this._elementRef.nativeElement,r=n.parentNode;t==="end"?(this._anchor||(this._anchor=this._doc.createComment("mat-drawer-anchor"),r.insertBefore(this._anchor,n)),r.appendChild(n)):this._anchor&&this._anchor.parentNode.insertBefore(n,this._anchor)}_handleTransitionEvent=t=>{let n=this._elementRef.nativeElement;t.target===n&&this._ngZone.run(()=>{t.type==="transitionrun"?this._animationStarted.next(t):(t.type==="transitionend"&&this._setIsAnimating(!1),this._animationEnd.next(t))})};static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer"]],viewQuery:function(n,r){if(n&1&&$e(Yg,5),n&2){let o;ge(o=fe())&&(r._content=o.first)}},hostAttrs:[1,"mat-drawer"],hostVars:12,hostBindings:function(n,r){n&2&&(Me("align",null)("tabIndex",r.mode!=="side"?"-1":null),Qe("visibility",!r._container&&!r.opened?"hidden":null),G("mat-drawer-end",r.position==="end")("mat-drawer-over",r.mode==="over")("mat-drawer-push",r.mode==="push")("mat-drawer-side",r.mode==="side"))},inputs:{position:"position",mode:"mode",disableClose:"disableClose",autoFocus:"autoFocus",opened:"opened"},outputs:{openedChange:"openedChange",_openedStream:"opened",openedStart:"openedStart",_closedStream:"closed",closedStart:"closedStart",onPositionChanged:"positionChanged"},exportAs:["matDrawer"],ngContentSelectors:$o,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(n,r){n&1&&(nn(),l(0,"div",1,0),dt(2),c())},dependencies:[ii],encapsulation:2,changeDetection:0})}return i})(),sr=(()=>{class i{_dir=f(Dl,{optional:!0});_element=f(mt);_ngZone=f(Lt);_changeDetectorRef=f(kr);_animationDisabled=Fr();_transitionsEnabled=!1;_allDrawers;_drawers=new ol;_content;_userContent;get start(){return this._start}get end(){return this._end}get autosize(){return this._autosize}set autosize(t){this._autosize=An(t)}_autosize=f(of);get hasBackdrop(){return this._drawerHasBackdrop(this._start)||this._drawerHasBackdrop(this._end)}set hasBackdrop(t){this._backdropOverride=t==null?null:An(t)}_backdropOverride=null;backdropClick=new J;_start=null;_end=null;_left=null;_right=null;_destroyed=new Z;_doCheckSubject=new Z;_contentMargins={left:null,right:null};_contentMarginChanges=new Z;get scrollable(){return this._userContent||this._content}_injector=f(ua);constructor(){let t=f(Rr),n=f(Nl);this._dir?.change.pipe(I(this._destroyed)).subscribe(()=>{this._validateDrawers(),this.updateContentMargins()}),n.change().pipe(I(this._destroyed)).subscribe(()=>this.updateContentMargins()),!this._animationDisabled&&t.isBrowser&&this._ngZone.runOutsideAngular(()=>{setTimeout(()=>{this._element.nativeElement.classList.add("mat-drawer-transition"),this._transitionsEnabled=!0},200)})}ngAfterContentInit(){this._allDrawers.changes.pipe(Jn(this._allDrawers),I(this._destroyed)).subscribe(t=>{this._drawers.reset(t.filter(n=>!n._container||n._container===this)),this._drawers.notifyOnChanges()}),this._drawers.changes.pipe(Jn(null)).subscribe(()=>{this._validateDrawers(),this._drawers.forEach(t=>{this._watchDrawerToggle(t),this._watchDrawerPosition(t),this._watchDrawerMode(t)}),(!this._drawers.length||this._isDrawerOpen(this._start)||this._isDrawerOpen(this._end))&&this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),this._ngZone.runOutsideAngular(()=>{this._doCheckSubject.pipe(Js(10),I(this._destroyed)).subscribe(()=>this.updateContentMargins())})}ngOnDestroy(){this._contentMarginChanges.complete(),this._doCheckSubject.complete(),this._drawers.destroy(),this._destroyed.next(),this._destroyed.complete()}open(){this._drawers.forEach(t=>t.open())}close(){this._drawers.forEach(t=>t.close())}updateContentMargins(){let t=0,n=0;if(this._left&&this._left.opened){if(this._left.mode=="side")t+=this._left._getWidth();else if(this._left.mode=="push"){let r=this._left._getWidth();t+=r,n-=r}}if(this._right&&this._right.opened){if(this._right.mode=="side")n+=this._right._getWidth();else if(this._right.mode=="push"){let r=this._right._getWidth();n+=r,t-=r}}t=t||null,n=n||null,(t!==this._contentMargins.left||n!==this._contentMargins.right)&&(this._contentMargins={left:t,right:n},this._ngZone.run(()=>this._contentMarginChanges.next(this._contentMargins)))}ngDoCheck(){this._autosize&&this._isPushed()&&this._ngZone.runOutsideAngular(()=>this._doCheckSubject.next())}_watchDrawerToggle(t){t._animationStarted.pipe(I(this._drawers.changes)).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),t.mode!=="side"&&t.openedChange.pipe(I(this._drawers.changes)).subscribe(()=>this._setContainerClass(t.opened))}_watchDrawerPosition(t){t.onPositionChanged.pipe(I(this._drawers.changes)).subscribe(()=>{ga({read:()=>this._validateDrawers()},{injector:this._injector})})}_watchDrawerMode(t){t._modeChanged.pipe(I(Zs(this._drawers.changes,this._destroyed))).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()})}_setContainerClass(t){let n=this._element.nativeElement.classList,r="mat-drawer-container-has-open";t?n.add(r):n.remove(r)}_validateDrawers(){this._start=this._end=null,this._drawers.forEach(t=>{t.position=="end"?(this._end!=null,this._end=t):(this._start!=null,this._start=t)}),this._right=this._left=null,this._dir&&this._dir.value==="rtl"?(this._left=this._end,this._right=this._start):(this._left=this._start,this._right=this._end)}_isPushed(){return this._isDrawerOpen(this._start)&&this._start.mode!="over"||this._isDrawerOpen(this._end)&&this._end.mode!="over"}_onBackdropClicked(){this.backdropClick.emit(),this._closeModalDrawersViaBackdrop()}_closeModalDrawersViaBackdrop(){[this._start,this._end].filter(t=>t&&!t.disableClose&&this._drawerHasBackdrop(t)).forEach(t=>t._closeViaBackdropClick())}_isShowingBackdrop(){return this._isDrawerOpen(this._start)&&this._drawerHasBackdrop(this._start)||this._isDrawerOpen(this._end)&&this._drawerHasBackdrop(this._end)}_isDrawerOpen(t){return t!=null&&t.opened}_drawerHasBackdrop(t){return this._backdropOverride==null?!!t&&t.mode!=="side":this._backdropOverride}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer-container"]],contentQueries:function(n,r,o){if(n&1&&ba(o,ki,5)(o,ar,5),n&2){let a;ge(a=fe())&&(r._content=a.first),ge(a=fe())&&(r._allDrawers=a)}},viewQuery:function(n,r){if(n&1&&$e(ki,5),n&2){let o;ge(o=fe())&&(r._userContent=o.first)}},hostAttrs:[1,"mat-drawer-container"],hostVars:2,hostBindings:function(n,r){n&2&&G("mat-drawer-container-explicit-backdrop",r._backdropOverride)},inputs:{autosize:"autosize",hasBackdrop:"hasBackdrop"},outputs:{backdropClick:"backdropClick"},exportAs:["matDrawerContainer"],features:[gn([{provide:Ps,useExisting:i}])],ngContentSelectors:Kg,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(n,r){n&1&&(nn(Qg),C(0,Xg,1,2,"div",0),dt(1),dt(2,1),C(3,Zg,2,0,"mat-drawer-content")),n&2&&(S(r.hasBackdrop?0:-1),p(3),S(r._content?-1:3))},dependencies:[ki],styles:[`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
358
- `],encapsulation:2,changeDetection:0})}return i})(),zo=(()=>{class i extends ki{static \u0275fac=(()=>{let t;return function(r){return(t||(t=wr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav-content"]],hostAttrs:[1,"mat-drawer-content","mat-sidenav-content"],features:[gn([{provide:ii,useExisting:i}]),Li],ngContentSelectors:$o,decls:1,vars:0,template:function(n,r){n&1&&(nn(),dt(0))},encapsulation:2,changeDetection:0})}return i})(),Os=(()=>{class i extends ar{get fixedInViewport(){return this._fixedInViewport}set fixedInViewport(t){this._fixedInViewport=An(t)}_fixedInViewport=!1;get fixedTopGap(){return this._fixedTopGap}set fixedTopGap(t){this._fixedTopGap=Sa(t)}_fixedTopGap=0;get fixedBottomGap(){return this._fixedBottomGap}set fixedBottomGap(t){this._fixedBottomGap=Sa(t)}_fixedBottomGap=0;static \u0275fac=(()=>{let t;return function(r){return(t||(t=wr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav"]],hostAttrs:[1,"mat-drawer","mat-sidenav"],hostVars:16,hostBindings:function(n,r){n&2&&(Me("tabIndex",r.mode!=="side"?"-1":null)("align",null),Qe("top",r.fixedInViewport?r.fixedTopGap:null,"px")("bottom",r.fixedInViewport?r.fixedBottomGap:null,"px"),G("mat-drawer-end",r.position==="end")("mat-drawer-over",r.mode==="over")("mat-drawer-push",r.mode==="push")("mat-drawer-side",r.mode==="side")("mat-sidenav-fixed",r.fixedInViewport))},inputs:{fixedInViewport:"fixedInViewport",fixedTopGap:"fixedTopGap",fixedBottomGap:"fixedBottomGap"},exportAs:["matSidenav"],features:[gn([{provide:ar,useExisting:i}]),Li],ngContentSelectors:$o,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(n,r){n&1&&(nn(),l(0,"div",1,0),dt(2),c())},dependencies:[ii],encapsulation:2,changeDetection:0})}return i})(),fp=(()=>{class i extends sr{_allDrawers=void 0;_content=void 0;static \u0275fac=(()=>{let t;return function(r){return(t||(t=wr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav-container"]],contentQueries:function(n,r,o){if(n&1&&ba(o,zo,5)(o,Os,5),n&2){let a;ge(a=fe())&&(r._content=a.first),ge(a=fe())&&(r._allDrawers=a)}},hostAttrs:[1,"mat-drawer-container","mat-sidenav-container"],hostVars:2,hostBindings:function(n,r){n&2&&G("mat-drawer-container-explicit-backdrop",r._backdropOverride)},exportAs:["matSidenavContainer"],features:[gn([{provide:Ps,useExisting:i},{provide:sr,useExisting:i}]),Li],ngContentSelectors:ef,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(n,r){n&1&&(nn(Jg),C(0,tf,1,2,"div",0),dt(1),dt(2,1),C(3,nf,2,0,"mat-sidenav-content")),n&2&&(S(r.hasBackdrop?0:-1),p(3),S(r._content?-1:3))},dependencies:[zo],styles:[rf],encapsulation:2,changeDetection:0})}return i})(),Bo=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[wa,$t,wa]})}return i})();var bp="mat-badge-content",af=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({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)}
359
- `],encapsulation:2,changeDetection:0})}return i})(),vp=(()=>{class i{_ngZone=f(Lt);_elementRef=f(mt);_ariaDescriber=f(Al);_renderer=f(xr);_animationsDisabled=Fr();_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(Nr);_document=f(ei);constructor(){let t=f(xl);t.load(af),t.load(Tl)}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(bp),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 > .${bp}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=cl({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,r){n&2&&G("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",Pr],disabled:[2,"matBadgeDisabled","disabled",Pr],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",Pr]}})}return i})(),yp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[kl,$t]})}return i})();var Pi=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=f(bi);project=f(ve);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){kn([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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ho=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 $(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),Mn({success:!1,error:r instanceof Error?r.message:"Validation failed"})}return new yr(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(Oe(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),mn(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let s=a.error?.error||a.message||"Upload failed";return Mn({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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Oi=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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var lf=["inputSection"],cf=()=>[];function df(i,e){if(i&1){let t=O();l(0,"button",20),v("click",function(){w(t);let r=g();return x(r.toggleFileDrawer())}),l(1,"mat-icon"),u(2,"folder_open"),c()()}if(i&2){let t=g();G("has-files",t.fileCount>0),E("title",pl("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function pf(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){w(t);let r=g();return x(r.toggleSharePanel())}),l(1,"mat-icon"),u(2,"group"),c()()}if(i&2){let t=g();G("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function mf(i,e){if(i&1&&(l(0,"div",6),u(1),c()),i&2){let t=g();p(),ni(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function uf(i,e){if(i&1&&(l(0,"div",22),u(1),c()),i&2){let t=g();G("error",t.uploadStatus.isError),p(),Ve(" ",t.uploadStatus.message," ")}}function hf(i,e){if(i&1){let t=O();l(0,"app-chat-textarea",23),v("messageSubmitted",function(r){w(t);let o=g();return x(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){w(t);let o=g();return x(o.onVoiceToggled(r))})("heightChanged",function(r){w(t);let o=g();return x(o.onInputHeightChanged(r))})("stopRequested",function(){w(t);let r=g();return x(r.onStopRequested())})("filesPasted",function(r){w(t);let o=g();return x(o.onFilesPasted(r))}),c()}if(i&2){let t=g();E("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function gf(i,e){if(i&1){let t=O();l(0,"app-choice-select",24),v("choiceSelected",function(r){w(t);let o=g();return x(o.onChoiceSelected(r))}),c()}if(i&2){let t=g();E("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function ff(i,e){i&1&&F(0,"app-oauth-request-panel")}function _f(i,e){if(i&1){let t=O();l(0,"app-file-exchange-drawer",25),v("closeDrawer",function(){w(t);let r=g();return x(r.closeDrawer())}),c()}if(i&2){let t=g();E("projectName",t.projectName)("threadId",t.threadId)}}function bf(i,e){if(i&1){let t=O();l(0,"app-thread-share",26),v("userAdded",function(r){w(t);let o=g();return x(o.onUserAdded(r))})("userRemoved",function(r){w(t);let o=g();return x(o.onUserRemoved(r))})("closed",function(){w(t);let r=g();return x(r.closeDrawer())}),c()}if(i&2){let t=g();E("threadId",t.threadId)("users",t.threadDetails.users||ml(3,cf))("currentUsername",t.currentUsername)}}function vf(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 Uo=class i{projectName;threadId;chatFocused=new J;drawerStateChange=new J;destroy$=new Z;connectionDestroy$=new Z;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(lt);oauthService=f(Cn);pendingOAuthRequest=Ae(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=f(ke);titleService=f(Pi);elementRef=f(mt);threadState=f(Ge);userService=f(Yt);router=f(zt);imageUploadService=f(Ho);fileExchangeState=f(yi);firstMessageState=f(Oi);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(I(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(I(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(I(this.connectionDestroy$)).subscribe(t=>{console.log("[THREAD] Messages updated:",t.length),this.messages=t}),this.codayService.streamingText$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.streamingText=t}),this.codayService.isThinking$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.isThinking=t}),this.codayService.currentChoice$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.currentChoice=t}),this.codayService.connectionStatus$.pipe(I(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(I(this.connectionDestroy$)).subscribe(t=>{t&&(console.log("[THREAD] Thread update event received:",t),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(I(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(I(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(I(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 $(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=R({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&$e(lf,5)(or,5),t&2){let r;ge(r=fe())&&(n.inputSection=r.first),ge(r=fe())&&(n.threadShareRef=r.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[jt],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,df,3,5,"button",4),C(5,pf,3,2,"button",5),C(6,mf,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,uf,2,3,"div",10),c()(),l(11,"div",11,0)(13,"div",12)(14,"div",13),C(15,hf,1,5,"app-chat-textarea",14),C(16,gf,1,4,"app-choice-select",15),C(17,ff,1,0,"app-oauth-request-panel"),c()()()()(),l(18,"mat-drawer",16),v("closed",function(){return n.closeDrawer()}),C(19,_f,1,2,"app-file-exchange-drawer",17),C(20,bf,1,4,"app-thread-share",18),c()(),C(21,vf,8,0,"div",19),c()),t&2&&(p(),E("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),E("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(),E("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:[Eo,ui,Mo,ko,Lo,or,Bo,ar,sr,ki,Re,de,rt,jr,yp,vp],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 Wo=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=R({type:i,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,n){t&1&&(un(0,"h1",0),u(1),hn()),t&2&&(p(),B(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 Cp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var Sp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var Ai=class i{currentThemeSubject=new W("light");currentTheme$=this.currentThemeSubject.asObservable();preferences=f(ke);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var yf=(i,e)=>e.code,Cf=(i,e)=>e.name+e.lang;function Sf(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 wf(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;E("value",t.code),p(),ni("",t.flag," ",t.label)}}function xf(i,e){i&1&&(l(0,"option",25),u(1,"Loading voices..."),c())}function Tf(i,e){i&1&&(l(0,"option",25),u(1,"No voice available"),c())}function Ef(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;E("value",t.name+"|"+t.lang),p(),Ve(" ",t.displayName," ")}}var lr=class i{destroy$=new Z;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(ke);voiceSynthesisService=f(vi);themeService=f(Ai);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(I(this.destroy$)).subscribe(e=>{this.selectedTheme=e}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(e=>{this.selectedVoiceLanguage=e}),this.preferencesService.enterToSend$.pipe(I(this.destroy$)).subscribe(e=>{this.useEnterToSend=e}),this.preferencesService.printTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.printTechnicalMessages=e}),this.preferencesService.hideTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.showTechnicalMessages=!e}),this.preferencesService.hideWarningMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.showWarningMessages=!e}),this.preferencesService.voiceAnnounceEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceAnnounceEnabled=e}),this.preferencesService.voiceMode$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceMode=e}),this.preferencesService.voiceReadFullText$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceReadFullText=e}),this.preferencesService.voiceVolume$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceVolume=Math.round(e*100)}),this.preferencesService.voiceRate$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceRate=Math.round(e*100)}),this.preferencesService.selectedVoice$.pipe(I(this.destroy$)).subscribe(e=>{this.selectedVoiceId=e}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(()=>{this.loadAvailableVoices()}),this.preferencesService.agentNotificationEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.agentNotificationEnabled=e}),this.preferencesService.notificationSoundEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.notificationSoundEnabled=e}),this.preferencesService.browserNotificationEnabled$.pipe(I(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 $(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=R({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),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(11,"span",7),u(12," Light "),c(),l(13,"label",5)(14,"input",8),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(15,"span",7),u(16," Dark "),c(),l(17,"label",5)(18,"input",9),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),F(33,"span",7),u(34," Enter to send "),c(),l(35,"label",5)(36,"input",11),re("ngModelChange",function(o){return ie(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),F(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(n.browserNotificationEnabled,o)||(n.browserNotificationEnabled=o),o}),v("change",function(){return n.onBrowserNotificationEnabledChange()}),c()(),C(75,Sf,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),re("ngModelChange",function(o){return ie(n.selectedVoiceLanguage,o)||(n.selectedVoiceLanguage=o),o}),v("change",function(){return n.onVoiceLanguageChange()}),we(86,wf,2,3,"option",18,yf),c()(),l(88,"div",3)(89,"span",10),u(90,"Automatic announcement:"),c(),l(91,"div",4)(92,"label",5)(93,"input",19),re("ngModelChange",function(o){return ie(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),F(94,"span",7),u(95," Enabled "),c(),l(96,"label",5)(97,"input",19),re("ngModelChange",function(o){return ie(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),F(106,"span",7),u(107," Voice synthesis "),c(),l(108,"label",5)(109,"input",21),re("ngModelChange",function(o){return ie(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),F(118,"span",7),u(119," Full message "),c(),l(120,"label",5)(121,"input",22),re("ngModelChange",function(o){return ie(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.selectedVoiceId,o)||(n.selectedVoiceId=o),o}),v("change",function(){return n.onSelectedVoiceChange()}),C(128,xf,2,0,"option",25),C(129,Tf,2,0,"option",25),we(130,Ef,2,2,"option",18,Cf),c(),F(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(n.voiceRate,o)||(n.voiceRate=o),o}),v("input",function(){return n.onVoiceRateChange()}),c()()()()),t&2&&(p(10),ne("ngModel",n.selectedTheme),p(4),ne("ngModel",n.selectedTheme),p(4),ne("ngModel",n.selectedTheme),p(14),E("value",!0),ne("ngModel",n.useEnterToSend),p(4),E("value",!1),ne("ngModel",n.useEnterToSend),p(7),ne("ngModel",n.showTechnicalMessages),p(5),ne("ngModel",n.showWarningMessages),p(5),ne("ngModel",n.printTechnicalMessages),p(11),ne("ngModel",n.agentNotificationEnabled),p(5),ne("ngModel",n.notificationSoundEnabled),E("disabled",!n.agentNotificationEnabled),p(5),ne("ngModel",n.browserNotificationEnabled),E("disabled",!n.agentNotificationEnabled||n.browserNotificationDenied),p(),S(n.browserNotificationDenied?75:-1),p(10),ne("ngModel",n.selectedVoiceLanguage),p(),xe(n.voiceLanguageOptions),p(7),E("value",!0),ne("ngModel",n.voiceAnnounceEnabled),p(4),E("value",!1),ne("ngModel",n.voiceAnnounceEnabled),p(8),ne("ngModel",n.voiceMode),p(4),ne("ngModel",n.voiceMode),p(8),E("value",!0),ne("ngModel",n.voiceReadFullText),p(4),E("value",!1),ne("ngModel",n.voiceReadFullText),p(6),ne("ngModel",n.selectedVoiceId),E("disabled",n.loadingVoices||n.availableVoices.length===0),p(),S(n.loadingVoices?128:-1),p(),S(!n.loadingVoices&&n.availableVoices.length===0?129:-1),p(),xe(n.availableVoices),p(8),Ve("Volume: ",n.voiceVolume,"%"),p(),ne("ngModel",n.voiceVolume),p(3),Ve("Speed: ",n.voiceRate,"%"),p(),ne("ngModel",n.voiceRate))},dependencies:[_t,Zl,Jl,ht,Kl,Xl,Ql,gt,ft,de,sc],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 Mf=(i,e)=>({subThreads:i,depth:e}),kf=i=>({subThreads:i,depth:1}),wp=(i,e)=>e.id,Pf=(i,e)=>e.label;function Of(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){w(t);let o=g().$implicit,a=g(3);return x(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=g().$implicit,n=g(3);p(),B(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function Af(i,e){i&1&&On(0)}function If(i,e){if(i&1&&ti(0,Af,1,0,"ng-container",11),i&2){let t=g().$implicit,n=g().depth;g();let r=ji(1);E("ngTemplateOutlet",r)("ngTemplateOutletContext",ul(2,Mf,t.subThreads,n+1))}}function Df(i,e){if(i&1){let t=O();l(0,"div",5)(1,"a",6),v("click",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())})("keydown.enter",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())})("keydown.space",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())}),C(2,Of,2,1,"mat-icon",7),l(3,"span",8),u(4),c(),l(5,"span",9),u(6),c()()(),C(7,If,1,5,"ng-container")}if(i&2){let t,n=e.$implicit,r=g().depth,o=g(2);Qe("--sub-depth",r),G("current",n.id===((t=o.currentThread())==null?null:t.id)),p(2),S(n.subThreads!=null&&n.subThreads.length?2:-1),p(2),B(n.delegatedAgentName||"Agent"),p(2),B(n.delegatedTask||n.name),p(),S(o.isParentExpanded(n.id)&&(n.subThreads!=null&&n.subThreads.length)?7:-1)}}function Rf(i,e){if(i&1&&we(0,Df,8,8,null,null,wp),i&2){let t=e.subThreads;xe(t)}}function Nf(i,e){i&1&&(l(0,"div",4),F(1,"span",12),l(2,"span",13),u(3,"Loading threads..."),c()())}function Ff(i,e){if(i&1&&(l(0,"div",25),u(1),c()),i&2){let t=g(6);p(),B(t.renameErrorMessage)}}function Lf(i,e){if(i&1){let t=O();l(0,"div",18)(1,"input",24),re("ngModelChange",function(r){w(t);let o=g(5);return ie(o.editingThreadName,r)||(o.editingThreadName=r),x(r)}),v("keydown",function(r){w(t);let o=g(5);return x(o.onEditKeydown(r))})("blur",function(){w(t);let r=g(5);return x(r.onEditBlur())})("click",function(r){return r.stopPropagation()}),c(),C(2,Ff,2,1,"div",25),c()}if(i&2){let t=g(5);p(),ne("ngModel",t.editingThreadName),E("disabled",t.isRenamingThread),p(),S(t.renameErrorMessage?2:-1)}}function jf(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){w(t);let o=g(2).$implicit,a=g(4);return x(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=g(2).$implicit,n=g(4);p(),B(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function Vf(i,e){if(i&1&&(l(0,"span",27),u(1),c()),i&2){let t=g(2).$implicit;p(),B(t.name)}}function zf(i,e){i&1&&(F(0,"mat-spinner",29),l(1,"span",30),u(2,"Generating name..."),c()),i&2&&E("diameter",16)}function $f(i,e){i&1&&(l(0,"mat-icon",28),u(1,"group"),c())}function Bf(i,e){if(i&1){let t=O();l(0,"a",26),v("click",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())})("keydown.enter",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())})("keydown.space",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())}),C(1,jf,2,1,"mat-icon",7),C(2,Vf,2,1,"span",27)(3,zf,3,1),C(4,$f,2,0,"mat-icon",28),c()}if(i&2){let t=g().$implicit,n=g(4);E("matTooltip",t.name?t.name+`
356
+ `:"")+s}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return B(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=R({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:[jt],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),we(1,Eh,2,1,null,null,wh),C(3,Mh,2,1,"div",1),C(4,kh,1,0,"app-thinking-loader"),C(5,Ph,3,0,"button",2),c()),t&2&&(p(),xe(n.messages),p(2),S(n.streamingText?3:-1),p(),S(n.isThinking?4:-1),p(),S(n.showGoToBottom?5:-1))},dependencies:[gi,de,Eo,Vr,To],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 Oh=["buttonContainer"],Ah=["freeTextInput"],Ih=(i,e)=>e.value;function Dh(i,e){i&1&&(l(0,"mat-icon",10),u(1,"keyboard_return"),c())}function Rh(i,e){if(i&1){let t=O();l(0,"button",8),v("click",function(){let r=w(t).$implicit,o=g(2);return x(o.onOptionClick(r.value))}),l(1,"span",9),u(2),c(),C(3,Dh,2,0,"mat-icon",10),c()}if(i&2){let t=e.$implicit,n=e.$index,r=g(2);G("highlighted",n===r.highlightedIndex),E("disabled",t.disabled)("id","choice-option-"+n),Me("aria-selected",n===r.highlightedIndex),p(2),$(t.label),p(),S(n===r.highlightedIndex?3:-1)}}function Nh(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),re("ngModelChange",function(r){w(t);let o=g(2);return ie(o.freeTextValue,r)||(o.freeTextValue=r),x(r)}),v("keydown",function(r){w(t);let o=g(2);return x(o.onFreeTextKeyDown(r))}),c(),l(6,"button",14),v("click",function(){w(t);let r=g(2);return x(r.onFreeTextSubmit())}),l(7,"mat-icon"),u(8,"send"),c()()()()}if(i&2){let t=g(2);p(4),ne("ngModel",t.freeTextValue),p(2),E("disabled",!t.freeTextValue.trim())}}function Fh(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=g(2);p(4),$(t.searchText)}}function Lh(i,e){if(i&1){let t=O();l(0,"div",2),F(1,"div",3),zi(2,"async"),l(3,"div",4,0),v("keydown",function(r){w(t);let o=g();return x(o.onKeyDown(r))}),we(5,Rh,4,7,"button",5,Ih),c(),C(7,Nh,9,2,"div",6),C(8,Fh,5,1,"div",7),c()}if(i&2){let t=g();p(),E("innerHTML",gl(2,4,t.renderedLabel$),ct),p(2),Me("aria-activedescendant","choice-option-"+t.highlightedIndex),p(2),xe(t.options),p(2),S(t.allowFreeText?7:-1),p(),S(t.searchText?8:-1)}}var ko=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new Z;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new J;renderedLabelSubject=new W("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=f(Vt);markdownService=f(Xt);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 B(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=R({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&$e(Oh,5)(Ah,5),t&2){let r;ge(r=fe())&&(n.buttonContainer=r.first),ge(r=fe())&&(n.freeTextInput=r.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[jt],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,Lh,9,6,"div",2),t&2&&S(n.isVisible?0:-1)},dependencies:[Re,de,_t,ht,gt,ft,_l],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 yi="coday_oauth_callback",Po=class i{route=f(Rr);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(yi,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(yi,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=R({type:i,selectors:[["app-oauth-callback"]],decls:2,vars:1,template:function(t,n){t&1&&(un(0,"p"),u(1),hn()),t&2&&(p(),$(n.message))},encapsulation:2})};var Cn=class i{eventStream=f(qt);messageApi=f(mi);pendingStates=new Map;popupCheckInterval=null;popupClosedAt=null;static POPUP_CLOSE_GRACE_MS=2e3;pendingRequest$=new W(null);messageHandler=e=>this.handlePopupMessage(e);storageHandler=e=>this.handleStorageEvent(e);constructor(){this.eventStream.events$.pipe(Se(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 At({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 At({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!==yi||!e.newValue||(console.log("[OAuth Service] Received localStorage callback fallback"),this.drainLocalStorage())}drainLocalStorage(){let e=localStorage.getItem(yi);if(e){localStorage.removeItem(yi),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 At({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 At({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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function jh(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=w(t),o=g();return x(o.onCancel(r))}),u(13,"Cancel"),c(),l(14,"button",7),v("click",function(){let r=w(t),o=g();return x(o.onAuthorize(r))}),l(15,"mat-icon"),u(16,"open_in_new"),c(),u(17," Authorize "),c()()()}i&2&&(p(9),$(e.integrationName))}var Oo=class i{oauthService=f(Cn);pendingRequest=Ae(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=R({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,jh,18,1,"div",0),t&2){let r;S((r=n.pendingRequest())?0:-1,r)}},dependencies:[Re,de],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 Ao=class i{http=f(it);projectState=f(ve);threadState=f(Ge);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 Cr(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(Oe(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ci=class i{fileApi=f(Ao);eventStream=f(qt);filesSignal=We([]);isLoadingSignal=We(!1);currentProjectSignal=We(null);currentThreadSignal=We(null);files=Tt(()=>this.filesSignal());isLoading=Tt(()=>this.isLoadingSignal());fileCount=Tt(()=>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(Y({},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 B(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 B(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(Se(e=>e instanceof yn),ut()).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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function Vh(i,e){if(i&1&&F(0,"div",1),i&2){let t=g();E("innerHTML",t.renderedContent,ct)}}function zh(i,e){if(i&1&&F(0,"iframe",2),i&2){let t=g();E("srcdoc",t.content,ct)}}function $h(i,e){if(i&1&&(l(0,"pre",3),u(1),c()),i&2){let t=g();p(),$(t.content)}}var Io=class i{content="";format="text";renderedContent="";sanitizer=f(Vt);markdownService=f(Xt);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return B(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=R({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[jt],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,Vh,1,1,"div",1)(2,zh,1,1,"iframe",2)(3,$h,2,1,"pre",3),c()),t&2&&(E("ngClass","format-"+n.format),p(),S(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[nt,Ir],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 Si=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(Oe(a=>{let s=a.body||"",d=new Blob([s]).size;return{content:s,format:o,filename:n,size:d}}),mn(a=>(console.error("[CONTENT_VIEWER] Error loading file:",n,a),Xn(()=>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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};function Bh(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){w(t);let r=g();return x(r.download())}),l(1,"mat-icon"),u(2,"download"),c()()}}function Hh(i,e){i&1&&(l(0,"div",9),F(1,"mat-spinner",13),l(2,"p"),u(3,"Loading file content..."),c()())}function Uh(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(){w(t);let r=g();return x(r.download())}),l(6,"mat-icon"),u(7,"download"),c(),u(8," Download instead "),c()()}if(i&2){let t=g();p(4),$(t.error)}}function Wh(i,e){if(i&1&&F(0,"app-content-renderer",11),i&2){let t=g();E("content",t.fileContent.content)("format",t.fileContent.format)}}var Do=class i{destroy$=new J;file;projectName;threadId;closeViewer=new Z;contentService=f(Si);eventStream=f(qt);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(Se(e=>e instanceof yn),Se(e=>e.filename===this.file.filename),Se(e=>e.operation==="updated"),I(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=R({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,Bh,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,Hh,4,0,"div",9),C(14,Uh,9,1,"div",10),C(15,Wh,1,2,"app-content-renderer",11),c()()),t&2&&(p(4),$(n.file.filename),p(2),$(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,Re,de,rt,jr,qe,_i,fi,Io],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 qh=Math.pow(10,8)*24*60*60*1e3,Rx=-qh,Ro=6048e5,Vd=864e5;var Gh=3600;var zd=Gh*24,Nx=zd*7,Yh=zd*365.2425,Qh=Yh/12,Fx=Qh*3,Ts=Symbol.for("constructDateFrom");function Ne(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Ts in i?i[Ts](e):i instanceof Date?new i.constructor(e):new Date(e)}function ye(i,e){return Ne(e||i,i)}function $d(i,e,t){let n=ye(i,t?.in);return isNaN(e)?Ne(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var Kh={};function Sn(){return Kh}function ln(i,e){let t=Sn(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=ye(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 $n(i,e){return ln(i,he(Y({},e),{weekStartsOn:1}))}function No(i,e){let t=ye(i,e?.in),n=t.getFullYear(),r=Ne(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let o=$n(r),a=Ne(t,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let s=$n(a);return t.getTime()>=o.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function Es(i){let e=ye(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 xi(i,...e){let t=Ne.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function Ti(i,e){let t=ye(i,e?.in);return t.setHours(0,0,0,0),t}function Fo(i,e,t){let[n,r]=xi(t?.in,i,e),o=Ti(n),a=Ti(r),s=+o-Es(o),d=+a-Es(a);return Math.round((s-d)/Vd)}function Bd(i,e){let t=No(i,e),n=Ne(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),$n(n)}function Hd(i){return Ne(i,Date.now())}function Ud(i,e,t){let[n,r]=xi(t?.in,i,e);return+Ti(n)==+Ti(r)}function Wd(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function qd(i){return!(!Wd(i)&&typeof i!="number"||isNaN(+ye(i)))}function Yd(i,e,t){let[n,r]=xi(t?.in,i,e),o=Gd(n,r),a=Math.abs(Fo(n,r));n.setDate(n.getDate()-o*a);let s=+(Gd(n,r)===-o),d=o*(a-s);return d===0?0:d}function Gd(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 Qd(i,e){let t=ye(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var Xh={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"}},Kd=(i,e,t)=>{let n,r=Xh[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 Lo(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var Jh={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Zh={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},eg={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Xd={date:Lo({formats:Jh,defaultWidth:"full"}),time:Lo({formats:Zh,defaultWidth:"full"}),dateTime:Lo({formats:eg,defaultWidth:"full"})};var tg={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Jd=(i,e,t,n)=>tg[i];function Ei(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 ng={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ig={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},rg={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"]},og={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"]},ag={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"}},sg={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"}},lg=(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"},Zd={ordinalNumber:lg,era:Ei({values:ng,defaultWidth:"wide"}),quarter:Ei({values:ig,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Ei({values:rg,defaultWidth:"wide"}),day:Ei({values:og,defaultWidth:"wide"}),dayPeriod:Ei({values:ag,defaultWidth:"wide",formattingValues:sg,defaultFormattingWidth:"wide"})};function Mi(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)?dg(s,b=>b.test(a)):cg(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 cg(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function dg(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function ep(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 pg=/^(\d+)(th|st|nd|rd)?/i,mg=/\d+/i,ug={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},hg={any:[/^b/i,/^(a|c)/i]},gg={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},fg={any:[/1/i,/2/i,/3/i,/4/i]},_g={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},bg={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]},vg={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},yg={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]},Cg={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},Sg={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}},tp={ordinalNumber:ep({matchPattern:pg,parsePattern:mg,valueCallback:i=>parseInt(i,10)}),era:Mi({matchPatterns:ug,defaultMatchWidth:"wide",parsePatterns:hg,defaultParseWidth:"any"}),quarter:Mi({matchPatterns:gg,defaultMatchWidth:"wide",parsePatterns:fg,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Mi({matchPatterns:_g,defaultMatchWidth:"wide",parsePatterns:bg,defaultParseWidth:"any"}),day:Mi({matchPatterns:vg,defaultMatchWidth:"wide",parsePatterns:yg,defaultParseWidth:"any"}),dayPeriod:Mi({matchPatterns:Cg,defaultMatchWidth:"any",parsePatterns:Sg,defaultParseWidth:"any"})};var Ms={code:"en-US",formatDistance:Kd,formatLong:Xd,formatRelative:Jd,localize:Zd,match:tp,options:{weekStartsOn:0,firstWeekContainsDate:1}};function np(i,e){let t=ye(i,e?.in);return Fo(t,Qd(t))+1}function ip(i,e){let t=ye(i,e?.in),n=+$n(t)-+Bd(t);return Math.round(n/Ro)+1}function jo(i,e){let t=ye(i,e?.in),n=t.getFullYear(),r=Sn(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=Ne(e?.in||i,0);a.setFullYear(n+1,0,o),a.setHours(0,0,0,0);let s=ln(a,e),d=Ne(e?.in||i,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);let m=ln(d,e);return+t>=+s?n+1:+t>=+m?n:n-1}function rp(i,e){let t=Sn(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=jo(i,e),o=Ne(e?.in||i,0);return o.setFullYear(r,0,n),o.setHours(0,0,0,0),ln(o,e)}function op(i,e){let t=ye(i,e?.in),n=+ln(t,e)-+rp(t,e);return Math.round(n/Ro)+1}function ae(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var cn={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return ae(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):ae(t+1,2)},d(i,e){return ae(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 ae(i.getHours()%12||12,e.length)},H(i,e){return ae(i.getHours(),e.length)},m(i,e){return ae(i.getMinutes(),e.length)},s(i,e){return ae(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),r=Math.trunc(n*Math.pow(10,t-3));return ae(r,e.length)}};var ki={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ks={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 cn.y(i,e)},Y:function(i,e,t,n){let r=jo(i,n),o=r>0?r:1-r;if(e==="YY"){let a=o%100;return ae(a,2)}return e==="Yo"?t.ordinalNumber(o,{unit:"year"}):ae(o,e.length)},R:function(i,e){let t=No(i);return ae(t,e.length)},u:function(i,e){let t=i.getFullYear();return ae(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 ae(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 ae(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 cn.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 ae(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=op(i,n);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):ae(r,e.length)},I:function(i,e,t){let n=ip(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):ae(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):cn.d(i,e)},D:function(i,e,t){let n=np(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):ae(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 ae(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 ae(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 ae(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=ki.noon:n===0?r=ki.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=ki.evening:n>=12?r=ki.afternoon:n>=4?r=ki.morning:r=ki.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 cn.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):cn.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):ae(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):ae(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):cn.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):cn.s(i,e)},S:function(i,e){return cn.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return sp(n);case"XXXX":case"XX":return Bn(n);default:return Bn(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return sp(n);case"xxxx":case"xx":return Bn(n);default:return Bn(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+ap(n,":");default:return"GMT"+Bn(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+ap(n,":");default:return"GMT"+Bn(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return ae(n,e.length)},T:function(i,e,t){return ae(+i,e.length)}};function ap(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+ae(o,2)}function sp(i,e){return i%60===0?(i>0?"-":"+")+ae(Math.abs(i)/60,2):Bn(i,e)}function Bn(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),r=ae(Math.trunc(n/60),2),o=ae(n%60,2);return t+r+e+o}var lp=(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"})}},cp=(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"})}},wg=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],r=t[2];if(!r)return lp(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}}",lp(n,e)).replace("{{time}}",cp(r,e))},dp={p:cp,P:wg};var xg=/^D+$/,Tg=/^Y+$/,Eg=["D","DD","YY","YYYY"];function pp(i){return xg.test(i)}function mp(i){return Tg.test(i)}function up(i,e,t){let n=Mg(i,e,t);if(console.warn(n),Eg.includes(i))throw new RangeError(n)}function Mg(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 kg=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Pg=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Og=/^'([^]*?)'?$/,Ag=/''/g,Ig=/[a-zA-Z]/;function Ps(i,e,t){let n=Sn(),r=t?.locale??n.locale??Ms,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=ye(i,t?.in);if(!qd(s))throw new RangeError("Invalid time value");let d=e.match(Pg).map(_=>{let b=_[0];if(b==="p"||b==="P"){let y=dp[b];return y(_,r.formatLong)}return _}).join("").match(kg).map(_=>{if(_==="''")return{isToken:!1,value:"'"};let b=_[0];if(b==="'")return{isToken:!1,value:Dg(_)};if(ks[b])return{isToken:!0,value:_};if(b.match(Ig))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&&mp(b)||!t?.useAdditionalDayOfYearTokens&&pp(b))&&up(b,e,String(i));let y=ks[b[0]];return y(s,b,r.localize,m)}).join("")}function Dg(i){let e=i.match(Og);return e?e[1].replace(Ag,"'"):i}function hp(i,e,t){return $d(i,-e,t)}function gp(i,e){return Ud(Ne(e?.in||i,i),hp(Hd(e?.in||i),1))}function fp(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=Ps(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(gp(i))return`yesterday ${t}`;let a=Yd(e,i);return a<7?`${a}d ago ${t}`:`${Ps(i,"dd/MM/yyyy")} ${t}`}var Rg=(i,e)=>e.filename;function Ng(i,e){if(i&1){let t=O();l(0,"button",11),v("click",function(){w(t);let r=g(2);return x(r.downloadAll())}),l(1,"mat-icon"),u(2,"download_for_offline"),c()()}}function Fg(i,e){i&1&&(l(0,"div",10),F(1,"span",12),l(2,"span",13),u(3,"Loading files..."),c()())}function Lg(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 jg(i,e){if(i&1){let t=O();l(0,"button",28),v("click",function(){w(t);let r=g().$implicit,o=g(4);return x(o.viewFile(r))}),l(1,"mat-icon"),u(2,"visibility"),c()()}}function Vg(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,jg,3,0,"button",25),l(11,"button",26),v("click",function(){let r=w(t).$implicit,o=g(4);return x(o.download(r))}),l(12,"mat-icon"),u(13,"download"),c()(),l(14,"button",27),v("click",function(){let r=w(t).$implicit,o=g(4);return x(o.delete(r))}),l(15,"mat-icon"),u(16,"delete"),c()()()()}if(i&2){let t=e.$implicit,n=g(4);p(3),$(n.getFileIcon(t.filename)),p(2),E("title",t.filename),p(),$(t.filename),p(2),ni("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),p(2),S(n.canViewFile(t)?10:-1)}}function zg(i,e){if(i&1&&we(0,Vg,17,6,"div",18,Rg),i&2){let t=g(3);xe(t.files())}}function $g(i,e){if(i&1&&C(0,Lg,7,0,"div",14)(1,zg,2,0),i&2){let t=g(2);S(t.files().length===0?0:1)}}function Bg(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,Ng,3,0,"button",7),l(9,"button",8),v("click",function(){w(t);let r=g();return x(r.close())}),l(10,"mat-icon"),u(11,"chevron_right"),c()()()(),l(12,"div",9),C(13,Fg,4,0,"div",10)(14,$g,2,1),c()()}if(i&2){let t=g();p(6),Ve("(",t.files().length,")"),p(2),S(t.files().length>0?8:-1),p(5),S(t.isLoading()?13:14)}}function Hg(i,e){if(i&1){let t=O();l(0,"app-content-viewer",29),v("closeViewer",function(){w(t);let r=g();return x(r.backToList())}),c()}if(i&2){let t=g();E("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var Vo=class i{projectName;threadId;closeDrawer=new Z;fileExchangeState=f(Ci);contentViewerService=f(Si);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 B(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 fp(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({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,Bg,15,3,"div",0),C(1,Hg,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,Re,de,rt,qe,Do],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 zo=class i{http=f(it);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var $o=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new Z;userApi=f(zo);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(Oe(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=R({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&&E("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[ec],styles:["[_nghost-%COMP%]{display:block}"]})};var Ug=(i,e)=>e.userId;function Wg(i,e){if(i&1&&(l(0,"div",7),u(1),c()),i&2){let t=g();p(),$(t.errorMessage())}}function qg(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.removeUser(r.userId))}),l(1,"mat-icon"),u(2,"close"),c()()}}function Gg(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,qg,3,0,"button",12),c()),i&2){let t=e.$implicit,n=g();p(4),$(t.userId),p(),S(n.users.length>1?5:-1)}}var ar=class i{threadId;users=[];currentUsername;userAdded=new Z;userRemoved=new Z;closed=new Z;isAdding=We(!1);errorMessage=We("");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=R({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,Wg,2,1,"div",7),l(16,"div",8),we(17,Gg,6,2,"div",9,Ug),c()()),t&2&&(p(14),E("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),p(),S(n.errorMessage()?15:-1),p(2),xe(n.users))},dependencies:[Re,de,rt,qe,$r,$o],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 Ho=["*"],Qg=["content"],Kg=[[["mat-drawer"]],[["mat-drawer-content"]],"*"],Xg=["mat-drawer","mat-drawer-content","*"];function Jg(i,e){if(i&1){let t=O();l(0,"div",1),v("click",function(){w(t);let r=g();return x(r._onBackdropClicked())}),c()}if(i&2){let t=g();G("mat-drawer-shown",t._isShowingBackdrop())}}function Zg(i,e){i&1&&(l(0,"mat-drawer-content"),dt(1,2),c())}var ef=[[["mat-sidenav"]],[["mat-sidenav-content"]],"*"],tf=["mat-sidenav","mat-sidenav-content","*"];function nf(i,e){if(i&1){let t=O();l(0,"div",1),v("click",function(){w(t);let r=g();return x(r._onBackdropClicked())}),c()}if(i&2){let t=g();G("mat-drawer-shown",t._isShowingBackdrop())}}function rf(i,e){i&1&&(l(0,"mat-sidenav-content"),dt(1,2),c())}var of=`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
357
+ `;var af=new Fi("MAT_DRAWER_DEFAULT_AUTOSIZE",{providedIn:"root",factory:()=>!1}),Os=new Fi("MAT_DRAWER_CONTAINER"),Pi=(()=>{class i extends ii{_platform=f(Nr);_changeDetectorRef=f(Pr);_container=f(lr);constructor(){let t=f(mt),n=f(Nl),r=f(Lt);super(t,n,r)}ngAfterContentInit(){this._container._contentMarginChanges.subscribe(()=>{this._changeDetectorRef.markForCheck()})}_shouldBeHidden(){if(this._platform.isBrowser)return!1;let{start:t,end:n}=this._container;return t!=null&&t.mode!=="over"&&t.opened||n!=null&&n.mode!=="over"&&n.opened}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer-content"]],hostAttrs:[1,"mat-drawer-content"],hostVars:6,hostBindings:function(n,r){n&2&&(Qe("margin-left",r._container._contentMargins.left,"px")("margin-right",r._container._contentMargins.right,"px"),G("mat-drawer-content-hidden",r._shouldBeHidden()))},features:[gn([{provide:ii,useExisting:i}]),ji],ngContentSelectors:Ho,decls:1,vars:0,template:function(n,r){n&1&&(nn(),dt(0))},encapsulation:2,changeDetection:0})}return i})(),sr=(()=>{class i{_elementRef=f(mt);_focusTrapFactory=f(kl);_focusMonitor=f(xl);_platform=f(Nr);_ngZone=f(Lt);_renderer=f(Tr);_interactivityChecker=f(Fr);_doc=f(ei);_container=f(Os,{optional:!0});_focusTrap=null;_elementFocusedBeforeDrawerWasOpened=null;_eventCleanups;_isAttached=!1;_anchor=null;get position(){return this._position}set position(t){t=t==="end"?"end":"start",t!==this._position&&(this._isAttached&&this._updatePositionInParent(t),this._position=t,this.onPositionChanged.emit())}_position="start";get mode(){return this._mode}set mode(t){this._mode=t,this._updateFocusTrapState(),this._modeChanged.next()}_mode="over";get disableClose(){return this._disableClose}set disableClose(t){this._disableClose=An(t)}_disableClose=!1;get autoFocus(){let t=this._autoFocus;return t??(this.mode==="side"?"dialog":"first-tabbable")}set autoFocus(t){(t==="true"||t==="false"||t==null)&&(t=An(t)),this._autoFocus=t}_autoFocus;get opened(){return this._opened()}set opened(t){this.toggle(An(t))}_opened=We(!1);_openedVia=null;_animationStarted=new J;_animationEnd=new J;openedChange=new Z(!0);_openedStream=this.openedChange.pipe(Se(t=>t),Oe(()=>{}));openedStart=this._animationStarted.pipe(Se(()=>this.opened),ca(void 0));_closedStream=this.openedChange.pipe(Se(t=>!t),Oe(()=>{}));closedStart=this._animationStarted.pipe(Se(()=>!this.opened),ca(void 0));_destroyed=new J;onPositionChanged=new Z;_content;_modeChanged=new J;_injector=f(ha);_changeDetectorRef=f(Pr);constructor(){this.openedChange.pipe(I(this._destroyed)).subscribe(t=>{t?(this._elementFocusedBeforeDrawerWasOpened=this._doc.activeElement,this._takeFocus()):this._isFocusWithinDrawer()&&this._restoreFocus(this._openedVia||"program")}),this._eventCleanups=this._ngZone.runOutsideAngular(()=>{let t=this._renderer,n=this._elementRef.nativeElement;return[t.listen(n,"keydown",r=>{r.keyCode===27&&!this.disableClose&&!Al(r)&&this._ngZone.run(()=>{this.close(),r.stopPropagation(),r.preventDefault()})}),t.listen(n,"transitionrun",this._handleTransitionEvent),t.listen(n,"transitionend",this._handleTransitionEvent),t.listen(n,"transitioncancel",this._handleTransitionEvent)]}),this._animationEnd.subscribe(()=>{this.openedChange.emit(this.opened)})}_forceFocus(t,n){this._interactivityChecker.isFocusable(t)||(t.tabIndex=-1,this._ngZone.runOutsideAngular(()=>{let r=()=>{o(),a(),t.removeAttribute("tabindex")},o=this._renderer.listen(t,"blur",r),a=this._renderer.listen(t,"mousedown",r)})),t.focus(n)}_focusByCssSelector(t,n){let r=this._elementRef.nativeElement.querySelector(t);r&&this._forceFocus(r,n)}_takeFocus(){if(!this._focusTrap)return;let t=this._elementRef.nativeElement;switch(this.autoFocus){case!1:case"dialog":return;case!0:case"first-tabbable":fa(()=>{!this._focusTrap.focusInitialElement()&&typeof t.focus=="function"&&t.focus()},{injector:this._injector});break;case"first-heading":this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');break;default:this._focusByCssSelector(this.autoFocus);break}}_restoreFocus(t){this.autoFocus!=="dialog"&&(this._elementFocusedBeforeDrawerWasOpened?this._focusMonitor.focusVia(this._elementFocusedBeforeDrawerWasOpened,t):this._elementRef.nativeElement.blur(),this._elementFocusedBeforeDrawerWasOpened=null)}_isFocusWithinDrawer(){let t=this._doc.activeElement;return!!t&&this._elementRef.nativeElement.contains(t)}ngAfterViewInit(){this._isAttached=!0,this._position==="end"&&this._updatePositionInParent("end"),this._platform.isBrowser&&(this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement),this._updateFocusTrapState())}ngOnDestroy(){this._eventCleanups.forEach(t=>t()),this._focusTrap?.destroy(),this._anchor?.remove(),this._anchor=null,this._animationStarted.complete(),this._animationEnd.complete(),this._modeChanged.complete(),this._destroyed.next(),this._destroyed.complete()}open(t){return this.toggle(!0,t)}close(){return this.toggle(!1)}_closeViaBackdropClick(){return this._setOpen(!1,!0,"mouse")}toggle(t=!this.opened,n){t&&n&&(this._openedVia=n);let r=this._setOpen(t,!t&&this._isFocusWithinDrawer(),this._openedVia||"program");return t||(this._openedVia=null),r}_setOpen(t,n,r){return t===this.opened?Promise.resolve(t?"open":"close"):(this._opened.set(t),this._container?._transitionsEnabled?this._setIsAnimating(!0):setTimeout(()=>{this._animationStarted.next(),this._animationEnd.next()}),this._elementRef.nativeElement.classList.toggle("mat-drawer-opened",t),!t&&n&&this._restoreFocus(r),this._changeDetectorRef.markForCheck(),this._updateFocusTrapState(),new Promise(o=>{this.openedChange.pipe(Jn(1)).subscribe(a=>o(a?"open":"close"))}))}_setIsAnimating(t){this._elementRef.nativeElement.classList.toggle("mat-drawer-animating",t)}_getWidth(){return this._elementRef.nativeElement.offsetWidth||0}_updateFocusTrapState(){this._focusTrap&&(this._focusTrap.enabled=this.opened&&!!this._container?._isShowingBackdrop())}_updatePositionInParent(t){if(!this._platform.isBrowser)return;let n=this._elementRef.nativeElement,r=n.parentNode;t==="end"?(this._anchor||(this._anchor=this._doc.createComment("mat-drawer-anchor"),r.insertBefore(this._anchor,n)),r.appendChild(n)):this._anchor&&this._anchor.parentNode.insertBefore(n,this._anchor)}_handleTransitionEvent=t=>{let n=this._elementRef.nativeElement;t.target===n&&this._ngZone.run(()=>{t.type==="transitionrun"?this._animationStarted.next(t):(t.type==="transitionend"&&this._setIsAnimating(!1),this._animationEnd.next(t))})};static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer"]],viewQuery:function(n,r){if(n&1&&$e(Qg,5),n&2){let o;ge(o=fe())&&(r._content=o.first)}},hostAttrs:[1,"mat-drawer"],hostVars:12,hostBindings:function(n,r){n&2&&(Me("align",null)("tabIndex",r.mode!=="side"?"-1":null),Qe("visibility",!r._container&&!r.opened?"hidden":null),G("mat-drawer-end",r.position==="end")("mat-drawer-over",r.mode==="over")("mat-drawer-push",r.mode==="push")("mat-drawer-side",r.mode==="side"))},inputs:{position:"position",mode:"mode",disableClose:"disableClose",autoFocus:"autoFocus",opened:"opened"},outputs:{openedChange:"openedChange",_openedStream:"opened",openedStart:"openedStart",_closedStream:"closed",closedStart:"closedStart",onPositionChanged:"positionChanged"},exportAs:["matDrawer"],ngContentSelectors:Ho,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(n,r){n&1&&(nn(),l(0,"div",1,0),dt(2),c())},dependencies:[ii],encapsulation:2,changeDetection:0})}return i})(),lr=(()=>{class i{_dir=f(Rl,{optional:!0});_element=f(mt);_ngZone=f(Lt);_changeDetectorRef=f(Pr);_animationDisabled=Lr();_transitionsEnabled=!1;_allDrawers;_drawers=new al;_content;_userContent;get start(){return this._start}get end(){return this._end}get autosize(){return this._autosize}set autosize(t){this._autosize=An(t)}_autosize=f(af);get hasBackdrop(){return this._drawerHasBackdrop(this._start)||this._drawerHasBackdrop(this._end)}set hasBackdrop(t){this._backdropOverride=t==null?null:An(t)}_backdropOverride=null;backdropClick=new Z;_start=null;_end=null;_left=null;_right=null;_destroyed=new J;_doCheckSubject=new J;_contentMargins={left:null,right:null};_contentMarginChanges=new J;get scrollable(){return this._userContent||this._content}_injector=f(ha);constructor(){let t=f(Nr),n=f(Fl);this._dir?.change.pipe(I(this._destroyed)).subscribe(()=>{this._validateDrawers(),this.updateContentMargins()}),n.change().pipe(I(this._destroyed)).subscribe(()=>this.updateContentMargins()),!this._animationDisabled&&t.isBrowser&&this._ngZone.runOutsideAngular(()=>{setTimeout(()=>{this._element.nativeElement.classList.add("mat-drawer-transition"),this._transitionsEnabled=!0},200)})}ngAfterContentInit(){this._allDrawers.changes.pipe(Zn(this._allDrawers),I(this._destroyed)).subscribe(t=>{this._drawers.reset(t.filter(n=>!n._container||n._container===this)),this._drawers.notifyOnChanges()}),this._drawers.changes.pipe(Zn(null)).subscribe(()=>{this._validateDrawers(),this._drawers.forEach(t=>{this._watchDrawerToggle(t),this._watchDrawerPosition(t),this._watchDrawerMode(t)}),(!this._drawers.length||this._isDrawerOpen(this._start)||this._isDrawerOpen(this._end))&&this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),this._ngZone.runOutsideAngular(()=>{this._doCheckSubject.pipe(el(10),I(this._destroyed)).subscribe(()=>this.updateContentMargins())})}ngOnDestroy(){this._contentMarginChanges.complete(),this._doCheckSubject.complete(),this._drawers.destroy(),this._destroyed.next(),this._destroyed.complete()}open(){this._drawers.forEach(t=>t.open())}close(){this._drawers.forEach(t=>t.close())}updateContentMargins(){let t=0,n=0;if(this._left&&this._left.opened){if(this._left.mode=="side")t+=this._left._getWidth();else if(this._left.mode=="push"){let r=this._left._getWidth();t+=r,n-=r}}if(this._right&&this._right.opened){if(this._right.mode=="side")n+=this._right._getWidth();else if(this._right.mode=="push"){let r=this._right._getWidth();n+=r,t-=r}}t=t||null,n=n||null,(t!==this._contentMargins.left||n!==this._contentMargins.right)&&(this._contentMargins={left:t,right:n},this._ngZone.run(()=>this._contentMarginChanges.next(this._contentMargins)))}ngDoCheck(){this._autosize&&this._isPushed()&&this._ngZone.runOutsideAngular(()=>this._doCheckSubject.next())}_watchDrawerToggle(t){t._animationStarted.pipe(I(this._drawers.changes)).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),t.mode!=="side"&&t.openedChange.pipe(I(this._drawers.changes)).subscribe(()=>this._setContainerClass(t.opened))}_watchDrawerPosition(t){t.onPositionChanged.pipe(I(this._drawers.changes)).subscribe(()=>{fa({read:()=>this._validateDrawers()},{injector:this._injector})})}_watchDrawerMode(t){t._modeChanged.pipe(I(Zs(this._drawers.changes,this._destroyed))).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()})}_setContainerClass(t){let n=this._element.nativeElement.classList,r="mat-drawer-container-has-open";t?n.add(r):n.remove(r)}_validateDrawers(){this._start=this._end=null,this._drawers.forEach(t=>{t.position=="end"?(this._end!=null,this._end=t):(this._start!=null,this._start=t)}),this._right=this._left=null,this._dir&&this._dir.value==="rtl"?(this._left=this._end,this._right=this._start):(this._left=this._start,this._right=this._end)}_isPushed(){return this._isDrawerOpen(this._start)&&this._start.mode!="over"||this._isDrawerOpen(this._end)&&this._end.mode!="over"}_onBackdropClicked(){this.backdropClick.emit(),this._closeModalDrawersViaBackdrop()}_closeModalDrawersViaBackdrop(){[this._start,this._end].filter(t=>t&&!t.disableClose&&this._drawerHasBackdrop(t)).forEach(t=>t._closeViaBackdropClick())}_isShowingBackdrop(){return this._isDrawerOpen(this._start)&&this._drawerHasBackdrop(this._start)||this._isDrawerOpen(this._end)&&this._drawerHasBackdrop(this._end)}_isDrawerOpen(t){return t!=null&&t.opened}_drawerHasBackdrop(t){return this._backdropOverride==null?!!t&&t.mode!=="side":this._backdropOverride}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({type:i,selectors:[["mat-drawer-container"]],contentQueries:function(n,r,o){if(n&1&&va(o,Pi,5)(o,sr,5),n&2){let a;ge(a=fe())&&(r._content=a.first),ge(a=fe())&&(r._allDrawers=a)}},viewQuery:function(n,r){if(n&1&&$e(Pi,5),n&2){let o;ge(o=fe())&&(r._userContent=o.first)}},hostAttrs:[1,"mat-drawer-container"],hostVars:2,hostBindings:function(n,r){n&2&&G("mat-drawer-container-explicit-backdrop",r._backdropOverride)},inputs:{autosize:"autosize",hasBackdrop:"hasBackdrop"},outputs:{backdropClick:"backdropClick"},exportAs:["matDrawerContainer"],features:[gn([{provide:Os,useExisting:i}])],ngContentSelectors:Xg,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(n,r){n&1&&(nn(Kg),C(0,Jg,1,2,"div",0),dt(1),dt(2,1),C(3,Zg,2,0,"mat-drawer-content")),n&2&&(S(r.hasBackdrop?0:-1),p(3),S(r._content?-1:3))},dependencies:[Pi],styles:[`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
358
+ `],encapsulation:2,changeDetection:0})}return i})(),Bo=(()=>{class i extends Pi{static \u0275fac=(()=>{let t;return function(r){return(t||(t=xr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav-content"]],hostAttrs:[1,"mat-drawer-content","mat-sidenav-content"],features:[gn([{provide:ii,useExisting:i}]),ji],ngContentSelectors:Ho,decls:1,vars:0,template:function(n,r){n&1&&(nn(),dt(0))},encapsulation:2,changeDetection:0})}return i})(),As=(()=>{class i extends sr{get fixedInViewport(){return this._fixedInViewport}set fixedInViewport(t){this._fixedInViewport=An(t)}_fixedInViewport=!1;get fixedTopGap(){return this._fixedTopGap}set fixedTopGap(t){this._fixedTopGap=wa(t)}_fixedTopGap=0;get fixedBottomGap(){return this._fixedBottomGap}set fixedBottomGap(t){this._fixedBottomGap=wa(t)}_fixedBottomGap=0;static \u0275fac=(()=>{let t;return function(r){return(t||(t=xr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav"]],hostAttrs:[1,"mat-drawer","mat-sidenav"],hostVars:16,hostBindings:function(n,r){n&2&&(Me("tabIndex",r.mode!=="side"?"-1":null)("align",null),Qe("top",r.fixedInViewport?r.fixedTopGap:null,"px")("bottom",r.fixedInViewport?r.fixedBottomGap:null,"px"),G("mat-drawer-end",r.position==="end")("mat-drawer-over",r.mode==="over")("mat-drawer-push",r.mode==="push")("mat-drawer-side",r.mode==="side")("mat-sidenav-fixed",r.fixedInViewport))},inputs:{fixedInViewport:"fixedInViewport",fixedTopGap:"fixedTopGap",fixedBottomGap:"fixedBottomGap"},exportAs:["matSidenav"],features:[gn([{provide:sr,useExisting:i}]),ji],ngContentSelectors:Ho,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(n,r){n&1&&(nn(),l(0,"div",1,0),dt(2),c())},dependencies:[ii],encapsulation:2,changeDetection:0})}return i})(),_p=(()=>{class i extends lr{_allDrawers=void 0;_content=void 0;static \u0275fac=(()=>{let t;return function(r){return(t||(t=xr(i)))(r||i)}})();static \u0275cmp=R({type:i,selectors:[["mat-sidenav-container"]],contentQueries:function(n,r,o){if(n&1&&va(o,Bo,5)(o,As,5),n&2){let a;ge(a=fe())&&(r._content=a.first),ge(a=fe())&&(r._allDrawers=a)}},hostAttrs:[1,"mat-drawer-container","mat-sidenav-container"],hostVars:2,hostBindings:function(n,r){n&2&&G("mat-drawer-container-explicit-backdrop",r._backdropOverride)},exportAs:["matSidenavContainer"],features:[gn([{provide:Os,useExisting:i},{provide:lr,useExisting:i}]),ji],ngContentSelectors:tf,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(n,r){n&1&&(nn(ef),C(0,nf,1,2,"div",0),dt(1),dt(2,1),C(3,rf,2,0,"mat-sidenav-content")),n&2&&(S(r.hasBackdrop?0:-1),p(3),S(r._content?-1:3))},dependencies:[Bo],styles:[of],encapsulation:2,changeDetection:0})}return i})(),Uo=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[xa,$t,xa]})}return i})();var vp="mat-badge-content",sf=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=R({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)}
359
+ `],encapsulation:2,changeDetection:0})}return i})(),yp=(()=>{class i{_ngZone=f(Lt);_elementRef=f(mt);_ariaDescriber=f(Il);_renderer=f(Tr);_animationsDisabled=Lr();_idGenerator=f(Ol);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(Fr);_document=f(ei);constructor(){let t=f(Tl);t.load(sf),t.load(El)}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(vp),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 > .${vp}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=dl({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,r){n&2&&G("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",Or],disabled:[2,"matBadgeDisabled","disabled",Or],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",Or]}})}return i})(),Cp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[Pl,$t]})}return i})();var Oi=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=f(bi);project=f(ve);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){kn([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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Wo=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 B(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),Mn({success:!1,error:r instanceof Error?r.message:"Validation failed"})}return new Cr(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(Oe(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),mn(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let s=a.error?.error||a.message||"Upload failed";return Mn({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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ai=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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var cf=["inputSection"],df=()=>[];function pf(i,e){if(i&1){let t=O();l(0,"button",20),v("click",function(){w(t);let r=g();return x(r.toggleFileDrawer())}),l(1,"mat-icon"),u(2,"folder_open"),c()()}if(i&2){let t=g();G("has-files",t.fileCount>0),E("title",ml("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function mf(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){w(t);let r=g();return x(r.toggleSharePanel())}),l(1,"mat-icon"),u(2,"group"),c()()}if(i&2){let t=g();G("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function uf(i,e){if(i&1&&(l(0,"div",6),u(1),c()),i&2){let t=g();p(),ni(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function hf(i,e){if(i&1&&(l(0,"div",22),u(1),c()),i&2){let t=g();G("error",t.uploadStatus.isError),p(),Ve(" ",t.uploadStatus.message," ")}}function gf(i,e){if(i&1){let t=O();l(0,"app-chat-textarea",23),v("messageSubmitted",function(r){w(t);let o=g();return x(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){w(t);let o=g();return x(o.onVoiceToggled(r))})("heightChanged",function(r){w(t);let o=g();return x(o.onInputHeightChanged(r))})("stopRequested",function(){w(t);let r=g();return x(r.onStopRequested())})("filesPasted",function(r){w(t);let o=g();return x(o.onFilesPasted(r))}),c()}if(i&2){let t=g();E("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function ff(i,e){if(i&1){let t=O();l(0,"app-choice-select",24),v("choiceSelected",function(r){w(t);let o=g();return x(o.onChoiceSelected(r))}),c()}if(i&2){let t=g();E("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function _f(i,e){i&1&&F(0,"app-oauth-request-panel")}function bf(i,e){if(i&1){let t=O();l(0,"app-file-exchange-drawer",25),v("closeDrawer",function(){w(t);let r=g();return x(r.closeDrawer())}),c()}if(i&2){let t=g();E("projectName",t.projectName)("threadId",t.threadId)}}function vf(i,e){if(i&1){let t=O();l(0,"app-thread-share",26),v("userAdded",function(r){w(t);let o=g();return x(o.onUserAdded(r))})("userRemoved",function(r){w(t);let o=g();return x(o.onUserRemoved(r))})("closed",function(){w(t);let r=g();return x(r.closeDrawer())}),c()}if(i&2){let t=g();E("threadId",t.threadId)("users",t.threadDetails.users||ul(3,df))("currentUsername",t.currentUsername)}}function yf(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 qo=class i{projectName;threadId;chatFocused=new Z;drawerStateChange=new Z;destroy$=new J;connectionDestroy$=new J;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(lt);oauthService=f(Cn);pendingOAuthRequest=Ae(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=f(ke);titleService=f(Oi);elementRef=f(mt);threadState=f(Ge);userService=f(Yt);router=f(zt);imageUploadService=f(Wo);fileExchangeState=f(Ci);firstMessageState=f(Ai);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(I(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(I(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(I(this.connectionDestroy$)).subscribe(t=>{console.log("[THREAD] Messages updated:",t.length),this.messages=t}),this.codayService.streamingText$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.streamingText=t}),this.codayService.isThinking$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.isThinking=t}),this.codayService.currentChoice$.pipe(I(this.connectionDestroy$)).subscribe(t=>{this.currentChoice=t}),this.codayService.connectionStatus$.pipe(I(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(I(this.connectionDestroy$)).subscribe(t=>{t&&(console.log("[THREAD] Thread update event received:",t),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(I(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(I(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(I(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 B(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=R({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&$e(cf,5)(ar,5),t&2){let r;ge(r=fe())&&(n.inputSection=r.first),ge(r=fe())&&(n.threadShareRef=r.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[jt],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,pf,3,5,"button",4),C(5,mf,3,2,"button",5),C(6,uf,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,hf,2,3,"div",10),c()(),l(11,"div",11,0)(13,"div",12)(14,"div",13),C(15,gf,1,5,"app-chat-textarea",14),C(16,ff,1,4,"app-choice-select",15),C(17,_f,1,0,"app-oauth-request-panel"),c()()()()(),l(18,"mat-drawer",16),v("closed",function(){return n.closeDrawer()}),C(19,bf,1,2,"app-file-exchange-drawer",17),C(20,vf,1,4,"app-thread-share",18),c()(),C(21,yf,8,0,"div",19),c()),t&2&&(p(),E("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),E("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(),E("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:[Mo,ui,ko,Oo,Vo,ar,Uo,sr,lr,Pi,Re,de,rt,Vr,Cp,yp],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 Go=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=R({type:i,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,n){t&1&&(un(0,"h1",0),u(1),hn()),t&2&&(p(),$(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 Sp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var wp=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=xt({type:i});static \u0275inj=wt({imports:[$t]})}return i})();var Ii=class i{currentThemeSubject=new W("light");currentTheme$=this.currentThemeSubject.asObservable();preferences=f(ke);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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var Cf=(i,e)=>e.code,Sf=(i,e)=>e.name+e.lang;function wf(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 xf(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;E("value",t.code),p(),ni("",t.flag," ",t.label)}}function Tf(i,e){i&1&&(l(0,"option",25),u(1,"Loading voices..."),c())}function Ef(i,e){i&1&&(l(0,"option",25),u(1,"No voice available"),c())}function Mf(i,e){if(i&1&&(l(0,"option",18),u(1),c()),i&2){let t=e.$implicit;E("value",t.name+"|"+t.lang),p(),Ve(" ",t.displayName," ")}}var cr=class i{destroy$=new J;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(ke);voiceSynthesisService=f(vi);themeService=f(Ii);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(I(this.destroy$)).subscribe(e=>{this.selectedTheme=e}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(e=>{this.selectedVoiceLanguage=e}),this.preferencesService.enterToSend$.pipe(I(this.destroy$)).subscribe(e=>{this.useEnterToSend=e}),this.preferencesService.printTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.printTechnicalMessages=e}),this.preferencesService.hideTechnicalMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.showTechnicalMessages=!e}),this.preferencesService.hideWarningMessages$.pipe(I(this.destroy$)).subscribe(e=>{this.showWarningMessages=!e}),this.preferencesService.voiceAnnounceEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceAnnounceEnabled=e}),this.preferencesService.voiceMode$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceMode=e}),this.preferencesService.voiceReadFullText$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceReadFullText=e}),this.preferencesService.voiceVolume$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceVolume=Math.round(e*100)}),this.preferencesService.voiceRate$.pipe(I(this.destroy$)).subscribe(e=>{this.voiceRate=Math.round(e*100)}),this.preferencesService.selectedVoice$.pipe(I(this.destroy$)).subscribe(e=>{this.selectedVoiceId=e}),this.preferencesService.voiceLanguage$.pipe(I(this.destroy$)).subscribe(()=>{this.loadAvailableVoices()}),this.preferencesService.agentNotificationEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.agentNotificationEnabled=e}),this.preferencesService.notificationSoundEnabled$.pipe(I(this.destroy$)).subscribe(e=>{this.notificationSoundEnabled=e}),this.preferencesService.browserNotificationEnabled$.pipe(I(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 B(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=R({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),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(11,"span",7),u(12," Light "),c(),l(13,"label",5)(14,"input",8),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(15,"span",7),u(16," Dark "),c(),l(17,"label",5)(18,"input",9),re("ngModelChange",function(o){return ie(n.selectedTheme,o)||(n.selectedTheme=o),o}),v("change",function(){return n.onThemeChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),F(33,"span",7),u(34," Enter to send "),c(),l(35,"label",5)(36,"input",11),re("ngModelChange",function(o){return ie(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),v("change",function(){return n.onEnterToSendChange()}),c(),F(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(n.browserNotificationEnabled,o)||(n.browserNotificationEnabled=o),o}),v("change",function(){return n.onBrowserNotificationEnabledChange()}),c()(),C(75,wf,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),re("ngModelChange",function(o){return ie(n.selectedVoiceLanguage,o)||(n.selectedVoiceLanguage=o),o}),v("change",function(){return n.onVoiceLanguageChange()}),we(86,xf,2,3,"option",18,Cf),c()(),l(88,"div",3)(89,"span",10),u(90,"Automatic announcement:"),c(),l(91,"div",4)(92,"label",5)(93,"input",19),re("ngModelChange",function(o){return ie(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),F(94,"span",7),u(95," Enabled "),c(),l(96,"label",5)(97,"input",19),re("ngModelChange",function(o){return ie(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),v("change",function(){return n.onVoiceAnnounceEnabledChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),F(106,"span",7),u(107," Voice synthesis "),c(),l(108,"label",5)(109,"input",21),re("ngModelChange",function(o){return ie(n.voiceMode,o)||(n.voiceMode=o),o}),v("change",function(){return n.onVoiceModeChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),F(118,"span",7),u(119," Full message "),c(),l(120,"label",5)(121,"input",22),re("ngModelChange",function(o){return ie(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),v("change",function(){return n.onVoiceReadFullTextChange()}),c(),F(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),re("ngModelChange",function(o){return ie(n.selectedVoiceId,o)||(n.selectedVoiceId=o),o}),v("change",function(){return n.onSelectedVoiceChange()}),C(128,Tf,2,0,"option",25),C(129,Ef,2,0,"option",25),we(130,Mf,2,2,"option",18,Sf),c(),F(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),re("ngModelChange",function(o){return ie(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),re("ngModelChange",function(o){return ie(n.voiceRate,o)||(n.voiceRate=o),o}),v("input",function(){return n.onVoiceRateChange()}),c()()()()),t&2&&(p(10),ne("ngModel",n.selectedTheme),p(4),ne("ngModel",n.selectedTheme),p(4),ne("ngModel",n.selectedTheme),p(14),E("value",!0),ne("ngModel",n.useEnterToSend),p(4),E("value",!1),ne("ngModel",n.useEnterToSend),p(7),ne("ngModel",n.showTechnicalMessages),p(5),ne("ngModel",n.showWarningMessages),p(5),ne("ngModel",n.printTechnicalMessages),p(11),ne("ngModel",n.agentNotificationEnabled),p(5),ne("ngModel",n.notificationSoundEnabled),E("disabled",!n.agentNotificationEnabled),p(5),ne("ngModel",n.browserNotificationEnabled),E("disabled",!n.agentNotificationEnabled||n.browserNotificationDenied),p(),S(n.browserNotificationDenied?75:-1),p(10),ne("ngModel",n.selectedVoiceLanguage),p(),xe(n.voiceLanguageOptions),p(7),E("value",!0),ne("ngModel",n.voiceAnnounceEnabled),p(4),E("value",!1),ne("ngModel",n.voiceAnnounceEnabled),p(8),ne("ngModel",n.voiceMode),p(4),ne("ngModel",n.voiceMode),p(8),E("value",!0),ne("ngModel",n.voiceReadFullText),p(4),E("value",!1),ne("ngModel",n.voiceReadFullText),p(6),ne("ngModel",n.selectedVoiceId),E("disabled",n.loadingVoices||n.availableVoices.length===0),p(),S(n.loadingVoices?128:-1),p(),S(!n.loadingVoices&&n.availableVoices.length===0?129:-1),p(),xe(n.availableVoices),p(8),Ve("Volume: ",n.voiceVolume,"%"),p(),ne("ngModel",n.voiceVolume),p(3),Ve("Speed: ",n.voiceRate,"%"),p(),ne("ngModel",n.voiceRate))},dependencies:[_t,Xl,Jl,ht,Ql,Kl,Yl,gt,ft,de,lc],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 kf=(i,e)=>({subThreads:i,depth:e}),Pf=i=>({subThreads:i,depth:1}),xp=(i,e)=>e.id,Of=(i,e)=>e.label;function Af(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){w(t);let o=g().$implicit,a=g(3);return x(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=g().$implicit,n=g(3);p(),$(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function If(i,e){i&1&&On(0)}function Df(i,e){if(i&1&&ti(0,If,1,0,"ng-container",11),i&2){let t=g().$implicit,n=g().depth;g();let r=Vi(1);E("ngTemplateOutlet",r)("ngTemplateOutletContext",hl(2,kf,t.subThreads,n+1))}}function Rf(i,e){if(i&1){let t=O();l(0,"div",5)(1,"a",6),v("click",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())})("keydown.enter",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())})("keydown.space",function(r){let o=w(t).$implicit;return g(3).selectThread(o.id),x(r.preventDefault())}),C(2,Af,2,1,"mat-icon",7),l(3,"span",8),u(4),c(),l(5,"span",9),u(6),c()()(),C(7,Df,1,5,"ng-container")}if(i&2){let t,n=e.$implicit,r=g().depth,o=g(2);Qe("--sub-depth",r),G("current",n.id===((t=o.currentThread())==null?null:t.id)),p(2),S(n.subThreads!=null&&n.subThreads.length?2:-1),p(2),$(n.delegatedAgentName||"Agent"),p(2),$(n.delegatedTask||n.name),p(),S(o.isParentExpanded(n.id)&&(n.subThreads!=null&&n.subThreads.length)?7:-1)}}function Nf(i,e){if(i&1&&we(0,Rf,8,8,null,null,xp),i&2){let t=e.subThreads;xe(t)}}function Ff(i,e){i&1&&(l(0,"div",4),F(1,"span",12),l(2,"span",13),u(3,"Loading threads..."),c()())}function Lf(i,e){if(i&1&&(l(0,"div",25),u(1),c()),i&2){let t=g(6);p(),$(t.renameErrorMessage)}}function jf(i,e){if(i&1){let t=O();l(0,"div",18)(1,"input",24),re("ngModelChange",function(r){w(t);let o=g(5);return ie(o.editingThreadName,r)||(o.editingThreadName=r),x(r)}),v("keydown",function(r){w(t);let o=g(5);return x(o.onEditKeydown(r))})("blur",function(){w(t);let r=g(5);return x(r.onEditBlur())})("click",function(r){return r.stopPropagation()}),c(),C(2,Lf,2,1,"div",25),c()}if(i&2){let t=g(5);p(),ne("ngModel",t.editingThreadName),E("disabled",t.isRenamingThread),p(),S(t.renameErrorMessage?2:-1)}}function Vf(i,e){if(i&1){let t=O();l(0,"mat-icon",10),v("click",function(r){w(t);let o=g(2).$implicit,a=g(4);return x(a.toggleSubThreads(r,o.id))}),u(1),c()}if(i&2){let t=g(2).$implicit,n=g(4);p(),$(n.isParentExpanded(t.id)?"expand_more":"chevron_right")}}function zf(i,e){if(i&1&&(l(0,"span",27),u(1),c()),i&2){let t=g(2).$implicit;p(),$(t.name)}}function $f(i,e){i&1&&(F(0,"mat-spinner",29),l(1,"span",30),u(2,"Generating name..."),c()),i&2&&E("diameter",16)}function Bf(i,e){i&1&&(l(0,"mat-icon",28),u(1,"group"),c())}function Hf(i,e){if(i&1){let t=O();l(0,"a",26),v("click",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())})("keydown.enter",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())})("keydown.space",function(r){w(t);let o=g().$implicit;return g(4).selectThread(o.id),x(r.preventDefault())}),C(1,Vf,2,1,"mat-icon",7),C(2,zf,2,1,"span",27)(3,$f,3,1),C(4,Bf,2,0,"mat-icon",28),c()}if(i&2){let t=g().$implicit,n=g(4);E("matTooltip",t.name?t.name+`
360
360
 
361
- `+(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 Hf(i,e){if(i&1){let t=O();l(0,"button",31),v("click",function(r){w(t);let o=g().$implicit,a=g(4);return x(a.startEditingThreadName(r,o))}),l(1,"mat-icon"),u(2,"edit"),c()()}}function Uf(i,e){i&1&&On(0)}function Wf(i,e){if(i&1&&ti(0,Uf,1,0,"ng-container",11),i&2){let t=g().$implicit;g(3);let n=ji(1);E("ngTemplateOutlet",n)("ngTemplateOutletContext",Tr(2,kf,t.subThreads))}}function qf(i,e){if(i&1){let t=O();l(0,"div",17),C(1,Lf,3,3,"div",18)(2,Bf,5,5,"a",19),l(3,"div",20),C(4,Hf,3,0,"button",21),l(5,"button",22),v("click",function(r){let o=w(t).$implicit,a=g(4);return x(a.toggleStar(r,o))}),l(6,"mat-icon"),u(7),c()(),l(8,"button",23),v("click",function(r){let o=w(t).$implicit,a=g(4);return x(a.deleteThread(r,o))}),l(9,"mat-icon"),u(10,"delete"),c()()()(),C(11,Wf,1,4,"ng-container")}if(i&2){let t,n=e.$implicit,r=g(4);G("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(),G("starred",r.isStarred(n)),E("title",r.isStarred(n)?"Unstar thread":"Star thread"),p(2),B(r.isStarred(n)?"star":"star_outline"),p(4),S(r.isParentExpanded(n.id)&&(n.subThreads!=null&&n.subThreads.length)?11:-1)}}function Gf(i,e){if(i&1&&(l(0,"div",14)(1,"div",16),u(2),c(),we(3,qf,12,9,null,null,wp),c()),i&2){let t=e.$implicit;p(2),B(t.label),p(),xe(t.threads)}}function Yf(i,e){i&1&&(l(0,"div",15),u(1,"No existing threads"),c())}function Qf(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=g(3);p(),Ve('No threads matching "',t.searchQuery(),'"')}}function Kf(i,e){if(i&1&&(we(0,Gf,5,1,"div",14,Pf),C(2,Yf,2,0,"div",15)(3,Qf,2,1,"div",15)),i&2){let t,n=g(2);xe(n.getGroupedThreads()),p(2),S(!((t=n.threads())!=null&&t.length)&&!n.searchQuery()?2:n.searchQuery()&&n.getGroupedThreads().length===0?3:-1)}}function Xf(i,e){if(i&1&&(ti(0,Rf,2,0,"ng-template",null,0,Er),l(2,"div",3),C(3,Nf,4,0,"div",4)(4,Kf,4,1),c()),i&2){let t=g();p(3),S(t.isLoadingThreadList()?3:4)}}function Zf(i,e){i&1&&(l(0,"span",32),u(1,"No project selected"),c())}function Jf(i,e){i&1&&(l(0,"span",32),u(1,"Loading..."),c())}function e0(i,e){if(i&1&&(l(0,"div",2),C(1,Zf,2,0,"span",32)(2,Jf,2,0,"span",32),c()),i&2){let t,n=g();p(),S((t=n.currentProject())!=null&&t.name?2:1)}}var qo=class i{projects=null;searchMode=!1;searchQuery=Mr("");searchModeChange=new J;threadSelected=new J;projectStateService=f(ve);threadStateService=f(Ge);threadApiService=f(Gt);userService=f(Yt);router=f(zt);destroyRef=f(Sr);currentThread=Ae(this.threadStateService.selectedThread$);currentProject=Ae(this.projectStateService.selectedProject$);threads=Ae(this.threadStateService.threadList$);isLoadingThreadList=Ae(this.threadStateService.isLoadingThreadList$);username=Ae(this.userService.username$);isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0;editingThreadId=null;editingThreadName="";isRenamingThread=!1;renameErrorMessage="";expandedParents=new Set;constructor(){Fi(()=>{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(N=>N.id)),n=e.filter(N=>!N.parentThreadId),r=e.filter(N=>!!N.parentThreadId),o=r.filter(N=>!t.has(N.parentThreadId)),a=r.filter(N=>t.has(N.parentThreadId)),s=new Map;for(let N of a){let X=N.parentThreadId;s.has(X)||s.set(X,[]),s.get(X).push(N)}let d=N=>(s.get(N)||[]).sort((U,Ee)=>U.modifiedDate>Ee.modifiedDate?-1:1).map(U=>he(Y({},U),{subThreads:d(U.id)})),m=[...n,...o];if(this.searchQuery()&&this.searchQuery().trim()){let N=this.searchQuery().toLowerCase().trim();m=m.filter(X=>X.name.toLowerCase().includes(N)||X.summary&&X.summary.toLowerCase().includes(N))}if(!m.length)return[];let _=this.username();if(!_)return[];let b=m.map(N=>he(Y({},N),{subThreads:d(N.id)})),y=b.filter(N=>N.starring&&N.starring.includes(_)),k=b.filter(N=>!N.starring||!N.starring.includes(_)),T=new Map,P=new Date;P.setHours(0,0,0,0);for(let N of k){let X=new Date(N.modifiedDate);X.setHours(0,0,0,0);let U=P.getTime()-X.getTime(),Ee=Math.floor(U/(1e3*60*60*24)),ce;Ee===0?ce="Today":Ee===1?ce="Yesterday":Ee<7?ce="This Week":Ee<30?ce="This Month":Ee<90?ce="Last 3 Months":ce="Older",T.has(ce)||T.set(ce,[]),T.get(ce).push(N)}let K=[];if(y.length>0){let N=[...y].sort((X,U)=>X.modifiedDate>U.modifiedDate?-1:1);K.push({label:"Starred",threads:N})}return["Today","Yesterday","This Week","This Month","Last 3 Months","Older"].filter(N=>T.has(N)).forEach(N=>{K.push({label:N,threads:T.get(N)})}),K}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(ut(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=R({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,Xf,5,1)(2,e0,3,1,"div",2),c()),t&2){let r;p(),S((r=n.currentProject())!=null&&r.name?1:2)}},dependencies:[Ir,_t,ht,gt,ec,ft,Re,de,rt,qe,nc,tc,_i,fi,zr,Yl],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 t0=["logsContent"],n0=(i,e)=>e.name;function i0(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.start(r.name))}),l(1,"mat-icon"),u(2,"play_arrow"),c()()}if(i&2){let t=g().$implicit;E("disabled",t.isLoading)}}function r0(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.stop(r.name))}),l(1,"mat-icon"),u(2,"stop"),c()()}if(i&2){let t=g().$implicit;E("disabled",t.isLoading)}}function o0(i,e){if(i&1&&(l(0,"a",8)(1,"mat-icon",14),u(2,"open_in_new"),c()()),i&2){let t=g().$implicit;E("href",t.url,Pn)("title",t.url)}}function a0(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=g(),n=t.$implicit,r=t.$index;Qe("order",r*2),p(),B(n.errorMessage)}}function s0(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){w(t);let r=g(3);return x(r.onManualRefresh())}),l(1,"mat-icon"),u(2,"refresh"),c()()}}function l0(i,e){if(i&1&&(l(0,"div",16)(1,"div",17)(2,"span",18),u(3),c(),C(4,s0,3,0,"button",19),c(),l(5,"pre",20,0),u(7),c()()),i&2){let t=g(),n=t.$implicit,r=t.$index,o=g();Qe("order",r*2+1),p(3),Ve("",n.name," logs"),p(),S(n.status==="running"?4:-1),p(3),B(o.logs()||"(empty)")}}function c0(i,e){if(i&1){let t=O();l(0,"div",2)(1,"span",3),u(2),c(),l(3,"div",4),C(4,i0,3,1,"button",5)(5,r0,3,1,"button",6),l(6,"span",7),u(7),c(),C(8,o0,3,2,"a",8),l(9,"button",9),v("click",function(){let r=w(t).$implicit,o=g();return x(o.toggleLogs(r.name))}),l(10,"mat-icon"),u(11),c()()()(),C(12,a0,2,3,"div",10),C(13,l0,8,5,"div",11)}if(i&2){let t=e.$implicit,n=e.$index,r=g();Qe("order",n*2),p(2),B(t.name),p(2),S(t.status==="stopped"?4:5),p(2),G("running",t.status==="running"),p(),Ve(" ",t.status==="running"?"Running":"Stopped"," "),p(),S(t.url?8:-1),p(),E("title",r.logsOpenFor()===t.name?"Hide logs":"Show logs"),p(2),B(r.logsOpenFor()===t.name?"expand_less":"terminal"),p(),S(t.errorMessage?12:-1),p(),S(r.logsOpenFor()===t.name?13:-1)}}var Go=class i{destroyRef=f(Sr);projectApi=f(Vr);projectName=Mr.required();entryStates=We([]);hasPreview=Tt(()=>this.entryStates().length>0);logsOpenFor=We(null);logs=We("");logsContent;logsPollTimer=null;logsTimeoutTimer=null;static LOGS_POLL_MS=5e3;static LOGS_TIMEOUT_MS=1200*1e3;constructor(){Fi(()=>{let e=this.projectName();e&&this.onProjectChanged(e)},{allowSignalWrites:!0}),Fi(()=>{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(ut(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));Xs(o).pipe(ut(this.destroyRef)).subscribe({next:a=>{this.entryStates.update(s=>s.map((d,m)=>{let _=a[m];return _?he(Y({},d),{status:_.status}):d}))},error:()=>{}})},error:()=>{}})}start(e){this.updateEntry(e,{isLoading:!0,errorMessage:""}),this.projectApi.startPreview(this.projectName(),e).pipe(ut(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(ut(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(ut(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?Y(Y({},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=R({type:i,selectors:[["app-preview-panel"]],viewQuery:function(t,n){if(t&1&&$e(t0,5),t&2){let r;ge(r=fe())&&(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),we(1,c0,14,12,null,null,n0),c()),t&2&&(p(),xe(n.entryStates()))},dependencies:[rt,qe,Re,de],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 d0(i,e){if(i&1&&(l(0,"div",3),u(1),c()),i&2){let t=g();p(),Ve("\u274C ",t.errorMessage)}}var cr=class i{dialogRef=f(jl);data=f(Vl);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=R({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),re("ngModelChange",function(o){return ie(n.jsonContent,o)||(n.jsonContent=o),o}),c(),C(7,d0,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(),Ve(" ",n.title," "),p(5),ne("ngModel",n.jsonContent),p(),S(n.errorMessage?7:-1))},dependencies:[nt,_t,ht,gt,ft,de,qe,Lr,Bl,Hl,Ul],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 p0=["threadSearchInput"],m0=["*"];function u0(i,e){if(i&1){let t=O();l(0,"button",26),v("click",function(){w(t);let r=g();return x(r.toggle())}),l(1,"mat-icon"),u(2,"menu"),c()(),l(3,"button",27),v("click",function(){w(t);let r=g();return x(r.createNewThread())}),l(4,"mat-icon",10),u(5,"play_circle"),c()()}if(i&2){let t=g();p(3),E("disabled",!t.selectedProjectName())}}function h0(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),re("ngModelChange",function(r){w(t);let o=g();return ie(o.threadSearchQuery,r)||(o.threadSearchQuery=r),x(r)}),v("input",function(){w(t);let r=g();return x(r.onThreadSearchInput())}),c(),l(5,"button",30),v("click",function(){w(t);let r=g();return x(r.closeThreadSearch())}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=g();p(3),ne("ngModel",t.threadSearchQuery)}}function g0(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){w(t);let o=g();return x(o.toggleThreadSearch(r))}),l(6,"mat-icon"),u(7,"search"),c()()()}}function f0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function _0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"hub"),c())}function b0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function v0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"tune"),c())}function y0(i,e){i&1&&(l(0,"div",33)(1,"div",37),F(2,"app-options-panel",38),c()())}function C0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(3).openProjectConfig(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"settings_applications"),c(),l(4,"span",23),u(5,"Project Configuration"),c()()()}}function S0(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 w0(i,e){if(i&1&&C(0,C0,6,0,"div",32)(1,S0,6,0,"div",32),i&2){let t=g(2);S(t.selectedProjectName()?0:1)}}function x0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openAgents(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"smart_toy"),c(),l(4,"span",23),u(5,"Agents"),c()()()}}function T0(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 E0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openPrompts(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"description"),c(),l(4,"span",23),u(5,"Prompts"),c()()()}}function M0(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 k0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openSchedulers(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"schedule"),c(),l(4,"span",23),u(5,"Schedulers"),c()()()}}function P0(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 O0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function A0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"rocket_launch"),c())}function I0(i,e){if(i&1&&(l(0,"div",33),F(1,"app-preview-panel",40),c()),i&2){let t=g(3);p(),E("projectName",t.selectedProjectName())}}function D0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).toggleSection("preview"),r.preventDefault(),x(r.stopPropagation())}),C(2,O0,2,0,"mat-icon",21)(3,A0,2,0,"mat-icon",22),l(4,"span",23),u(5,"Preview Server"),c()(),C(6,I0,2,1,"div",33),c()}if(i&2){let t=g(2);G("expanded",t.expandedSections.preview),p(),G("active",t.expandedSections.preview),p(),S(t.expandedSections.preview?2:3),p(4),S(t.expandedSections.preview?6:-1)}}function R0(i,e){if(i&1){let t=O();l(0,"div",24)(1,"div",32)(2,"a",20),v("click",function(r){return w(t),g().toggleSection("config"),x(r.preventDefault())}),C(3,b0,2,0,"mat-icon",21)(4,v0,2,0,"mat-icon",22),l(5,"span",23),u(6,"Preferences"),c()(),C(7,y0,3,0,"div",33),c(),l(8,"div",32)(9,"a",20),v("click",function(r){return w(t),g().openTokenUsage(),r.preventDefault(),x(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 w(t),g().openUserConfig(),r.preventDefault(),x(r.stopPropagation())}),l(16,"mat-icon",22),u(17,"manage_accounts"),c(),l(18,"span",23),u(19,"User Configuration"),c()()(),C(20,w0,2,1),C(21,x0,6,0,"div",32)(22,T0,6,0,"div",32),C(23,E0,6,0,"div",32)(24,M0,6,0,"div",32),C(25,k0,6,0,"div",32)(26,P0,6,0,"div",32),C(27,D0,7,6,"div",34),l(28,"div",32)(29,"a",35),F(30,"img",36),l(31,"span",23),u(32,"Contribute on GitHub"),c()()()()}if(i&2){let t=g();p(),G("expanded",t.expandedSections.config),p(),G("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),Me("src","CODAY-Logo.png",Pn)}}function N0(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(){w(t);let r=g();return x(r.configErrorMessage="")}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=g();p(4),B(t.configErrorMessage)}}var dr=class i{destroy$=new Z;sidenavStateChange=new J;drawerOpen=!1;breakpointObserver=f(El);isDesktop=Ae(this.breakpointObserver.observe("(min-width: 1400px)").pipe(Oe(e=>e.matches)),{initialValue:!1});userOpenPreference=We(!0);isOpen=Tt(()=>this.userOpenPreference());isAdmin=!1;configErrorMessage="";expandedSections={config:!1,preview:!1,settings:!1};isThreadSearchActive=!1;threadSearchQuery="";threadSearchInput;dialog=f($l);configApi=f(ac);projectStateService=f(ve);projectApi=f(Vr);router=f(zt);preferences=f(ke);threadStateService=f(Ge);projects=Ae(this.projectStateService.projectList$);selectedProject=Ae(this.projectStateService.selectedProject$);selectedProjectName=Ae(this.projectStateService.selectedProject$.pipe(Oe(e=>e?.name)));isProjectVolatile=Ae(this.projectStateService.selectedProject$.pipe(Oe(e=>e?.config?.volatile||!1)));forcedProject=Ae(this.projectStateService.forcedProject$);hasPreviewConfig=Ae(this.projectStateService.selectedProject$.pipe(Oe(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(I(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"]),this.close()}openUserConfig(){console.log("[SIDENAV] openUserConfig called"),this.configErrorMessage="",this.configApi.getUserConfig().pipe(I(this.destroy$)).subscribe({next:e=>{console.log("[SIDENAV] User config loaded, opening dialog"),this.dialog.open(cr,{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(I(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(I(this.destroy$)).subscribe({next:t=>{console.log("[SIDENAV] Project config loaded, opening dialog"),this.dialog.open(cr,{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(I(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"]),this.close()}openPrompts(){if(!this.requireProjectSelection("open prompts"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"prompts"]),this.close()}openSchedulers(){if(!this.requireProjectSelection("open schedulers"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"schedulers"]),this.close()}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=R({type:i,selectors:[["app-sidenav"]],viewQuery:function(t,n){if(t&1&&$e(p0,5),t&2){let r;ge(r=fe())&&(n.threadSearchInput=r.first)}},inputs:{drawerOpen:"drawerOpen"},outputs:{sidenavStateChange:"sidenavStateChange"},ngContentSelectors:m0,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&&(nn(),C(0,u0,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,h0,8,1,"div",14)(20,g0,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,f0,2,0,"mat-icon",21)(27,_0,2,0,"mat-icon",22),l(28,"span",23),u(29,"Control Center"),c()(),C(30,R0,33,12,"div",24),c()()(),l(31,"mat-sidenav-content"),dt(32),c()(),C(33,N0,8,1,"div",25)),t&2&&(S(!n.isOpen()&&!n.drawerOpen?0:-1),p(),G("sidenav-open",n.isOpen()),E("hasBackdrop",!1),p(),E("opened",n.isOpen())("disableClose",!0),p(5),G("sidenav-logo",!0)("clickable",!n.forcedProject())("disabled",n.forcedProject()),E("title",n.forcedProject()?"Project selection disabled":"Go to project selection"),Me("src","CODAY-Logo.png",Pn)("role",n.forcedProject()?null:"button")("tabindex",n.forcedProject()?null:"0"),p(3),B(n.selectedProjectName()),p(9),S(n.isThreadSearchActive?19:20),p(3),E("searchMode",n.isThreadSearchActive)("searchQuery",n.threadSearchQuery),p(),G("is-admin",n.isAdmin),p(),G("expanded",n.expandedSections.settings),p(),G("active",n.expandedSections.settings),p(),S(n.expandedSections.settings?26:27),p(4),S(n.expandedSections.settings?30:-1),p(),G("sidenav-closed-offset",!n.isOpen()),p(2),S(n.configErrorMessage?33:-1))},dependencies:[_t,ht,gt,ft,Bo,Os,fp,zo,Re,de,rt,qe,Cp,Sp,lr,qo,Go],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 Yo=class i{destroy$=new Z;isSetup=!1;codayService=f(lt);preferencesService=f(ke);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(I(this.destroy$),da(),Se(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(I(this.destroy$),da(),Se(([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 $(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var F0=["inputSection"];function L0(i,e){if(i&1){let t=O();l(0,"app-thread",4),v("chatFocused",function(){w(t);let r=g();return x(r.onChatFocusedOnMobile())})("drawerStateChange",function(r){w(t);let o=g();return x(o.onDrawerStateChange(r))}),c()}if(i&2){let t=g();E("projectName",t.projectName)("threadId",t.threadId)}}function j0(i,e){if(i&1){let t=O();l(0,"div",5),F(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){w(t);let o=g();return x(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){w(t);let o=g();return x(o.onVoiceToggled(r))})("heightChanged",function(r){w(t);let o=g();return x(o.onInputHeightChanged(r))})("textareaFocused",function(){w(t);let r=g();return x(r.onChatFocusedOnMobile())}),c()()()()}if(i&2){let t=g();p(6),E("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var pr=class i{destroy$=new Z;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=f(lt);titleService=f(Pi);preferencesService=f(ke);route=f(Dr);router=f(zt);threadApiService=f(Gt);agentNotificationService=f(Yo);firstMessageState=f(Oi);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(I(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=R({type:i,selectors:[["app-main"]],viewQuery:function(t,n){if(t&1&&$e(F0,5)(dr,5),t&2){let r;ge(r=fe())&&(n.inputSection=r.first),ge(r=fe())&&(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,L0,1,2,"app-thread",3)(3,j0,7,5),c()()),t&2&&(E("drawerOpen",n.isDrawerOpen),p(2),S(n.threadId?2:3))},dependencies:[ui,Uo,Wo,dr],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:[xa("slideIn",[Br(":enter",[fn({transform:"translateY(100%)",opacity:0}),$r("300ms ease-out",fn({transform:"translateY(0)",opacity:1}))]),Br(":leave",[$r("200ms ease-in",fn({transform:"translateY(100%)",opacity:0}))])])]}})};var Qo=class i{route=f(Dr);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){alert(`OAuth error: ${n}${r?" - "+r:""}. Please close this window.`);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||!t){console.error("[OAuth Callback] Missing code or state");return}if(!window.opener){console.error("[OAuth Callback] No window.opener - popup may have been opened incorrectly"),alert("OAuth callback error: No parent window found. Please close this window and try again.");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=R({type:i,selectors:[["app-oauth-callback"]],decls:2,vars:0,template:function(t,n){t&1&&(un(0,"p"),u(1,"Authentication in progress..."),hn())},encapsulation:2})};var Ii=i=>$(null,null,function*(){let e=f(ve),t=i.params.projectName;return t?e.getSelectedProjectId()===t?!0:(e.selectProject(t),(yield Ks(e.selectedProject$.pipe(el(r=>r?.name===t))))?.name===t):(console.log("[PROJECT GUARD] no project id in route"),!1)});var xp=i=>$(null,null,function*(){let e=f(Ge),t=f(Yt),n=i.params.threadId;if(!t.getUsername())try{yield sa(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 sa(kn([e.isLoading$,e.selectedThread$]).pipe(pt(([a,s])=>console.log(`\u{1F43C} [${a?"loading":"loaded"}]`,s?.id)),Se(([a,s])=>!a&&!!s),Zn(1),Oe(([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 Tp=[{path:"",component:po},{path:"oauth/callback",component:Qo},{path:"project/new",loadComponent:()=>import("./chunk-Q6VCYSB2.js").then(i=>i.ProjectNewComponent)},{path:"project/:projectName",component:pr,canActivate:[Ii]},{path:"project/:projectName/prompts",loadComponent:()=>import("./chunk-OEWE7VBT.js").then(i=>i.PromptListComponent),canActivate:[Ii]},{path:"project/:projectName/schedulers",loadComponent:()=>import("./chunk-OIIJPQ2M.js").then(i=>i.SchedulerListComponent),canActivate:[Ii]},{path:"project/:projectName/agents",loadComponent:()=>import("./chunk-HX6IQXOO.js").then(i=>i.AgentListComponent),canActivate:[Ii]},{path:"project/:projectName/thread/:threadId",component:pr,canActivate:[Ii,xp]},{path:"token-usage",loadComponent:()=>import("./chunk-DOKGAGLU.js").then(i=>i.TokenUsageComponent)},{path:"agentos",loadChildren:()=>import("./chunk-UVKQUFKA.js").then(i=>i.AGENTOS_ROUTES)},{path:"**",redirectTo:""}];function V0(i){return()=>i.initializeDefaultProject()}function z0(i){return()=>{console.log("[APP_INIT] OAuthService initialized")}}var Ep={providers:[rl(),gl({eventCoalescing:!0}),Cl(Tp),vl(),od(),nl(Ll),{provide:fa,useFactory:V0,deps:[ve],multi:!0},{provide:fa,useFactory:z0,deps:[Cn],multi:!0},Wl({basePath:"/api/agentos"}),{provide:zl,useValue:{width:"80vw",maxWidth:"80vw",maxHeight:"80vh"}}]};var Ko=class i{title="client";themeService=f(Ai);ngOnInit(){console.log("[APP] Application initialized with theme:",this.themeService.getCurrentTheme())}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({type:i,selectors:[["app-root"]],decls:1,vars:0,template:function(t,n){t&1&&F(0,"router-outlet")},dependencies:[Sl,yl],encapsulation:2})};bl(Ko,Ep).catch(i=>console.error(i));
361
+ `+(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 Uf(i,e){if(i&1){let t=O();l(0,"button",31),v("click",function(r){w(t);let o=g().$implicit,a=g(4);return x(a.startEditingThreadName(r,o))}),l(1,"mat-icon"),u(2,"edit"),c()()}}function Wf(i,e){i&1&&On(0)}function qf(i,e){if(i&1&&ti(0,Wf,1,0,"ng-container",11),i&2){let t=g().$implicit;g(3);let n=Vi(1);E("ngTemplateOutlet",n)("ngTemplateOutletContext",Er(2,Pf,t.subThreads))}}function Gf(i,e){if(i&1){let t=O();l(0,"div",17),C(1,jf,3,3,"div",18)(2,Hf,5,5,"a",19),l(3,"div",20),C(4,Uf,3,0,"button",21),l(5,"button",22),v("click",function(r){let o=w(t).$implicit,a=g(4);return x(a.toggleStar(r,o))}),l(6,"mat-icon"),u(7),c()(),l(8,"button",23),v("click",function(r){let o=w(t).$implicit,a=g(4);return x(a.deleteThread(r,o))}),l(9,"mat-icon"),u(10,"delete"),c()()()(),C(11,qf,1,4,"ng-container")}if(i&2){let t,n=e.$implicit,r=g(4);G("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(),G("starred",r.isStarred(n)),E("title",r.isStarred(n)?"Unstar thread":"Star thread"),p(2),$(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(),we(3,Gf,12,9,null,null,xp),c()),i&2){let t=e.$implicit;p(2),$(t.label),p(),xe(t.threads)}}function Qf(i,e){i&1&&(l(0,"div",15),u(1,"No existing threads"),c())}function Kf(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=g(3);p(),Ve('No threads matching "',t.searchQuery(),'"')}}function Xf(i,e){if(i&1&&(we(0,Yf,5,1,"div",14,Of),C(2,Qf,2,0,"div",15)(3,Kf,2,1,"div",15)),i&2){let t,n=g(2);xe(n.getGroupedThreads()),p(2),S(!((t=n.threads())!=null&&t.length)&&!n.searchQuery()?2:n.searchQuery()&&n.getGroupedThreads().length===0?3:-1)}}function Jf(i,e){if(i&1&&(ti(0,Nf,2,0,"ng-template",null,0,Mr),l(2,"div",3),C(3,Ff,4,0,"div",4)(4,Xf,4,1),c()),i&2){let t=g();p(3),S(t.isLoadingThreadList()?3:4)}}function Zf(i,e){i&1&&(l(0,"span",32),u(1,"No project selected"),c())}function e0(i,e){i&1&&(l(0,"span",32),u(1,"Loading..."),c())}function t0(i,e){if(i&1&&(l(0,"div",2),C(1,Zf,2,0,"span",32)(2,e0,2,0,"span",32),c()),i&2){let t,n=g();p(),S((t=n.currentProject())!=null&&t.name?2:1)}}var Yo=class i{projects=null;searchMode=!1;searchQuery=kr("");searchModeChange=new Z;threadSelected=new Z;projectStateService=f(ve);threadStateService=f(Ge);threadApiService=f(Gt);userService=f(Yt);router=f(zt);destroyRef=f(wr);currentThread=Ae(this.threadStateService.selectedThread$);currentProject=Ae(this.projectStateService.selectedProject$);threads=Ae(this.threadStateService.threadList$);isLoadingThreadList=Ae(this.threadStateService.isLoadingThreadList$);username=Ae(this.userService.username$);isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0;editingThreadId=null;editingThreadName="";isRenamingThread=!1;renameErrorMessage="";expandedParents=new Set;constructor(){Li(()=>{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(N=>N.id)),n=e.filter(N=>!N.parentThreadId),r=e.filter(N=>!!N.parentThreadId),o=r.filter(N=>!t.has(N.parentThreadId)),a=r.filter(N=>t.has(N.parentThreadId)),s=new Map;for(let N of a){let X=N.parentThreadId;s.has(X)||s.set(X,[]),s.get(X).push(N)}let d=N=>(s.get(N)||[]).sort((U,Ee)=>U.modifiedDate>Ee.modifiedDate?-1:1).map(U=>he(Y({},U),{subThreads:d(U.id)})),m=[...n,...o];if(this.searchQuery()&&this.searchQuery().trim()){let N=this.searchQuery().toLowerCase().trim();m=m.filter(X=>X.name.toLowerCase().includes(N)||X.summary&&X.summary.toLowerCase().includes(N))}if(!m.length)return[];let _=this.username();if(!_)return[];let b=m.map(N=>he(Y({},N),{subThreads:d(N.id)})),y=b.filter(N=>N.starring&&N.starring.includes(_)),k=b.filter(N=>!N.starring||!N.starring.includes(_)),T=new Map,P=new Date;P.setHours(0,0,0,0);for(let N of k){let X=new Date(N.modifiedDate);X.setHours(0,0,0,0);let U=P.getTime()-X.getTime(),Ee=Math.floor(U/(1e3*60*60*24)),ce;Ee===0?ce="Today":Ee===1?ce="Yesterday":Ee<7?ce="This Week":Ee<30?ce="This Month":Ee<90?ce="Last 3 Months":ce="Older",T.has(ce)||T.set(ce,[]),T.get(ce).push(N)}let K=[];if(y.length>0){let N=[...y].sort((X,U)=>X.modifiedDate>U.modifiedDate?-1:1);K.push({label:"Starred",threads:N})}return["Today","Yesterday","This Week","This Month","Last 3 Months","Older"].filter(N=>T.has(N)).forEach(N=>{K.push({label:N,threads:T.get(N)})}),K}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(ut(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=R({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,Jf,5,1)(2,t0,3,1,"div",2),c()),t&2){let r;p(),S((r=n.currentProject())!=null&&r.name?1:2)}},dependencies:[Dr,_t,ht,gt,Zl,ft,Re,de,rt,qe,ic,nc,_i,fi,$r,tc],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 n0=["logsContent"],i0=(i,e)=>e.name;function r0(i,e){if(i&1){let t=O();l(0,"button",12),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.start(r.name))}),l(1,"mat-icon"),u(2,"play_arrow"),c()()}if(i&2){let t=g().$implicit;E("disabled",t.isLoading)}}function o0(i,e){if(i&1){let t=O();l(0,"button",13),v("click",function(){w(t);let r=g().$implicit,o=g();return x(o.stop(r.name))}),l(1,"mat-icon"),u(2,"stop"),c()()}if(i&2){let t=g().$implicit;E("disabled",t.isLoading)}}function a0(i,e){if(i&1&&(l(0,"a",8)(1,"mat-icon",14),u(2,"open_in_new"),c()()),i&2){let t=g().$implicit;E("href",t.url,Pn)("title",t.url)}}function s0(i,e){if(i&1&&(l(0,"div",15),u(1),c()),i&2){let t=g(),n=t.$implicit,r=t.$index;Qe("order",r*2),p(),$(n.errorMessage)}}function l0(i,e){if(i&1){let t=O();l(0,"button",21),v("click",function(){w(t);let r=g(3);return x(r.onManualRefresh())}),l(1,"mat-icon"),u(2,"refresh"),c()()}}function c0(i,e){if(i&1&&(l(0,"div",16)(1,"div",17)(2,"span",18),u(3),c(),C(4,l0,3,0,"button",19),c(),l(5,"pre",20,0),u(7),c()()),i&2){let t=g(),n=t.$implicit,r=t.$index,o=g();Qe("order",r*2+1),p(3),Ve("",n.name," logs"),p(),S(n.status==="running"?4:-1),p(3),$(o.logs()||"(empty)")}}function d0(i,e){if(i&1){let t=O();l(0,"div",2)(1,"span",3),u(2),c(),l(3,"div",4),C(4,r0,3,1,"button",5)(5,o0,3,1,"button",6),l(6,"span",7),u(7),c(),C(8,a0,3,2,"a",8),l(9,"button",9),v("click",function(){let r=w(t).$implicit,o=g();return x(o.toggleLogs(r.name))}),l(10,"mat-icon"),u(11),c()()()(),C(12,s0,2,3,"div",10),C(13,c0,8,5,"div",11)}if(i&2){let t=e.$implicit,n=e.$index,r=g();Qe("order",n*2),p(2),$(t.name),p(2),S(t.status==="stopped"?4:5),p(2),G("running",t.status==="running"),p(),Ve(" ",t.status==="running"?"Running":"Stopped"," "),p(),S(t.url?8:-1),p(),E("title",r.logsOpenFor()===t.name?"Hide logs":"Show logs"),p(2),$(r.logsOpenFor()===t.name?"expand_less":"terminal"),p(),S(t.errorMessage?12:-1),p(),S(r.logsOpenFor()===t.name?13:-1)}}var Qo=class i{destroyRef=f(wr);projectApi=f(zr);projectName=kr.required();entryStates=We([]);hasPreview=Tt(()=>this.entryStates().length>0);logsOpenFor=We(null);logs=We("");logsContent;logsPollTimer=null;logsTimeoutTimer=null;static LOGS_POLL_MS=5e3;static LOGS_TIMEOUT_MS=1200*1e3;constructor(){Li(()=>{let e=this.projectName();e&&this.onProjectChanged(e)},{allowSignalWrites:!0}),Li(()=>{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(ut(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));Js(o).pipe(ut(this.destroyRef)).subscribe({next:a=>{this.entryStates.update(s=>s.map((d,m)=>{let _=a[m];return _?he(Y({},d),{status:_.status}):d}))},error:()=>{}})},error:()=>{}})}start(e){this.updateEntry(e,{isLoading:!0,errorMessage:""}),this.projectApi.startPreview(this.projectName(),e).pipe(ut(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(ut(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(ut(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?Y(Y({},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=R({type:i,selectors:[["app-preview-panel"]],viewQuery:function(t,n){if(t&1&&$e(n0,5),t&2){let r;ge(r=fe())&&(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),we(1,d0,14,12,null,null,i0),c()),t&2&&(p(),xe(n.entryStates()))},dependencies:[rt,qe,Re,de],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 p0(i,e){if(i&1&&(l(0,"div",3),u(1),c()),i&2){let t=g();p(),Ve("\u274C ",t.errorMessage)}}var dr=class i{dialogRef=f(Vl);data=f(zl);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=R({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),re("ngModelChange",function(o){return ie(n.jsonContent,o)||(n.jsonContent=o),o}),c(),C(7,p0,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(),Ve(" ",n.title," "),p(5),ne("ngModel",n.jsonContent),p(),S(n.errorMessage?7:-1))},dependencies:[nt,_t,ht,gt,ft,de,qe,jr,Hl,Ul,Wl],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 m0=["threadSearchInput"],u0=["*"];function h0(i,e){if(i&1){let t=O();l(0,"button",26),v("click",function(){w(t);let r=g();return x(r.toggle())}),l(1,"mat-icon"),u(2,"menu"),c()(),l(3,"button",27),v("click",function(){w(t);let r=g();return x(r.createNewThread())}),l(4,"mat-icon",10),u(5,"play_circle"),c()()}if(i&2){let t=g();p(3),E("disabled",!t.selectedProjectName())}}function g0(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),re("ngModelChange",function(r){w(t);let o=g();return ie(o.threadSearchQuery,r)||(o.threadSearchQuery=r),x(r)}),v("input",function(){w(t);let r=g();return x(r.onThreadSearchInput())}),c(),l(5,"button",30),v("click",function(){w(t);let r=g();return x(r.closeThreadSearch())}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=g();p(3),ne("ngModel",t.threadSearchQuery)}}function f0(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){w(t);let o=g();return x(o.toggleThreadSearch(r))}),l(6,"mat-icon"),u(7,"search"),c()()()}}function _0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function b0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"hub"),c())}function v0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function y0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"tune"),c())}function C0(i,e){i&1&&(l(0,"div",33)(1,"div",37),F(2,"app-options-panel",38),c()())}function S0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(3).openProjectConfig(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"settings_applications"),c(),l(4,"span",23),u(5,"Project Configuration"),c()()()}}function w0(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 x0(i,e){if(i&1&&C(0,S0,6,0,"div",32)(1,w0,6,0,"div",32),i&2){let t=g(2);S(t.selectedProjectName()?0:1)}}function T0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openAgents(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"smart_toy"),c(),l(4,"span",23),u(5,"Agents"),c()()()}}function E0(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 M0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openPrompts(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"description"),c(),l(4,"span",23),u(5,"Prompts"),c()()()}}function k0(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 P0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).openSchedulers(),r.preventDefault(),x(r.stopPropagation())}),l(2,"mat-icon",22),u(3,"schedule"),c(),l(4,"span",23),u(5,"Schedulers"),c()()()}}function O0(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 A0(i,e){i&1&&(l(0,"mat-icon",21),u(1,"keyboard_arrow_up"),c())}function I0(i,e){i&1&&(l(0,"mat-icon",22),u(1,"rocket_launch"),c())}function D0(i,e){if(i&1&&(l(0,"div",33),F(1,"app-preview-panel",40),c()),i&2){let t=g(3);p(),E("projectName",t.selectedProjectName())}}function R0(i,e){if(i&1){let t=O();l(0,"div",32)(1,"a",20),v("click",function(r){return w(t),g(2).toggleSection("preview"),r.preventDefault(),x(r.stopPropagation())}),C(2,A0,2,0,"mat-icon",21)(3,I0,2,0,"mat-icon",22),l(4,"span",23),u(5,"Preview Server"),c()(),C(6,D0,2,1,"div",33),c()}if(i&2){let t=g(2);G("expanded",t.expandedSections.preview),p(),G("active",t.expandedSections.preview),p(),S(t.expandedSections.preview?2:3),p(4),S(t.expandedSections.preview?6:-1)}}function N0(i,e){if(i&1){let t=O();l(0,"div",24)(1,"div",32)(2,"a",20),v("click",function(r){return w(t),g().toggleSection("config"),x(r.preventDefault())}),C(3,v0,2,0,"mat-icon",21)(4,y0,2,0,"mat-icon",22),l(5,"span",23),u(6,"Preferences"),c()(),C(7,C0,3,0,"div",33),c(),l(8,"div",32)(9,"a",20),v("click",function(r){return w(t),g().openTokenUsage(),r.preventDefault(),x(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 w(t),g().openUserConfig(),r.preventDefault(),x(r.stopPropagation())}),l(16,"mat-icon",22),u(17,"manage_accounts"),c(),l(18,"span",23),u(19,"User Configuration"),c()()(),C(20,x0,2,1),C(21,T0,6,0,"div",32)(22,E0,6,0,"div",32),C(23,M0,6,0,"div",32)(24,k0,6,0,"div",32),C(25,P0,6,0,"div",32)(26,O0,6,0,"div",32),C(27,R0,7,6,"div",34),l(28,"div",32)(29,"a",35),F(30,"img",36),l(31,"span",23),u(32,"Contribute on GitHub"),c()()()()}if(i&2){let t=g();p(),G("expanded",t.expandedSections.config),p(),G("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),Me("src","CODAY-Logo.png",Pn)}}function F0(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(){w(t);let r=g();return x(r.configErrorMessage="")}),l(6,"mat-icon"),u(7,"close"),c()()()}if(i&2){let t=g();p(4),$(t.configErrorMessage)}}var pr=class i{destroy$=new J;sidenavStateChange=new Z;drawerOpen=!1;breakpointObserver=f(Ml);isDesktop=Ae(this.breakpointObserver.observe("(min-width: 1400px)").pipe(Oe(e=>e.matches)),{initialValue:!1});userOpenPreference=We(!0);isOpen=Tt(()=>this.userOpenPreference());isAdmin=!1;configErrorMessage="";expandedSections={config:!1,preview:!1,settings:!1};isThreadSearchActive=!1;threadSearchQuery="";threadSearchInput;dialog=f(Bl);configApi=f(sc);projectStateService=f(ve);projectApi=f(zr);router=f(zt);preferences=f(ke);threadStateService=f(Ge);projects=Ae(this.projectStateService.projectList$);selectedProject=Ae(this.projectStateService.selectedProject$);selectedProjectName=Ae(this.projectStateService.selectedProject$.pipe(Oe(e=>e?.name)));isProjectVolatile=Ae(this.projectStateService.selectedProject$.pipe(Oe(e=>e?.config?.volatile||!1)));forcedProject=Ae(this.projectStateService.forcedProject$);hasPreviewConfig=Ae(this.projectStateService.selectedProject$.pipe(Oe(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(I(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"]),this.close()}openUserConfig(){console.log("[SIDENAV] openUserConfig called"),this.configErrorMessage="",this.configApi.getUserConfig().pipe(I(this.destroy$)).subscribe({next:e=>{console.log("[SIDENAV] User config loaded, opening dialog"),this.dialog.open(dr,{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(I(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(I(this.destroy$)).subscribe({next:t=>{console.log("[SIDENAV] Project config loaded, opening dialog"),this.dialog.open(dr,{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(I(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"]),this.close()}openPrompts(){if(!this.requireProjectSelection("open prompts"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"prompts"]),this.close()}openSchedulers(){if(!this.requireProjectSelection("open schedulers"))return;let e=this.selectedProjectName();this.router.navigate(["project",e,"schedulers"]),this.close()}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=R({type:i,selectors:[["app-sidenav"]],viewQuery:function(t,n){if(t&1&&$e(m0,5),t&2){let r;ge(r=fe())&&(n.threadSearchInput=r.first)}},inputs:{drawerOpen:"drawerOpen"},outputs:{sidenavStateChange:"sidenavStateChange"},ngContentSelectors:u0,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&&(nn(),C(0,h0,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,g0,8,1,"div",14)(20,f0,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,_0,2,0,"mat-icon",21)(27,b0,2,0,"mat-icon",22),l(28,"span",23),u(29,"Control Center"),c()(),C(30,N0,33,12,"div",24),c()()(),l(31,"mat-sidenav-content"),dt(32),c()(),C(33,F0,8,1,"div",25)),t&2&&(S(!n.isOpen()&&!n.drawerOpen?0:-1),p(),G("sidenav-open",n.isOpen()),E("hasBackdrop",!1),p(),E("opened",n.isOpen())("disableClose",!0),p(5),G("sidenav-logo",!0)("clickable",!n.forcedProject())("disabled",n.forcedProject()),E("title",n.forcedProject()?"Project selection disabled":"Go to project selection"),Me("src","CODAY-Logo.png",Pn)("role",n.forcedProject()?null:"button")("tabindex",n.forcedProject()?null:"0"),p(3),$(n.selectedProjectName()),p(9),S(n.isThreadSearchActive?19:20),p(3),E("searchMode",n.isThreadSearchActive)("searchQuery",n.threadSearchQuery),p(),G("is-admin",n.isAdmin),p(),G("expanded",n.expandedSections.settings),p(),G("active",n.expandedSections.settings),p(),S(n.expandedSections.settings?26:27),p(4),S(n.expandedSections.settings?30:-1),p(),G("sidenav-closed-offset",!n.isOpen()),p(2),S(n.configErrorMessage?33:-1))},dependencies:[_t,ht,gt,ft,Uo,As,_p,Bo,Re,de,rt,qe,Sp,wp,cr,Yo,Qo],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 Ko=class i{destroy$=new J;isSetup=!1;codayService=f(lt);preferencesService=f(ke);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(I(this.destroy$),pa(),Se(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(I(this.destroy$),pa(),Se(([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 B(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=H({token:i,factory:i.\u0275fac,providedIn:"root"})};var L0=["inputSection"];function j0(i,e){if(i&1){let t=O();l(0,"app-thread",4),v("chatFocused",function(){w(t);let r=g();return x(r.onChatFocusedOnMobile())})("drawerStateChange",function(r){w(t);let o=g();return x(o.onDrawerStateChange(r))}),c()}if(i&2){let t=g();E("projectName",t.projectName)("threadId",t.threadId)}}function V0(i,e){if(i&1){let t=O();l(0,"div",5),F(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){w(t);let o=g();return x(o.onMessageSubmitted(r))})("voiceRecordingToggled",function(r){w(t);let o=g();return x(o.onVoiceToggled(r))})("heightChanged",function(r){w(t);let o=g();return x(o.onInputHeightChanged(r))})("textareaFocused",function(){w(t);let r=g();return x(r.onChatFocusedOnMobile())}),c()()()()}if(i&2){let t=g();p(6),E("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var mr=class i{destroy$=new J;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=f(lt);titleService=f(Oi);preferencesService=f(ke);route=f(Rr);router=f(zt);threadApiService=f(Gt);agentNotificationService=f(Ko);firstMessageState=f(Ai);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(I(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=R({type:i,selectors:[["app-main"]],viewQuery:function(t,n){if(t&1&&$e(L0,5)(pr,5),t&2){let r;ge(r=fe())&&(n.inputSection=r.first),ge(r=fe())&&(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,j0,1,2,"app-thread",3)(3,V0,7,5),c()()),t&2&&(E("drawerOpen",n.isDrawerOpen),p(2),S(n.threadId?2:3))},dependencies:[ui,qo,Go,pr],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:[Ta("slideIn",[Hr(":enter",[fn({transform:"translateY(100%)",opacity:0}),Br("300ms ease-out",fn({transform:"translateY(0)",opacity:1}))]),Hr(":leave",[Br("200ms ease-in",fn({transform:"translateY(100%)",opacity:0}))])])]}})};var Di=i=>B(null,null,function*(){let e=f(ve),t=i.params.projectName;return t?e.getSelectedProjectId()===t?!0:(e.selectProject(t),(yield Xs(e.selectedProject$.pipe(tl(r=>r?.name===t))))?.name===t):(console.log("[PROJECT GUARD] no project id in route"),!1)});var Tp=i=>B(null,null,function*(){let e=f(Ge),t=f(Yt),n=i.params.threadId;if(!t.getUsername())try{yield la(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 la(kn([e.isLoading$,e.selectedThread$]).pipe(pt(([a,s])=>console.log(`\u{1F43C} [${a?"loading":"loaded"}]`,s?.id)),Se(([a,s])=>!a&&!!s),Jn(1),Oe(([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 Ep=[{path:"",component:mo},{path:"oauth/callback",component:Po},{path:"project/new",loadComponent:()=>import("./chunk-4TOD23CW.js").then(i=>i.ProjectNewComponent)},{path:"project/:projectName",component:mr,canActivate:[Di]},{path:"project/:projectName/prompts",loadComponent:()=>import("./chunk-YKARRAPE.js").then(i=>i.PromptListComponent),canActivate:[Di]},{path:"project/:projectName/schedulers",loadComponent:()=>import("./chunk-ZP4X376S.js").then(i=>i.SchedulerListComponent),canActivate:[Di]},{path:"project/:projectName/agents",loadComponent:()=>import("./chunk-6LHAGXIC.js").then(i=>i.AgentListComponent),canActivate:[Di]},{path:"project/:projectName/thread/:threadId",component:mr,canActivate:[Di,Tp]},{path:"token-usage",loadComponent:()=>import("./chunk-YRNTZU7L.js").then(i=>i.TokenUsageComponent)},{path:"agentos",loadChildren:()=>import("./chunk-2NHY3763.js").then(i=>i.AGENTOS_ROUTES)},{path:"**",redirectTo:""}];function z0(i){return()=>i.initializeDefaultProject()}function $0(i){return()=>{console.log("[APP_INIT] OAuthService initialized")}}var Mp={providers:[ol(),fl({eventCoalescing:!0}),Sl(Ep),yl(),ad(),il(jl),{provide:_a,useFactory:z0,deps:[ve],multi:!0},{provide:_a,useFactory:$0,deps:[Cn],multi:!0},ql({basePath:"/api/agentos"}),{provide:$l,useValue:{width:"80vw",maxWidth:"80vw",maxHeight:"80vh"}}]};var Xo=class i{title="client";themeService=f(Ii);ngOnInit(){console.log("[APP] Application initialized with theme:",this.themeService.getCurrentTheme())}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=R({type:i,selectors:[["app-root"]],decls:1,vars:0,template:function(t,n){t&1&&F(0,"router-outlet")},dependencies:[wl,Cl],encapsulation:2})};vl(Xo,Mp).catch(i=>console.error(i));