@whoz-oss/coday-client 0.41.2 → 0.41.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.
package/browser/index.html
CHANGED
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
<style>:root{--color-bg:linear-gradient(135deg, #f0f4ff 0%, #e8ecf9 100%);--color-bg-solid:#f0f4ff;--color-bg-secondary:rgba(255, 255, 255, .7);--color-text:#1d1d1f;--color-text-secondary:#6e6e73;--color-text-inverse:#ffffff;--color-primary:#007aff;--color-primary-hover:#0051d5;--color-accent:#8b5cf6;--color-link:#007aff;--color-border:rgba(0, 0, 0, .1);--color-border-light:rgba(40, 40, 40, .08);--color-input-bg:rgba(255, 255, 255, .8);--color-success:#34c759;--color-error:#ff3b30;--color-warning:#ff9500;--color-info:#5ac8fa;--color-message-user:rgba(0, 122, 255, .1);--color-message-ai:rgba(255, 255, 255, .8);--color-code-bg:rgba(142, 142, 147, .12);--color-code-text:#ff375f;--color-bg-hover:rgba(0, 0, 0, .04);--glass-bg:rgba(255, 255, 255, .72);--glass-border:rgba(255, 255, 255, .18);--glass-shadow:0 8px 32px 0 rgba(31, 38, 135, .15);--glass-backdrop-blur:blur(20px);--color-shadow:rgba(0, 0, 0, .08);--color-overlay:rgba(0, 0, 0, .4)}@media print{html,body,app-root{height:auto!important;max-height:none!important;min-height:auto!important;overflow:visible!important;position:static!important}body{background:#fff!important;color:#000!important;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif!important;font-size:11pt;line-height:1.6;padding:1rem!important}*{animation:none!important;transition:none!important;box-shadow:none!important;text-shadow:none!important}}*{box-sizing:border-box}html{--mat-sys-background:light-dark(#fef8fc, #151316);--mat-sys-error:light-dark(#ba1a1a, #ffb4ab);--mat-sys-error-container:light-dark(#ffdad6, #93000a);--mat-sys-inverse-on-surface:light-dark(#f5eff4, #323033);--mat-sys-inverse-primary:light-dark(#d5baff, #7d00fa);--mat-sys-inverse-surface:light-dark(#323033, #e6e1e6);--mat-sys-on-background:light-dark(#1d1b1e, #e6e1e6);--mat-sys-on-error:light-dark(#ffffff, #690005);--mat-sys-on-error-container:light-dark(#93000a, #ffdad6);--mat-sys-on-primary:light-dark(#ffffff, #42008a);--mat-sys-on-primary-container:light-dark(#5f00c0, #ecdcff);--mat-sys-on-primary-fixed:light-dark(#270057, #270057);--mat-sys-on-primary-fixed-variant:light-dark(#5f00c0, #5f00c0);--mat-sys-on-secondary:light-dark(#ffffff, #352d40);--mat-sys-on-secondary-container:light-dark(#4b4357, #eadef7);--mat-sys-on-secondary-fixed:light-dark(#1f182a, #1f182a);--mat-sys-on-secondary-fixed-variant:light-dark(#4b4357, #4b4357);--mat-sys-on-surface:light-dark(#1d1b1e, #e6e1e6);--mat-sys-on-surface-variant:light-dark(#49454e, #e8e0eb);--mat-sys-on-tertiary:light-dark(#ffffff, #42008a);--mat-sys-on-tertiary-container:light-dark(#5f00c0, #ecdcff);--mat-sys-on-tertiary-fixed:light-dark(#270057, #270057);--mat-sys-on-tertiary-fixed-variant:light-dark(#5f00c0, #5f00c0);--mat-sys-outline:light-dark(#7b757f, #958e99);--mat-sys-outline-variant:light-dark(#cbc4cf, #49454e);--mat-sys-primary:light-dark(#7d00fa, #d5baff);--mat-sys-primary-container:light-dark(#ecdcff, #5f00c0);--mat-sys-primary-fixed:light-dark(#ecdcff, #ecdcff);--mat-sys-primary-fixed-dim:light-dark(#d5baff, #d5baff);--mat-sys-scrim:light-dark(#000000, #000000);--mat-sys-secondary:light-dark(#645b70, #cec2db);--mat-sys-secondary-container:light-dark(#eadef7, #4b4357);--mat-sys-secondary-fixed:light-dark(#eadef7, #eadef7);--mat-sys-secondary-fixed-dim:light-dark(#cec2db, #cec2db);--mat-sys-shadow:light-dark(#000000, #000000);--mat-sys-surface:light-dark(#fef8fc, #151316);--mat-sys-surface-bright:light-dark(#fef8fc, #3b383c);--mat-sys-surface-container:light-dark(#f2ecf1, #211f22);--mat-sys-surface-container-high:light-dark(#ede6eb, #2b292d);--mat-sys-surface-container-highest:light-dark(#e6e1e6, #363437);--mat-sys-surface-container-low:light-dark(#f8f2f6, #1d1b1e);--mat-sys-surface-container-lowest:light-dark(#ffffff, #0f0d11);--mat-sys-surface-dim:light-dark(#ded8dd, #151316);--mat-sys-surface-tint:light-dark(#7d00fa, #d5baff);--mat-sys-surface-variant:light-dark(#e8e0eb, #49454e);--mat-sys-tertiary:light-dark(#7d00fa, #d5baff);--mat-sys-tertiary-container:light-dark(#ecdcff, #5f00c0);--mat-sys-tertiary-fixed:light-dark(#ecdcff, #ecdcff);--mat-sys-tertiary-fixed-dim:light-dark(#d5baff, #d5baff);--mat-sys-neutral-variant20:#332f37;--mat-sys-neutral10:#1d1b1e;--mat-sys-level0:0px 0px 0px 0px rgba(0, 0, 0, .2), 0px 0px 0px 0px rgba(0, 0, 0, .14), 0px 0px 0px 0px rgba(0, 0, 0, .12);--mat-sys-level1:0px 2px 1px -1px rgba(0, 0, 0, .2), 0px 1px 1px 0px rgba(0, 0, 0, .14), 0px 1px 3px 0px rgba(0, 0, 0, .12);--mat-sys-level2:0px 3px 3px -2px rgba(0, 0, 0, .2), 0px 3px 4px 0px rgba(0, 0, 0, .14), 0px 1px 8px 0px rgba(0, 0, 0, .12);--mat-sys-level3:0px 3px 5px -1px rgba(0, 0, 0, .2), 0px 6px 10px 0px rgba(0, 0, 0, .14), 0px 1px 18px 0px rgba(0, 0, 0, .12);--mat-sys-level4:0px 5px 5px -3px rgba(0, 0, 0, .2), 0px 8px 10px 1px rgba(0, 0, 0, .14), 0px 3px 14px 2px rgba(0, 0, 0, .12);--mat-sys-level5:0px 7px 8px -4px rgba(0, 0, 0, .2), 0px 12px 17px 2px rgba(0, 0, 0, .14), 0px 5px 22px 4px rgba(0, 0, 0, .12);--mat-sys-body-large:400 1rem / 1.5rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-large-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-large-line-height:1.5rem;--mat-sys-body-large-size:1rem;--mat-sys-body-large-tracking:.031rem;--mat-sys-body-large-weight:400;--mat-sys-body-medium:400 .875rem / 1.25rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-medium-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-medium-line-height:1.25rem;--mat-sys-body-medium-size:.875rem;--mat-sys-body-medium-tracking:.016rem;--mat-sys-body-medium-weight:400;--mat-sys-body-small:400 .75rem / 1rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-small-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-body-small-line-height:1rem;--mat-sys-body-small-size:.75rem;--mat-sys-body-small-tracking:.025rem;--mat-sys-body-small-weight:400;--mat-sys-display-large:400 3.562rem / 4rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-large-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-large-line-height:4rem;--mat-sys-display-large-size:3.562rem;--mat-sys-display-large-tracking:-.016rem;--mat-sys-display-large-weight:400;--mat-sys-display-medium:400 2.812rem / 3.25rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-medium-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-medium-line-height:3.25rem;--mat-sys-display-medium-size:2.812rem;--mat-sys-display-medium-tracking:0;--mat-sys-display-medium-weight:400;--mat-sys-display-small:400 2.25rem / 2.75rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-small-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-display-small-line-height:2.75rem;--mat-sys-display-small-size:2.25rem;--mat-sys-display-small-tracking:0;--mat-sys-display-small-weight:400;--mat-sys-headline-large:400 2rem / 2.5rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-large-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-large-line-height:2.5rem;--mat-sys-headline-large-size:2rem;--mat-sys-headline-large-tracking:0;--mat-sys-headline-large-weight:400;--mat-sys-headline-medium:400 1.75rem / 2.25rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-medium-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-medium-line-height:2.25rem;--mat-sys-headline-medium-size:1.75rem;--mat-sys-headline-medium-tracking:0;--mat-sys-headline-medium-weight:400;--mat-sys-headline-small:400 1.5rem / 2rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-small-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-headline-small-line-height:2rem;--mat-sys-headline-small-size:1.5rem;--mat-sys-headline-small-tracking:0;--mat-sys-headline-small-weight:400;--mat-sys-label-large:500 .875rem / 1.25rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-large-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-large-line-height:1.25rem;--mat-sys-label-large-size:.875rem;--mat-sys-label-large-tracking:.006rem;--mat-sys-label-large-weight:500;--mat-sys-label-large-weight-prominent:700;--mat-sys-label-medium:500 .75rem / 1rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-medium-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-medium-line-height:1rem;--mat-sys-label-medium-size:.75rem;--mat-sys-label-medium-tracking:.031rem;--mat-sys-label-medium-weight:500;--mat-sys-label-medium-weight-prominent:700;--mat-sys-label-small:500 .688rem / 1rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-small-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-label-small-line-height:1rem;--mat-sys-label-small-size:.688rem;--mat-sys-label-small-tracking:.031rem;--mat-sys-label-small-weight:500;--mat-sys-title-large:400 1.375rem / 1.75rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-large-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-large-line-height:1.75rem;--mat-sys-title-large-size:1.375rem;--mat-sys-title-large-tracking:0;--mat-sys-title-large-weight:400;--mat-sys-title-medium:500 1rem / 1.5rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-medium-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-medium-line-height:1.5rem;--mat-sys-title-medium-size:1rem;--mat-sys-title-medium-tracking:.009rem;--mat-sys-title-medium-weight:500;--mat-sys-title-small:500 .875rem / 1.25rem -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-small-font:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;--mat-sys-title-small-line-height:1.25rem;--mat-sys-title-small-size:.875rem;--mat-sys-title-small-tracking:.006rem;--mat-sys-title-small-weight:500;--mat-sys-corner-extra-large:28px;--mat-sys-corner-extra-large-top:28px 28px 0 0;--mat-sys-corner-extra-small:4px;--mat-sys-corner-extra-small-top:4px 4px 0 0;--mat-sys-corner-full:9999px;--mat-sys-corner-large:16px;--mat-sys-corner-large-end:0 16px 16px 0;--mat-sys-corner-large-start:16px 0 0 16px;--mat-sys-corner-large-top:16px 16px 0 0;--mat-sys-corner-medium:12px;--mat-sys-corner-none:0;--mat-sys-corner-small:8px;--mat-sys-dragged-state-layer-opacity:.16;--mat-sys-focus-state-layer-opacity:.12;--mat-sys-hover-state-layer-opacity:.08;--mat-sys-pressed-state-layer-opacity:.12;--mat-snack-bar-container-shape:transparent;--mat-snack-bar-container-color:transparent;--mat-snack-bar-supporting-text-color:var(--color-text)}html,body{margin:0;padding:0;width:100%;height:100%}body{background:var(--color-bg);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,Segoe UI,Helvetica Neue,Arial,sans-serif;transition:background .3s ease,color .3s ease;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}</style><link rel="stylesheet" href="styles-PBVWFSON.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles-PBVWFSON.css"></noscript></head>
|
|
14
14
|
<body>
|
|
15
15
|
<app-root></app-root>
|
|
16
|
-
<script src="polyfills-7R4CRVNH.js" type="module"></script><script src="main-
|
|
16
|
+
<script src="polyfills-7R4CRVNH.js" type="module"></script><script src="main-FVIO4HBI.js" type="module"></script></body>
|
|
17
17
|
</html>
|
|
@@ -76,9 +76,9 @@ ${n}</tr>
|
|
|
76
76
|
Please report this to https://github.com/markedjs/marked.`,n){let i="<p>An error occurred:</p><pre>"+Ii(e.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(e);throw e}}},Bo=new p2;function Be(n,t){return Bo.parse(n,t)}Be.options=Be.setOptions=function(n){return Bo.setOptions(n),Be.defaults=Bo.defaults,mT(Be.defaults),Be};Be.getDefaults=my;Be.defaults=Ho;Be.use=function(...n){return Bo.use(...n),Be.defaults=Bo.defaults,mT(Be.defaults),Be};Be.walkTokens=function(n,t){return Bo.walkTokens(n,t)};Be.parseInline=Bo.parseInline;Be.Parser=ti;Be.parser=ti.parse;Be.Renderer=va;Be.TextRenderer=Ey;Be.Lexer=ei;Be.lexer=ei.lex;Be.Tokenizer=np;Be.Hooks=Qc;Be.parse=Be;var Moe=Be.options,Toe=Be.setOptions,Ioe=Be.use,koe=Be.walkTokens,Aoe=Be.parseInline;var Ooe=ti.parse,Roe=ei.lex;var _a=class n{renderer;constructor(){this.renderer=new va,this.configureRenderer()}configureRenderer(){let t=this.renderer.link.bind(this.renderer);this.renderer.link=e=>{let i=this.isExternalLink(e.href),r=t(e);if(i){r=r.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let o=e.title?`${e.text} - ${e.title} (opens in new tab)`:`${e.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(t){if(!t||t.startsWith("/")||t.startsWith("#")||t.startsWith("?"))return!1;if(t.startsWith("//"))return!0;try{return new URL(t,window.location.href).hostname!==window.location.hostname}catch{return!1}}escapeHtml(t){let e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,i=>e[i]||i)}parse(t){return ue(this,null,function*(){return Be.parse(t,{renderer:this.renderer})})}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var m2=["choiceSelect"],g2=(n,t)=>t.value;function v2(n,t){if(n&1&&(h(0,"option",7),b(1),p()),n&2){let e=t.$implicit;R("value",e.value),g(),Ae(" ",e.label," ")}}function _2(n,t){if(n&1){let e=$();h(0,"form",2),S("ngSubmit",function(){x(e);let r=y();return D(r.onSubmit())}),U(1,"div",3),Yv(2,"async"),h(3,"div",4)(4,"select",5,0),xe("ngModelChange",function(r){x(e);let o=y();return Te(o.selectedValue,r)||(o.selectedValue=r),D(r)}),S("change",function(){x(e);let r=y();return D(r.onSelectChange())})("keydown.enter",function(){x(e);let r=y();return D(r.onSubmit())})("focus",function(){x(e);let r=y();return D(r.isFocused=!0)})("blur",function(){x(e);let r=y();return D(r.isFocused=!1)}),h(6,"option",6),b(7,"-- Select an option --"),p(),wt(8,v2,2,2,"option",7,g2),p(),h(10,"button",8)(11,"mat-icon"),b(12,"send"),p()()()()}if(n&2){let e=y();g(),R("innerHTML",Qv(2,5,e.renderedLabel$),Ss),g(2),W("focused",e.isFocused),g(),Se("ngModel",e.selectedValue),g(4),Et(e.options),g(2),R("disabled",!e.selectedValue)}}var ba=class n{options=[];set labelHtml(t){typeof t=="object"?this.renderedLabelSubject.next(t):this.renderLabelMarkdown(t)}isVisible=!1;choiceSelected=new V;selectElement;selectedValue="";isFocused=!1;renderedLabelSubject=new q("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=u(Co);markdownService=u(_a);ngOnDestroy(){this.renderedLabelSubject.complete()}ngAfterViewInit(){this.isVisible&&this.selectElement&&setTimeout(()=>this.focusSelect(),100)}ngOnChanges(t){t.isVisible&&(console.log("[CHOICE-SELECT] isVisible changed:",t.isVisible.previousValue,"->",t.isVisible.currentValue),t.isVisible.currentValue&&!t.isVisible.previousValue&&(console.log("[CHOICE-SELECT] Component becoming visible, setting focus..."),setTimeout(()=>this.focusSelect(),150)))}focusSelect(){this.selectElement?.nativeElement&&(this.selectElement.nativeElement.focus(),console.log("[CHOICE-SELECT] Focus set on select element"))}onSubmit(){this.selectedValue?(console.log("[CHOICE-SELECT] Choice selected:",this.selectedValue),this.choiceSelected.emit(this.selectedValue),this.selectedValue=""):console.warn("[CHOICE-SELECT] No choice selected")}onSelectChange(){console.log("[CHOICE-SELECT] Selection changed to:",this.selectedValue)}renderLabelMarkdown(t){return ue(this,null,function*(){if(!t){this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(""));return}try{let e=yield this.markdownService.parse(t);this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(e))}catch(e){console.error("[CHOICE-SELECT] Error parsing label markdown:",e),this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(t))}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-choice-select"]],viewQuery:function(e,i){if(e&1&&Me(m2,5),e&2){let r;ce(r=de())&&(i.selectElement=r.first)}},inputs:{options:"options",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[qe],decls:1,vars:1,consts:[["choiceSelect",""],[1,"choice-form"],[1,"choice-form",3,"ngSubmit"],[1,"choice-label",3,"innerHTML"],[1,"select-button-row"],["name","choice","required","",1,"choice-select-inline",3,"ngModelChange","change","keydown.enter","focus","blur","ngModel"],["value","","disabled",""],[3,"value"],["type","submit","mat-icon-button","","title","Submit selection",1,"submit-btn",3,"disabled"]],template:function(e,i){e&1&&I(0,_2,13,7,"form",1),e&2&&k(i.isVisible?0:-1)},dependencies:[Gt,Kh,ma,ga,Lr,hn,qh,$c,tn,zc,Ti,kt,Ln,Cn,h_],styles:[`.choice-form[_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}.select-button-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;background:transparent;border:2px solid var(--color-border);border-radius:12px;padding:.5rem;transition:all .2s ease}.select-button-row.focused[_ngcontent-%COMP%]{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.choice-select-inline[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent;font-size:1rem;padding:.5rem 2.5rem .5rem .5rem;color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;cursor:pointer;line-height:1.5;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M7 10l5 5 5-5z"/></svg>');background-repeat:no-repeat;background-position:right .5rem center;background-size:24px 24px}.choice-select-inline[_ngcontent-%COMP%]:focus{outline:none}.choice-select-inline[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.choice-select-inline[_ngcontent-%COMP%] option[_ngcontent-%COMP%]:disabled{color:var(--color-text-secondary);font-style:italic}.submit-btn[_ngcontent-%COMP%]{flex-shrink:0;background:var(--color-primary);color:#fff;transition:all .2s ease}.submit-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover);transform:scale(1.05)}.submit-btn[_ngcontent-%COMP%]:disabled{background:var(--color-text-secondary);cursor:not-allowed;opacity:.5}@media (max-width: 480px){.choice-form[_ngcontent-%COMP%]{gap:.75rem}.choice-label[_ngcontent-%COMP%], .choice-select-inline[_ngcontent-%COMP%]{font-size:.95rem}}@media print{.submit-btn[_ngcontent-%COMP%]{display:none!important}}`]})};var ya=class n{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(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(e,i){e&1&&(Ie(0,"h1",0),b(1),ke()),e&2&&(g(),Ee(i.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(2.5rem,6vw,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:inline-block;min-height:1.2em}@media (max-width: 768px){.welcome-title[_ngcontent-%COMP%]{font-size:clamp(2rem,5vw,3rem)}}@media (max-width: 480px){.welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,2rem)}}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var b2=["inputElement"];function y2(n,t){if(n&1&&(h(0,"span",3),b(1),p()),n&2){let e=y();g(),Ee(e.label)}}function C2(n,t){if(n&1&&(h(0,"small",5),b(1),p()),n&2){let e=y();g(),Ee(e.hint)}}var op=class n{label="";placeholder="";hint="";isDisabled=!1;value="";autoFocus=!0;valueChange=new V;enterPressed=new V;inputElement;inputValue="";ngAfterViewInit(){this.inputValue=this.value,this.autoFocus&&setTimeout(()=>this.inputElement?.nativeElement.focus(),100)}onValueChange(t){this.valueChange.emit(t)}onEnter(){this.inputValue.trim()&&this.enterPressed.emit(this.inputValue.trim())}focus(){this.inputElement?.nativeElement.focus()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-text-input"]],viewQuery:function(e,i){if(e&1&&Me(b2,5),e&2){let r;ce(r=de())&&(i.inputElement=r.first)}},inputs:{label:"label",placeholder:"placeholder",hint:"hint",isDisabled:"isDisabled",value:"value",autoFocus:"autoFocus"},outputs:{valueChange:"valueChange",enterPressed:"enterPressed"},decls:6,vars:5,consts:[["inputElement",""],[1,"text-input-container"],[1,"text-input-wrapper"],[1,"text-input-label"],["type","text",1,"text-input-field",3,"ngModelChange","keydown.enter","ngModel","placeholder","disabled"],[1,"text-input-hint"]],template:function(e,i){if(e&1){let r=$();h(0,"div",1)(1,"label",2),I(2,y2,2,1,"span",3),h(3,"input",4,0),xe("ngModelChange",function(s){return x(r),Te(i.inputValue,s)||(i.inputValue=s),D(s)}),S("ngModelChange",function(s){return x(r),D(i.onValueChange(s))})("keydown.enter",function(){return x(r),D(i.onEnter())}),p()(),I(5,C2,2,1,"small",5),p()}e&2&&(g(2),k(i.label?2:-1),g(),Se("ngModel",i.inputValue),R("placeholder",i.placeholder)("disabled",i.isDisabled),g(2),k(i.hint?5:-1))},dependencies:[Gt,fn,hn,tn,nt],styles:[".text-input-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;width:100%}.text-input-wrapper[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;width:100%;cursor:text}.text-input-label[_ngcontent-%COMP%]{font-size:.95rem;font-weight:500;color:var(--color-text);margin:0}.text-input-field[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;font-size:1rem;color:var(--color-text);background:var(--color-bg);border:1px solid var(--color-border);border-radius:8px;outline:none;transition:all .2s ease}.text-input-field[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.7}.text-input-field[_ngcontent-%COMP%]:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px rgba(var(--color-primary-rgb),.1)}.text-input-field[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed;background:var(--color-surface)}.text-input-hint[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);margin:0;font-style:italic}@media (max-width: 768px){.text-input-field[_ngcontent-%COMP%]{padding:.65rem .85rem;font-size:.95rem}.text-input-label[_ngcontent-%COMP%]{font-size:.9rem}.text-input-hint[_ngcontent-%COMP%]{font-size:.8rem}}"]})};var w2=["nameInput"],E2=["pathInput"];function S2(n,t){if(n&1&&(h(0,"div",7),b(1),p()),n&2){let e=y();g(),Ee(e.errorMessage)}}var sp=class n{isCreating=!1;create=new V;cancelled=new V;nameInput;pathInput;projectName="";projectPath="";errorMessage="";isValid(){return this.projectName.trim()!==""&&this.projectPath.trim()!==""}onNameEnter(){this.projectName.trim()&&setTimeout(()=>this.pathInput?.focus(),50)}onCreate(){this.isValid()?(this.errorMessage="",this.create.emit({name:this.projectName.trim(),path:this.projectPath.trim()})):this.errorMessage="Both name and path are required"}onCancel(){this.cancelled.emit()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-project-create"]],viewQuery:function(e,i){if(e&1&&(Me(w2,5),Me(E2,5)),e&2){let r;ce(r=de())&&(i.nameInput=r.first),ce(r=de())&&(i.pathInput=r.first)}},inputs:{isCreating:"isCreating"},outputs:{create:"create",cancelled:"cancelled"},decls:14,vars:10,consts:[["nameInput",""],["pathInput",""],[1,"project-create"],[1,"create-title"],[1,"create-form"],["label","Project Name","placeholder","my-project",3,"valueChange","enterPressed","value","isDisabled","autoFocus"],["label","Project Path","placeholder","/path/to/project","hint","Absolute path to the project directory",3,"valueChange","enterPressed","value","isDisabled","autoFocus"],[1,"error-message"],[1,"form-actions"],[1,"cancel-btn",3,"click","disabled"],[1,"create-btn",3,"click","disabled"]],template:function(e,i){if(e&1){let r=$();h(0,"div",2)(1,"h3",3),b(2,"Create New Project"),p(),h(3,"div",4)(4,"app-text-input",5,0),S("valueChange",function(s){return x(r),D(i.projectName=s)})("enterPressed",function(){return x(r),D(i.onNameEnter())}),p(),h(6,"app-text-input",6,1),S("valueChange",function(s){return x(r),D(i.projectPath=s)})("enterPressed",function(){return x(r),D(i.onCreate())}),p(),I(8,S2,2,1,"div",7),p(),h(9,"div",8)(10,"button",9),S("click",function(){return x(r),D(i.onCancel())}),b(11,"Cancel"),p(),h(12,"button",10),S("click",function(){return x(r),D(i.onCreate())}),b(13),p()()()}e&2&&(g(4),R("value",i.projectName)("isDisabled",i.isCreating)("autoFocus",!0),g(2),R("value",i.projectPath)("isDisabled",i.isCreating)("autoFocus",!1),g(2),k(i.errorMessage?8:-1),g(2),R("disabled",i.isCreating),g(2),R("disabled",!i.isValid()||i.isCreating),g(),Ae(" ",i.isCreating?"Creating...":"Create Project"," "))},dependencies:[nt,op],styles:[".project-create[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1rem;animation:_ngcontent-%COMP%_slideIn .3s ease-out}.create-title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text);text-align:center}.create-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.error-message[_ngcontent-%COMP%]{padding:.75rem 1rem;background:#dc26261a;border:1px solid rgba(220,38,38,.3);border-radius:8px;color:var(--color-error);font-size:.9rem;text-align:center}.form-actions[_ngcontent-%COMP%]{display:flex;gap:1rem;justify-content:flex-end;margin-top:.5rem}.cancel-btn[_ngcontent-%COMP%], .create-btn[_ngcontent-%COMP%]{padding:.75rem 1.5rem;font-size:1rem;font-weight:500;border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.cancel-btn[_ngcontent-%COMP%]:disabled, .create-btn[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.cancel-btn[_ngcontent-%COMP%]{background:var(--color-surface);color:var(--color-text);border:1px solid var(--color-border)}.cancel-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.create-btn[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff}.create-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover);transform:translateY(-1px);box-shadow:0 4px 8px #00000026}.create-btn[_ngcontent-%COMP%]:active:not(:disabled){transform:translateY(0)}@keyframes _ngcontent-%COMP%_slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@media (max-width: 768px){.project-create[_ngcontent-%COMP%]{gap:1.25rem;padding:.75rem}.create-title[_ngcontent-%COMP%]{font-size:1.3rem}.form-actions[_ngcontent-%COMP%]{flex-direction:column-reverse;gap:.75rem}.form-actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{width:100%}}@media (max-width: 480px){.project-create[_ngcontent-%COMP%]{gap:1rem;padding:.5rem}.create-title[_ngcontent-%COMP%]{font-size:1.2rem}.cancel-btn[_ngcontent-%COMP%], .create-btn[_ngcontent-%COMP%]{padding:.65rem 1.25rem;font-size:.95rem}}"]})};function x2(n,t){if(n&1){let e=$();h(0,"app-project-create",9),S("create",function(r){x(e);let o=y();return D(o.onCreateProject(r))})("cancelled",function(){x(e);let r=y();return D(r.closeCreateForm())}),p()}if(n&2){let e=y();R("isCreating",e.isCreating)}}function D2(n,t){n&1&&(h(0,"div",6),U(1,"div",10),h(2,"p",11),b(3,"Loading projects..."),p()())}function M2(n,t){if(n&1&&(h(0,"div",7)(1,"p",12),b(2),p()()),n&2){let e=y();g(2),Ee(e.error)}}function T2(n,t){if(n&1){let e=$();h(0,"div",14)(1,"button",15),S("click",function(){x(e);let r=y(2);return D(r.openCreateForm())}),b(2,"\u2795 Create New Project"),p()()}}function I2(n,t){if(n&1){let e=$();h(0,"app-choice-select",13),S("choiceSelected",function(r){x(e);let o=y();return D(o.selectProject(r))}),p(),I(1,T2,3,0,"div",14)}if(n&2){let e=y();R("options",e.projectOptions())("labelHtml","Select a project to continue")("isVisible",!0),g(),k(e.showCreateButton()?1:-1)}}function k2(n,t){if(n&1){let e=$();h(0,"div",8)(1,"p",16),b(2,"No projects available."),p(),h(3,"button",15),S("click",function(){x(e);let r=y();return D(r.openCreateForm())}),b(4,"\u2795 Create Your First Project"),p()()}}var ap=class n{isLoading=!1;error=null;showCreateForm=!1;isCreating=!1;router=u(Dt);projectStateService=u(vt);projects=en(this.projectStateService.projectList$);forcedProject=en(this.projectStateService.forcedProject$);projectOptions=St(()=>{let t=this.projects();if(!t)return[];let e=t.filter(o=>!o.volatile),i=t.filter(o=>o.volatile);return[...e,...i].map(o=>({value:o.name,label:o.volatile?`${o.name} \u{1F538}temp`:o.name}))});showCreateButton=St(()=>!this.forcedProject());constructor(){this.projectStateService.selectedProject$.pipe(jh(),_e(t=>!!t),_e(()=>this.router.url.split("?")[0]==="/"),Ze(1)).subscribe(t=>{console.log(`\u{1F43C} navigate to ${t.name}`),this.router.navigate(["project",t.name])})}selectProject(t){this.projectStateService.selectProject(t)}openCreateForm(){this.showCreateForm=!0}closeCreateForm(){this.showCreateForm=!1,this.isCreating=!1}onCreateProject(t){this.isCreating=!0,this.error=null,this.projectStateService.createProject(t.name,t.path).subscribe({next:e=>{console.log("[PROJECT-SELECTION] Project created:",e.message),this.isCreating=!1,this.closeCreateForm(),this.selectProject(t.name)},error:e=>{console.error("[PROJECT-SELECTION] Error creating project:",e),this.error=e.error?.error||"Failed to create project",this.isCreating=!1}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-project-selection"]],decls:11,vars:1,consts:[[1,"project-selection"],[1,"centered-content"],[1,"welcome-section"],[1,"choice-section"],[1,"choice-glass"],[3,"isCreating"],[1,"loading-container"],[1,"error-container"],[1,"no-projects-container"],[3,"create","cancelled","isCreating"],[1,"loading-spinner"],[1,"loading-text"],[1,"error-text"],[3,"choiceSelected","options","labelHtml","isVisible"],[1,"create-action"],[1,"create-project-btn",3,"click"],[1,"no-projects-text"]],template:function(e,i){e&1&&(h(0,"div",0)(1,"div",1)(2,"div",2),U(3,"app-welcome-message"),p(),h(4,"div",3)(5,"div",4),I(6,x2,1,1,"app-project-create",5)(7,D2,4,0,"div",6)(8,M2,3,1,"div",7)(9,I2,2,4)(10,k2,5,0,"div",8),p()()()()),e&2&&(g(6),k(i.showCreateForm?6:i.isLoading?7:i.error?8:i.projects()&&i.projects().length>0?9:10))},dependencies:[nt,ba,ya,sp],styles:[".project-selection[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:100vh;width:100%;overflow:hidden;background:var(--color-bg);padding:2rem}.centered-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3rem;width:100%;max-width:800px;animation:_ngcontent-%COMP%_fadeIn .6s ease-out}.welcome-section[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_slideUp .8s ease-out}.choice-section[_ngcontent-%COMP%]{width:100%;animation:_ngcontent-%COMP%_slideUp .8s ease-out .2s both}.choice-glass[_ngcontent-%COMP%]{background:var(--color-surface);border:1px solid var(--color-border);border-radius:12px;padding:1.5rem;box-shadow:0 4px 6px #0000001a;transition:all .3s ease}.choice-glass[_ngcontent-%COMP%]:hover{box-shadow:0 8px 12px #00000026}.loading-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:1rem;padding:2rem}.loading-spinner[_ngcontent-%COMP%]{width:40px;height:40px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin 1s linear infinite}.loading-text[_ngcontent-%COMP%]{color:var(--color-text-secondary);margin:0}.error-container[_ngcontent-%COMP%]{padding:2rem;text-align:center}.error-text[_ngcontent-%COMP%]{color:var(--color-error);margin:0}.no-projects-container[_ngcontent-%COMP%]{padding:2rem;text-align:center}.no-projects-text[_ngcontent-%COMP%]{color:var(--color-text);margin:0 0 .5rem;font-size:1.1rem}.no-projects-hint[_ngcontent-%COMP%]{color:var(--color-text-secondary);margin:0;font-size:.9rem}.create-action[_ngcontent-%COMP%]{margin-top:1.5rem;padding-top:1.5rem;border-top:1px solid var(--color-border);display:flex;justify-content:center}.create-project-btn[_ngcontent-%COMP%]{padding:.75rem 1.5rem;font-size:1rem;font-weight:500;color:var(--color-primary);background:transparent;border:2px solid var(--color-primary);border-radius:8px;cursor:pointer;transition:all .3s ease}.create-project-btn[_ngcontent-%COMP%]:hover{background:var(--color-primary);color:#fff;transform:translateY(-2px);box-shadow:0 4px 12px #00000026}.create-project-btn[_ngcontent-%COMP%]:active{transform:translateY(0)}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0}to{opacity:1}}@keyframes _ngcontent-%COMP%_slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}@media (max-width: 768px){.project-selection[_ngcontent-%COMP%]{padding:1.5rem}.centered-content[_ngcontent-%COMP%]{gap:2rem}.choice-glass[_ngcontent-%COMP%]{padding:1rem}}@media (max-width: 480px){.project-selection[_ngcontent-%COMP%]{padding:1rem}.centered-content[_ngcontent-%COMP%]{gap:1.5rem}.choice-glass[_ngcontent-%COMP%]{padding:.75rem}.create-action[_ngcontent-%COMP%]{margin-top:1rem;padding-top:1rem}.create-project-btn[_ngcontent-%COMP%]{width:100%;padding:.65rem 1.25rem;font-size:.95rem}}"]})};var _t=class n{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new q("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();enterToSendSubject=new q(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new q(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new q("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new q(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new q(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new q(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new q(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new q(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new q(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new q(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();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 t=this.getPreferenceSync("voiceLanguage","en-US")??"en-US";this.voiceLanguageSubject.next(t),console.log("[PREFERENCES] Voice language initialized to:",t);let e=this.getPreferenceSync("useEnterToSend",!0)??!0;this.enterToSendSubject.next(e),console.log("[PREFERENCES] Enter to send initialized to:",e);let i=this.getPreferenceSync("voiceAnnounceEnabled",!1)??!1;this.voiceAnnounceEnabledSubject.next(i);let r=this.getPreferenceSync("voiceMode","speech")??"speech";this.voiceModeSubject.next(r);let o=this.getPreferenceSync("voiceReadFullText",!1)??!1;this.voiceReadFullTextSubject.next(o);let s=this.getPreferenceSync("voiceVolume",.8)??.8;this.voiceVolumeSubject.next(s);let a=this.getPreferenceSync("voiceRate",1.2)??1.2;this.voiceRateSubject.next(a);let l=this.getPreferenceSync("selectedVoice",null)??null;this.selectedVoiceSubject.next(l);let c=this.getPreferenceSync("printTechnicalMessages",!1)??!1;this.printTechnicalMessagesSubject.next(c);let d=this.getPreferenceSync("hideTechnicalMessages",!0)??!0;this.hideTechnicalMessagesSubject.next(d);let f=this.getPreferenceSync("hideWarningMessages",!1)??!1;this.hideWarningMessagesSubject.next(f),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return ue(this,null,function*(){let t=(yield this.getPreferenceAsync("voiceLanguage","en-US"))??"en-US";this.voiceLanguageSubject.next(t),console.log("[PREFERENCES] Voice language initialized to:",t);let e=(yield this.getPreferenceAsync("useEnterToSend",!0))??!0;this.enterToSendSubject.next(e),console.log("[PREFERENCES] Enter to send initialized to:",e);let i=(yield this.getPreferenceAsync("voiceAnnounceEnabled",!1))??!1;this.voiceAnnounceEnabledSubject.next(i);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 s=(yield this.getPreferenceAsync("voiceVolume",.8))??.8;this.voiceVolumeSubject.next(s);let a=(yield this.getPreferenceAsync("voiceRate",1.2))??1.2;this.voiceRateSubject.next(a);let l=(yield this.getPreferenceAsync("selectedVoice",null))??null;this.selectedVoiceSubject.next(l);let c=(yield this.getPreferenceAsync("printTechnicalMessages",!1))??!1;this.printTechnicalMessagesSubject.next(c);let d=(yield this.getPreferenceAsync("hideTechnicalMessages",!0))??!0;this.hideTechnicalMessagesSubject.next(d);let f=(yield this.getPreferenceAsync("hideWarningMessages",!1))??!1;this.hideWarningMessagesSubject.next(f),console.log("[PREFERENCES] All preferences initialized successfully (async)")})}getPreference(t,e){return this.getPreferenceSync(t,e)}getPreferenceSync(t,e){try{let i=localStorage.getItem(this.STORAGE_KEY);if(!i)return e;let r=JSON.parse(i);return r[t]!==void 0?r[t]:e}catch{return e}}getPreferenceAsync(t,e){return ue(this,null,function*(){if(!this.electronStorage)return this.getPreferenceSync(t,e);try{let i=yield this.electronStorage.get(this.STORAGE_KEY);if(!i)return e;let r=JSON.parse(i);return r[t]!==void 0?r[t]:e}catch{return e}})}setPreference(t,e){this.isDesktopApp?this.setPreferenceAsync(t,e):this.setPreferenceSync(t,e)}setPreferenceSync(t,e){try{let i=localStorage.getItem(this.STORAGE_KEY),r=i?JSON.parse(i):{};r[t]=e,localStorage.setItem(this.STORAGE_KEY,JSON.stringify(r)),this.updateSubject(t,e)}catch(i){console.error("Failed to set preference:",i)}}setPreferenceAsync(t,e){return ue(this,null,function*(){if(!this.electronStorage){this.setPreferenceSync(t,e);return}try{let i=yield this.electronStorage.get(this.STORAGE_KEY),r=i?JSON.parse(i):{};r[t]=e,yield this.electronStorage.set(this.STORAGE_KEY,JSON.stringify(r)),this.updateSubject(t,e)}catch(i){console.error("Failed to set preference:",i)}})}updateSubject(t,e){t==="voiceLanguage"&&this.voiceLanguageSubject.next(e),t==="useEnterToSend"&&this.enterToSendSubject.next(e),t==="voiceAnnounceEnabled"&&this.voiceAnnounceEnabledSubject.next(e),t==="voiceMode"&&this.voiceModeSubject.next(e),t==="voiceReadFullText"&&this.voiceReadFullTextSubject.next(e),t==="voiceVolume"&&this.voiceVolumeSubject.next(e),t==="voiceRate"&&this.voiceRateSubject.next(e),t==="selectedVoice"&&this.selectedVoiceSubject.next(e),t==="printTechnicalMessages"&&this.printTechnicalMessagesSubject.next(e),t==="hideTechnicalMessages"&&this.hideTechnicalMessagesSubject.next(e),t==="hideWarningMessages"&&this.hideWarningMessagesSubject.next(e)}setVoiceLanguage(t){console.log("[PREFERENCES] Setting voice language to:",t),this.setPreference("voiceLanguage",t)}getVoiceLanguage(){return this.getPreference("voiceLanguage","en-US")??"en-US"}setEnterToSend(t){console.log("[PREFERENCES] Setting Enter to send to:",t),this.setPreference("useEnterToSend",t)}getEnterToSend(){return this.getPreference("useEnterToSend",!1)??!1}setVoiceAnnounceEnabled(t){console.log("[PREFERENCES] Setting voice announce enabled to:",t),this.setPreference("voiceAnnounceEnabled",t)}getVoiceAnnounceEnabled(){return this.getPreference("voiceAnnounceEnabled",!1)??!1}setVoiceMode(t){console.log("[PREFERENCES] Setting voice mode to:",t),this.setPreference("voiceMode",t)}getVoiceMode(){return this.getPreference("voiceMode","speech")??"speech"}setVoiceReadFullText(t){console.log("[PREFERENCES] Setting voice read full text to:",t),this.setPreference("voiceReadFullText",t)}getVoiceReadFullText(){return this.getPreference("voiceReadFullText",!1)??!1}setVoiceVolume(t){let e=Math.max(0,Math.min(1,t));console.log("[PREFERENCES] Setting voice volume to:",e),this.setPreference("voiceVolume",e)}getVoiceVolume(){return this.getPreference("voiceVolume",.8)??.8}setVoiceRate(t){let e=Math.max(.5,Math.min(2,t));console.log("[PREFERENCES] Setting voice rate to:",e),this.setPreference("voiceRate",e)}getVoiceRate(){return this.getPreference("voiceRate",1.2)??1.2}setSelectedVoice(t){console.log("[PREFERENCES] Setting selected voice to:",t),this.setPreference("selectedVoice",t)}getSelectedVoice(){return this.getPreference("selectedVoice",null)??null}setPrintTechnicalMessages(t){console.log("[PREFERENCES] Setting print technical messages to:",t),this.setPreference("printTechnicalMessages",t)}getPrintTechnicalMessages(){return this.getPreference("printTechnicalMessages",!1)??!1}setHideTechnicalMessages(t){console.log("[PREFERENCES] Setting hide technical messages to:",t),this.setPreference("hideTechnicalMessages",t)}getHideTechnicalMessages(){return this.getPreference("hideTechnicalMessages",!0)??!0}setHideWarningMessages(t){console.log("[PREFERENCES] Setting hide warning messages to:",t),this.setPreference("hideWarningMessages",t)}getHideWarningMessages(){return this.getPreference("hideWarningMessages",!1)??!1}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};function Sy(n,t=80){if(n.length<=t)return n;try{if(n.trim().startsWith("{")||n.trim().startsWith("[")){let e=JSON.parse(n),i=JSON.stringify(e);return i.length<=t?i:i.substring(0,t)+`...(${i.length} chars)`}}catch{}return n.substring(0,t)+"..."}var rn=class{constructor(t,e){this.type=e;if(t.timestamp)this.timestamp=t.timestamp;else{let i=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${i}`}this.parentKey=t.parentKey,this.length=0}timestamp;parentKey;static type;length},lp=class extends rn{invite;constructor(t,e){super(t,e),this.invite=t.invite}buildAnswer(t){return new jr({answer:t,parentKey:this.timestamp,invite:this.invite})}},Ca=class n extends rn{static type="heartbeat";constructor(t){super(t,n.type)}},wa=class n extends lp{defaultValue;static type="invite";constructor(t){super(t,n.type),this.defaultValue=t.defaultValue}},xy="InviteEventDefault",jr=class n extends rn{answer;invite;static type="answer";constructor(t){super(t,n.type),this.answer=t.answer??"No answer",this.invite=t.invite}},Ea=class n extends rn{speaker;text;static type="text";constructor(t){super(t,n.type),this.speaker=t.speaker,this.text=t.text}},Sa=class n extends rn{warning;static type="warn";constructor(t){super(t,n.type),this.warning=t.warning}},Xi=class n extends rn{error;static type="error";constructor(t){super(t,n.type),this.error=t.error}},xa=class n extends lp{options;optionalQuestion;static type="choice";constructor(t){super(t,n.type),this.options=t.options,this.optionalQuestion=t.optionalQuestion}},Da=class n extends rn{toolRequestId;name;args;static type="tool_request";constructor(t){super(t,n.type),this.toolRequestId=t.toolRequestId??this.timestamp,this.name=t.name,this.args=t.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(t){return new zo({output:t,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(t=50){let e=Sy(this.args,t);return`\u{1F527} ${this.name}(${e})`}},zo=class n extends rn{toolRequestId;output;static type="tool_response";constructor(t){if(super(t,n.type),this.toolRequestId=t.toolRequestId||this.timestamp||new Date().toISOString(),this.output=t.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 e=(this.output.width??0)*(this.output.height??0)/750;this.length=(e?e*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(t=50){let e=this.getTextOutput(),i=Sy(e,t),r=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${i}${r}`}},Uo=class n extends rn{static type="thinking";static debounce=5e3;constructor(t){super(t,n.type)}},cp=class n extends rn{summary;static type="summary";constructor(t){super(t,n.type),this.summary=t.summary,this.length=this.summary.length}toSingleLineString(t=80){return`\u{1F4CB} Summary: ${Sy(this.summary,t)}`}},Ma=class n extends rn{role;name;content;static type="message";constructor(t){super(t,n.type),this.role=t.role,this.name=t.name,this.content=t.content,this.length=this.content.map(e=>{if(e.type==="text")return e.content.length;if(e.type==="image"){let i=(e.width||0)*(e.height||0)/750;return i?i*3.5:e.content.length}return 0}).reduce((e,i)=>e+i,0)}getTextContent(){return this.content.filter(t=>t.type==="text").map(t=>t.content).join(`
|
|
77
77
|
`)}},Ta=class n extends rn{threadId;name;static type="thread_update";constructor(t){super(t,n.type),this.threadId=t.threadId,this.name=t.name}},Ia=class n extends rn{filename;operation;size;mimeType;static type="file";constructor(t){super(t,n.type),this.filename=t.filename,this.operation=t.operation,this.size=t.size,this.mimeType=t.mimeType}toSingleLineString(){let t=this.operation==="created"?"\u{1F4C4}":this.operation==="updated"?"\u{1F4DD}":"\u{1F5D1}\uFE0F",e=this.size?` (${(this.size/1024).toFixed(1)} KB)`:"";return`${t} ${this.operation}: ${this.filename}${e}`}},A2={[Ma.type]:Ma,[jr.type]:jr,[xa.type]:xa,[Xi.type]:Xi,[Ca.type]:Ca,[wa.type]:wa,[Da.type]:Da,[zo.type]:zo,[Ea.type]:Ea,[Uo.type]:Uo,[Sa.type]:Sa,[Ta.type]:Ta,[cp.type]:cp,[Ia.type]:Ia};function DT(n){let t=A2[n.type];return t?new t(n):void 0}var ka=class n{eventSource=null;eventsSubject=new F;connectionStatusSubject=new q({connected:!1,reconnectAttempts:0,maxAttempts:3});reconnectAttempts=0;MAX_RECONNECT_ATTEMPTS=3;RECONNECT_DELAY=2e3;events$=this.eventsSubject.asObservable();connectionStatus$=this.connectionStatusSubject.asObservable();ngZone=u(B);connectToThread(t,e){console.log("[SSE] Connecting to thread event stream:",t,e),this.eventSource&&(console.log("[SSE] Closing existing EventSource"),this.eventSource.close());let i=`/api/projects/${t}/threads/${e}/event-stream`;console.log("[SSE] EventSource URL:",i),this.eventSource=new EventSource(i),this.setupEventHandlers()}setupEventHandlers(){this.eventSource&&(this.eventSource.onmessage=t=>{this.ngZone.run(()=>{console.log("[SSE] Message received:",t.data.substring(0,100)),this.reconnectAttempts=0,this.updateConnectionStatus(!0,0);try{let e=JSON.parse(t.data),i=DT(e);i?(console.log("[SSE] Event:",i.type),this.eventsSubject.next(i)):console.warn("[SSE] Failed to build event:",e.type)}catch(e){console.error("[SSE] Parse error:",e.message)}})},this.eventSource.onopen=()=>{this.ngZone.run(()=>{console.log("[SSE] Connection established"),this.reconnectAttempts=0,this.updateConnectionStatus(!0,0)})},this.eventSource.onerror=t=>{this.ngZone.run(()=>{console.log("[SSE] EventSource error:",t),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 Xi({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 Xi({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(t,e){this.connectionStatusSubject.next({connected:t,reconnectAttempts:e,maxAttempts:this.MAX_RECONNECT_ATTEMPTS})}ngOnDestroy(){this.disconnect(),this.eventsSubject.complete(),this.connectionStatusSubject.complete()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var dp=class n{http=u(gt);getMessages(t,e){return this.http.get(`/api/projects/${t}/threads/${e}/messages`)}sendMessage(t,e,i){return this.http.post(`/api/projects/${t}/threads/${e}/messages`,i,{responseType:"text"})}getMessage(t,e,i){return this.http.get(`/api/projects/${t}/threads/${e}/messages/${encodeURIComponent(i)}`)}deleteMessage(t,e,i){return this.http.delete(`/api/projects/${t}/threads/${e}/messages/${encodeURIComponent(i)}`)}getFormattedMessage(t,e,i){return this.http.get(`/api/projects/${t}/threads/${e}/messages/${encodeURIComponent(i)}/formatted`,{responseType:"text"})}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var Vr=class n{http=u(gt);getBaseUrl(t){return`/api/projects/${t}/threads`}listThreads(t){return this.http.get(this.getBaseUrl(t))}getThread(t,e){return this.http.get(`${this.getBaseUrl(t)}/${e}`)}createThread(t,e){let i=e?{name:e}:{};return this.http.post(this.getBaseUrl(t),i)}updateThread(t,e,i){return this.http.put(`${this.getBaseUrl(t)}/${e}`,{name:i})}starThread(t,e){return this.http.post(`${this.getBaseUrl(t)}/${e}/star`,{})}unstarThread(t,e){return this.http.delete(`${this.getBaseUrl(t)}/${e}/star`)}deleteThread(t,e){return this.http.delete(`${this.getBaseUrl(t)}/${e}`)}stopThread(t,e){return this.http.post(`${this.getBaseUrl(t)}/${e}/stop`,{})}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var pn=class n{selectedThreadIdSubject=new q(null);isLoadingSubject=new q(!1);isLoadingThreadListSubject=new q(!1);refreshThreadListSubject=new F;threadListSubject=new q([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=u(Vr);projectStateService=u(vt);projectName$=this.projectStateService.selectedProject$.pipe(j(t=>t?.name),sr());constructor(){Ht([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(an(void 0))]).pipe(be(([t])=>{t!==this.currentProjectName&&(console.log("[THREAD_STATE] Project changed, clearing thread list"),this.threadListSubject.next([]),this.currentProjectName=t),t?this.hasLoadedOncePerProject.get(t)?console.log("[THREAD_STATE] Refreshing thread list for project",t,"(no spinner)"):(console.log("[THREAD_STATE] Initial load for project",t,"- showing spinner"),this.isLoadingThreadListSubject.next(!0)):(console.log("[THREAD_STATE] No project selected, hiding spinner"),this.isLoadingThreadListSubject.next(!1))}),Ke(([t])=>t?(console.log("[THREAD_STATE] Fetching threads for project:",t),this.threadApi.listThreads(t).pipe(j(e=>({threads:e,projectName:t})),zt(e=>(console.error("[THREAD_STATE] Error loading thread list:",e),L({threads:[],projectName:t}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),L({threads:[],projectName:null}))),be(({threads:t,projectName:e})=>{console.log("[THREAD_STATE] Thread list loaded:",t.length,"threads for project",e),e&&this.hasLoadedOncePerProject.set(e,!0),this.isLoadingThreadListSubject.next(!1),this.threadListSubject.next(t)})).subscribe()}threadList$=this.threadListSubject.asObservable();selectedThread$=Ht([this.projectName$,this.selectedThreadIdSubject.pipe(sr())]).pipe(be(([t,e])=>{console.log("\u{1F43C} combineLatest emitted:",{projectName:t,threadId:e})}),Ke(([t,e])=>!t||!e?(console.log("\u{1F43C} null"),L(null)):(console.log("\u{1F43C} loading thread:",e),this.isLoadingSubject.next(!0),this.threadApi.getThread(t,e).pipe(be(i=>{console.log("\u{1F43C} loaded thread:",i?.id)}),si({bufferSize:1,refCount:!0})))),be(()=>{console.log("\u{1F43C} finished loading"),this.isLoadingSubject.next(!1)}));selectThread(t){this.selectedThreadIdSubject.next(t)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let t=this.projectStateService.getSelectedProjectId(),e=this.selectedThreadIdSubject.value;if(!t||!e){console.error("[THREAD_STATE] Cannot stop: no project or thread selected");return}console.log("[THREAD_STATE] Stopping thread:",e,"in project:",t),this.threadApi.stopThread(t,e).subscribe({next:i=>console.log("[THREAD_STATE] Stop signal sent:",i.message),error:i=>console.error("[THREAD_STATE] Error stopping thread:",i)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var ki=class n{destroy$=new F;currentProject=null;currentThread=null;messagesSubject=new q([]);isThinkingSubject=new q(!1);currentChoiceSubject=new q(null);projectTitleSubject=new q("Coday");currentInviteEventSubject=new q(null);messageToRestoreSubject=new q("");threadUpdateEventSubject=new q(null);currentChoiceEvent=null;thinkingTimeout=null;messages$=this.messagesSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();projectTitle$=this.projectTitleSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=u(ka);messageApi=u(dp);projectState=u(vt);threadState=u(pn);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling()}setTabTitleService(t){this.tabTitleService=t}connectToThread(t,e){console.log("[CODAY] Connecting to thread:",t,e),this.currentProject=t,this.currentThread=e,this.eventStream.connectToThread(t,e)}resetMessages(){console.log("[CODAY] Resetting messages for context change"),this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.stopThinking()}sendMessage(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}console.log("[CODAY] Setting thinking state to true (message sent)"),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let e=this.currentInviteEventSubject.value;if(e){let i=e.buildAnswer(t);this.currentInviteEventSubject.next(null),this.messageApi.sendMessage(this.currentProject,this.currentThread,i).subscribe({error:r=>{console.error("[CODAY] Send error:",r),this.stopThinking()}})}else{let i=new jr({answer:t});this.messageApi.sendMessage(this.currentProject,this.currentThread,i).subscribe({error:r=>{console.error("[CODAY] Send error:",r),this.stopThinking()}})}}sendChoice(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){console.log("[CODAY] Setting thinking state to true (choice sent)"),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let e=this.currentChoiceEvent.buildAnswer(t);console.log("[CODAY-CHOICE] Choice sent successfully, clearing UI"),this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(this.currentProject,this.currentThread,e).subscribe({next:()=>{},error:i=>{console.error("[CODAY-CHOICE] Choice error:",i),this.stopThinking()}})}else console.error("[CODAY-CHOICE] No choice event available for choice:",t)}deleteMessage(t){console.log("[CODAY] Deleting message:",t);let e=this.projectState.getSelectedProjectId(),i=this.threadState.getSelectedThreadId();if(!e||!i)throw new Error("Cannot delete message: no project or thread selected");let r=this.messagesSubject.value.find(s=>s.id===t),o=this.extractTextContentFromMessage(r);return this.messageApi.deleteMessage(e,i,t).pipe(be(s=>{s.success?(console.log("[CODAY] Message deleted successfully, updating local messages"),this.removeMessagesFromIndex(t),o.trim()&&(console.log("[CODAY] Restoring deleted message content to textarea"),this.messageToRestoreSubject.next(o))):console.warn("[CODAY] Failed to delete message:",s.error)}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){console.log("[CODAY] Setting thinking state for pending first message"),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive()}initializeEventHandling(){this.eventStream.events$.pipe(H(this.destroy$)).subscribe({next:t=>this.handleEvent(t),error:t=>console.error("[CODAY] Event stream error:",t),complete:()=>console.log("[CODAY] Event stream completed")})}handleEvent(t){t instanceof Ma?this.handleMessageEvent(t):t instanceof Ea?this.handleTextEvent(t):t instanceof jr?this.handleAnswerEvent(t):t instanceof Xi?this.handleErrorEvent(t):t instanceof Sa?this.handleWarnEvent(t):t instanceof Uo?this.handleThinkingEvent(t):t instanceof Da?this.handleToolRequestEvent(t):t instanceof zo?this.handleToolResponseEvent(t):t instanceof xa?this.handleChoiceEvent(t):t instanceof Ca?this.handleHeartBeatEvent(t):t instanceof wa?this.handleInviteEvent(t):t instanceof Ta?this.handleThreadUpdateEvent(t):console.warn("[CODAY] Unhandled event type:",t.type)}handleThreadUpdateEvent(t){console.log("[CODAY] Thread update event received:",t),this.threadUpdateEventSubject.next(t)}handleMessageEvent(t){let e={id:t.timestamp,role:t.role,speaker:t.name,content:t.content,timestamp:new Date,type:"text"};this.addMessage(e)}handleTextEvent(t){let e={id:t.timestamp,role:t.speaker?"assistant":"system",speaker:t.speaker??"System",content:[{type:"text",content:t.text}],timestamp:new Date,type:t.speaker?"text":"technical"};this.addMessage(e)}handleAnswerEvent(t){let e={id:t.timestamp,role:"user",speaker:"User",content:[{type:"text",content:t.answer}],timestamp:new Date,type:"text"};this.addMessage(e)}handleErrorEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(t.error)}`}],timestamp:new Date,type:"error"};this.addMessage(e)}handleWarnEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Warning: ${JSON.stringify(t.warning)}`}],timestamp:new Date,type:"warning"};this.addMessage(e)}handleThinkingEvent(t){if(this.currentInviteEventSubject.value){console.log("[CODAY] Ignoring ThinkingEvent - active invite waiting for user response");return}if(this.currentChoiceEvent){console.log("[CODAY] Ignoring ThinkingEvent - active choice waiting for user response");return}this.clearThinkingTimeout(),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(!1),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive()},Uo.debounce+1e3)}handleToolRequestEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:t.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:t.timestamp};this.addMessage(e)}handleToolResponseEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:t.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:t.timestamp};this.addMessage(e)}handleChoiceEvent(t){this.stopThinking(),this.currentChoiceEvent=t,this.tabTitleService?.setSystemInactive();let e=t.options.map(r=>({value:r,label:r})),i=t.optionalQuestion?`${t.optionalQuestion} ${t.invite}`:t.invite;this.currentChoiceSubject.next({options:e,label:i})}handleHeartBeatEvent(t){}handleInviteEvent(t){this.stopThinking();let e=this.messagesSubject.value,i=e[e.length-1];if(!(!(t.invite===xy)&&i&&i.role==="assistant"&&i.content.some(s=>s.type==="text"&&s.content.includes(t.invite)))&&t.invite!==xy){let s={id:t.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:t.invite}],timestamp:new Date,type:"text"};this.addMessage(s)}else console.log("[CODAY] Invite already displayed in last message, skipping duplicate");console.log("[CODAY] Setting current invite event"),this.currentInviteEventSubject.next(t),this.tabTitleService?.setSystemInactive()}addMessage(t){let i=[...this.messagesSubject.value,t];this.messagesSubject.next(i)}removeMessagesFromIndex(t){let e=this.messagesSubject.value,i=e.findIndex(o=>o.id===t);if(i===-1){console.warn("[CODAY] Message not found for local deletion:",t);return}if(i===0){console.warn("[CODAY] Cannot delete first message locally");return}let r=e.slice(0,i);console.log(`[CODAY] Locally removed ${e.length-r.length} messages from index ${i}`),this.messagesSubject.next(r),this.stopThinking()}extractTextContentFromMessage(t){return t?t.content.filter(e=>e.type==="text").map(e=>e.content).join(`
|
|
78
78
|
|
|
79
|
-
`):""}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.eventStream.disconnect()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var O2=["messageInput"];function R2(n,t){n&1&&(h(0,"div",2),U(1,"span",5),b(2," Recording... Release to stop "),p())}function P2(n,t){if(n&1){let e=$();h(0,"button",7),S("click",function(){x(e);let r=y(2);return D(r.onStopClick())}),h(1,"mat-icon"),b(2,"stop"),p()()}}function N2(n,t){if(n&1){let e=$();h(0,"button",8),S("click",function(){x(e);let r=y(2);return D(r.sendMessage())}),h(1,"mat-icon"),b(2,"send"),p()(),h(3,"button",9),S("mousedown",function(r){x(e);let o=y(2);return D(o.onVoiceButtonMouseDown(r))})("mouseup",function(){x(e);let r=y(2);return D(r.onVoiceButtonMouseUp())})("mouseleave",function(){x(e);let r=y(2);return D(r.onVoiceButtonMouseLeave())})("touchstart",function(r){x(e);let o=y(2);return D(o.onVoiceButtonTouchStart(r))})("touchend",function(r){x(e);let o=y(2);return D(o.onVoiceButtonTouchEnd(r))})("keydown",function(r){x(e);let o=y(2);return D(o.onVoiceButtonKeyDown(r))})("keyup",function(r){x(e);let o=y(2);return D(o.onVoiceButtonKeyUp(r))}),h(4,"mat-icon"),b(5),p()()}if(n&2){let e=y(2);W("hidden",e.isDisabled||!e.message.trim()||e.isLocallyDisabled)("active",!!e.message.trim()&&!e.isDisabled&&!e.isLocallyDisabled),R("disabled",e.isDisabled||!e.message.trim()||e.isLocallyDisabled)("title",e.getSendButtonTooltip()),g(3),W("recording",e.isRecording)("hidden",e.message.trim()),g(2),Ee(e.isRecording?"fiber_manual_record":"mic")}}function F2(n,t){if(n&1&&I(0,P2,3,0,"button",6)(1,N2,6,11),n&2){let e=y();k(e.isThinking?0:1)}}var Aa=class n{static MIN_TEXTAREA_LINES=2;static MAX_TEXTAREA_LINES=15;isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;isLocallyDisabled=!1;messageSubmitted=new V;voiceRecordingToggled=new V;heightChanged=new V;stopRequested=new V;messageInput;message="";isRecording=!1;isFocused=!1;recognition=null;sessionHadTranscript=!1;pendingLineBreaksTimeout=null;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;preferencesService=u(_t);codayService=u(ki);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(t=>{this.useEnterToSend=t})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore()}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200)})}ngOnChanges(t){t.isThinking&&(t.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=!1,this.isLocallyDisabled=!1,t.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})))),t.isSessionInitializing&&!t.isSessionInitializing.currentValue&&t.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),this.isLocallyDisabled=!1,requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})),t.isStarting&&!t.isStarting.currentValue&&t.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(t=>t.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation()}onKeyDown(t){t.key==="Enter"&&(this.useEnterToSend?!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),this.sendMessage()):(navigator.platform.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey)&&!t.shiftKey&&(t.preventDefault(),this.sendMessage()))}onInput(){this.adjustTextareaHeight()}sendMessage(){
|
|
79
|
+
`):""}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.eventStream.disconnect()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var O2=["messageInput"];function R2(n,t){n&1&&(h(0,"div",2),U(1,"span",5),b(2," Recording... Release to stop "),p())}function P2(n,t){if(n&1){let e=$();h(0,"button",7),S("click",function(){x(e);let r=y(2);return D(r.onStopClick())}),h(1,"mat-icon"),b(2,"stop"),p()()}}function N2(n,t){if(n&1){let e=$();h(0,"button",8),S("click",function(){x(e);let r=y(2);return D(r.sendMessage())}),h(1,"mat-icon"),b(2,"send"),p()(),h(3,"button",9),S("mousedown",function(r){x(e);let o=y(2);return D(o.onVoiceButtonMouseDown(r))})("mouseup",function(){x(e);let r=y(2);return D(r.onVoiceButtonMouseUp())})("mouseleave",function(){x(e);let r=y(2);return D(r.onVoiceButtonMouseLeave())})("touchstart",function(r){x(e);let o=y(2);return D(o.onVoiceButtonTouchStart(r))})("touchend",function(r){x(e);let o=y(2);return D(o.onVoiceButtonTouchEnd(r))})("keydown",function(r){x(e);let o=y(2);return D(o.onVoiceButtonKeyDown(r))})("keyup",function(r){x(e);let o=y(2);return D(o.onVoiceButtonKeyUp(r))}),h(4,"mat-icon"),b(5),p()()}if(n&2){let e=y(2);W("hidden",e.isDisabled||!e.message.trim()||e.isLocallyDisabled)("active",!!e.message.trim()&&!e.isDisabled&&!e.isLocallyDisabled),R("disabled",e.isDisabled||!e.message.trim()||e.isLocallyDisabled)("title",e.getSendButtonTooltip()),g(3),W("recording",e.isRecording)("hidden",e.message.trim()),g(2),Ee(e.isRecording?"fiber_manual_record":"mic")}}function F2(n,t){if(n&1&&I(0,P2,3,0,"button",6)(1,N2,6,11),n&2){let e=y();k(e.isThinking?0:1)}}var Aa=class n{static MIN_TEXTAREA_LINES=2;static MAX_TEXTAREA_LINES=15;isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;isLocallyDisabled=!1;messageSubmitted=new V;voiceRecordingToggled=new V;heightChanged=new V;stopRequested=new V;messageInput;message="";isRecording=!1;isFocused=!1;recognition=null;sessionHadTranscript=!1;pendingLineBreaksTimeout=null;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;preferencesService=u(_t);codayService=u(ki);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(t=>{this.useEnterToSend=t})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore()}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200)})}ngOnChanges(t){t.isThinking&&(t.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=!1,this.isLocallyDisabled=!1,t.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})))),t.isSessionInitializing&&!t.isSessionInitializing.currentValue&&t.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),this.isLocallyDisabled=!1,requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})),t.isStarting&&!t.isStarting.currentValue&&t.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(t=>t.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation()}onKeyDown(t){t.key==="Enter"&&(this.useEnterToSend?!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),this.sendMessage(!0)):(navigator.platform.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey)&&!t.shiftKey&&(t.preventDefault(),this.sendMessage(!0)))}onInput(){this.adjustTextareaHeight()}sendMessage(t=!1){let e=this.message.trim();!this.isDisabled&&!this.isLocallyDisabled&&(t||e)&&(this.isLocallyDisabled=!0,this.messageSubmitted.emit(e),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0))}onStopClick(){this.isStopping=!0,this.stopRequested.emit()}onVoiceButtonMouseDown(t){t.preventDefault(),this.startRecording()}onVoiceButtonMouseUp(){this.stopRecording()}onVoiceButtonMouseLeave(){this.stopRecording()}onVoiceButtonTouchStart(t){t.preventDefault(),this.startRecording()}onVoiceButtonTouchEnd(t){t.preventDefault(),this.stopRecording()}onVoiceButtonKeyDown(t){(t.code==="Space"||t.key===" "||t.keyCode===32)&&(t.preventDefault(),this.isRecording||this.startRecording())}onVoiceButtonKeyUp(t){(t.code==="Space"||t.key===" "||t.keyCode===32)&&(t.preventDefault(),this.stopRecording())}initializeVoiceInput(){let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",t),!t){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new t,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{console.log("[SPEECH] Advanced speech recognition parameters not supported")}this.recognition.onresult=e=>{let i="";for(let r=e.resultIndex;r<e.results.length;r++){let o=e.results[r][0].transcript;e.results[r].isFinal&&(i+=o)}if(i){let r=this.improveTranscriptPunctuation(i.trim());this.sessionHadTranscript=!0,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r)}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=!1,this.voiceRecordingToggled.emit(this.isRecording)},this.recognition.onerror=e=>{console.error("[SPEECH] Speech recognition error:",e.error),console.log("[SPEECH] Error details:",{error:e.error,message:e.message,timeStamp:e.timeStamp}),this.isRecording=!1,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 ue(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording")}catch(t){console.error("[SPEECH] Failed to start recording:",t),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(t){console.error("[SPEECH] Failed to stop recording:",t)}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let t=this.getSelectedLanguage();this.recognition.lang=t,console.log("[SPEECH] Language changed to:",t)}}improveTranscriptPunctuation(t){let e=t;return/[.!?]$/.test(e.trim())||(e=e.trim()+"."),e=e.charAt(0).toUpperCase()+e.slice(1),e=e.replace(/\s+/g," "),e=e+" ",e}appendToTextarea(t){let e=this.message;if(this.message=e?`${e}${t}`:t,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let i=this.message.length;this.messageInput.nativeElement.setSelectionRange(i,i)}setTimeout(()=>this.adjustTextareaHeight(),0)}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
80
80
|
|
|
81
|
-
`),this.sessionHadTranscript=!1),this.pendingLineBreaksTimeout=null},500)}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null)}adjustTextareaHeight(){let t=this.messageInput?.nativeElement;if(!t)return;let e=window.getComputedStyle(t),i=parseFloat(e.fontSize),r=parseFloat(e.lineHeight)||i*1.5,o=r*n.MIN_TEXTAREA_LINES+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom),s=r*n.MAX_TEXTAREA_LINES+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom);t.style.height="auto";let a=t.scrollHeight;a<o?a=o:a>s&&(a=s),t.style.height=`${a}px`;let l=t.parentElement?.offsetHeight||a+32;this.heightChanged.emit(l)}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?":this.currentInvite?"Type your message here...":"Type your prompt here"}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(t=>{t?this.handleInviteEvent(t.invite,t.defaultValue):this.currentInvite=""}))}handleInviteEvent(t,e){this.currentInvite=t,e&&(this.message=e,setTimeout(()=>this.adjustTextareaHeight(),0)),this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus()}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(t=>{t.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",t.substring(0,50)+"..."),this.restoreMessageContent(t))}))}restoreMessageContent(t){this.message=t,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let e=this.messageInput.nativeElement,i=this.message.length;e.setSelectionRange(i,i)},0)),setTimeout(()=>this.adjustTextareaHeight(),10)}focusTextarea(){let t=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!t,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:t?.disabled,isSessionInitializing:this.isSessionInitializing}),t&&!t.disabled?(t.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available")}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-chat-textarea"]],viewQuery:function(e,i){if(e&1&&Me(O2,7),e&2){let r;ce(r=de())&&(i.messageInput=r.first)}},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{messageSubmitted:"messageSubmitted",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested"},features:[qe],decls:6,vars:11,consts:[["messageInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"recording-dot"],["mat-icon-button","","title","Stop generation","type","button",1,"stop-btn"],["mat-icon-button","","title","Stop generation","type","button",1,"stop-btn",3,"click"],["mat-icon-button","","type","button",1,"send-btn",3,"click","disabled","title"],["mat-icon-button","","tabindex","0","title","Hold mouse click, touch, or spacebar to speak",1,"voice-btn",3,"mousedown","mouseup","mouseleave","touchstart","touchend","keydown","keyup"]],template:function(e,i){if(e&1){let r=$();h(0,"div",1),I(1,R2,3,0,"div",2),h(2,"div",3)(3,"textarea",4,0),xe("ngModelChange",function(s){return x(r),Te(i.message,s)||(i.message=s),D(s)}),S("keydown",function(s){return x(r),D(i.onKeyDown(s))})("input",function(){return x(r),D(i.onInput())})("focus",function(){return x(r),D(i.isFocused=!0)})("blur",function(){return x(r),D(i.isFocused=!1)}),p(),I(5,F2,2,1),p()()}e&2&&(g(),k(i.isRecording?1:-1),g(),W("focused",i.isFocused)("welcome-mode",i.showWelcome)("is-thinking",i.isThinking),g(),Se("ngModel",i.message),R("placeholder",i.getPlaceholder())("disabled",i.isDisabled||i.isThinking||i.isLocallyDisabled),g(2),k(i.isSessionInitializing?-1:5))},dependencies:[Gt,fn,hn,tn,Cn,kt],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:center;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%);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;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%] .stop-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.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;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%], .stop-btn[_ngcontent-%COMP%]{margin:0 .5rem 0 .08rem}.voice-btn[_ngcontent-%COMP%]:hover:not(.recording), .send-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.voice-btn.recording[_ngcontent-%COMP%]{background:#ff3b3024;color:var(--color-error)}.send-btn[_ngcontent-%COMP%]{background:var(--color-primary)}.stop-btn[_ngcontent-%COMP%]{transition:background .18s,transform .12s}.stop-btn[_ngcontent-%COMP%]:hover{opacity:.85;transform:scale(1.05)}.stop-btn[_ngcontent-%COMP%]:active{transform:scale(.95)}.voice-btn[_ngcontent-%COMP%]{transition:background .18s,box-shadow .18s,transform .12s,opacity .5s;position:relative}.voice-btn.recording[_ngcontent-%COMP%]{background:#ff3b3012;color:var(--color-error);animation:_ngcontent-%COMP%_pulse 1.5s infinite}.voice-btn.recording[_ngcontent-%COMP%]:hover{background:#ff3b301c}.send-btn[_ngcontent-%COMP%]{transition:background .18s,box-shadow .18s,transform .12s,opacity .4s,margin-left .4s;position:relative}.send-btn.active[_ngcontent-%COMP%]{background:transparent;opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active){color:var(--color-secondary);background:transparent;opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_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:_ngcontent-%COMP%_sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_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}}@keyframes _ngcontent-%COMP%_sendButtonGradientShift{0%{background-position:0% center}50%{background-position:50% 10%}to{background-position:0% center}}@media print{.thinking-progress[_ngcontent-%COMP%], .stop-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%]{display:none!important}}']})};var L2=(n,t)=>t.label;function j2(n,t){if(n&1){let e=$();h(0,"button",2),S("click",function(r){let o=x(e).$implicit,s=y();return D(s.executeAction(o,r))}),h(1,"mat-icon"),b(2),p()()}if(n&2){let e=t.$implicit;Ce("title",e.tooltip||e.label),g(),Ce("aria-label",e.label),g(),Ee(e.icon)}}var up=class n{actions=[];executeAction(t,e){e.stopPropagation(),t.action()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,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(e,i){e&1&&(h(0,"div",0),wt(1,j2,3,3,"button",1,L2),p()),e&2&&(g(),Et(i.actions))},dependencies:[nt,Cn,kt],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var fp=class n{snackBar=u(sy);success(t,e=2e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-success"]})}error(t,e=3e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-error"]})}info(t,e=2e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-info"]})}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var V2=n=>({"user-message-wrapper":n});function B2(n,t){if(n&1&&(h(0,"div",5)(1,"div",8),b(2),p()()),n&2){let e=y(2);g(2),Ae(" ",e.message.speaker," ")}}function H2(n,t){if(n&1&&(h(0,"div",7),U(1,"app-message-context-menu",9),p()),n&2){let e=y(2);g(),R("actions",e.actions)}}function z2(n,t){if(n&1&&(I(0,B2,3,1,"div",5),U(1,"div",6),I(2,H2,2,1,"div",7)),n&2){let e=y();k(e.shouldShowSpeaker?0:-1),g(),R("innerHTML",e.renderedContent,Ss),g(),k(e.isLongMessage&&e.shouldShowActions&&e.message.role==="assistant"?2:-1)}}function U2(n,t){if(n&1&&(h(0,"a",11),b(1,"view"),p()),n&2){let e=y(2);R("href",e.eventLink,go)}}function $2(n,t){if(n&1&&(h(0,"div",2),U(1,"span",10),I(2,U2,2,1,"a",11),p()),n&2){let e=y();g(),R("innerHTML",e.renderedContent,Ss),g(),k(e.eventLink?2:-1)}}function W2(n,t){if(n&1&&(h(0,"div",3),U(1,"app-message-context-menu",9),p()),n&2){let e=y();g(),R("actions",e.actions)}}function G2(n,t){if(n&1&&(h(0,"div",4),U(1,"app-message-context-menu",9),p()),n&2){let e=y();g(),R("actions",e.actions)}}var hp=class n{destroy$=new F;message;canDelete=!0;copyRequested=new V;deleteRequested=new V;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=u(Co);notificationService=u(fp);preferencesService=u(_t);projectState=u(vt);threadState=u(pn);markdownService=u(_a);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"}}ngOnInit(){return ue(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(H(this.destroy$)).subscribe(t=>{this.shouldHideTechnical=t}),this.preferencesService.hideWarningMessages$.pipe(H(this.destroy$)).subscribe(t=>{this.shouldHideWarning=t}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}get shouldShowSpeaker(){return!1}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}get isLongMessage(){let t=this.extractTextContent();return t.length>1e3||t.split(`
|
|
81
|
+
`),this.sessionHadTranscript=!1),this.pendingLineBreaksTimeout=null},500)}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null)}adjustTextareaHeight(){let t=this.messageInput?.nativeElement;if(!t)return;let e=window.getComputedStyle(t),i=parseFloat(e.fontSize),r=parseFloat(e.lineHeight)||i*1.5,o=r*n.MIN_TEXTAREA_LINES+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom),s=r*n.MAX_TEXTAREA_LINES+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom);t.style.height="auto";let a=t.scrollHeight;a<o?a=o:a>s&&(a=s),t.style.height=`${a}px`;let l=t.parentElement?.offsetHeight??a+32;this.heightChanged.emit(l)}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?":this.currentInvite?"Type your message here...":"Type your prompt here"}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(t=>{t?this.handleInviteEvent(t.invite,t.defaultValue):this.currentInvite=""}))}handleInviteEvent(t,e){this.currentInvite=t,e&&(this.message=e,setTimeout(()=>this.adjustTextareaHeight(),0)),this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus()}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(t=>{t.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",t.substring(0,50)+"..."),this.restoreMessageContent(t))}))}restoreMessageContent(t){this.message=t,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let e=this.messageInput.nativeElement,i=this.message.length;e.setSelectionRange(i,i)},0)),setTimeout(()=>this.adjustTextareaHeight(),10)}focusTextarea(){let t=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!t,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:t?.disabled,isSessionInitializing:this.isSessionInitializing}),t&&!t.disabled?(t.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available")}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-chat-textarea"]],viewQuery:function(e,i){if(e&1&&Me(O2,7),e&2){let r;ce(r=de())&&(i.messageInput=r.first)}},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{messageSubmitted:"messageSubmitted",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested"},features:[qe],decls:6,vars:11,consts:[["messageInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"recording-dot"],["mat-icon-button","","title","Stop generation","type","button",1,"stop-btn"],["mat-icon-button","","title","Stop generation","type","button",1,"stop-btn",3,"click"],["mat-icon-button","","type","button",1,"send-btn",3,"click","disabled","title"],["mat-icon-button","","tabindex","0","title","Hold mouse click, touch, or spacebar to speak",1,"voice-btn",3,"mousedown","mouseup","mouseleave","touchstart","touchend","keydown","keyup"]],template:function(e,i){if(e&1){let r=$();h(0,"div",1),I(1,R2,3,0,"div",2),h(2,"div",3)(3,"textarea",4,0),xe("ngModelChange",function(s){return x(r),Te(i.message,s)||(i.message=s),D(s)}),S("keydown",function(s){return x(r),D(i.onKeyDown(s))})("input",function(){return x(r),D(i.onInput())})("focus",function(){return x(r),D(i.isFocused=!0)})("blur",function(){return x(r),D(i.isFocused=!1)}),p(),I(5,F2,2,1),p()()}e&2&&(g(),k(i.isRecording?1:-1),g(),W("focused",i.isFocused)("welcome-mode",i.showWelcome)("is-thinking",i.isThinking),g(),Se("ngModel",i.message),R("placeholder",i.getPlaceholder())("disabled",i.isDisabled||i.isThinking||i.isLocallyDisabled),g(2),k(i.isSessionInitializing?-1:5))},dependencies:[Gt,fn,hn,tn,Cn,kt],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:center;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%);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;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%] .stop-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.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;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%], .stop-btn[_ngcontent-%COMP%]{margin:0 .5rem 0 .08rem}.voice-btn[_ngcontent-%COMP%]:hover:not(.recording), .send-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.voice-btn.recording[_ngcontent-%COMP%]{background:#ff3b3024;color:var(--color-error)}.send-btn[_ngcontent-%COMP%]{background:var(--color-primary)}.stop-btn[_ngcontent-%COMP%]{transition:background .18s,transform .12s}.stop-btn[_ngcontent-%COMP%]:hover{opacity:.85;transform:scale(1.05)}.stop-btn[_ngcontent-%COMP%]:active{transform:scale(.95)}.voice-btn[_ngcontent-%COMP%]{transition:background .18s,box-shadow .18s,transform .12s,opacity .5s;position:relative}.voice-btn.recording[_ngcontent-%COMP%]{background:#ff3b3012;color:var(--color-error);animation:_ngcontent-%COMP%_pulse 1.5s infinite}.voice-btn.recording[_ngcontent-%COMP%]:hover{background:#ff3b301c}.send-btn[_ngcontent-%COMP%]{transition:background .18s,box-shadow .18s,transform .12s,opacity .4s,margin-left .4s;position:relative}.send-btn.active[_ngcontent-%COMP%]{background:transparent;opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active){color:var(--color-secondary);background:transparent;opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_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:_ngcontent-%COMP%_sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_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}}@keyframes _ngcontent-%COMP%_sendButtonGradientShift{0%{background-position:0% center}50%{background-position:50% 10%}to{background-position:0% center}}@media print{.thinking-progress[_ngcontent-%COMP%], .stop-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%]{display:none!important}}']})};var L2=(n,t)=>t.label;function j2(n,t){if(n&1){let e=$();h(0,"button",2),S("click",function(r){let o=x(e).$implicit,s=y();return D(s.executeAction(o,r))}),h(1,"mat-icon"),b(2),p()()}if(n&2){let e=t.$implicit;Ce("title",e.tooltip||e.label),g(),Ce("aria-label",e.label),g(),Ee(e.icon)}}var up=class n{actions=[];executeAction(t,e){e.stopPropagation(),t.action()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,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(e,i){e&1&&(h(0,"div",0),wt(1,j2,3,3,"button",1,L2),p()),e&2&&(g(),Et(i.actions))},dependencies:[nt,Cn,kt],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var fp=class n{snackBar=u(sy);success(t,e=2e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-success"]})}error(t,e=3e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-error"]})}info(t,e=2e3){this.snackBar.open(t,"",{duration:e,horizontalPosition:"center",verticalPosition:"bottom",panelClass:["snackbar-info"]})}static \u0275fac=function(e){return new(e||n)};static \u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})};var V2=n=>({"user-message-wrapper":n});function B2(n,t){if(n&1&&(h(0,"div",5)(1,"div",8),b(2),p()()),n&2){let e=y(2);g(2),Ae(" ",e.message.speaker," ")}}function H2(n,t){if(n&1&&(h(0,"div",7),U(1,"app-message-context-menu",9),p()),n&2){let e=y(2);g(),R("actions",e.actions)}}function z2(n,t){if(n&1&&(I(0,B2,3,1,"div",5),U(1,"div",6),I(2,H2,2,1,"div",7)),n&2){let e=y();k(e.shouldShowSpeaker?0:-1),g(),R("innerHTML",e.renderedContent,Ss),g(),k(e.isLongMessage&&e.shouldShowActions&&e.message.role==="assistant"?2:-1)}}function U2(n,t){if(n&1&&(h(0,"a",11),b(1,"view"),p()),n&2){let e=y(2);R("href",e.eventLink,go)}}function $2(n,t){if(n&1&&(h(0,"div",2),U(1,"span",10),I(2,U2,2,1,"a",11),p()),n&2){let e=y();g(),R("innerHTML",e.renderedContent,Ss),g(),k(e.eventLink?2:-1)}}function W2(n,t){if(n&1&&(h(0,"div",3),U(1,"app-message-context-menu",9),p()),n&2){let e=y();g(),R("actions",e.actions)}}function G2(n,t){if(n&1&&(h(0,"div",4),U(1,"app-message-context-menu",9),p()),n&2){let e=y();g(),R("actions",e.actions)}}var hp=class n{destroy$=new F;message;canDelete=!0;copyRequested=new V;deleteRequested=new V;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=u(Co);notificationService=u(fp);preferencesService=u(_t);projectState=u(vt);threadState=u(pn);markdownService=u(_a);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"}}ngOnInit(){return ue(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(H(this.destroy$)).subscribe(t=>{this.shouldHideTechnical=t}),this.preferencesService.hideWarningMessages$.pipe(H(this.destroy$)).subscribe(t=>{this.shouldHideWarning=t}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}get shouldShowSpeaker(){return!1}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}get isLongMessage(){let t=this.extractTextContent();return t.length>1e3||t.split(`
|
|
82
82
|
`).length>20}get actions(){let t=[];return this.message.role==="user"&&this.canDelete&&t.push({icon:"delete",label:"Delete from here",tooltip:"Delete this message and all following messages",action:()=>this.onDelete(),destructive:!0}),t.push({icon:"content_copy",label:"Copy message",tooltip:"Copy message content to clipboard",action:()=>this.onCopy()}),t}get eventLink(){if(!this.message.eventId)return null;let t=this.projectState.getSelectedProjectId(),e=this.threadState.getSelectedThreadId();return!t||!e?null:`/api/projects/${t}/threads/${e}/messages/${encodeURIComponent(this.message.eventId)}/formatted`}renderMarkdown(){return ue(this,null,function*(){try{let t=yield this.renderRichContent(this.message.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t)}catch(t){console.error("Error parsing rich content:",t);let e=this.extractTextContent();this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e)}})}renderRichContent(t){return ue(this,null,function*(){let e=[];for(let i of t)if(i.type==="text"){let r=yield this.markdownService.parse(i.content);e.push(`<div class="text-part">${r}</div>`)}else if(i.type==="image"){let r=`data:${i.mimeType};base64,${i.content}`,o=i.source||"Image",s=`
|
|
83
83
|
<div class="image-content">
|
|
84
84
|
<img src="${r}"
|