@whoz-oss/coday-client 0.88.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,5 +13,5 @@
13
13
  <style>:root{--color-bg:linear-gradient(135deg, #fafbfc 0%, #f5f6f8 100%);--color-bg-solid:#fafbfc;--color-bg-secondary:rgba(255, 255, 255, .7);--color-bg-secondary-rgb:255 255 255;--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{color-scheme:light;--mat-sys-background:light-dark(#faf9fd, #121316);--mat-sys-error:light-dark(#ba1a1a, #ffb4ab);--mat-sys-error-container:light-dark(#ffdad6, #93000a);--mat-sys-inverse-on-surface:light-dark(#f2f0f4, #2f3033);--mat-sys-inverse-primary:light-dark(#abc7ff, #005cbb);--mat-sys-inverse-surface:light-dark(#2f3033, #e3e2e6);--mat-sys-on-background:light-dark(#1a1b1f, #e3e2e6);--mat-sys-on-error:light-dark(#ffffff, #690005);--mat-sys-on-error-container:light-dark(#93000a, #ffdad6);--mat-sys-on-primary:light-dark(#ffffff, #002f65);--mat-sys-on-primary-container:light-dark(#00458f, #d7e3ff);--mat-sys-on-primary-fixed:light-dark(#001b3f, #001b3f);--mat-sys-on-primary-fixed-variant:light-dark(#00458f, #00458f);--mat-sys-on-secondary:light-dark(#ffffff, #283041);--mat-sys-on-secondary-container:light-dark(#3e4759, #dae2f9);--mat-sys-on-secondary-fixed:light-dark(#131c2b, #131c2b);--mat-sys-on-secondary-fixed-variant:light-dark(#3e4759, #3e4759);--mat-sys-on-surface:light-dark(#1a1b1f, #e3e2e6);--mat-sys-on-surface-variant:light-dark(#44474e, #e0e2ec);--mat-sys-on-tertiary:light-dark(#ffffff, #002f65);--mat-sys-on-tertiary-container:light-dark(#00458f, #d7e3ff);--mat-sys-on-tertiary-fixed:light-dark(#001b3f, #001b3f);--mat-sys-on-tertiary-fixed-variant:light-dark(#00458f, #00458f);--mat-sys-outline:light-dark(#74777f, #8e9099);--mat-sys-outline-variant:light-dark(#c4c6d0, #44474e);--mat-sys-primary:light-dark(#005cbb, #abc7ff);--mat-sys-primary-container:light-dark(#d7e3ff, #00458f);--mat-sys-primary-fixed:light-dark(#d7e3ff, #d7e3ff);--mat-sys-primary-fixed-dim:light-dark(#abc7ff, #abc7ff);--mat-sys-scrim:light-dark(#000000, #000000);--mat-sys-secondary:light-dark(#565e71, #bec6dc);--mat-sys-secondary-container:light-dark(#dae2f9, #3e4759);--mat-sys-secondary-fixed:light-dark(#dae2f9, #dae2f9);--mat-sys-secondary-fixed-dim:light-dark(#bec6dc, #bec6dc);--mat-sys-shadow:light-dark(#000000, #000000);--mat-sys-surface:light-dark(#faf9fd, #121316);--mat-sys-surface-bright:light-dark(#faf9fd, #38393c);--mat-sys-surface-container:light-dark(#efedf0, #1f2022);--mat-sys-surface-container-high:light-dark(#e9e7eb, #292a2c);--mat-sys-surface-container-highest:light-dark(#e3e2e6, #343537);--mat-sys-surface-container-low:light-dark(#f4f3f6, #1a1b1f);--mat-sys-surface-container-lowest:light-dark(#ffffff, #0d0e11);--mat-sys-surface-dim:light-dark(#dbd9dd, #121316);--mat-sys-surface-tint:light-dark(#005cbb, #abc7ff);--mat-sys-surface-variant:light-dark(#e0e2ec, #44474e);--mat-sys-tertiary:light-dark(#005cbb, #abc7ff);--mat-sys-tertiary-container:light-dark(#d7e3ff, #00458f);--mat-sys-tertiary-fixed:light-dark(#d7e3ff, #d7e3ff);--mat-sys-tertiary-fixed-dim:light-dark(#abc7ff, #abc7ff);--mat-sys-neutral-variant20:#2d3038;--mat-sys-neutral10:#1a1b1f;--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-I3V5BO4R.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles-I3V5BO4R.css"></noscript></head>
14
14
  <body>
15
15
  <app-root></app-root>
16
- <link rel="modulepreload" href="chunk-ODM275WP.js"><link rel="modulepreload" href="chunk-QITHUHCN.js"><link rel="modulepreload" href="chunk-Y5DXUE3H.js"><link rel="modulepreload" href="chunk-GBTE3TIN.js"><link rel="modulepreload" href="chunk-WG23DARU.js"><script src="polyfills-7R4CRVNH.js" type="module"></script><script src="main-2PDLAJ3P.js" type="module"></script></body>
16
+ <link rel="modulepreload" href="chunk-ODM275WP.js"><link rel="modulepreload" href="chunk-QITHUHCN.js"><link rel="modulepreload" href="chunk-Y5DXUE3H.js"><link rel="modulepreload" href="chunk-GBTE3TIN.js"><link rel="modulepreload" href="chunk-WG23DARU.js"><script src="polyfills-7R4CRVNH.js" type="module"></script><script src="main-N5KV5ABJ.js" type="module"></script></body>
17
17
  </html>
@@ -65,7 +65,7 @@ ${o}</tr>
65
65
  `+this.renderer.text(c);e?i+=this.renderer.paragraph({type:"paragraph",raw:h,text:h,tokens:[{type:"text",raw:h,text:h,escaped:!0}]}):i+=h;continue}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}parseInline(t,e=this.renderer){let i="";for(let n=0;n<t.length;n++){let r=t[n];if(this.options.extensions?.renderers?.[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let a=r;switch(a.type){case"escape":{i+=e.text(a);break}case"html":{i+=e.html(a);break}case"link":{i+=e.link(a);break}case"image":{i+=e.image(a);break}case"strong":{i+=e.strong(a);break}case"em":{i+=e.em(a);break}case"codespan":{i+=e.codespan(a);break}case"br":{i+=e.br(a);break}case"del":{i+=e.del(a);break}case"text":{i+=e.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},Xr=class{options;block;constructor(o){this.options=o||ro}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(o){return o}postprocess(o){return o}processAllTokens(o){return o}emStrongMask(o){return o}provideLexer(){return this.block?Ci.lex:Ci.lexInline}provideParser(){return this.block?xi.parse:xi.parseInline}},F_=class{defaults=Bc();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=xi;Renderer=$o;TextRenderer=Qc;Lexer=Ci;Tokenizer=Rs;Hooks=Xr;constructor(...o){this.use(...o)}walkTokens(o,t){let e=[];for(let i of o)switch(e=e.concat(t.call(this,i)),i.type){case"table":{let n=i;for(let r of n.header)e=e.concat(this.walkTokens(r.tokens,t));for(let r of n.rows)for(let a of r)e=e.concat(this.walkTokens(a.tokens,t));break}case"list":{let n=i;e=e.concat(this.walkTokens(n.items,t));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(r=>{let a=n[r].flat(1/0);e=e.concat(this.walkTokens(a,t))}):n.tokens&&(e=e.concat(this.walkTokens(n.tokens,t)))}}return e}use(...o){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return o.forEach(e=>{let i=Z({},e);if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let r=t.renderers[n.name];r?t.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=r.apply(this,a)),c}:t.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[n.level];r?r.unshift(n.tokenizer):t[n.level]=[n.tokenizer],n.start&&(n.level==="block"?t.startBlock?t.startBlock.push(n.start):t.startBlock=[n.start]:n.level==="inline"&&(t.startInline?t.startInline.push(n.start):t.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(t.childTokens[n.name]=n.childTokens)}),i.extensions=t),e.renderer){let n=this.defaults.renderer||new $o(this.defaults);for(let r in e.renderer){if(!(r in n))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let a=r,c=e.renderer[a],h=n[a];n[a]=(...u)=>{let b=c.apply(n,u);return b===!1&&(b=h.apply(n,u)),b||""}}i.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new Rs(this.defaults);for(let r in e.tokenizer){if(!(r in n))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let a=r,c=e.tokenizer[a],h=n[a];n[a]=(...u)=>{let b=c.apply(n,u);return b===!1&&(b=h.apply(n,u)),b}}i.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new Xr;for(let r in e.hooks){if(!(r in n))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let a=r,c=e.hooks[a],h=n[a];Xr.passThroughHooks.has(r)?n[a]=u=>{if(this.defaults.async&&Xr.passThroughHooksRespectAsync.has(r))return ee(this,null,function*(){let x=yield c.call(n,u);return h.call(n,x)});let b=c.call(n,u);return h.call(n,b)}:n[a]=(...u)=>{if(this.defaults.async)return ee(this,null,function*(){let x=yield c.apply(n,u);return x===!1&&(x=yield h.apply(n,u)),x});let b=c.apply(n,u);return b===!1&&(b=h.apply(n,u)),b}}i.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,r=e.walkTokens;i.walkTokens=function(a){let c=[];return c.push(r.call(this,a)),n&&(c=c.concat(n.call(this,a))),c}}this.defaults=Z(Z({},this.defaults),i)}),this}setOptions(o){return this.defaults=Z(Z({},this.defaults),o),this}lexer(o,t){return Ci.lex(o,t??this.defaults)}parser(o,t){return xi.parse(o,t??this.defaults)}parseMarkdown(o){return(t,e)=>{let i=Z({},e),n=Z(Z({},this.defaults),i),r=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=o),n.async)return ee(this,null,function*(){let a=n.hooks?yield n.hooks.preprocess(t):t,c=yield(n.hooks?yield n.hooks.provideLexer():o?Ci.lex:Ci.lexInline)(a,n),h=n.hooks?yield n.hooks.processAllTokens(c):c;n.walkTokens&&(yield Promise.all(this.walkTokens(h,n.walkTokens)));let u=yield(n.hooks?yield n.hooks.provideParser():o?xi.parse:xi.parseInline)(h,n);return n.hooks?yield n.hooks.postprocess(u):u}).catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let a=(n.hooks?n.hooks.provideLexer():o?Ci.lex:Ci.lexInline)(t,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():o?xi.parse:xi.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return r(a)}}}onError(o,t){return e=>{if(e.message+=`
66
66
  Please report this to https://github.com/markedjs/marked.`,o){let i="<p>An error occurred:</p><pre>"+Bi(e.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(e);throw e}}},oo=new F_;function Ee(o,t){return oo.parse(o,t)}Ee.options=Ee.setOptions=function(o){return oo.setOptions(o),Ee.defaults=oo.defaults,yh(Ee.defaults),Ee};Ee.getDefaults=Bc;Ee.defaults=ro;Ee.use=function(...o){return oo.use(...o),Ee.defaults=oo.defaults,yh(Ee.defaults),Ee};Ee.walkTokens=function(o,t){return oo.walkTokens(o,t)};Ee.parseInline=oo.parseInline;Ee.Parser=xi;Ee.parser=xi.parse;Ee.Renderer=$o;Ee.TextRenderer=Qc;Ee.Lexer=Ci;Ee.lexer=Ci.lex;Ee.Tokenizer=Rs;Ee.Hooks=Xr;Ee.parse=Ee;var Yk=Ee.options,Qk=Ee.setOptions,Xk=Ee.use,Kk=Ee.walkTokens,Zk=Ee.parseInline;var Jk=xi.parse,e1=Ci.lex;var{entries:zh,setPrototypeOf:Ah,isFrozen:N_,getPrototypeOf:L_,getOwnPropertyDescriptor:V_}=Object,{freeze:Lt,seal:ri,create:id}=Object,{apply:nd,construct:od}=typeof Reflect<"u"&&Reflect;Lt||(Lt=function(t){return t});ri||(ri=function(t){return t});nd||(nd=function(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return t.apply(e,n)});od||(od=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return new t(...i)});var Ls=Vt(Array.prototype.forEach),z_=Vt(Array.prototype.lastIndexOf),Ih=Vt(Array.prototype.pop),Jr=Vt(Array.prototype.push),j_=Vt(Array.prototype.splice),zs=Vt(String.prototype.toLowerCase),Xc=Vt(String.prototype.toString),Kc=Vt(String.prototype.match),ea=Vt(String.prototype.replace),B_=Vt(String.prototype.indexOf),H_=Vt(String.prototype.trim),wi=Vt(Object.prototype.hasOwnProperty),Nt=Vt(RegExp.prototype.test),ta=W_(TypeError);function Vt(o){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return nd(o,t,i)}}function W_(o){return function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return od(o,e)}}function he(o,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zs;Ah&&Ah(o,null);let i=t.length;for(;i--;){let n=t[i];if(typeof n=="string"){let r=e(n);r!==n&&(N_(t)||(t[i]=r),n=r)}o[n]=!0}return o}function $_(o){for(let t=0;t<o.length;t++)wi(o,t)||(o[t]=null);return o}function Hi(o){let t=id(null);for(let[e,i]of zh(o))wi(o,e)&&(Array.isArray(i)?t[e]=$_(i):i&&typeof i=="object"&&i.constructor===Object?t[e]=Hi(i):t[e]=i);return t}function ia(o,t){for(;o!==null;){let i=V_(o,t);if(i){if(i.get)return Vt(i.get);if(typeof i.value=="function")return Vt(i.value)}o=L_(o)}function e(){return null}return e}var Dh=Lt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Zc=Lt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Jc=Lt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),U_=Lt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ed=Lt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),q_=Lt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rh=Lt(["#text"]),Fh=Lt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),td=Lt(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Nh=Lt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vs=Lt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),G_=ri(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y_=ri(/<%[\w\W]*|[\w\W]*%>/gm),Q_=ri(/\$\{[\w\W]*/gm),X_=ri(/^data-[\-\w.\u00B7-\uFFFF]+$/),K_=ri(/^aria-[\-\w]+$/),jh=ri(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Z_=ri(/^(?:\w+script|data):/i),J_=ri(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Bh=ri(/^html$/i),eb=ri(/^[a-z][.\w]*(-[.\w]+)+$/i),Lh=Object.freeze({__proto__:null,ARIA_ATTR:K_,ATTR_WHITESPACE:J_,CUSTOM_ELEMENT:eb,DATA_ATTR:X_,DOCTYPE_NAME:Bh,ERB_EXPR:Y_,IS_ALLOWED_URI:jh,IS_SCRIPT_OR_DATA:Z_,MUSTACHE_EXPR:G_,TMPLIT_EXPR:Q_}),na={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},tb=function(){return typeof window>"u"?null:window},ib=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(i=e.getAttribute(n));let r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Vh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hh(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:tb(),t=Y=>Hh(Y);if(t.version="3.3.1",t.removed=[],!o||!o.document||o.document.nodeType!==na.document||!o.Element)return t.isSupported=!1,t;let{document:e}=o,i=e,n=i.currentScript,{DocumentFragment:r,HTMLTemplateElement:a,Node:c,Element:h,NodeFilter:u,NamedNodeMap:b=o.NamedNodeMap||o.MozNamedAttrMap,HTMLFormElement:x,DOMParser:E,trustedTypes:R}=o,k=h.prototype,O=ia(k,"cloneNode"),pe=ia(k,"remove"),Ce=ia(k,"nextSibling"),be=ia(k,"childNodes"),Ye=ia(k,"parentNode");if(typeof a=="function"){let Y=e.createElement("template");Y.content&&Y.content.ownerDocument&&(e=Y.content.ownerDocument)}let ue,Ht="",{implementation:dt,createNodeIterator:Qe,createDocumentFragment:Ct,getElementsByTagName:Xi}=e,{importNode:vn}=i,mt=Vh();t.isSupported=typeof zh=="function"&&typeof Ye=="function"&&dt&&dt.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:mi,ERB_EXPR:zn,TMPLIT_EXPR:fo,DATA_ATTR:fa,ARIA_ATTR:$,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:K,CUSTOM_ELEMENT:ge}=Lh,{IS_ALLOWED_URI:tt}=Lh,Pe=null,xt=he({},[...Dh,...Zc,...Jc,...ed,...Rh]),De=null,Re=he({},[...Fh,...td,...Nh,...Vs]),He=Object.seal(id(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),jn=null,nt=null,Wt=Object.seal(id(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Pt=!0,yn=!0,_o=!1,Dd=!0,bo=!1,_a=!0,Bn=!1,Al=!1,Il=!1,vo=!1,ba=!1,va=!1,Rd=!0,Fd=!1,_g="user-content-",Dl=!0,Cr=!1,yo={},Ti=null,Rl=he({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Nd=null,Ld=he({},["audio","video","img","source","image","track"]),Fl=null,Vd=he({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ya="http://www.w3.org/1998/Math/MathML",Ca="http://www.w3.org/2000/svg",Ki="http://www.w3.org/1999/xhtml",Co=Ki,Nl=!1,Ll=null,bg=he({},[ya,Ca,Ki],Xc),xa=he({},["mi","mo","mn","ms","mtext"]),wa=he({},["annotation-xml"]),vg=he({},["title","style","font","a","script"]),xr=null,yg=["application/xhtml+xml","text/html"],Cg="text/html",lt=null,xo=null,xg=e.createElement("form"),zd=function(f){return f instanceof RegExp||f instanceof Function},Vl=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xo&&xo===f)){if((!f||typeof f!="object")&&(f={}),f=Hi(f),xr=yg.indexOf(f.PARSER_MEDIA_TYPE)===-1?Cg:f.PARSER_MEDIA_TYPE,lt=xr==="application/xhtml+xml"?Xc:zs,Pe=wi(f,"ALLOWED_TAGS")?he({},f.ALLOWED_TAGS,lt):xt,De=wi(f,"ALLOWED_ATTR")?he({},f.ALLOWED_ATTR,lt):Re,Ll=wi(f,"ALLOWED_NAMESPACES")?he({},f.ALLOWED_NAMESPACES,Xc):bg,Fl=wi(f,"ADD_URI_SAFE_ATTR")?he(Hi(Vd),f.ADD_URI_SAFE_ATTR,lt):Vd,Nd=wi(f,"ADD_DATA_URI_TAGS")?he(Hi(Ld),f.ADD_DATA_URI_TAGS,lt):Ld,Ti=wi(f,"FORBID_CONTENTS")?he({},f.FORBID_CONTENTS,lt):Rl,jn=wi(f,"FORBID_TAGS")?he({},f.FORBID_TAGS,lt):Hi({}),nt=wi(f,"FORBID_ATTR")?he({},f.FORBID_ATTR,lt):Hi({}),yo=wi(f,"USE_PROFILES")?f.USE_PROFILES:!1,Pt=f.ALLOW_ARIA_ATTR!==!1,yn=f.ALLOW_DATA_ATTR!==!1,_o=f.ALLOW_UNKNOWN_PROTOCOLS||!1,Dd=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,bo=f.SAFE_FOR_TEMPLATES||!1,_a=f.SAFE_FOR_XML!==!1,Bn=f.WHOLE_DOCUMENT||!1,vo=f.RETURN_DOM||!1,ba=f.RETURN_DOM_FRAGMENT||!1,va=f.RETURN_TRUSTED_TYPE||!1,Il=f.FORCE_BODY||!1,Rd=f.SANITIZE_DOM!==!1,Fd=f.SANITIZE_NAMED_PROPS||!1,Dl=f.KEEP_CONTENT!==!1,Cr=f.IN_PLACE||!1,tt=f.ALLOWED_URI_REGEXP||jh,Co=f.NAMESPACE||Ki,xa=f.MATHML_TEXT_INTEGRATION_POINTS||xa,wa=f.HTML_INTEGRATION_POINTS||wa,He=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&zd(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(He.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&zd(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(He.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(He.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),bo&&(yn=!1),ba&&(vo=!0),yo&&(Pe=he({},Rh),De=[],yo.html===!0&&(he(Pe,Dh),he(De,Fh)),yo.svg===!0&&(he(Pe,Zc),he(De,td),he(De,Vs)),yo.svgFilters===!0&&(he(Pe,Jc),he(De,td),he(De,Vs)),yo.mathMl===!0&&(he(Pe,ed),he(De,Nh),he(De,Vs))),f.ADD_TAGS&&(typeof f.ADD_TAGS=="function"?Wt.tagCheck=f.ADD_TAGS:(Pe===xt&&(Pe=Hi(Pe)),he(Pe,f.ADD_TAGS,lt))),f.ADD_ATTR&&(typeof f.ADD_ATTR=="function"?Wt.attributeCheck=f.ADD_ATTR:(De===Re&&(De=Hi(De)),he(De,f.ADD_ATTR,lt))),f.ADD_URI_SAFE_ATTR&&he(Fl,f.ADD_URI_SAFE_ATTR,lt),f.FORBID_CONTENTS&&(Ti===Rl&&(Ti=Hi(Ti)),he(Ti,f.FORBID_CONTENTS,lt)),f.ADD_FORBID_CONTENTS&&(Ti===Rl&&(Ti=Hi(Ti)),he(Ti,f.ADD_FORBID_CONTENTS,lt)),Dl&&(Pe["#text"]=!0),Bn&&he(Pe,["html","head","body"]),Pe.table&&(he(Pe,["tbody"]),delete jn.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw ta('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ta('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ue=f.TRUSTED_TYPES_POLICY,Ht=ue.createHTML("")}else ue===void 0&&(ue=ib(R,n)),ue!==null&&typeof Ht=="string"&&(Ht=ue.createHTML(""));Lt&&Lt(f),xo=f}},jd=he({},[...Zc,...Jc,...U_]),Bd=he({},[...ed,...q_]),wg=function(f){let P=Ye(f);(!P||!P.tagName)&&(P={namespaceURI:Co,tagName:"template"});let U=zs(f.tagName),We=zs(P.tagName);return Ll[f.namespaceURI]?f.namespaceURI===Ca?P.namespaceURI===Ki?U==="svg":P.namespaceURI===ya?U==="svg"&&(We==="annotation-xml"||xa[We]):!!jd[U]:f.namespaceURI===ya?P.namespaceURI===Ki?U==="math":P.namespaceURI===Ca?U==="math"&&wa[We]:!!Bd[U]:f.namespaceURI===Ki?P.namespaceURI===Ca&&!wa[We]||P.namespaceURI===ya&&!xa[We]?!1:!Bd[U]&&(vg[U]||!jd[U]):!!(xr==="application/xhtml+xml"&&Ll[f.namespaceURI]):!1},Ei=function(f){Jr(t.removed,{element:f});try{Ye(f).removeChild(f)}catch{pe(f)}},Hn=function(f,P){try{Jr(t.removed,{attribute:P.getAttributeNode(f),from:P})}catch{Jr(t.removed,{attribute:null,from:P})}if(P.removeAttribute(f),f==="is")if(vo||ba)try{Ei(P)}catch{}else try{P.setAttribute(f,"")}catch{}},Hd=function(f){let P=null,U=null;if(Il)f="<remove></remove>"+f;else{let ot=Kc(f,/^[\r\n\t ]+/);U=ot&&ot[0]}xr==="application/xhtml+xml"&&Co===Ki&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");let We=ue?ue.createHTML(f):f;if(Co===Ki)try{P=new E().parseFromString(We,xr)}catch{}if(!P||!P.documentElement){P=dt.createDocument(Co,"template",null);try{P.documentElement.innerHTML=Nl?Ht:We}catch{}}let wt=P.body||P.documentElement;return f&&U&&wt.insertBefore(e.createTextNode(U),wt.childNodes[0]||null),Co===Ki?Xi.call(P,Bn?"html":"body")[0]:Bn?P.documentElement:wt},Wd=function(f){return Qe.call(f.ownerDocument||f,f,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},zl=function(f){return f instanceof x&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof b)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},$d=function(f){return typeof c=="function"&&f instanceof c};function Zi(Y,f,P){Ls(Y,U=>{U.call(t,f,P,xo)})}let Ud=function(f){let P=null;if(Zi(mt.beforeSanitizeElements,f,null),zl(f))return Ei(f),!0;let U=lt(f.nodeName);if(Zi(mt.uponSanitizeElement,f,{tagName:U,allowedTags:Pe}),_a&&f.hasChildNodes()&&!$d(f.firstElementChild)&&Nt(/<[/\w!]/g,f.innerHTML)&&Nt(/<[/\w!]/g,f.textContent)||f.nodeType===na.progressingInstruction||_a&&f.nodeType===na.comment&&Nt(/<[/\w]/g,f.data))return Ei(f),!0;if(!(Wt.tagCheck instanceof Function&&Wt.tagCheck(U))&&(!Pe[U]||jn[U])){if(!jn[U]&&Gd(U)&&(He.tagNameCheck instanceof RegExp&&Nt(He.tagNameCheck,U)||He.tagNameCheck instanceof Function&&He.tagNameCheck(U)))return!1;if(Dl&&!Ti[U]){let We=Ye(f)||f.parentNode,wt=be(f)||f.childNodes;if(wt&&We){let ot=wt.length;for(let $t=ot-1;$t>=0;--$t){let Ji=O(wt[$t],!0);Ji.__removalCount=(f.__removalCount||0)+1,We.insertBefore(Ji,Ce(f))}}}return Ei(f),!0}return f instanceof h&&!wg(f)||(U==="noscript"||U==="noembed"||U==="noframes")&&Nt(/<\/no(script|embed|frames)/i,f.innerHTML)?(Ei(f),!0):(bo&&f.nodeType===na.text&&(P=f.textContent,Ls([mi,zn,fo],We=>{P=ea(P,We," ")}),f.textContent!==P&&(Jr(t.removed,{element:f.cloneNode()}),f.textContent=P)),Zi(mt.afterSanitizeElements,f,null),!1)},qd=function(f,P,U){if(Rd&&(P==="id"||P==="name")&&(U in e||U in xg))return!1;if(!(yn&&!nt[P]&&Nt(fa,P))){if(!(Pt&&Nt($,P))){if(!(Wt.attributeCheck instanceof Function&&Wt.attributeCheck(P,f))){if(!De[P]||nt[P]){if(!(Gd(f)&&(He.tagNameCheck instanceof RegExp&&Nt(He.tagNameCheck,f)||He.tagNameCheck instanceof Function&&He.tagNameCheck(f))&&(He.attributeNameCheck instanceof RegExp&&Nt(He.attributeNameCheck,P)||He.attributeNameCheck instanceof Function&&He.attributeNameCheck(P,f))||P==="is"&&He.allowCustomizedBuiltInElements&&(He.tagNameCheck instanceof RegExp&&Nt(He.tagNameCheck,U)||He.tagNameCheck instanceof Function&&He.tagNameCheck(U))))return!1}else if(!Fl[P]){if(!Nt(tt,ea(U,K,""))){if(!((P==="src"||P==="xlink:href"||P==="href")&&f!=="script"&&B_(U,"data:")===0&&Nd[f])){if(!(_o&&!Nt(G,ea(U,K,"")))){if(U)return!1}}}}}}}return!0},Gd=function(f){return f!=="annotation-xml"&&Kc(f,ge)},Yd=function(f){Zi(mt.beforeSanitizeAttributes,f,null);let{attributes:P}=f;if(!P||zl(f))return;let U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:De,forceKeepAttr:void 0},We=P.length;for(;We--;){let wt=P[We],{name:ot,namespaceURI:$t,value:Ji}=wt,wo=lt(ot),jl=Ji,bt=ot==="value"?jl:H_(jl);if(U.attrName=wo,U.attrValue=bt,U.keepAttr=!0,U.forceKeepAttr=void 0,Zi(mt.uponSanitizeAttribute,f,U),bt=U.attrValue,Fd&&(wo==="id"||wo==="name")&&(Hn(ot,f),bt=_g+bt),_a&&Nt(/((--!?|])>)|<\/(style|title|textarea)/i,bt)){Hn(ot,f);continue}if(wo==="attributename"&&Kc(bt,"href")){Hn(ot,f);continue}if(U.forceKeepAttr)continue;if(!U.keepAttr){Hn(ot,f);continue}if(!Dd&&Nt(/\/>/i,bt)){Hn(ot,f);continue}bo&&Ls([mi,zn,fo],Xd=>{bt=ea(bt,Xd," ")});let Qd=lt(f.nodeName);if(!qd(Qd,wo,bt)){Hn(ot,f);continue}if(ue&&typeof R=="object"&&typeof R.getAttributeType=="function"&&!$t)switch(R.getAttributeType(Qd,wo)){case"TrustedHTML":{bt=ue.createHTML(bt);break}case"TrustedScriptURL":{bt=ue.createScriptURL(bt);break}}if(bt!==jl)try{$t?f.setAttributeNS($t,ot,bt):f.setAttribute(ot,bt),zl(f)?Ei(f):Ih(t.removed)}catch{Hn(ot,f)}}Zi(mt.afterSanitizeAttributes,f,null)},Sg=function Y(f){let P=null,U=Wd(f);for(Zi(mt.beforeSanitizeShadowDOM,f,null);P=U.nextNode();)Zi(mt.uponSanitizeShadowNode,P,null),Ud(P),Yd(P),P.content instanceof r&&Y(P.content);Zi(mt.afterSanitizeShadowDOM,f,null)};return t.sanitize=function(Y){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},P=null,U=null,We=null,wt=null;if(Nl=!Y,Nl&&(Y="<!-->"),typeof Y!="string"&&!$d(Y))if(typeof Y.toString=="function"){if(Y=Y.toString(),typeof Y!="string")throw ta("dirty is not a string, aborting")}else throw ta("toString is not a function");if(!t.isSupported)return Y;if(Al||Vl(f),t.removed=[],typeof Y=="string"&&(Cr=!1),Cr){if(Y.nodeName){let Ji=lt(Y.nodeName);if(!Pe[Ji]||jn[Ji])throw ta("root node is forbidden and cannot be sanitized in-place")}}else if(Y instanceof c)P=Hd("<!---->"),U=P.ownerDocument.importNode(Y,!0),U.nodeType===na.element&&U.nodeName==="BODY"||U.nodeName==="HTML"?P=U:P.appendChild(U);else{if(!vo&&!bo&&!Bn&&Y.indexOf("<")===-1)return ue&&va?ue.createHTML(Y):Y;if(P=Hd(Y),!P)return vo?null:va?Ht:""}P&&Il&&Ei(P.firstChild);let ot=Wd(Cr?Y:P);for(;We=ot.nextNode();)Ud(We),Yd(We),We.content instanceof r&&Sg(We.content);if(Cr)return Y;if(vo){if(ba)for(wt=Ct.call(P.ownerDocument);P.firstChild;)wt.appendChild(P.firstChild);else wt=P;return(De.shadowroot||De.shadowrootmode)&&(wt=vn.call(i,wt,!0)),wt}let $t=Bn?P.outerHTML:P.innerHTML;return Bn&&Pe["!doctype"]&&P.ownerDocument&&P.ownerDocument.doctype&&P.ownerDocument.doctype.name&&Nt(Bh,P.ownerDocument.doctype.name)&&($t="<!DOCTYPE "+P.ownerDocument.doctype.name+`>
67
67
  `+$t),bo&&Ls([mi,zn,fo],Ji=>{$t=ea($t,Ji," ")}),ue&&va?ue.createHTML($t):$t},t.setConfig=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Vl(Y),Al=!0},t.clearConfig=function(){xo=null,Al=!1},t.isValidAttribute=function(Y,f,P){xo||Vl({});let U=lt(Y),We=lt(f);return qd(U,We,P)},t.addHook=function(Y,f){typeof f=="function"&&Jr(mt[Y],f)},t.removeHook=function(Y,f){if(f!==void 0){let P=z_(mt[Y],f);return P===-1?void 0:j_(mt[Y],P,1)[0]}return Ih(mt[Y])},t.removeHooks=function(Y){mt[Y]=[]},t.removeAllHooks=function(){mt=Vh()},t}var Wh=Hh();var Wi=class o{renderer;constructor(){this.renderer=new $o,this.configureRenderer()}configureRenderer(){let t=this.renderer.link.bind(this.renderer);this.renderer.link=e=>{let i=this.isExternalLink(e.href),n=t(e);if(i){n=n.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=e.title?`${e.text} - ${e.title} (opens in new tab)`:`${e.text} (opens in new tab)`;n=n.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),n=n.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>')}return n}}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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return t.replace(/[&<>"']/g,i=>e[i]||i)}parse(t){return ee(this,null,function*(){let e=yield Ee.parse(t,{renderer:this.renderer,breaks:!0,gfm:!0});return Wh.sanitize(e,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var nb=["buttonContainer"],ob=["freeTextInput"],rb=(o,t)=>t.value;function ab(o,t){o&1&&(s(0,"mat-icon",10),p(1,"keyboard_return"),l())}function sb(o,t){if(o&1){let e=T();s(0,"button",8),_("click",function(){let n=v(e).$implicit,r=g(2);return y(r.onOptionClick(n.value))}),s(1,"span",9),p(2),l(),w(3,ab,2,0,"mat-icon",10),l()}if(o&2){let e=t.$implicit,i=t.$index,n=g(2);I("highlighted",i===n.highlightedIndex),C("disabled",e.disabled)("id","choice-option-"+i),Q("aria-selected",i===n.highlightedIndex),d(2),B(e.label),d(),S(i===n.highlightedIndex?3:-1)}}function lb(o,t){if(o&1){let e=T();s(0,"div",6)(1,"span",11),p(2,"Or type your own answer:"),l(),s(3,"div",12)(4,"input",13,1),j("ngModelChange",function(n){v(e);let r=g(2);return z(r.freeTextValue,n)||(r.freeTextValue=n),y(n)}),_("keydown",function(n){v(e);let r=g(2);return y(r.onFreeTextKeyDown(n))}),l(),s(6,"button",14),_("click",function(){v(e);let n=g(2);return y(n.onFreeTextSubmit())}),s(7,"mat-icon"),p(8,"send"),l()()()()}if(o&2){let e=g(2);d(4),V("ngModel",e.freeTextValue),d(2),C("disabled",!e.freeTextValue.trim())}}function cb(o,t){if(o&1&&(s(0,"div",7)(1,"mat-icon"),p(2,"search"),l(),s(3,"span"),p(4),l()()),o&2){let e=g(2);d(4),B(e.searchText)}}function db(o,t){if(o&1){let e=T();s(0,"div",2),A(1,"div",3),Xn(2,"async"),s(3,"div",4,0),_("keydown",function(n){v(e);let r=g();return y(r.onKeyDown(n))}),Se(5,sb,4,7,"button",5,rb),l(),w(7,lb,9,2,"div",6),w(8,cb,5,1,"div",7),l()}if(o&2){let e=g();d(),C("innerHTML",gm(2,4,e.renderedLabel$),Xt),d(2),Q("aria-activedescendant","choice-option-"+e.highlightedIndex),d(2),ke(e.options),d(2),S(e.allowFreeText?7:-1),d(),S(e.searchText?8:-1)}}var Uo=class o{options=[];allowFreeText=!1;set labelHtml(t){typeof t=="object"?this.renderedLabelSubject.next(t):this.renderLabelMarkdown(t)}isVisible=!1;choiceSelected=new q;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new D;renderedLabelSubject=new le("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=m(Di);markdownService=m(Wi);ngOnDestroy(){this.renderedLabelSubject.complete(),this.destroy$.next(),this.destroy$.complete(),this.searchTimeout&&clearTimeout(this.searchTimeout)}ngAfterViewInit(){this.isVisible&&this.buttonContainer&&setTimeout(()=>this.focusContainer(),100)}ngOnChanges(t){t.isVisible&&t.isVisible.currentValue&&!t.isVisible.previousValue&&(this.highlightedIndex=0,setTimeout(()=>this.focusContainer(),150)),t.options&&!t.options.firstChange&&(this.highlightedIndex=0,this.searchText="",this.freeTextValue="")}focusContainer(){this.buttonContainer?.nativeElement&&this.buttonContainer.nativeElement.focus()}onKeyDown(t){if(this.options.filter(i=>!i.disabled).length!==0)switch(t.key){case"ArrowDown":t.preventDefault(),this.moveHighlight(1);break;case"ArrowUp":t.preventDefault(),this.moveHighlight(-1);break;case"Enter":case" ":t.preventDefault(),this.selectHighlighted();break;case"Home":t.preventDefault(),this.highlightFirst();break;case"End":t.preventDefault(),this.highlightLast();break;case"Escape":t.preventDefault();break;default:t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&this.handleTypeAhead(t.key);break}}moveHighlight(t){let e=this.options.map((r,a)=>({opt:r,idx:a})).filter(({opt:r})=>!r.disabled).map(({idx:r})=>r);if(e.length===0)return;let n=e.findIndex(r=>r===this.highlightedIndex)+t;if(n>=0&&n<e.length){let r=e[n];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted())}else if(t===1&&n>=e.length){let r=e[0];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted())}else if(t===-1&&n<0){let r=e[e.length-1];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted())}}highlightFirst(){let t=this.options.findIndex(e=>!e.disabled);t>=0&&(this.highlightedIndex=t,this.scrollToHighlighted())}highlightLast(){let t=this.options.map((e,i)=>({opt:e,idx:i})).filter(({opt:e})=>!e.disabled).map(({idx:e})=>e);if(t.length>0){let e=t[t.length-1];e!==void 0&&(this.highlightedIndex=e,this.scrollToHighlighted())}}scrollToHighlighted(){setTimeout(()=>{let t=document.getElementById("choice-option-"+this.highlightedIndex);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}selectHighlighted(){let t=this.options[this.highlightedIndex];t&&!t.disabled&&this.onOptionClick(t.value)}handleTypeAhead(t){this.searchText+=t.toLowerCase();let e=this.options.findIndex(i=>!i.disabled&&i.label.toLowerCase().startsWith(this.searchText));e>=0&&(this.highlightedIndex=e,this.scrollToHighlighted()),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchText=""},1e3)}onOptionClick(t){this.choiceSelected.emit(t)}onFreeTextSubmit(){let t=this.freeTextValue.trim();t&&(this.freeTextValue="",this.choiceSelected.emit(t))}onFreeTextKeyDown(t){t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.onFreeTextSubmit())}renderLabelMarkdown(t){return ee(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||o)};static \u0275cmp=M({type:o,selectors:[["app-choice-select"]],viewQuery:function(e,i){if(e&1&&(X(nb,5),X(ob,5)),e&2){let n;H(n=W())&&(i.buttonContainer=n.first),H(n=W())&&(i.freeTextInput=n.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Ze],decls:1,vars:1,consts:[["buttonContainer",""],["freeTextInput",""],[1,"choice-container"],[1,"choice-label",3,"innerHTML"],["role","listbox","tabindex","0",1,"choice-buttons",3,"keydown"],["type","button","role","option",1,"choice-button",3,"highlighted","disabled","id"],[1,"free-text-section"],[1,"search-indicator"],["type","button","role","option",1,"choice-button",3,"click","disabled","id"],[1,"choice-button-label"],[1,"choice-button-icon"],[1,"free-text-hint"],[1,"free-text-input-row"],["type","text","placeholder","Type a custom answer\u2026","aria-label","Custom answer",1,"free-text-input",3,"ngModelChange","keydown","ngModel"],["type","button","aria-label","Send custom answer",1,"free-text-send-btn",3,"click","disabled"]],template:function(e,i){e&1&&w(0,db,9,6,"div",2),e&2&&S(i.isVisible?0:-1)},dependencies:[Fe,_e,ze,Ne,Le,Ve,Cm],styles:[".choice-container[_ngcontent-%COMP%]{width:100%;display:flex;flex-direction:column;gap:1rem}.choice-label[_ngcontent-%COMP%]{display:block;font-weight:500;color:var(--color-text);font-size:1rem;line-height:1.5}.choice-label[_ngcontent-%COMP%] p{margin:0 0 .5rem}.choice-label[_ngcontent-%COMP%] p:last-child{margin-bottom:0}.choice-label[_ngcontent-%COMP%] code{background:var(--color-code-bg);padding:.2em .4em;border-radius:4px;font-family:monospace;font-size:.9em}.choice-label[_ngcontent-%COMP%] strong{font-weight:600}.choice-buttons[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-height:400px;overflow-y:auto;padding:.5rem;background:var(--color-background);border:2px solid var(--color-border);border-radius:12px;outline:none}.choice-buttons[_ngcontent-%COMP%]:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:var(--color-background);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.choice-button[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;width:100%;padding:.75rem 1rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;text-align:left;cursor:pointer;transition:all .2s ease}.choice-button[_ngcontent-%COMP%]:hover:not(:disabled):not(.highlighted){background:var(--color-bg-hover);border-color:var(--color-primary);transform:translate(2px)}.choice-button.highlighted[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary);box-shadow:0 2px 8px #007aff4d}.choice-button.highlighted[_ngcontent-%COMP%] .choice-button-icon[_ngcontent-%COMP%]{color:#fff}.choice-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.choice-button[_ngcontent-%COMP%]:focus{outline:none}.choice-button-label[_ngcontent-%COMP%]{flex:1;line-height:1.5}.choice-button-icon[_ngcontent-%COMP%]{flex-shrink:0;margin-left:.5rem;font-size:1.2rem;width:1.2rem;height:1.2rem}.free-text-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.free-text-hint[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.free-text-input-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center}.free-text-input[_ngcontent-%COMP%]{flex:1;padding:.625rem .875rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.free-text-input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.free-text-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.7}.free-text-send-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:8px;background:var(--color-primary);color:#fff;cursor:pointer;transition:background .2s ease,opacity .2s ease}.free-text-send-btn[_ngcontent-%COMP%]:hover:not(:disabled){opacity:.9}.free-text-send-btn[_ngcontent-%COMP%]:disabled{opacity:.4;cursor:not-allowed}.free-text-send-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.2rem;width:1.2rem;height:1.2rem}.search-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:var(--color-primary);color:#fff;border-radius:8px;font-size:.9rem;font-weight:500;animation:_ngcontent-%COMP%_fadeIn .2s ease}.search-indicator[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem;color:#fff}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (max-width: 480px){.choice-container[_ngcontent-%COMP%]{gap:.75rem}.choice-label[_ngcontent-%COMP%]{font-size:.95rem}.choice-buttons[_ngcontent-%COMP%]{max-height:300px;gap:.375rem}.choice-button[_ngcontent-%COMP%]{font-size:.95rem;padding:.625rem .875rem}}@media print{.choice-buttons[_ngcontent-%COMP%]{max-height:none;overflow:visible}.search-indicator[_ngcontent-%COMP%]{display:none!important}}"]})};var qo=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(e,i){e&1&&(ti(0,"h1",0),p(1),ii()),e&2&&(d(),B(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 mb=["inputElement"];function pb(o,t){if(o&1&&(s(0,"span",3),p(1),l()),o&2){let e=g();d(),B(e.label)}}function hb(o,t){if(o&1&&(s(0,"small",5),p(1),l()),o&2){let e=g();d(),B(e.hint)}}var js=class o{label="";placeholder="";hint="";isDisabled=!1;value="";autoFocus=!0;valueChange=new q;enterPressed=new q;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||o)};static \u0275cmp=M({type:o,selectors:[["app-text-input"]],viewQuery:function(e,i){if(e&1&&X(mb,5),e&2){let n;H(n=W())&&(i.inputElement=n.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 n=T();s(0,"div",1)(1,"label",2),w(2,pb,2,1,"span",3),s(3,"input",4,0),j("ngModelChange",function(a){return v(n),z(i.inputValue,a)||(i.inputValue=a),y(a)}),_("ngModelChange",function(a){return v(n),y(i.onValueChange(a))})("keydown.enter",function(){return v(n),y(i.onEnter())}),l()(),w(5,hb,2,1,"small",5),l()}e&2&&(d(2),S(i.label?2:-1),d(),V("ngModel",i.inputValue),C("placeholder",i.placeholder)("disabled",i.isDisabled),d(2),S(i.hint?5:-1))},dependencies:[ze,Ne,Le,Ve,Me],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 ub=["nameInput"],gb=["pathInput"];function fb(o,t){if(o&1&&(s(0,"div",7),p(1),l()),o&2){let e=g();d(),B(e.errorMessage)}}var Bs=class o{isCreating=!1;create=new q;cancelled=new q;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||o)};static \u0275cmp=M({type:o,selectors:[["app-project-create"]],viewQuery:function(e,i){if(e&1&&(X(ub,5),X(gb,5)),e&2){let n;H(n=W())&&(i.nameInput=n.first),H(n=W())&&(i.pathInput=n.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"],["matButton","",3,"click","disabled"],["matButton","filled",3,"click","disabled"]],template:function(e,i){if(e&1){let n=T();s(0,"div",2)(1,"h3",3),p(2,"Create New Project"),l(),s(3,"div",4)(4,"app-text-input",5,0),_("valueChange",function(a){return v(n),y(i.projectName=a)})("enterPressed",function(){return v(n),y(i.onNameEnter())}),l(),s(6,"app-text-input",6,1),_("valueChange",function(a){return v(n),y(i.projectPath=a)})("enterPressed",function(){return v(n),y(i.onCreate())}),l(),w(8,fb,2,1,"div",7),l(),s(9,"div",8)(10,"button",9),_("click",function(){return v(n),y(i.onCancel())}),p(11,"Cancel"),l(),s(12,"button",10),_("click",function(){return v(n),y(i.onCreate())}),p(13),l()()()}e&2&&(d(4),C("value",i.projectName)("isDisabled",i.isCreating)("autoFocus",!0),d(2),C("value",i.projectPath)("isDisabled",i.isCreating)("autoFocus",!1),d(2),S(i.errorMessage?8:-1),d(2),C("disabled",i.isCreating),d(2),C("disabled",!i.isValid()||i.isCreating),d(),ne(" ",i.isCreating?"Creating...":"Create Project"," "))},dependencies:[Me,js,Mt],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}@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}}@media (max-width: 480px){.project-create[_ngcontent-%COMP%]{gap:1rem;padding:.5rem}.create-title[_ngcontent-%COMP%]{font-size:1.2rem}}"]})};function _b(o,t){if(o&1){let e=T();s(0,"app-project-create",10),_("create",function(n){v(e);let r=g();return y(r.onCreateProject(n))})("cancelled",function(){v(e);let n=g();return y(n.closeCreateForm())}),l()}if(o&2){let e=g();C("isCreating",e.isCreating)}}function bb(o,t){o&1&&(s(0,"div",6),A(1,"div",11),s(2,"p",12),p(3,"Loading projects..."),l()())}function vb(o,t){if(o&1&&(s(0,"div",7)(1,"p",13),p(2),l()()),o&2){let e=g();d(2),B(e.error)}}function yb(o,t){if(o&1){let e=T();s(0,"app-choice-select",14),_("choiceSelected",function(n){v(e);let r=g();return y(r.selectProject(n))}),l()}if(o&2){let e=g();C("options",e.projectOptions())("labelHtml","Select a project to continue")("isVisible",!0)}}function Cb(o,t){if(o&1){let e=T();s(0,"div",9)(1,"p",15),p(2,"No projects available."),l(),s(3,"button",16),_("click",function(){v(e);let n=g();return y(n.openCreateForm())}),p(4,"Create your first project"),l()()}}var Hs=class o{isLoading=!1;error=null;showCreateForm=!1;isCreating=!1;router=m(Mn);projectStateService=m(Te);projects=Rt(this.projectStateService.projectList$);forcedProject=Rt(this.projectStateService.forcedProject$);projectOptions=hi(()=>{let t=this.projects();if(!t)return[];let e=t.filter(a=>!a.volatile),i=t.filter(a=>a.volatile),r=[...e,...i].map(a=>({value:a.name,label:a.volatile?`${a.name} \u{1F538}temp`:a.name}));return t.length>0&&r.push({value:"__new_project__",label:"New project..."}),r});showCreateButton=hi(()=>!this.forcedProject());constructor(){this.projectStateService.selectedProject$.pipe($a(),ce(t=>!!t),ce(()=>this.router.url.split("?")[0]==="/"),Ut(1)).subscribe(t=>{console.log(`\u{1F43C} navigate to ${t.name}`),this.router.navigate(["project",t.name])})}selectProject(t){if(t==="__new_project__"){this.openCreateForm();return}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||o)};static \u0275cmp=M({type:o,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"],[3,"options","labelHtml","isVisible"],[1,"no-projects-container"],[3,"create","cancelled","isCreating"],[1,"loading-spinner"],[1,"loading-text"],[1,"error-text"],[3,"choiceSelected","options","labelHtml","isVisible"],[1,"no-projects-text"],["matButton","filled","color","primary",3,"click"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"div",2),A(3,"app-welcome-message"),l(),s(4,"div",3)(5,"div",4),w(6,_b,1,1,"app-project-create",5)(7,bb,4,0,"div",6)(8,vb,3,1,"div",7)(9,yb,1,3,"app-choice-select",8)(10,Cb,5,0,"div",9),l()()()()),e&2&&(d(6),S(i.showCreateForm?6:i.isLoading?7:i.error?8:i.projects()&&i.projects().length>0?9:10))},dependencies:[Me,Uo,qo,Bs,Mt],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 1rem;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}@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}}"]})};var et=class o{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new le("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();enterToSendSubject=new le(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new le(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new le("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new le(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new le(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new le(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new le(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new le(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new le(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new le(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new le(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new le(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new le(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.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 n=this.getPreferenceSync("voiceMode","speech")??"speech";this.voiceModeSubject.next(n);let r=this.getPreferenceSync("voiceReadFullText",!1)??!1;this.voiceReadFullTextSubject.next(r);let a=this.getPreferenceSync("voiceVolume",.8)??.8;this.voiceVolumeSubject.next(a);let c=this.getPreferenceSync("voiceRate",1.2)??1.2;this.voiceRateSubject.next(c);let h=this.getPreferenceSync("selectedVoice",null)??null;this.selectedVoiceSubject.next(h);let u=this.getPreferenceSync("printTechnicalMessages",!1)??!1;this.printTechnicalMessagesSubject.next(u);let b=this.getPreferenceSync("hideTechnicalMessages",!0)??!0;this.hideTechnicalMessagesSubject.next(b);let x=this.getPreferenceSync("hideWarningMessages",!1)??!1;this.hideWarningMessagesSubject.next(x);let E=this.getPreferenceSync("agentNotificationEnabled",!1)??!1;this.agentNotificationEnabledSubject.next(E);let R=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(R);let k=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(k),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return ee(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 n=(yield this.getPreferenceAsync("voiceMode","speech"))??"speech";this.voiceModeSubject.next(n);let r=(yield this.getPreferenceAsync("voiceReadFullText",!1))??!1;this.voiceReadFullTextSubject.next(r);let a=(yield this.getPreferenceAsync("voiceVolume",.8))??.8;this.voiceVolumeSubject.next(a);let c=(yield this.getPreferenceAsync("voiceRate",1.2))??1.2;this.voiceRateSubject.next(c);let h=(yield this.getPreferenceAsync("selectedVoice",null))??null;this.selectedVoiceSubject.next(h);let u=(yield this.getPreferenceAsync("printTechnicalMessages",!1))??!1;this.printTechnicalMessagesSubject.next(u);let b=(yield this.getPreferenceAsync("hideTechnicalMessages",!0))??!0;this.hideTechnicalMessagesSubject.next(b);let x=(yield this.getPreferenceAsync("hideWarningMessages",!1))??!1;this.hideWarningMessagesSubject.next(x);let E=(yield this.getPreferenceAsync("agentNotificationEnabled",!1))??!1;this.agentNotificationEnabledSubject.next(E);let R=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(R);let k=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(k),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 n=JSON.parse(i);return n[t]!==void 0?n[t]:e}catch{return e}}getPreferenceAsync(t,e){return ee(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 n=JSON.parse(i);return n[t]!==void 0?n[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),n=i?JSON.parse(i):{};n[t]=e,localStorage.setItem(this.STORAGE_KEY,JSON.stringify(n)),this.updateSubject(t,e)}catch(i){console.error("Failed to set preference:",i)}}setPreferenceAsync(t,e){return ee(this,null,function*(){if(!this.electronStorage){this.setPreferenceSync(t,e);return}try{let i=yield this.electronStorage.get(this.STORAGE_KEY),n=i?JSON.parse(i):{};n[t]=e,yield this.electronStorage.set(this.STORAGE_KEY,JSON.stringify(n)),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),t==="agentNotificationEnabled"&&this.agentNotificationEnabledSubject.next(e),t==="notificationSoundEnabled"&&this.notificationSoundEnabledSubject.next(e),t==="browserNotificationEnabled"&&this.browserNotificationEnabledSubject.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}setAgentNotificationEnabled(t){console.log("[PREFERENCES] Setting agent notification enabled to:",t),this.setPreference("agentNotificationEnabled",t)}getAgentNotificationEnabled(){return this.getPreference("agentNotificationEnabled",!1)??!1}setNotificationSoundEnabled(t){console.log("[PREFERENCES] Setting notification sound enabled to:",t),this.setPreference("notificationSoundEnabled",t)}getNotificationSoundEnabled(){return this.getPreference("notificationSoundEnabled",!0)??!0}setBrowserNotificationEnabled(t){console.log("[PREFERENCES] Setting browser notification enabled to:",t),this.setPreference("browserNotificationEnabled",t)}getBrowserNotificationEnabled(){return this.getPreference("browserNotificationEnabled",!1)??!1}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};function rd(o,t=80){if(o.length<=t)return o;try{if(o.trim().startsWith("{")||o.trim().startsWith("[")){let e=JSON.parse(o),i=JSON.stringify(e);return i.length<=t?i:i.substring(0,t)+`...(${i.length} chars)`}}catch{}return o.substring(0,t)+"..."}var ct=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.threadId=t.threadId,this.length=0}timestamp;parentKey;static type;length;threadId;get date(){let t=this.timestamp.lastIndexOf("-");if(t>0){let e=this.timestamp.substring(t+1);if(e.length===5&&/^[a-z0-9]+$/.test(e))return new Date(this.timestamp.substring(0,t))}return new Date(this.timestamp)}},Ws=class extends ct{invite;constructor(t,e){super(t,e),this.invite=t.invite}buildAnswer(t){return new zt({answer:t,parentKey:this.timestamp,invite:this.invite})}},Go=class o extends ct{static type="heartbeat";constructor(t){super(t,o.type)}},un=class o extends Ws{defaultValue;static type="invite";constructor(t){super(t,o.type),this.defaultValue=t.defaultValue}},ad="InviteEventDefault",zt=class o extends ct{answer;invite;static type="answer";constructor(t){super(t,o.type),this.answer=t.answer??"No answer",this.invite=t.invite}},$i=class o extends ct{speaker;text;static type="text";constructor(t){super(t,o.type),this.speaker=t.speaker,this.text=t.text}},Fn=class o extends ct{chunk;static type="text_chunk";constructor(t){super(t,o.type),this.chunk=t.chunk,this.length=this.chunk.length}},ao=class o extends ct{warning;static type="warn";constructor(t){super(t,o.type),this.warning=t.warning}},Si=class o extends ct{error;static type="error";constructor(t){super(t,o.type),this.error=t.error}},gn=class o extends Ws{options;optionalQuestion;allowFreeText;static type="choice";constructor(t){super(t,o.type),this.options=t.options,this.optionalQuestion=t.optionalQuestion,this.allowFreeText=t.allowFreeText??!1}},ki=class o extends ct{toolRequestId;name;args;static type="tool_request";constructor(t){super(t,o.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 li({output:t,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(t=50){let e=rd(this.args,t);return`\u{1F527} ${this.name}(${e})`}},li=class o extends ct{toolRequestId;output;static type="tool_response";constructor(t){if(super(t,o.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=rd(e,t),n=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${i}${n}`}},Nn=class o extends ct{static type="thinking";static debounce=5e3;constructor(t){super(t,o.type)}},so=class o extends ct{summary;static type="summary";constructor(t){super(t,o.type),this.summary=t.summary,this.length=this.summary.length}toSingleLineString(t=80){return`\u{1F4CB} Summary: ${rd(this.summary,t)}`}},Mi=class o extends ct{role;name;content;static type="message";constructor(t){super(t,o.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(`
68
- `)}},Yo=class o extends ct{threadId;name;summary;static type="thread_update";constructor(t){super(t,o.type),this.threadId=t.threadId,this.name=t.name,this.summary=t.summary}},Ln=class o extends ct{filename;operation;size;mimeType;static type="file";constructor(t){super(t,o.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}`}},Qo=class o extends ct{authUrl;state;integrationName;static type="oauth_request";constructor(t){super(t,o.type),this.authUrl=t.authUrl,this.state=t.state,this.integrationName=t.integrationName}},Ui=class o extends ct{subThreadId;agentName;static type="delegation";constructor(t){super(t,o.type),this.subThreadId=t.subThreadId,this.agentName=t.agentName}},qi=class o extends ct{code;state;integrationName;error;errorDescription;static type="oauth_callback";constructor(t){super(t,o.type),this.code=t.code,this.state=t.state,this.integrationName=t.integrationName,this.error=t.error,this.errorDescription=t.errorDescription}},xb={[Mi.type]:Mi,[zt.type]:zt,[gn.type]:gn,[Ui.type]:Ui,[Si.type]:Si,[Go.type]:Go,[un.type]:un,[ki.type]:ki,[li.type]:li,[$i.type]:$i,[Fn.type]:Fn,[Nn.type]:Nn,[ao.type]:ao,[Yo.type]:Yo,[so.type]:so,[Ln.type]:Ln,[Qo.type]:Qo,[qi.type]:qi};function oa(o){let t=xb[o.type];return t?new t(o):void 0}var DM=[{id:"builtin-plan",name:"plan",description:"Build a plan to complete the given task",source:"builtin",commands:[`@ We start a 3 phase process to build a comprehensive execution plan for the following task:
68
+ `)}},Yo=class o extends ct{threadId;name;summary;users;static type="thread_update";constructor(t){super(t,o.type),this.threadId=t.threadId,this.name=t.name,this.summary=t.summary,this.users=t.users}},Ln=class o extends ct{filename;operation;size;mimeType;static type="file";constructor(t){super(t,o.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}`}},Qo=class o extends ct{authUrl;state;integrationName;static type="oauth_request";constructor(t){super(t,o.type),this.authUrl=t.authUrl,this.state=t.state,this.integrationName=t.integrationName}},Ui=class o extends ct{subThreadId;agentName;static type="delegation";constructor(t){super(t,o.type),this.subThreadId=t.subThreadId,this.agentName=t.agentName}},qi=class o extends ct{code;state;integrationName;error;errorDescription;static type="oauth_callback";constructor(t){super(t,o.type),this.code=t.code,this.state=t.state,this.integrationName=t.integrationName,this.error=t.error,this.errorDescription=t.errorDescription}},xb={[Mi.type]:Mi,[zt.type]:zt,[gn.type]:gn,[Ui.type]:Ui,[Si.type]:Si,[Go.type]:Go,[un.type]:un,[ki.type]:ki,[li.type]:li,[$i.type]:$i,[Fn.type]:Fn,[Nn.type]:Nn,[ao.type]:ao,[Yo.type]:Yo,[so.type]:so,[Ln.type]:Ln,[Qo.type]:Qo,[qi.type]:qi};function oa(o){let t=xb[o.type];return t?new t(o):void 0}var DM=[{id:"builtin-plan",name:"plan",description:"Build a plan to complete the given task",source:"builtin",commands:[`@ We start a 3 phase process to build a comprehensive execution plan for the following task:
69
69
 
70
70
  <task>
71
71
  {{PARAMETERS}}
@@ -333,7 +333,7 @@ Verify the memory system's overall health:
333
333
  - List any remaining issues or concerns
334
334
  - Provide recommendations for maintaining memory quality
335
335
 
336
- This ensures the memory system stays efficient and valuable.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""}];var qM=[Mi.type,ki.type,li.type,so.type,un.type,gn.type,zt.type,Ui.type];var $h={CONFLUENCE:[],GIT:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},dT=Object.keys($h).filter(o=>$h[o]?.length===0);var Gi=class o{eventSource=null;eventsSubject=new D;connectionStatusSubject=new le({connected:!1,reconnectAttempts:0,maxAttempts:3});reconnectAttempts=0;MAX_RECONNECT_ATTEMPTS=3;RECONNECT_DELAY=2e3;events$=this.eventsSubject.asObservable();connectionStatus$=this.connectionStatusSubject.asObservable();ngZone=m(de);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=oa(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 Si({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 Si({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||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Yi=class o{http=m(Je);projectState=m(Te);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads`}listThreads(){return this.http.get(this.getBaseUrl())}getThread(t){return this.http.get(`${this.getBaseUrl()}/${t}`)}createThread(t){let e=t?{name:t}:{};return this.http.post(this.getBaseUrl(),e)}updateThread(t,e){return this.http.put(`${this.getBaseUrl()}/${t}`,{name:e})}starThread(t){return this.http.post(`${this.getBaseUrl()}/${t}/star`,{})}unstarThread(t){return this.http.delete(`${this.getBaseUrl()}/${t}/star`)}deleteThread(t){return this.http.delete(`${this.getBaseUrl()}/${t}`)}stopThread(t){return this.http.post(`${this.getBaseUrl()}/${t}/stop`,{})}getThreadMessages(t){return this.http.get(`${this.getBaseUrl()}/${t}/messages`)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Tt=class o{selectedThreadIdSubject=new le(null);isLoadingSubject=new le(!1);isLoadingThreadListSubject=new le(!1);refreshThreadListSubject=new D;threadListSubject=new le([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=m(Yi);projectStateService=m(Te);projectName$=this.projectStateService.selectedProject$.pipe(Oe(t=>t?.name),Sa());constructor(){Wn([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(At(void 0))]).pipe(ht(([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))}),Un(([t])=>t?(console.log("[THREAD_STATE] Fetching threads for project:",t),this.threadApi.listThreads().pipe(Oe(e=>({threads:e,projectName:t})),$n(e=>(console.error("[THREAD_STATE] Error loading thread list:",e),Ot({threads:[],projectName:t}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),Ot({threads:[],projectName:null}))),ht(({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$=Wn([this.projectName$,this.selectedThreadIdSubject.pipe(Sa())]).pipe(ht(([t,e])=>{console.log("\u{1F43C} combineLatest emitted:",{projectName:t,threadId:e})}),Un(([t,e])=>!t||!e?(console.log("\u{1F43C} null"),Ot(null)):(console.log("\u{1F43C} loading thread:",e),this.isLoadingSubject.next(!0),this.threadApi.getThread(e).pipe(ht(i=>{console.log("\u{1F43C} loaded thread:",i?.id)}),Sr({bufferSize:1,refCount:!0})))),ht(()=>{console.log("\u{1F43C} finished loading"),this.isLoadingSubject.next(!1)}));selectThread(t){this.selectedThreadIdSubject.next(t)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}getSelectedThreadIdOrThrow(){let t=this.selectedThreadIdSubject.value;if(!t)throw new Error("[THREAD_STATE] No thread selected");return t}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let t=this.selectedThreadIdSubject.value;if(!t){console.error("[THREAD_STATE] Cannot stop: no thread selected");return}console.log("[THREAD_STATE] Stopping thread:",t),this.threadApi.stopThread(t).subscribe({next:e=>console.log("[THREAD_STATE] Stop signal sent:",e.message),error:e=>console.error("[THREAD_STATE] Error stopping thread:",e)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}renameThread(t,e){let i=e.trim();return!i||i.length===0?(console.error("[THREAD_STATE] Cannot rename thread: name is empty after trimming"),wr(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",t,"to:",i),this.threadApi.updateThread(t,i).pipe(ht(n=>{console.log("[THREAD_STATE] Thread renamed successfully:",n),this.refreshThreadList()}),$n(n=>(console.error("[THREAD_STATE] Error renaming thread:",n),wr(()=>n)))))}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Xo=class o{http=m(Je);projectState=m(Te);threadState=m(Tt);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/messages`}getMessages(){return this.http.get(this.getBaseUrl())}sendMessage(t){return this.http.post(this.getBaseUrl(),t,{responseType:"text"})}getMessage(t){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(t)}`)}deleteMessage(t){return this.http.delete(`${this.getBaseUrl()}/${encodeURIComponent(t)}`)}getFormattedMessage(t){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(t)}/formatted`,{responseType:"text"})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Yt=class o{destroy$=new D;currentProject=null;currentThread=null;messagesSubject=new le([]);isThinkingSubject=new le(!1);currentChoiceSubject=new le(null);projectTitleSubject=new le("Coday");currentInviteEventSubject=new le(null);messageToRestoreSubject=new le("");threadUpdateEventSubject=new le(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new le("");subThreadEventsSubject=new D;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(t){return this.subThreadEventBuffers.get(t)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=m(Gi);messageApi=m(Xo);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling()}setTabTitleService(t){this.tabTitleService=t}connectToThread(t,e){this.currentProject=t,this.currentThread=e,this.eventStream.connectToThread(t,e),setTimeout(()=>this.processUnansweredInvites(),500)}processUnansweredInvites(){let t=this.messagesSubject.value,e=t.filter(i=>i.type==="text"&&i.parentKey===void 0&&i.invite!==void 0).filter(i=>!t.some(n=>n.type==="text"&&n.role==="user"&&n.parentKey===i.id));e.length>0&&console.log("[CODAY] Found",e.length,"unanswered invite(s)")}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking()}sendMessage(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}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(i).subscribe({error:n=>{console.error("[CODAY] Send error:",n),this.stopThinking()}})}else{let i=new zt({answer:t});this.messageApi.sendMessage(i).subscribe({error:n=>{console.error("[CODAY] Send error:",n),this.stopThinking()}})}}sendChoice(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let e=this.currentChoiceEvent.buildAnswer(t);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(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){let e=this.messagesSubject.value.find(n=>n.id===t),i=this.extractTextContentFromMessage(e);return this.messageApi.deleteMessage(t).pipe(ht(n=>{n.success&&(this.removeMessagesFromIndex(t),i.trim()&&this.messageToRestoreSubject.next(i))}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive()}initializeEventHandling(){this.eventStream.events$.pipe(N(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){if(t.threadId&&t.threadId!==this.currentThread){let e=this.subThreadEventBuffers.get(t.threadId);e?e.push(t):this.subThreadEventBuffers.set(t.threadId,[t]),this.subThreadEventsSubject.next(t);return}t instanceof Mi?this.handleMessageEvent(t):t instanceof Fn?this.handleTextChunkEvent(t):t instanceof $i?this.handleTextEvent(t):t instanceof zt?this.handleAnswerEvent(t):t instanceof Si?this.handleErrorEvent(t):t instanceof ao?this.handleWarnEvent(t):t instanceof Nn?this.handleThinkingEvent(t):t instanceof ki?this.handleToolRequestEvent(t):t instanceof li?this.handleToolResponseEvent(t):t instanceof gn?this.handleChoiceEvent(t):t instanceof Go?this.handleHeartBeatEvent(t):t instanceof un?this.handleInviteEvent(t):t instanceof Yo?this.handleThreadUpdateEvent(t):t instanceof Ui?this.handleDelegationEvent(t):t instanceof Qo||t instanceof qi||console.warn("[CODAY] Unhandled event type:",t.type)}handleDelegationEvent(t){if(console.log("[CODAY] DelegationEvent received:",t.subThreadId,t.agentName),this.messagesSubject.value.findIndex(n=>n.subThreadId===t.subThreadId)===-1){let n={id:t.timestamp,role:"system",speaker:t.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:t.subThreadId,delegationAgentName:t.agentName};this.addMessage(n)}}handleThreadUpdateEvent(t){this.threadUpdateEventSubject.next(t)}handleMessageEvent(t){t.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let e={id:t.timestamp,role:t.role,speaker:t.name,content:t.content,timestamp:t.date,type:"text"};this.addMessage(e)}handleTextChunkEvent(t){this.accumulatedChunks+=t.chunk,this.streamingTextSubject.next(this.accumulatedChunks)}handleTextEvent(t){let e={id:t.timestamp,role:t.speaker?"assistant":"system",speaker:t.speaker??"System",content:[{type:"text",content:t.text}],timestamp:t.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:t.date,type:"text",parentKey:t.parentKey,invite:t.invite};this.addMessage(e)}handleErrorEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(t.error)}`}],timestamp:t.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:t.date,type:"warning"};this.addMessage(e)}handleThinkingEvent(t){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(!1),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive()},Nn.debounce+1e3))}handleToolRequestEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:t.toSingleLineString()}],timestamp:t.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:t.date,type:"technical",eventId:t.timestamp};this.addMessage(e)}handleChoiceEvent(t){this.stopThinking(),this.currentChoiceEvent=t,this.tabTitleService?.setSystemInactive();let e=t.options.map(n=>({value:n,label:n})),i=t.optionalQuestion?`${t.optionalQuestion} ${t.invite}`:t.invite;this.currentChoiceSubject.next({options:e,label:i,allowFreeText:t.allowFreeText})}handleHeartBeatEvent(t){}handleInviteEvent(t){this.stopThinking();let e=this.messagesSubject.value,i=e[e.length-1];if(!(!(t.invite===ad)&&i&&i.role==="assistant"&&i.content.some(a=>a.type==="text"&&a.content.includes(t.invite)))&&t.invite!==ad){let a={id:t.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:t.invite}],timestamp:t.date,type:"text"};this.addMessage(a)}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(r=>r.id===t);if(i===-1||i===0)return;let n=e.slice(0,i);this.messagesSubject.next(n),this.stopThinking()}extractTextContentFromMessage(t){return t?t.content.filter(e=>e.type==="text").map(e=>e.content).join(`
336
+ This ensures the memory system stays efficient and valuable.`],createdBy:"system",createdAt:new Date("2024-01-01").toISOString(),webhookEnabled:!1,parameterFormat:""}];var GM=[Mi.type,ki.type,li.type,so.type,un.type,gn.type,zt.type,Ui.type];var $h={CONFLUENCE:[],GIT:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},mT=Object.keys($h).filter(o=>$h[o]?.length===0);var Gi=class o{eventSource=null;eventsSubject=new D;connectionStatusSubject=new le({connected:!1,reconnectAttempts:0,maxAttempts:3});reconnectAttempts=0;MAX_RECONNECT_ATTEMPTS=3;RECONNECT_DELAY=2e3;events$=this.eventsSubject.asObservable();connectionStatus$=this.connectionStatusSubject.asObservable();ngZone=m(de);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=oa(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 Si({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 Si({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||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Yi=class o{http=m(Je);projectState=m(Te);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads`}listThreads(){return this.http.get(this.getBaseUrl())}getThread(t){return this.http.get(`${this.getBaseUrl()}/${t}`)}createThread(t){let e=t?{name:t}:{};return this.http.post(this.getBaseUrl(),e)}updateThread(t,e){return this.http.put(`${this.getBaseUrl()}/${t}`,{name:e})}starThread(t){return this.http.post(`${this.getBaseUrl()}/${t}/star`,{})}unstarThread(t){return this.http.delete(`${this.getBaseUrl()}/${t}/star`)}deleteThread(t){return this.http.delete(`${this.getBaseUrl()}/${t}`)}stopThread(t){return this.http.post(`${this.getBaseUrl()}/${t}/stop`,{})}getThreadMessages(t){return this.http.get(`${this.getBaseUrl()}/${t}/messages`)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Tt=class o{selectedThreadIdSubject=new le(null);isLoadingSubject=new le(!1);isLoadingThreadListSubject=new le(!1);refreshThreadListSubject=new D;threadListSubject=new le([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=m(Yi);projectStateService=m(Te);projectName$=this.projectStateService.selectedProject$.pipe(Oe(t=>t?.name),Sa());constructor(){Wn([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(At(void 0))]).pipe(ht(([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))}),Un(([t])=>t?(console.log("[THREAD_STATE] Fetching threads for project:",t),this.threadApi.listThreads().pipe(Oe(e=>({threads:e,projectName:t})),$n(e=>(console.error("[THREAD_STATE] Error loading thread list:",e),Ot({threads:[],projectName:t}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),Ot({threads:[],projectName:null}))),ht(({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$=Wn([this.projectName$,this.selectedThreadIdSubject.pipe(Sa())]).pipe(ht(([t,e])=>{console.log("\u{1F43C} combineLatest emitted:",{projectName:t,threadId:e})}),Un(([t,e])=>!t||!e?(console.log("\u{1F43C} null"),Ot(null)):(console.log("\u{1F43C} loading thread:",e),this.isLoadingSubject.next(!0),this.threadApi.getThread(e).pipe(ht(i=>{console.log("\u{1F43C} loaded thread:",i?.id)}),Sr({bufferSize:1,refCount:!0})))),ht(()=>{console.log("\u{1F43C} finished loading"),this.isLoadingSubject.next(!1)}));selectThread(t){this.selectedThreadIdSubject.next(t)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}getSelectedThreadIdOrThrow(){let t=this.selectedThreadIdSubject.value;if(!t)throw new Error("[THREAD_STATE] No thread selected");return t}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let t=this.selectedThreadIdSubject.value;if(!t){console.error("[THREAD_STATE] Cannot stop: no thread selected");return}console.log("[THREAD_STATE] Stopping thread:",t),this.threadApi.stopThread(t).subscribe({next:e=>console.log("[THREAD_STATE] Stop signal sent:",e.message),error:e=>console.error("[THREAD_STATE] Error stopping thread:",e)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}renameThread(t,e){let i=e.trim();return!i||i.length===0?(console.error("[THREAD_STATE] Cannot rename thread: name is empty after trimming"),wr(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",t,"to:",i),this.threadApi.updateThread(t,i).pipe(ht(n=>{console.log("[THREAD_STATE] Thread renamed successfully:",n),this.refreshThreadList()}),$n(n=>(console.error("[THREAD_STATE] Error renaming thread:",n),wr(()=>n)))))}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Xo=class o{http=m(Je);projectState=m(Te);threadState=m(Tt);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/messages`}getMessages(){return this.http.get(this.getBaseUrl())}sendMessage(t){return this.http.post(this.getBaseUrl(),t,{responseType:"text"})}getMessage(t){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(t)}`)}deleteMessage(t){return this.http.delete(`${this.getBaseUrl()}/${encodeURIComponent(t)}`)}getFormattedMessage(t){return this.http.get(`${this.getBaseUrl()}/${encodeURIComponent(t)}/formatted`,{responseType:"text"})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Yt=class o{destroy$=new D;currentProject=null;currentThread=null;messagesSubject=new le([]);isThinkingSubject=new le(!1);currentChoiceSubject=new le(null);projectTitleSubject=new le("Coday");currentInviteEventSubject=new le(null);messageToRestoreSubject=new le("");threadUpdateEventSubject=new le(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new le("");subThreadEventsSubject=new D;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(t){return this.subThreadEventBuffers.get(t)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=m(Gi);messageApi=m(Xo);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling()}setTabTitleService(t){this.tabTitleService=t}connectToThread(t,e){this.currentProject=t,this.currentThread=e,this.eventStream.connectToThread(t,e),setTimeout(()=>this.processUnansweredInvites(),500)}processUnansweredInvites(){let t=this.messagesSubject.value,e=t.filter(i=>i.type==="text"&&i.parentKey===void 0&&i.invite!==void 0).filter(i=>!t.some(n=>n.type==="text"&&n.role==="user"&&n.parentKey===i.id));e.length>0&&console.log("[CODAY] Found",e.length,"unanswered invite(s)")}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking()}sendMessage(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}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(i).subscribe({error:n=>{console.error("[CODAY] Send error:",n),this.stopThinking()}})}else{let i=new zt({answer:t});this.messageApi.sendMessage(i).subscribe({error:n=>{console.error("[CODAY] Send error:",n),this.stopThinking()}})}}sendChoice(t){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let e=this.currentChoiceEvent.buildAnswer(t);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(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){let e=this.messagesSubject.value.find(n=>n.id===t),i=this.extractTextContentFromMessage(e);return this.messageApi.deleteMessage(t).pipe(ht(n=>{n.success&&(this.removeMessagesFromIndex(t),i.trim()&&this.messageToRestoreSubject.next(i))}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive()}initializeEventHandling(){this.eventStream.events$.pipe(N(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){if(t.threadId&&t.threadId!==this.currentThread){let e=this.subThreadEventBuffers.get(t.threadId);e?e.push(t):this.subThreadEventBuffers.set(t.threadId,[t]),this.subThreadEventsSubject.next(t);return}t instanceof Mi?this.handleMessageEvent(t):t instanceof Fn?this.handleTextChunkEvent(t):t instanceof $i?this.handleTextEvent(t):t instanceof zt?this.handleAnswerEvent(t):t instanceof Si?this.handleErrorEvent(t):t instanceof ao?this.handleWarnEvent(t):t instanceof Nn?this.handleThinkingEvent(t):t instanceof ki?this.handleToolRequestEvent(t):t instanceof li?this.handleToolResponseEvent(t):t instanceof gn?this.handleChoiceEvent(t):t instanceof Go?this.handleHeartBeatEvent(t):t instanceof un?this.handleInviteEvent(t):t instanceof Yo?this.handleThreadUpdateEvent(t):t instanceof Ui?this.handleDelegationEvent(t):t instanceof Qo||t instanceof qi||console.warn("[CODAY] Unhandled event type:",t.type)}handleDelegationEvent(t){if(console.log("[CODAY] DelegationEvent received:",t.subThreadId,t.agentName),this.messagesSubject.value.findIndex(n=>n.subThreadId===t.subThreadId)===-1){let n={id:t.timestamp,role:"system",speaker:t.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:t.subThreadId,delegationAgentName:t.agentName};this.addMessage(n)}}handleThreadUpdateEvent(t){this.threadUpdateEventSubject.next(t)}handleMessageEvent(t){t.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let e={id:t.timestamp,role:t.role,speaker:t.name,content:t.content,timestamp:t.date,type:"text"};this.addMessage(e)}handleTextChunkEvent(t){this.accumulatedChunks+=t.chunk,this.streamingTextSubject.next(this.accumulatedChunks)}handleTextEvent(t){let e={id:t.timestamp,role:t.speaker?"assistant":"system",speaker:t.speaker??"System",content:[{type:"text",content:t.text}],timestamp:t.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:t.date,type:"text",parentKey:t.parentKey,invite:t.invite};this.addMessage(e)}handleErrorEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(t.error)}`}],timestamp:t.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:t.date,type:"warning"};this.addMessage(e)}handleThinkingEvent(t){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(!1),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive()},Nn.debounce+1e3))}handleToolRequestEvent(t){let e={id:t.timestamp,role:"system",speaker:"System",content:[{type:"text",content:t.toSingleLineString()}],timestamp:t.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:t.date,type:"technical",eventId:t.timestamp};this.addMessage(e)}handleChoiceEvent(t){this.stopThinking(),this.currentChoiceEvent=t,this.tabTitleService?.setSystemInactive();let e=t.options.map(n=>({value:n,label:n})),i=t.optionalQuestion?`${t.optionalQuestion} ${t.invite}`:t.invite;this.currentChoiceSubject.next({options:e,label:i,allowFreeText:t.allowFreeText})}handleHeartBeatEvent(t){}handleInviteEvent(t){this.stopThinking();let e=this.messagesSubject.value,i=e[e.length-1];if(!(!(t.invite===ad)&&i&&i.role==="assistant"&&i.content.some(a=>a.type==="text"&&a.content.includes(t.invite)))&&t.invite!==ad){let a={id:t.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:t.invite}],timestamp:t.date,type:"text"};this.addMessage(a)}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(r=>r.id===t);if(i===-1||i===0)return;let n=e.slice(0,i);this.messagesSubject.next(n),this.stopThinking()}extractTextContentFromMessage(t){return t?t.content.filter(e=>e.type==="text").map(e=>e.content).join(`
337
337
 
338
338
  `):""}clearThinkingTimeout(){this.thinkingTimeout&&(clearTimeout(this.thinkingTimeout),this.thinkingTimeout=null)}stopThinking(){this.clearThinkingTimeout(),this.isThinkingSubject.next(!1),this.tabTitleService&&this.tabTitleService.setSystemInactive()}ngOnDestroy(){this.clearThinkingTimeout(),this.destroy$.next(),this.destroy$.complete(),this.currentInviteEventSubject.complete(),this.messageToRestoreSubject.complete(),this.threadUpdateEventSubject.complete(),this.streamingTextSubject.complete(),this.eventStream.disconnect()}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ko=class o{http=m(Je);agentsCache=new Map;getAgents(t){let e=this.agentsCache.get(t);return e?Ot(e):this.http.get(`/api/projects/${t}/agents`).pipe(ht(i=>{this.agentsCache.set(t,i)}))}getAgentsAutocomplete(t,e){return this.getAgents(t).pipe(Oe(i=>{if(!e)return i;let n=e.toLowerCase();return i.filter(r=>{let a=r.name.toLowerCase(),c=r.description?.toLowerCase()||"";return a.includes(n)||c.includes(n)})}))}clearCache(t){this.agentsCache.delete(t)}clearAllCache(){this.agentsCache.clear()}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var ci=class o{http=m(Je);projectState=m(Te);promptsCache=new Map;getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/prompts`}listPrompts(){return this.http.get(this.getBaseUrl())}getPromptsAutocomplete(t,e){let i=this.promptsCache.get(t);return i?Ot(this.filterPromptsForAutocomplete(i,e)):this.http.get(`/api/projects/${t}/prompts`).pipe(Oe(n=>(this.promptsCache.set(t,n),this.filterPromptsForAutocomplete(n,e))))}filterPromptsForAutocomplete(t,e){let i=e.toLowerCase();return t.filter(r=>r.name.toLowerCase().includes(i)||r.description.toLowerCase().includes(i)).map(r=>({name:r.name,description:r.description,parameterFormat:r.parameterFormat}))}clearCache(t){t?this.promptsCache.delete(t):this.promptsCache.clear()}getPrompt(t){return this.http.get(`${this.getBaseUrl()}/${t}`)}createPrompt(t){return this.http.post(this.getBaseUrl(),t).pipe(Oe(e=>(this.clearCache(this.projectState.getSelectedProjectId()??void 0),e)))}updatePrompt(t,e){return this.http.put(`${this.getBaseUrl()}/${t}`,e).pipe(Oe(i=>(this.clearCache(this.projectState.getSelectedProjectId()??void 0),i)))}deletePrompt(t){return this.http.delete(`${this.getBaseUrl()}/${t}`).pipe(Oe(e=>(this.clearCache(this.projectState.getSelectedProjectId()??void 0),e)))}enableWebhook(t){return this.http.post(`${this.getBaseUrl()}/${t}/webhook`,{})}disableWebhook(t){return this.http.delete(`${this.getBaseUrl()}/${t}/webhook`)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var $s=class o{sanitizer=m(Di);transform(t,e){if(!e||!t)return t;let i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`(${i})`,"gi"),r=t.replace(n,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=dm({name:"highlight",type:o,pure:!0})};var Sb=["messageInput"],kb=["fileInput"],Mb=(o,t)=>t.name;function Tb(o,t){o&1&&(s(0,"div",3),A(1,"span",7),p(2," Recording... Click mic to stop "),l())}function Eb(o,t){if(o&1&&(s(0,"span",12),p(1),l()),o&2){let e=g().$implicit,i=g(2);d(),B(" "+(i.getParameterFormat(e)||""))}}function Pb(o,t){if(o&1){let e=T();s(0,"div",9),_("click",function(){let n=v(e).$index,r=g(2);return y(r.selectAutocompleteItemByClick(n))})("keydown.enter",function(){let n=v(e).$index,r=g(2);return y(r.selectAutocompleteItemByClick(n))})("keydown.space",function(){let n=v(e).$index,r=g(2);return y(r.selectAutocompleteItemByClick(n))})("mouseenter",function(){let n=v(e).$index,r=g(2);return y(r.selectedAutocompleteIndex=n)}),s(1,"div",10),A(2,"span",11),Xn(3,"highlight"),w(4,Eb,2,1,"span",12),l(),A(5,"div",13),Xn(6,"highlight"),l()}if(o&2){let e=t.$implicit,i=t.$index,n=g(2);I("selected",i===n.selectedAutocompleteIndex),Q("aria-selected",i===n.selectedAutocompleteIndex),d(2),C("innerHTML",Tr(3,6,n.autocompleteTrigger+e.name,n.getAutocompleteQuery()),Xt),d(2),S(n.hasParameterFormat(e)?4:-1),d(),C("innerHTML",Tr(6,9,e.description,n.getAutocompleteQuery()),Xt)}}function Ob(o,t){if(o&1&&(s(0,"div",4),Se(1,Pb,7,12,"div",8,Mb),l()),o&2){let e=g();d(),ke(e.autocompleteItems)}}function Ab(o,t){if(o&1){let e=T();s(0,"ds-icon-button",15),_("action",function(){v(e);let n=g(2);return y(n.onStopClick())}),l()}}function Ib(o,t){if(o&1){let e=T();s(0,"ds-icon-button",18),_("action",function(){v(e);let n=g(3);return y(n.triggerFileUpload())}),l(),s(1,"input",19,1),_("change",function(n){v(e);let r=g(3);return y(r.onFileInputChange(n))}),l()}if(o&2){let e=g(3);C("disabled",e.isDisabled||e.isLocallyDisabled)}}function Db(o,t){if(o&1){let e=T();s(0,"ds-icon-button",16),_("action",function(){v(e);let n=g(2);return y(n.sendMessage())}),l(),w(1,Ib,3,1),s(2,"ds-icon-button",17),_("action",function(){v(e);let n=g(2);return y(n.toggleRecording())}),l()}if(o&2){let e=g(2);I("hidden",e.isDisabled||!e.message.trim()||e.isLocallyDisabled)("active",!!e.message.trim()&&!e.isDisabled&&!e.isLocallyDisabled),C("title",e.getSendButtonTooltip())("disabled",e.isDisabled||!e.message.trim()||e.isLocallyDisabled),d(),S(e.showWelcome?-1:1),d(),I("recording",e.isRecording)("hidden",e.message.trim()),C("icon",e.isRecording?"fiber_manual_record":"mic")("title",e.isRecording?"Click to stop recording":"Click to start recording")}}function Rb(o,t){if(o&1&&w(0,Ab,1,0,"ds-icon-button",14)(1,Db,3,13),o&2){let e=g();S(e.isThinking?0:1)}}var Zo=class o{static MIN_TEXTAREA_LINES=2;static MAX_TEXTAREA_LINES=15;isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;isLocallyDisabled=!1;filesPasted=new q;messageSubmitted=new q;voiceRecordingToggled=new q;heightChanged=new q;stopRequested=new q;messageInput;fileInput;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;autocompleteVisible=!1;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=m(et);codayService=m(Yt);agentApiService=m(Ko);promptApiService=m(ci);projectStateService=m(Te);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){if(this.autocompleteVisible)switch(t.key){case"ArrowDown":t.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case"ArrowUp":t.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case"Tab":case"Enter":if(!this.message.includes(" ")){t.preventDefault(),this.selectAutocompleteItem();return}break;case"Escape":t.preventDefault(),this.hideAutocomplete();return}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(),this.checkForAutocomplete()}onPaste(t){let e=t.clipboardData?.items;if(!e)return;let i=Array.from(e).filter(r=>r.kind==="file");if(!i.length)return;t.preventDefault();let n=i.reduce((r,a)=>{let c=a.getAsFile();return c?[...r,c]:r},[]);n.length&&this.filesPasted.emit(n)}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click()}onFileInputChange(t){let e=t.target,i=e.files;if(!i||i.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",i.length);let n=Array.from(i);this.filesPasted.emit(n),e.value=""}onDocumentClick(t){if(!this.autocompleteVisible)return;let e=t.target,i=document.querySelector(".autocomplete-popup"),n=this.messageInput?.nativeElement;i&&!i.contains(e)&&n&&!n.contains(e)&&this.hideAutocomplete()}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()}toggleRecording(){this.isRecording?this.stopRecording():this.startRecording()}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 n=e.resultIndex;n<e.results.length;n++){let r=e.results[n][0].transcript;e.results[n].isFinal&&(i+=r)}if(i){let n=this.improveTranscriptPunctuation(i.trim());this.sessionHadTranscript=!0,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(n)}},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 ee(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(`
339
339
 
@@ -359,7 +359,7 @@ This action cannot be undone once you post another message.`)&&(console.log("[CH
359
359
 
360
360
  `)}extractPartialText(t){return t.split(`
361
361
  `).filter(a=>a.trim().length>0).reduce((a,c)=>{if(a.paragraphs>=3)return a;let h=c.length>80?1:0;return{paragraphs:a.paragraphs+h,text:a.text+(a.text?`
362
- `:"")+c}},{paragraphs:0,text:""}).text||t}renderStreamingText(){return ee(this,null,function*(){if(!this.streamingText){this.renderedStreamingText="";return}try{let t=yield this.markdownService.parse(this.streamingText);this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(t)}catch(t){console.error("[CHAT-HISTORY] Error rendering streaming text markdown:",t),this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(this.streamingText)}})}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-chat-history"]],hostBindings:function(e,i){e&1&&_("scroll",function(){return i.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Ze],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn"],[3,"subThreadId","agentName"],[3,"message","canDelete"],[3,"copyRequested","deleteRequested","message","canDelete"],[1,"content","markdown-content",3,"innerHTML"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn",3,"click"],["fontSet","material-icons-outlined"]],template:function(e,i){e&1&&(s(0,"div",0),Se(1,l0,2,1,null,null,r0),w(3,c0,2,1,"div",1),w(4,d0,1,0,"app-thinking-loader"),w(5,m0,3,0,"button",2),l()),e&2&&(d(),ke(i.messages),d(2),S(i.streamingText?3:-1),d(),S(i.isThinking?4:-1),d(),S(i.showGoToBottom?5:-1))},dependencies:[Jo,_e,Ys,Wa,Gs],styles:[".streaming-message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.streaming-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{color:var(--color-text);line-height:1.5}.go-to-bottom-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:120px!important;right:2rem!important;z-index:1000!important}@media (max-width: 768px){.go-to-bottom-btn[_ngcontent-%COMP%]{right:1rem!important;bottom:100px!important}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.chat-history[_ngcontent-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.go-to-bottom-btn[_ngcontent-%COMP%]{display:none!important}}"]})};var Xs=class o{http=m(Je);projectState=m(Te);threadState=m(Tt);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/files`}uploadFile(t){let e=this.projectState.getSelectedProjectIdOrThrow(),i=this.threadState.getSelectedThreadIdOrThrow();return new Oi(n=>{let r=new FileReader;r.onload=()=>{let c=r.result.split(",")[1];this.http.post(`/api/projects/${e}/threads/${i}/upload`,{content:c,mimeType:t.type||"application/octet-stream",filename:t.name}).subscribe({next:h=>{n.next({success:h.success,filename:h.filename}),n.complete()},error:h=>n.error(h)})},r.onerror=()=>n.error(new Error("Failed to read file")),r.readAsDataURL(t)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(Oe(t=>t.files))}downloadFile(t){let e=encodeURIComponent(t);return this.http.get(`${this.getBaseUrl()}/${e}`,{responseType:"blob"})}deleteFile(t){let e=encodeURIComponent(t);return this.http.delete(`${this.getBaseUrl()}/${e}`)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var or=class o{fileApi=m(Xs);eventStream=m(Gi);filesSignal=rt([]);isLoadingSignal=rt(!1);currentProjectSignal=rt(null);currentThreadSignal=rt(null);files=hi(()=>this.filesSignal());isLoading=hi(()=>this.isLoadingSignal());fileCount=hi(()=>this.filesSignal().length);constructor(){this.subscribeToFileEvents()}initializeForThread(t,e){this.currentProjectSignal.set(t),this.currentThreadSignal.set(e),this.refreshFileList()}clear(){this.filesSignal.set([]),this.currentProjectSignal.set(null),this.currentThreadSignal.set(null)}refreshFileList(){this.isLoadingSignal.set(!0),this.fileApi.listFiles().subscribe({next:t=>{let e=t.map(i=>pt(Z({},i),{lastModified:new Date(i.lastModified)})).sort((i,n)=>n.lastModified.getTime()-i.lastModified.getTime());this.filesSignal.set(e),this.isLoadingSignal.set(!1)},error:t=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",t),this.isLoadingSignal.set(!1)}})}uploadFile(t){return ee(this,null,function*(){return new Promise(e=>{this.fileApi.uploadFile(t).subscribe({next:()=>{this.refreshFileList(),e({success:!0})},error:i=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",i),e({success:!1,error:i.message||"Upload failed"})}})})})}downloadAllFiles(){let t=this.filesSignal();if(t.length===0){console.warn("[FILE_EXCHANGE_STATE] No files to download");return}t.forEach((e,i)=>{setTimeout(()=>{this.downloadFile(e.filename)},i*300)})}downloadFile(t){this.fileApi.downloadFile(t).subscribe({next:e=>{let i=window.URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,n.click(),window.URL.revokeObjectURL(i)},error:e=>{console.error("[FILE_EXCHANGE_STATE] Download error:",e)}})}deleteFile(t){return ee(this,null,function*(){return new Promise(e=>{this.fileApi.deleteFile(t).subscribe({next:()=>{this.refreshFileList(),e({success:!0})},error:i=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",i),e({success:!1,error:i.message||"Delete failed"})}})})})}subscribeToFileEvents(){this.eventStream.events$.pipe(ce(t=>t instanceof Ln),$a()).subscribe(t=>{this.handleFileEvent(t)})}handleFileEvent(t){let e=this.filesSignal();switch(t.operation){case"created":{let i=t.timestamp,n=t.timestamp.lastIndexOf("-");if(n>0){let a=t.timestamp.substring(n+1);a.length===5&&/^[a-z0-9]+$/.test(a)&&(i=t.timestamp.substring(0,n))}let r={filename:t.filename,size:t.size||0,lastModified:new Date(i)};this.filesSignal.set([r,...e]);break}case"updated":{let i=e.filter(h=>h.filename!==t.filename),n=e.find(h=>h.filename===t.filename),r=t.timestamp,a=t.timestamp.lastIndexOf("-");if(a>0){let h=t.timestamp.substring(a+1);h.length===5&&/^[a-z0-9]+$/.test(h)&&(r=t.timestamp.substring(0,a))}let c={filename:t.filename,size:t.size||n?.size||0,lastModified:new Date(r)};this.filesSignal.set([c,...i]);break}case"deleted":{let i=e.filter(n=>n.filename!==t.filename);this.filesSignal.set(i);break}}}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};function p0(o,t){if(o&1&&A(0,"div",1),o&2){let e=g();C("innerHTML",e.renderedContent,Xt)}}function h0(o,t){if(o&1&&A(0,"iframe",2),o&2){let e=g();C("srcdoc",e.content,Xt)}}function u0(o,t){if(o&1&&(s(0,"pre",3),p(1),l()),o&2){let e=g();d(),B(e.content)}}var Ks=class o{content="";format="text";renderedContent="";sanitizer=m(Di);markdownService=m(Wi);ngOnChanges(t){(t.content||t.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return ee(this,null,function*(){try{let t=yield this.markdownService.parse(this.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t)}catch(t){console.error("[CONTENT_RENDERER] Error rendering markdown:",t),this.content=this.content}})}formatJson(){try{let t=JSON.parse(this.content);this.content=JSON.stringify(t,null,2)}catch(t){console.error("[CONTENT_RENDERER] Error formatting JSON:",t)}}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Ze],decls:4,vars:2,consts:[[1,"content-renderer",3,"ngClass"],[1,"markdown-content",3,"innerHTML"],["sandbox","allow-same-origin",1,"html-viewer",3,"srcdoc"],[1,"code-content"]],template:function(e,i){e&1&&(s(0,"div",0),w(1,p0,1,1,"div",1)(2,h0,1,1,"iframe",2)(3,u0,2,1,"pre",3),l()),e&2&&(C("ngClass","format-"+i.format),d(),S(i.format==="markdown"?1:i.format==="html"?2:3))},dependencies:[Me,kn],styles:[".content-renderer[_ngcontent-%COMP%]{width:100%;height:100%;overflow:auto;padding:1rem}.markdown-content[_ngcontent-%COMP%]{line-height:1.6;color:var(--color-text)}.code-content[_ngcontent-%COMP%]{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9rem;line-height:1.5;margin:0;white-space:pre-wrap;word-wrap:break-word;color:var(--color-text)}.format-json[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-code-text, #d63384)}.format-yaml[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%], .format-text[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-text)}.html-viewer[_ngcontent-%COMP%]{width:100%;height:100%;min-height:400px;border:1px solid var(--color-border);border-radius:8px;background:#fff}"]})};var rr=class o{http=m(Je);MAX_FILE_SIZE=20*1024*1024;isViewable(t){return t<=this.MAX_FILE_SIZE}isFormatViewable(t){let e=t.split(".").pop()?.toLowerCase();return!(e&&["pdf","png","jpg","jpeg","gif","webp","zip","tar","gz","exe","bin","doc","docx","xls","xlsx","ppt","pptx"].includes(e))}detectFormat(t){switch(t.split(".").pop()?.toLowerCase()){case"md":return"markdown";case"json":return"json";case"yaml":case"yml":return"yaml";case"html":case"htm":return"html";default:return"text"}}loadFileContent(t,e,i){let n=`/api/projects/${t}/threads/${e}/files/${encodeURIComponent(i)}`,r=this.detectFormat(i);return this.http.get(n,{responseType:"text",observe:"response"}).pipe(Oe(a=>{let c=a.body||"",h=new Blob([c]).size;return{content:c,format:r,filename:i,size:h}}),$n(a=>(console.error("[CONTENT_VIEWER] Error loading file:",i,a),wr(()=>new Error(`Failed to load file: ${a.message||"Unknown error"}`)))))}formatSize(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};function g0(o,t){if(o&1){let e=T();s(0,"button",12),_("click",function(){v(e);let n=g();return y(n.download())}),s(1,"mat-icon"),p(2,"download"),l()()}}function f0(o,t){o&1&&(s(0,"div",9),A(1,"mat-spinner",13),s(2,"p"),p(3,"Loading file content..."),l()())}function _0(o,t){if(o&1){let e=T();s(0,"div",10)(1,"mat-icon",14),p(2,"error_outline"),l(),s(3,"p",15),p(4),l(),s(5,"button",16),_("click",function(){v(e);let n=g();return y(n.download())}),s(6,"mat-icon"),p(7,"download"),l(),p(8," Download instead "),l()()}if(o&2){let e=g();d(4),B(e.error)}}function b0(o,t){if(o&1&&A(0,"app-content-renderer",11),o&2){let e=g();C("content",e.fileContent.content)("format",e.fileContent.format)}}var Zs=class o{destroy$=new D;file;projectName;threadId;closeViewer=new q;contentService=m(rr);eventStream=m(Gi);fileContent=null;isLoading=!1;error="";ngOnInit(){this.loadContent(),this.subscribeToFileEvents()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadContent(){if(!this.contentService.isViewable(this.file.size)){this.error=`File too large to view (${this.contentService.formatSize(this.file.size)}). Maximum size: 20 MB.`;return}this.isLoading=!0,this.error="",this.contentService.loadFileContent(this.projectName,this.threadId,this.file.filename).subscribe({next:t=>{console.log("[CONTENT_VIEWER] Content loaded:",t.filename),this.fileContent=t,this.isLoading=!1},error:t=>{console.error("[CONTENT_VIEWER] Error loading content:",t),this.error=t.message||"Failed to load file content",this.isLoading=!1}})}onClose(){this.closeViewer.emit()}download(){let t=new Blob([this.fileContent?.content||""],{type:"text/plain"}),e=window.URL.createObjectURL(t),i=document.createElement("a");i.href=e,i.download=this.file.filename,i.click(),window.URL.revokeObjectURL(e)}formatSize(t){return this.contentService.formatSize(t)}subscribeToFileEvents(){this.eventStream.events$.pipe(ce(t=>t instanceof Ln),ce(t=>t.filename===this.file.filename),ce(t=>t.operation==="updated"),N(this.destroy$)).subscribe(t=>{console.log("[CONTENT_VIEWER] File updated event received, reloading:",t.filename),t.size&&(this.file.size=t.size),this.loadContent()})}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-content-viewer"]],inputs:{file:"file",projectName:"projectName",threadId:"threadId"},outputs:{closeViewer:"closeViewer"},decls:16,vars:6,consts:[[1,"viewer-container"],[1,"viewer-header"],[1,"header-info"],[1,"filename"],[1,"file-size"],[1,"header-actions"],["mat-icon-button","","title","Download","type","button"],["mat-icon-button","","title","Close","type","button",3,"click"],[1,"viewer-content"],[1,"loading-state"],[1,"error-state"],[3,"content","format"],["mat-icon-button","","title","Download","type","button",3,"click"],["diameter","48"],[1,"error-icon"],[1,"error-message"],["mat-raised-button","","color","primary","type","button",3,"click"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),p(4),l(),s(5,"span",4),p(6),l()(),s(7,"div",5),w(8,g0,3,0,"button",6),s(9,"button",7),_("click",function(){return i.onClose()}),s(10,"mat-icon"),p(11,"chevron_right"),l()()()(),s(12,"div",8),w(13,f0,4,0,"div",9),w(14,_0,9,1,"div",10),w(15,b0,1,2,"app-content-renderer",11),l()()),e&2&&(d(4),B(i.file.filename),d(2),B(i.formatSize(i.file.size)),d(2),S(i.fileContent&&!i.isLoading&&!i.error?8:-1),d(5),S(i.isLoading?13:-1),d(),S(i.error?14:-1),d(),S(i.fileContent&&!i.isLoading&&!i.error?15:-1))},dependencies:[Me,Fe,_e,_t,Mt,gt,tr,er,Ks],styles:[".viewer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--color-bg)}.viewer-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:1rem;border-bottom:1px solid var(--color-border);background:var(--color-bg);flex-shrink:0}.header-info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.filename[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-size[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary)}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0}.viewer-content[_ngcontent-%COMP%]{flex:1;overflow:auto;background:var(--color-bg)}.loading-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;color:var(--color-text-secondary)}.error-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;padding:2rem;text-align:center}.error-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;color:var(--color-error)}.error-message[_ngcontent-%COMP%]{color:var(--color-text);margin:0;max-width:400px}"]})};var v0=Math.pow(10,8)*24*60*60*1e3,kI=-v0,Js=6048e5,Gh=864e5;var y0=3600;var Yh=y0*24,MI=Yh*7,C0=Yh*365.2425,x0=C0/12,TI=x0*3,ld=Symbol.for("constructDateFrom");function at(o,t){return typeof o=="function"?o(t):o&&typeof o=="object"&&ld in o?o[ld](t):o instanceof Date?new o.constructor(t):new Date(t)}function Ge(o,t){return at(t||o,o)}function Qh(o,t,e){let i=Ge(o,e?.in);return isNaN(t)?at(e?.in||o,NaN):(t&&i.setDate(i.getDate()+t),i)}var w0={};function Vn(){return w0}function fn(o,t){let e=Vn(),i=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??e.weekStartsOn??e.locale?.options?.weekStartsOn??0,n=Ge(o,t?.in),r=n.getDay(),a=(r<i?7:0)+r-i;return n.setDate(n.getDate()-a),n.setHours(0,0,0,0),n}function co(o,t){return fn(o,pt(Z({},t),{weekStartsOn:1}))}function el(o,t){let e=Ge(o,t?.in),i=e.getFullYear(),n=at(e,0);n.setFullYear(i+1,0,4),n.setHours(0,0,0,0);let r=co(n),a=at(e,0);a.setFullYear(i,0,4),a.setHours(0,0,0,0);let c=co(a);return e.getTime()>=r.getTime()?i+1:e.getTime()>=c.getTime()?i:i-1}function cd(o){let t=Ge(o),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+o-+e}function ar(o,...t){let e=at.bind(null,o||t.find(i=>typeof i=="object"));return t.map(e)}function sr(o,t){let e=Ge(o,t?.in);return e.setHours(0,0,0,0),e}function tl(o,t,e){let[i,n]=ar(e?.in,o,t),r=sr(i),a=sr(n),c=+r-cd(r),h=+a-cd(a);return Math.round((c-h)/Gh)}function Xh(o,t){let e=el(o,t),i=at(t?.in||o,0);return i.setFullYear(e,0,4),i.setHours(0,0,0,0),co(i)}function Kh(o){return at(o,Date.now())}function Zh(o,t,e){let[i,n]=ar(e?.in,o,t);return+sr(i)==+sr(n)}function Jh(o){return o instanceof Date||typeof o=="object"&&Object.prototype.toString.call(o)==="[object Date]"}function eu(o){return!(!Jh(o)&&typeof o!="number"||isNaN(+Ge(o)))}function iu(o,t,e){let[i,n]=ar(e?.in,o,t),r=tu(i,n),a=Math.abs(tl(i,n));i.setDate(i.getDate()-r*a);let c=+(tu(i,n)===-r),h=r*(a-c);return h===0?0:h}function tu(o,t){let e=o.getFullYear()-t.getFullYear()||o.getMonth()-t.getMonth()||o.getDate()-t.getDate()||o.getHours()-t.getHours()||o.getMinutes()-t.getMinutes()||o.getSeconds()-t.getSeconds()||o.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function nu(o,t){let e=Ge(o,t?.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}var S0={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ou=(o,t,e)=>{let i,n=S0[o];return typeof n=="string"?i=n:t===1?i=n.one:i=n.other.replace("{{count}}",t.toString()),e?.addSuffix?e.comparison&&e.comparison>0?"in "+i:i+" ago":i};function il(o){return(t={})=>{let e=t.width?String(t.width):o.defaultWidth;return o.formats[e]||o.formats[o.defaultWidth]}}var k0={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},M0={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},T0={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ru={date:il({formats:k0,defaultWidth:"full"}),time:il({formats:M0,defaultWidth:"full"}),dateTime:il({formats:T0,defaultWidth:"full"})};var E0={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},au=(o,t,e,i)=>E0[o];function lr(o){return(t,e)=>{let i=e?.context?String(e.context):"standalone",n;if(i==="formatting"&&o.formattingValues){let a=o.defaultFormattingWidth||o.defaultWidth,c=e?.width?String(e.width):a;n=o.formattingValues[c]||o.formattingValues[a]}else{let a=o.defaultWidth,c=e?.width?String(e.width):o.defaultWidth;n=o.values[c]||o.values[a]}let r=o.argumentCallback?o.argumentCallback(t):t;return n[r]}}var P0={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},O0={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},A0={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},I0={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},D0={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},R0={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},F0=(o,t)=>{let e=Number(o),i=e%100;if(i>20||i<10)switch(i%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},su={ordinalNumber:F0,era:lr({values:P0,defaultWidth:"wide"}),quarter:lr({values:O0,defaultWidth:"wide",argumentCallback:o=>o-1}),month:lr({values:A0,defaultWidth:"wide"}),day:lr({values:I0,defaultWidth:"wide"}),dayPeriod:lr({values:D0,defaultWidth:"wide",formattingValues:R0,defaultFormattingWidth:"wide"})};function cr(o){return(t,e={})=>{let i=e.width,n=i&&o.matchPatterns[i]||o.matchPatterns[o.defaultMatchWidth],r=t.match(n);if(!r)return null;let a=r[0],c=i&&o.parsePatterns[i]||o.parsePatterns[o.defaultParseWidth],h=Array.isArray(c)?L0(c,x=>x.test(a)):N0(c,x=>x.test(a)),u;u=o.valueCallback?o.valueCallback(h):h,u=e.valueCallback?e.valueCallback(u):u;let b=t.slice(a.length);return{value:u,rest:b}}}function N0(o,t){for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e)&&t(o[e]))return e}function L0(o,t){for(let e=0;e<o.length;e++)if(t(o[e]))return e}function lu(o){return(t,e={})=>{let i=t.match(o.matchPattern);if(!i)return null;let n=i[0],r=t.match(o.parsePattern);if(!r)return null;let a=o.valueCallback?o.valueCallback(r[0]):r[0];a=e.valueCallback?e.valueCallback(a):a;let c=t.slice(n.length);return{value:a,rest:c}}}var V0=/^(\d+)(th|st|nd|rd)?/i,z0=/\d+/i,j0={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},B0={any:[/^b/i,/^(a|c)/i]},H0={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},W0={any:[/1/i,/2/i,/3/i,/4/i]},$0={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},U0={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},q0={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},G0={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Y0={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Q0={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},cu={ordinalNumber:lu({matchPattern:V0,parsePattern:z0,valueCallback:o=>parseInt(o,10)}),era:cr({matchPatterns:j0,defaultMatchWidth:"wide",parsePatterns:B0,defaultParseWidth:"any"}),quarter:cr({matchPatterns:H0,defaultMatchWidth:"wide",parsePatterns:W0,defaultParseWidth:"any",valueCallback:o=>o+1}),month:cr({matchPatterns:$0,defaultMatchWidth:"wide",parsePatterns:U0,defaultParseWidth:"any"}),day:cr({matchPatterns:q0,defaultMatchWidth:"wide",parsePatterns:G0,defaultParseWidth:"any"}),dayPeriod:cr({matchPatterns:Y0,defaultMatchWidth:"any",parsePatterns:Q0,defaultParseWidth:"any"})};var dd={code:"en-US",formatDistance:ou,formatLong:ru,formatRelative:au,localize:su,match:cu,options:{weekStartsOn:0,firstWeekContainsDate:1}};function du(o,t){let e=Ge(o,t?.in);return tl(e,nu(e))+1}function mu(o,t){let e=Ge(o,t?.in),i=+co(e)-+Xh(e);return Math.round(i/Js)+1}function nl(o,t){let e=Ge(o,t?.in),i=e.getFullYear(),n=Vn(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=at(t?.in||o,0);a.setFullYear(i+1,0,r),a.setHours(0,0,0,0);let c=fn(a,t),h=at(t?.in||o,0);h.setFullYear(i,0,r),h.setHours(0,0,0,0);let u=fn(h,t);return+e>=+c?i+1:+e>=+u?i:i-1}function pu(o,t){let e=Vn(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??e.firstWeekContainsDate??e.locale?.options?.firstWeekContainsDate??1,n=nl(o,t),r=at(t?.in||o,0);return r.setFullYear(n,0,i),r.setHours(0,0,0,0),fn(r,t)}function hu(o,t){let e=Ge(o,t?.in),i=+fn(e,t)-+pu(e,t);return Math.round(i/Js)+1}function we(o,t){let e=o<0?"-":"",i=Math.abs(o).toString().padStart(t,"0");return e+i}var _n={y(o,t){let e=o.getFullYear(),i=e>0?e:1-e;return we(t==="yy"?i%100:i,t.length)},M(o,t){let e=o.getMonth();return t==="M"?String(e+1):we(e+1,2)},d(o,t){return we(o.getDate(),t.length)},a(o,t){let e=o.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(o,t){return we(o.getHours()%12||12,t.length)},H(o,t){return we(o.getHours(),t.length)},m(o,t){return we(o.getMinutes(),t.length)},s(o,t){return we(o.getSeconds(),t.length)},S(o,t){let e=t.length,i=o.getMilliseconds(),n=Math.trunc(i*Math.pow(10,e-3));return we(n,t.length)}};var dr={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},md={G:function(o,t,e){let i=o.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(i,{width:"abbreviated"});case"GGGGG":return e.era(i,{width:"narrow"});case"GGGG":default:return e.era(i,{width:"wide"})}},y:function(o,t,e){if(t==="yo"){let i=o.getFullYear(),n=i>0?i:1-i;return e.ordinalNumber(n,{unit:"year"})}return _n.y(o,t)},Y:function(o,t,e,i){let n=nl(o,i),r=n>0?n:1-n;if(t==="YY"){let a=r%100;return we(a,2)}return t==="Yo"?e.ordinalNumber(r,{unit:"year"}):we(r,t.length)},R:function(o,t){let e=el(o);return we(e,t.length)},u:function(o,t){let e=o.getFullYear();return we(e,t.length)},Q:function(o,t,e){let i=Math.ceil((o.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return we(i,2);case"Qo":return e.ordinalNumber(i,{unit:"quarter"});case"QQQ":return e.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(i,{width:"wide",context:"formatting"})}},q:function(o,t,e){let i=Math.ceil((o.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return we(i,2);case"qo":return e.ordinalNumber(i,{unit:"quarter"});case"qqq":return e.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(i,{width:"wide",context:"standalone"})}},M:function(o,t,e){let i=o.getMonth();switch(t){case"M":case"MM":return _n.M(o,t);case"Mo":return e.ordinalNumber(i+1,{unit:"month"});case"MMM":return e.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(i,{width:"wide",context:"formatting"})}},L:function(o,t,e){let i=o.getMonth();switch(t){case"L":return String(i+1);case"LL":return we(i+1,2);case"Lo":return e.ordinalNumber(i+1,{unit:"month"});case"LLL":return e.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(i,{width:"wide",context:"standalone"})}},w:function(o,t,e,i){let n=hu(o,i);return t==="wo"?e.ordinalNumber(n,{unit:"week"}):we(n,t.length)},I:function(o,t,e){let i=mu(o);return t==="Io"?e.ordinalNumber(i,{unit:"week"}):we(i,t.length)},d:function(o,t,e){return t==="do"?e.ordinalNumber(o.getDate(),{unit:"date"}):_n.d(o,t)},D:function(o,t,e){let i=du(o);return t==="Do"?e.ordinalNumber(i,{unit:"dayOfYear"}):we(i,t.length)},E:function(o,t,e){let i=o.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(i,{width:"short",context:"formatting"});case"EEEE":default:return e.day(i,{width:"wide",context:"formatting"})}},e:function(o,t,e,i){let n=o.getDay(),r=(n-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return we(r,2);case"eo":return e.ordinalNumber(r,{unit:"day"});case"eee":return e.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(n,{width:"short",context:"formatting"});case"eeee":default:return e.day(n,{width:"wide",context:"formatting"})}},c:function(o,t,e,i){let n=o.getDay(),r=(n-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return we(r,t.length);case"co":return e.ordinalNumber(r,{unit:"day"});case"ccc":return e.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(n,{width:"narrow",context:"standalone"});case"cccccc":return e.day(n,{width:"short",context:"standalone"});case"cccc":default:return e.day(n,{width:"wide",context:"standalone"})}},i:function(o,t,e){let i=o.getDay(),n=i===0?7:i;switch(t){case"i":return String(n);case"ii":return we(n,t.length);case"io":return e.ordinalNumber(n,{unit:"day"});case"iii":return e.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(i,{width:"short",context:"formatting"});case"iiii":default:return e.day(i,{width:"wide",context:"formatting"})}},a:function(o,t,e){let n=o.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(o,t,e){let i=o.getHours(),n;switch(i===12?n=dr.noon:i===0?n=dr.midnight:n=i/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(o,t,e){let i=o.getHours(),n;switch(i>=17?n=dr.evening:i>=12?n=dr.afternoon:i>=4?n=dr.morning:n=dr.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(o,t,e){if(t==="ho"){let i=o.getHours()%12;return i===0&&(i=12),e.ordinalNumber(i,{unit:"hour"})}return _n.h(o,t)},H:function(o,t,e){return t==="Ho"?e.ordinalNumber(o.getHours(),{unit:"hour"}):_n.H(o,t)},K:function(o,t,e){let i=o.getHours()%12;return t==="Ko"?e.ordinalNumber(i,{unit:"hour"}):we(i,t.length)},k:function(o,t,e){let i=o.getHours();return i===0&&(i=24),t==="ko"?e.ordinalNumber(i,{unit:"hour"}):we(i,t.length)},m:function(o,t,e){return t==="mo"?e.ordinalNumber(o.getMinutes(),{unit:"minute"}):_n.m(o,t)},s:function(o,t,e){return t==="so"?e.ordinalNumber(o.getSeconds(),{unit:"second"}):_n.s(o,t)},S:function(o,t){return _n.S(o,t)},X:function(o,t,e){let i=o.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return gu(i);case"XXXX":case"XX":return mo(i);case"XXXXX":case"XXX":default:return mo(i,":")}},x:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"x":return gu(i);case"xxxx":case"xx":return mo(i);case"xxxxx":case"xxx":default:return mo(i,":")}},O:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+uu(i,":");case"OOOO":default:return"GMT"+mo(i,":")}},z:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+uu(i,":");case"zzzz":default:return"GMT"+mo(i,":")}},t:function(o,t,e){let i=Math.trunc(+o/1e3);return we(i,t.length)},T:function(o,t,e){return we(+o,t.length)}};function uu(o,t=""){let e=o>0?"-":"+",i=Math.abs(o),n=Math.trunc(i/60),r=i%60;return r===0?e+String(n):e+String(n)+t+we(r,2)}function gu(o,t){return o%60===0?(o>0?"-":"+")+we(Math.abs(o)/60,2):mo(o,t)}function mo(o,t=""){let e=o>0?"-":"+",i=Math.abs(o),n=we(Math.trunc(i/60),2),r=we(i%60,2);return e+n+t+r}var fu=(o,t)=>{switch(o){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},_u=(o,t)=>{switch(o){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},X0=(o,t)=>{let e=o.match(/(P+)(p+)?/)||[],i=e[1],n=e[2];if(!n)return fu(o,t);let r;switch(i){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;case"PPPP":default:r=t.dateTime({width:"full"});break}return r.replace("{{date}}",fu(i,t)).replace("{{time}}",_u(n,t))},bu={p:_u,P:X0};var K0=/^D+$/,Z0=/^Y+$/,J0=["D","DD","YY","YYYY"];function vu(o){return K0.test(o)}function yu(o){return Z0.test(o)}function Cu(o,t,e){let i=ev(o,t,e);if(console.warn(i),J0.includes(o))throw new RangeError(i)}function ev(o,t,e){let i=o[0]==="Y"?"years":"days of the month";return`Use \`${o.toLowerCase()}\` instead of \`${o}\` (in \`${t}\`) for formatting ${i} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var tv=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,iv=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nv=/^'([^]*?)'?$/,ov=/''/g,rv=/[a-zA-Z]/;function pd(o,t,e){let i=Vn(),n=e?.locale??i.locale??dd,r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,c=Ge(o,e?.in);if(!eu(c))throw new RangeError("Invalid time value");let h=t.match(iv).map(b=>{let x=b[0];if(x==="p"||x==="P"){let E=bu[x];return E(b,n.formatLong)}return b}).join("").match(tv).map(b=>{if(b==="''")return{isToken:!1,value:"'"};let x=b[0];if(x==="'")return{isToken:!1,value:av(b)};if(md[x])return{isToken:!0,value:b};if(x.match(rv))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:b}});n.localize.preprocessor&&(h=n.localize.preprocessor(c,h));let u={firstWeekContainsDate:r,weekStartsOn:a,locale:n};return h.map(b=>{if(!b.isToken)return b.value;let x=b.value;(!e?.useAdditionalWeekYearTokens&&yu(x)||!e?.useAdditionalDayOfYearTokens&&vu(x))&&Cu(x,t,String(o));let E=md[x[0]];return E(c,x,n.localize,u)}).join("")}function av(o){let t=o.match(nv);return t?t[1].replace(ov,"'"):o}function xu(o,t,e){return Qh(o,-t,e)}function wu(o,t){return Zh(at(t?.in||o,o),xu(Kh(t?.in||o),1))}function Su(o){if(!o||isNaN(o.getTime()))return"unknown";let t=new Date,e=pd(o,"HH:mm:ss"),i=t.getTime()-o.getTime(),n=Math.floor(i/(1e3*60));if(n<1)return`just now (${e})`;if(n<60)return`${n} min ago (${e})`;let r=Math.floor(i/(1e3*60*60));if(r<24)return`${r}h ago (${e})`;if(wu(o))return`yesterday ${e}`;let a=iu(t,o);return a<7?`${a}d ago ${e}`:`${pd(o,"dd/MM/yyyy")} ${e}`}var sv=(o,t)=>t.filename;function lv(o,t){if(o&1){let e=T();s(0,"button",11),_("click",function(){v(e);let n=g(2);return y(n.downloadAll())}),s(1,"mat-icon"),p(2,"download_for_offline"),l()()}}function cv(o,t){o&1&&(s(0,"div",10),A(1,"span",12),s(2,"span",13),p(3,"Loading files..."),l()())}function dv(o,t){o&1&&(s(0,"div",14)(1,"mat-icon",15),p(2,"folder_open"),l(),s(3,"p",16),p(4,"No files in exchange space"),l(),s(5,"p",17),p(6,"Upload files to share with the agent"),l()())}function mv(o,t){if(o&1){let e=T();s(0,"button",28),_("click",function(){v(e);let n=g().$implicit,r=g(4);return y(r.viewFile(n))}),s(1,"mat-icon"),p(2,"visibility"),l()()}}function pv(o,t){if(o&1){let e=T();s(0,"div",18)(1,"div",19)(2,"mat-icon",20),p(3),l(),s(4,"div",21)(5,"span",22),p(6),l(),s(7,"span",23),p(8),l()()(),s(9,"div",24),w(10,mv,3,0,"button",25),s(11,"button",26),_("click",function(){let n=v(e).$implicit,r=g(4);return y(r.download(n))}),s(12,"mat-icon"),p(13,"download"),l()(),s(14,"button",27),_("click",function(){let n=v(e).$implicit,r=g(4);return y(r.delete(n))}),s(15,"mat-icon"),p(16,"delete"),l()()()()}if(o&2){let e=t.$implicit,i=g(4);d(3),B(i.getFileIcon(e.filename)),d(2),C("title",e.filename),d(),B(e.filename),d(2),xn("",i.formatSize(e.size)," \u2022 ",i.formatDate(e.lastModified)),d(2),S(i.canViewFile(e)?10:-1)}}function hv(o,t){if(o&1&&Se(0,pv,17,6,"div",18,sv),o&2){let e=g(3);ke(e.files())}}function uv(o,t){if(o&1&&w(0,dv,7,0,"div",14)(1,hv,2,0),o&2){let e=g(2);S(e.files().length===0?0:1)}}function gv(o,t){if(o&1){let e=T();s(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),p(4,"Exchange"),l(),s(5,"span",5),p(6),l()(),s(7,"div",6),w(8,lv,3,0,"button",7),s(9,"button",8),_("click",function(){v(e);let n=g();return y(n.close())}),s(10,"mat-icon"),p(11,"chevron_right"),l()()()(),s(12,"div",9),w(13,cv,4,0,"div",10)(14,uv,2,1),l()()}if(o&2){let e=g();d(6),ne("(",e.files().length,")"),d(2),S(e.files().length>0?8:-1),d(5),S(e.isLoading()?13:14)}}function fv(o,t){if(o&1){let e=T();s(0,"app-content-viewer",29),_("closeViewer",function(){v(e);let n=g();return y(n.backToList())}),l()}if(o&2){let e=g();C("file",e.currentFile)("projectName",e.projectName)("threadId",e.threadId)}}var ol=class o{projectName;threadId;closeDrawer=new q;fileExchangeState=m(or);contentViewerService=m(rr);files=this.fileExchangeState.files;isLoading=this.fileExchangeState.isLoading;viewerState="list";currentFile=null;close(){this.viewerState==="content"?this.backToList():this.closeDrawer.emit()}viewFile(t){this.currentFile=t,this.viewerState="content"}backToList(){this.viewerState="list",this.currentFile=null}downloadAll(){this.fileExchangeState.downloadAllFiles()}download(t){this.fileExchangeState.downloadFile(t.filename)}delete(t){return ee(this,null,function*(){if(!confirm(`Delete file "${t.filename}"?`))return;let i=yield this.fileExchangeState.deleteFile(t.filename);i.success||alert(`Failed to delete file: ${i.error}`)})}getFileIcon(t){switch(t.split(".").pop()?.toLowerCase()){case"pdf":return"picture_as_pdf";case"csv":case"xlsx":case"xls":return"table_chart";case"txt":case"md":return"description";case"jpg":case"jpeg":case"png":case"gif":case"webp":return"image";case"zip":case"tar":case"gz":return"folder_zip";default:return"insert_drive_file"}}formatSize(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}formatDate(t){return Su(t)}canViewFile(t){return this.contentViewerService.isFormatViewable(t.filename)&&this.contentViewerService.isViewable(t.size)}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-file-exchange-drawer"]],inputs:{projectName:"projectName",threadId:"threadId"},outputs:{closeDrawer:"closeDrawer"},decls:2,vars:2,consts:[[1,"file-drawer-container"],[3,"file","projectName","threadId"],[1,"drawer-header"],[1,"header-left"],[1,"drawer-title"],[1,"file-count"],[1,"header-actions"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"file-list"],[1,"file-loading"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn",3,"click"],[1,"loading-spinner"],[1,"loading-text"],[1,"file-empty"],[1,"empty-icon"],[1,"empty-text"],[1,"empty-hint"],[1,"file-item"],[1,"file-info"],[1,"file-icon"],[1,"file-details"],[1,"file-name",3,"title"],[1,"file-meta"],[1,"file-actions"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn"],["mat-icon-button","","title","Download","type","button",1,"action-btn","download-btn",3,"click"],["mat-icon-button","","title","Delete","type","button",1,"action-btn","delete-btn",3,"click"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn",3,"click"],[3,"closeViewer","file","projectName","threadId"]],template:function(e,i){e&1&&(w(0,gv,15,3,"div",0),w(1,fv,1,3,"app-content-viewer",1)),e&2&&(S(i.viewerState==="list"?0:-1),d(),S(i.viewerState==="content"&&i.currentFile?1:-1))},dependencies:[Me,Fe,_e,_t,gt,Zs],styles:[".file-drawer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.drawer-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--color-border);flex-shrink:0}.header-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.5rem}.header-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem}.drawer-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text)}.file-count[_ngcontent-%COMP%]{font-size:.9rem;color:var(--color-text-secondary)}.download-all-btn[_ngcontent-%COMP%]{color:var(--color-primary)}.download-all-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.file-list[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:.5rem}.file-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;gap:1rem;color:var(--color-text-secondary)}.loading-spinner[_ngcontent-%COMP%]{display:inline-block;width:32px;height:32px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.loading-text[_ngcontent-%COMP%]{font-size:.9rem}.file-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;text-align:center;color:var(--color-text-secondary)}.empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:1rem;opacity:.5}.empty-text[_ngcontent-%COMP%]{margin:0 0 .5rem;font-size:1rem;font-weight:500}.empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;opacity:.7}.file-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-radius:8px;transition:background .2s;gap:1rem}.file-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.file-item[_ngcontent-%COMP%]:hover .file-actions[_ngcontent-%COMP%]{opacity:1}.file-info[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-icon[_ngcontent-%COMP%]{flex-shrink:0;color:var(--color-primary);font-size:28px;width:28px;height:28px}.file-details[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;min-width:0}.file-name[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.file-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .2s}.action-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.action-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.action-btn.view-btn[_ngcontent-%COMP%]:hover, .action-btn.download-btn[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.action-btn.delete-btn[_ngcontent-%COMP%]:hover{color:var(--color-error)}@media (max-width: 768px){.file-actions[_ngcontent-%COMP%]{opacity:1}.file-item[_ngcontent-%COMP%]{padding:1rem .75rem}.drawer-header[_ngcontent-%COMP%]{padding:.75rem}}"]})};var al=["*"],_v=["content"],bv=[[["mat-drawer"]],[["mat-drawer-content"]],"*"],vv=["mat-drawer","mat-drawer-content","*"];function yv(o,t){if(o&1){let e=T();s(0,"div",1),_("click",function(){v(e);let n=g();return y(n._onBackdropClicked())}),l()}if(o&2){let e=g();I("mat-drawer-shown",e._isShowingBackdrop())}}function Cv(o,t){o&1&&(s(0,"mat-drawer-content"),me(1,2),l())}var xv=[[["mat-sidenav"]],[["mat-sidenav-content"]],"*"],wv=["mat-sidenav","mat-sidenav-content","*"];function Sv(o,t){if(o&1){let e=T();s(0,"div",1),_("click",function(){v(e);let n=g();return y(n._onBackdropClicked())}),l()}if(o&2){let e=g();I("mat-drawer-shown",e._isShowingBackdrop())}}function kv(o,t){o&1&&(s(0,"mat-sidenav-content"),me(1,2),l())}var Mv=`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
362
+ `:"")+c}},{paragraphs:0,text:""}).text||t}renderStreamingText(){return ee(this,null,function*(){if(!this.streamingText){this.renderedStreamingText="";return}try{let t=yield this.markdownService.parse(this.streamingText);this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(t)}catch(t){console.error("[CHAT-HISTORY] Error rendering streaming text markdown:",t),this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(this.streamingText)}})}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-chat-history"]],hostBindings:function(e,i){e&1&&_("scroll",function(){return i.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Ze],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn"],[3,"subThreadId","agentName"],[3,"message","canDelete"],[3,"copyRequested","deleteRequested","message","canDelete"],[1,"content","markdown-content",3,"innerHTML"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn",3,"click"],["fontSet","material-icons-outlined"]],template:function(e,i){e&1&&(s(0,"div",0),Se(1,l0,2,1,null,null,r0),w(3,c0,2,1,"div",1),w(4,d0,1,0,"app-thinking-loader"),w(5,m0,3,0,"button",2),l()),e&2&&(d(),ke(i.messages),d(2),S(i.streamingText?3:-1),d(),S(i.isThinking?4:-1),d(),S(i.showGoToBottom?5:-1))},dependencies:[Jo,_e,Ys,Wa,Gs],styles:[".streaming-message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.streaming-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{color:var(--color-text);line-height:1.5}.go-to-bottom-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:120px!important;right:2rem!important;z-index:1000!important}@media (max-width: 768px){.go-to-bottom-btn[_ngcontent-%COMP%]{right:1rem!important;bottom:100px!important}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.chat-history[_ngcontent-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.go-to-bottom-btn[_ngcontent-%COMP%]{display:none!important}}"]})};var Xs=class o{http=m(Je);projectState=m(Te);threadState=m(Tt);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/files`}uploadFile(t){let e=this.projectState.getSelectedProjectIdOrThrow(),i=this.threadState.getSelectedThreadIdOrThrow();return new Oi(n=>{let r=new FileReader;r.onload=()=>{let c=r.result.split(",")[1];this.http.post(`/api/projects/${e}/threads/${i}/upload`,{content:c,mimeType:t.type||"application/octet-stream",filename:t.name}).subscribe({next:h=>{n.next({success:h.success,filename:h.filename}),n.complete()},error:h=>n.error(h)})},r.onerror=()=>n.error(new Error("Failed to read file")),r.readAsDataURL(t)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(Oe(t=>t.files))}downloadFile(t){let e=encodeURIComponent(t);return this.http.get(`${this.getBaseUrl()}/${e}`,{responseType:"blob"})}deleteFile(t){let e=encodeURIComponent(t);return this.http.delete(`${this.getBaseUrl()}/${e}`)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var or=class o{fileApi=m(Xs);eventStream=m(Gi);filesSignal=rt([]);isLoadingSignal=rt(!1);currentProjectSignal=rt(null);currentThreadSignal=rt(null);files=hi(()=>this.filesSignal());isLoading=hi(()=>this.isLoadingSignal());fileCount=hi(()=>this.filesSignal().length);constructor(){this.subscribeToFileEvents()}initializeForThread(t,e){this.currentProjectSignal.set(t),this.currentThreadSignal.set(e),this.refreshFileList()}clear(){this.filesSignal.set([]),this.currentProjectSignal.set(null),this.currentThreadSignal.set(null)}refreshFileList(){this.isLoadingSignal.set(!0),this.fileApi.listFiles().subscribe({next:t=>{let e=t.map(i=>pt(Z({},i),{lastModified:new Date(i.lastModified)})).sort((i,n)=>n.lastModified.getTime()-i.lastModified.getTime());this.filesSignal.set(e),this.isLoadingSignal.set(!1)},error:t=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",t),this.isLoadingSignal.set(!1)}})}uploadFile(t){return ee(this,null,function*(){return new Promise(e=>{this.fileApi.uploadFile(t).subscribe({next:()=>{this.refreshFileList(),e({success:!0})},error:i=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",i),e({success:!1,error:i.message||"Upload failed"})}})})})}downloadAllFiles(){let t=this.filesSignal();if(t.length===0){console.warn("[FILE_EXCHANGE_STATE] No files to download");return}t.forEach((e,i)=>{setTimeout(()=>{this.downloadFile(e.filename)},i*300)})}downloadFile(t){this.fileApi.downloadFile(t).subscribe({next:e=>{let i=window.URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,n.click(),window.URL.revokeObjectURL(i)},error:e=>{console.error("[FILE_EXCHANGE_STATE] Download error:",e)}})}deleteFile(t){return ee(this,null,function*(){return new Promise(e=>{this.fileApi.deleteFile(t).subscribe({next:()=>{this.refreshFileList(),e({success:!0})},error:i=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",i),e({success:!1,error:i.message||"Delete failed"})}})})})}subscribeToFileEvents(){this.eventStream.events$.pipe(ce(t=>t instanceof Ln),$a()).subscribe(t=>{this.handleFileEvent(t)})}handleFileEvent(t){let e=this.filesSignal();switch(t.operation){case"created":{let i=t.timestamp,n=t.timestamp.lastIndexOf("-");if(n>0){let a=t.timestamp.substring(n+1);a.length===5&&/^[a-z0-9]+$/.test(a)&&(i=t.timestamp.substring(0,n))}let r={filename:t.filename,size:t.size||0,lastModified:new Date(i)};this.filesSignal.set([r,...e]);break}case"updated":{let i=e.filter(h=>h.filename!==t.filename),n=e.find(h=>h.filename===t.filename),r=t.timestamp,a=t.timestamp.lastIndexOf("-");if(a>0){let h=t.timestamp.substring(a+1);h.length===5&&/^[a-z0-9]+$/.test(h)&&(r=t.timestamp.substring(0,a))}let c={filename:t.filename,size:t.size||n?.size||0,lastModified:new Date(r)};this.filesSignal.set([c,...i]);break}case"deleted":{let i=e.filter(n=>n.filename!==t.filename);this.filesSignal.set(i);break}}}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};function p0(o,t){if(o&1&&A(0,"div",1),o&2){let e=g();C("innerHTML",e.renderedContent,Xt)}}function h0(o,t){if(o&1&&A(0,"iframe",2),o&2){let e=g();C("srcdoc",e.content,Xt)}}function u0(o,t){if(o&1&&(s(0,"pre",3),p(1),l()),o&2){let e=g();d(),B(e.content)}}var Ks=class o{content="";format="text";renderedContent="";sanitizer=m(Di);markdownService=m(Wi);ngOnChanges(t){(t.content||t.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return ee(this,null,function*(){try{let t=yield this.markdownService.parse(this.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t)}catch(t){console.error("[CONTENT_RENDERER] Error rendering markdown:",t),this.content=this.content}})}formatJson(){try{let t=JSON.parse(this.content);this.content=JSON.stringify(t,null,2)}catch(t){console.error("[CONTENT_RENDERER] Error formatting JSON:",t)}}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Ze],decls:4,vars:2,consts:[[1,"content-renderer",3,"ngClass"],[1,"markdown-content",3,"innerHTML"],["sandbox","allow-same-origin",1,"html-viewer",3,"srcdoc"],[1,"code-content"]],template:function(e,i){e&1&&(s(0,"div",0),w(1,p0,1,1,"div",1)(2,h0,1,1,"iframe",2)(3,u0,2,1,"pre",3),l()),e&2&&(C("ngClass","format-"+i.format),d(),S(i.format==="markdown"?1:i.format==="html"?2:3))},dependencies:[Me,kn],styles:[".content-renderer[_ngcontent-%COMP%]{width:100%;height:100%;overflow:auto;padding:1rem}.markdown-content[_ngcontent-%COMP%]{line-height:1.6;color:var(--color-text)}.code-content[_ngcontent-%COMP%]{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9rem;line-height:1.5;margin:0;white-space:pre-wrap;word-wrap:break-word;color:var(--color-text)}.format-json[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-code-text, #d63384)}.format-yaml[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%], .format-text[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-text)}.html-viewer[_ngcontent-%COMP%]{width:100%;height:100%;min-height:400px;border:1px solid var(--color-border);border-radius:8px;background:#fff}"]})};var rr=class o{http=m(Je);MAX_FILE_SIZE=20*1024*1024;isViewable(t){return t<=this.MAX_FILE_SIZE}isFormatViewable(t){let e=t.split(".").pop()?.toLowerCase();return!(e&&["pdf","png","jpg","jpeg","gif","webp","zip","tar","gz","exe","bin","doc","docx","xls","xlsx","ppt","pptx"].includes(e))}detectFormat(t){switch(t.split(".").pop()?.toLowerCase()){case"md":return"markdown";case"json":return"json";case"yaml":case"yml":return"yaml";case"html":case"htm":return"html";default:return"text"}}loadFileContent(t,e,i){let n=`/api/projects/${t}/threads/${e}/files/${encodeURIComponent(i)}`,r=this.detectFormat(i);return this.http.get(n,{responseType:"text",observe:"response"}).pipe(Oe(a=>{let c=a.body||"",h=new Blob([c]).size;return{content:c,format:r,filename:i,size:h}}),$n(a=>(console.error("[CONTENT_VIEWER] Error loading file:",i,a),wr(()=>new Error(`Failed to load file: ${a.message||"Unknown error"}`)))))}formatSize(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};function g0(o,t){if(o&1){let e=T();s(0,"button",12),_("click",function(){v(e);let n=g();return y(n.download())}),s(1,"mat-icon"),p(2,"download"),l()()}}function f0(o,t){o&1&&(s(0,"div",9),A(1,"mat-spinner",13),s(2,"p"),p(3,"Loading file content..."),l()())}function _0(o,t){if(o&1){let e=T();s(0,"div",10)(1,"mat-icon",14),p(2,"error_outline"),l(),s(3,"p",15),p(4),l(),s(5,"button",16),_("click",function(){v(e);let n=g();return y(n.download())}),s(6,"mat-icon"),p(7,"download"),l(),p(8," Download instead "),l()()}if(o&2){let e=g();d(4),B(e.error)}}function b0(o,t){if(o&1&&A(0,"app-content-renderer",11),o&2){let e=g();C("content",e.fileContent.content)("format",e.fileContent.format)}}var Zs=class o{destroy$=new D;file;projectName;threadId;closeViewer=new q;contentService=m(rr);eventStream=m(Gi);fileContent=null;isLoading=!1;error="";ngOnInit(){this.loadContent(),this.subscribeToFileEvents()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadContent(){if(!this.contentService.isViewable(this.file.size)){this.error=`File too large to view (${this.contentService.formatSize(this.file.size)}). Maximum size: 20 MB.`;return}this.isLoading=!0,this.error="",this.contentService.loadFileContent(this.projectName,this.threadId,this.file.filename).subscribe({next:t=>{console.log("[CONTENT_VIEWER] Content loaded:",t.filename),this.fileContent=t,this.isLoading=!1},error:t=>{console.error("[CONTENT_VIEWER] Error loading content:",t),this.error=t.message||"Failed to load file content",this.isLoading=!1}})}onClose(){this.closeViewer.emit()}download(){let t=new Blob([this.fileContent?.content||""],{type:"text/plain"}),e=window.URL.createObjectURL(t),i=document.createElement("a");i.href=e,i.download=this.file.filename,i.click(),window.URL.revokeObjectURL(e)}formatSize(t){return this.contentService.formatSize(t)}subscribeToFileEvents(){this.eventStream.events$.pipe(ce(t=>t instanceof Ln),ce(t=>t.filename===this.file.filename),ce(t=>t.operation==="updated"),N(this.destroy$)).subscribe(t=>{console.log("[CONTENT_VIEWER] File updated event received, reloading:",t.filename),t.size&&(this.file.size=t.size),this.loadContent()})}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-content-viewer"]],inputs:{file:"file",projectName:"projectName",threadId:"threadId"},outputs:{closeViewer:"closeViewer"},decls:16,vars:6,consts:[[1,"viewer-container"],[1,"viewer-header"],[1,"header-info"],[1,"filename"],[1,"file-size"],[1,"header-actions"],["mat-icon-button","","title","Download","type","button"],["mat-icon-button","","title","Close","type","button",3,"click"],[1,"viewer-content"],[1,"loading-state"],[1,"error-state"],[3,"content","format"],["mat-icon-button","","title","Download","type","button",3,"click"],["diameter","48"],[1,"error-icon"],[1,"error-message"],["mat-raised-button","","color","primary","type","button",3,"click"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),p(4),l(),s(5,"span",4),p(6),l()(),s(7,"div",5),w(8,g0,3,0,"button",6),s(9,"button",7),_("click",function(){return i.onClose()}),s(10,"mat-icon"),p(11,"chevron_right"),l()()()(),s(12,"div",8),w(13,f0,4,0,"div",9),w(14,_0,9,1,"div",10),w(15,b0,1,2,"app-content-renderer",11),l()()),e&2&&(d(4),B(i.file.filename),d(2),B(i.formatSize(i.file.size)),d(2),S(i.fileContent&&!i.isLoading&&!i.error?8:-1),d(5),S(i.isLoading?13:-1),d(),S(i.error?14:-1),d(),S(i.fileContent&&!i.isLoading&&!i.error?15:-1))},dependencies:[Me,Fe,_e,_t,Mt,gt,tr,er,Ks],styles:[".viewer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--color-bg)}.viewer-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:1rem;border-bottom:1px solid var(--color-border);background:var(--color-bg);flex-shrink:0}.header-info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.filename[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-size[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary)}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0}.viewer-content[_ngcontent-%COMP%]{flex:1;overflow:auto;background:var(--color-bg)}.loading-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;color:var(--color-text-secondary)}.error-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;padding:2rem;text-align:center}.error-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;color:var(--color-error)}.error-message[_ngcontent-%COMP%]{color:var(--color-text);margin:0;max-width:400px}"]})};var v0=Math.pow(10,8)*24*60*60*1e3,MI=-v0,Js=6048e5,Gh=864e5;var y0=3600;var Yh=y0*24,TI=Yh*7,C0=Yh*365.2425,x0=C0/12,EI=x0*3,ld=Symbol.for("constructDateFrom");function at(o,t){return typeof o=="function"?o(t):o&&typeof o=="object"&&ld in o?o[ld](t):o instanceof Date?new o.constructor(t):new Date(t)}function Ge(o,t){return at(t||o,o)}function Qh(o,t,e){let i=Ge(o,e?.in);return isNaN(t)?at(e?.in||o,NaN):(t&&i.setDate(i.getDate()+t),i)}var w0={};function Vn(){return w0}function fn(o,t){let e=Vn(),i=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??e.weekStartsOn??e.locale?.options?.weekStartsOn??0,n=Ge(o,t?.in),r=n.getDay(),a=(r<i?7:0)+r-i;return n.setDate(n.getDate()-a),n.setHours(0,0,0,0),n}function co(o,t){return fn(o,pt(Z({},t),{weekStartsOn:1}))}function el(o,t){let e=Ge(o,t?.in),i=e.getFullYear(),n=at(e,0);n.setFullYear(i+1,0,4),n.setHours(0,0,0,0);let r=co(n),a=at(e,0);a.setFullYear(i,0,4),a.setHours(0,0,0,0);let c=co(a);return e.getTime()>=r.getTime()?i+1:e.getTime()>=c.getTime()?i:i-1}function cd(o){let t=Ge(o),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+o-+e}function ar(o,...t){let e=at.bind(null,o||t.find(i=>typeof i=="object"));return t.map(e)}function sr(o,t){let e=Ge(o,t?.in);return e.setHours(0,0,0,0),e}function tl(o,t,e){let[i,n]=ar(e?.in,o,t),r=sr(i),a=sr(n),c=+r-cd(r),h=+a-cd(a);return Math.round((c-h)/Gh)}function Xh(o,t){let e=el(o,t),i=at(t?.in||o,0);return i.setFullYear(e,0,4),i.setHours(0,0,0,0),co(i)}function Kh(o){return at(o,Date.now())}function Zh(o,t,e){let[i,n]=ar(e?.in,o,t);return+sr(i)==+sr(n)}function Jh(o){return o instanceof Date||typeof o=="object"&&Object.prototype.toString.call(o)==="[object Date]"}function eu(o){return!(!Jh(o)&&typeof o!="number"||isNaN(+Ge(o)))}function iu(o,t,e){let[i,n]=ar(e?.in,o,t),r=tu(i,n),a=Math.abs(tl(i,n));i.setDate(i.getDate()-r*a);let c=+(tu(i,n)===-r),h=r*(a-c);return h===0?0:h}function tu(o,t){let e=o.getFullYear()-t.getFullYear()||o.getMonth()-t.getMonth()||o.getDate()-t.getDate()||o.getHours()-t.getHours()||o.getMinutes()-t.getMinutes()||o.getSeconds()-t.getSeconds()||o.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function nu(o,t){let e=Ge(o,t?.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}var S0={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ou=(o,t,e)=>{let i,n=S0[o];return typeof n=="string"?i=n:t===1?i=n.one:i=n.other.replace("{{count}}",t.toString()),e?.addSuffix?e.comparison&&e.comparison>0?"in "+i:i+" ago":i};function il(o){return(t={})=>{let e=t.width?String(t.width):o.defaultWidth;return o.formats[e]||o.formats[o.defaultWidth]}}var k0={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},M0={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},T0={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ru={date:il({formats:k0,defaultWidth:"full"}),time:il({formats:M0,defaultWidth:"full"}),dateTime:il({formats:T0,defaultWidth:"full"})};var E0={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},au=(o,t,e,i)=>E0[o];function lr(o){return(t,e)=>{let i=e?.context?String(e.context):"standalone",n;if(i==="formatting"&&o.formattingValues){let a=o.defaultFormattingWidth||o.defaultWidth,c=e?.width?String(e.width):a;n=o.formattingValues[c]||o.formattingValues[a]}else{let a=o.defaultWidth,c=e?.width?String(e.width):o.defaultWidth;n=o.values[c]||o.values[a]}let r=o.argumentCallback?o.argumentCallback(t):t;return n[r]}}var P0={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},O0={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},A0={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},I0={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},D0={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},R0={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},F0=(o,t)=>{let e=Number(o),i=e%100;if(i>20||i<10)switch(i%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},su={ordinalNumber:F0,era:lr({values:P0,defaultWidth:"wide"}),quarter:lr({values:O0,defaultWidth:"wide",argumentCallback:o=>o-1}),month:lr({values:A0,defaultWidth:"wide"}),day:lr({values:I0,defaultWidth:"wide"}),dayPeriod:lr({values:D0,defaultWidth:"wide",formattingValues:R0,defaultFormattingWidth:"wide"})};function cr(o){return(t,e={})=>{let i=e.width,n=i&&o.matchPatterns[i]||o.matchPatterns[o.defaultMatchWidth],r=t.match(n);if(!r)return null;let a=r[0],c=i&&o.parsePatterns[i]||o.parsePatterns[o.defaultParseWidth],h=Array.isArray(c)?L0(c,x=>x.test(a)):N0(c,x=>x.test(a)),u;u=o.valueCallback?o.valueCallback(h):h,u=e.valueCallback?e.valueCallback(u):u;let b=t.slice(a.length);return{value:u,rest:b}}}function N0(o,t){for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e)&&t(o[e]))return e}function L0(o,t){for(let e=0;e<o.length;e++)if(t(o[e]))return e}function lu(o){return(t,e={})=>{let i=t.match(o.matchPattern);if(!i)return null;let n=i[0],r=t.match(o.parsePattern);if(!r)return null;let a=o.valueCallback?o.valueCallback(r[0]):r[0];a=e.valueCallback?e.valueCallback(a):a;let c=t.slice(n.length);return{value:a,rest:c}}}var V0=/^(\d+)(th|st|nd|rd)?/i,z0=/\d+/i,j0={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},B0={any:[/^b/i,/^(a|c)/i]},H0={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},W0={any:[/1/i,/2/i,/3/i,/4/i]},$0={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},U0={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},q0={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},G0={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Y0={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Q0={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},cu={ordinalNumber:lu({matchPattern:V0,parsePattern:z0,valueCallback:o=>parseInt(o,10)}),era:cr({matchPatterns:j0,defaultMatchWidth:"wide",parsePatterns:B0,defaultParseWidth:"any"}),quarter:cr({matchPatterns:H0,defaultMatchWidth:"wide",parsePatterns:W0,defaultParseWidth:"any",valueCallback:o=>o+1}),month:cr({matchPatterns:$0,defaultMatchWidth:"wide",parsePatterns:U0,defaultParseWidth:"any"}),day:cr({matchPatterns:q0,defaultMatchWidth:"wide",parsePatterns:G0,defaultParseWidth:"any"}),dayPeriod:cr({matchPatterns:Y0,defaultMatchWidth:"any",parsePatterns:Q0,defaultParseWidth:"any"})};var dd={code:"en-US",formatDistance:ou,formatLong:ru,formatRelative:au,localize:su,match:cu,options:{weekStartsOn:0,firstWeekContainsDate:1}};function du(o,t){let e=Ge(o,t?.in);return tl(e,nu(e))+1}function mu(o,t){let e=Ge(o,t?.in),i=+co(e)-+Xh(e);return Math.round(i/Js)+1}function nl(o,t){let e=Ge(o,t?.in),i=e.getFullYear(),n=Vn(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=at(t?.in||o,0);a.setFullYear(i+1,0,r),a.setHours(0,0,0,0);let c=fn(a,t),h=at(t?.in||o,0);h.setFullYear(i,0,r),h.setHours(0,0,0,0);let u=fn(h,t);return+e>=+c?i+1:+e>=+u?i:i-1}function pu(o,t){let e=Vn(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??e.firstWeekContainsDate??e.locale?.options?.firstWeekContainsDate??1,n=nl(o,t),r=at(t?.in||o,0);return r.setFullYear(n,0,i),r.setHours(0,0,0,0),fn(r,t)}function hu(o,t){let e=Ge(o,t?.in),i=+fn(e,t)-+pu(e,t);return Math.round(i/Js)+1}function we(o,t){let e=o<0?"-":"",i=Math.abs(o).toString().padStart(t,"0");return e+i}var _n={y(o,t){let e=o.getFullYear(),i=e>0?e:1-e;return we(t==="yy"?i%100:i,t.length)},M(o,t){let e=o.getMonth();return t==="M"?String(e+1):we(e+1,2)},d(o,t){return we(o.getDate(),t.length)},a(o,t){let e=o.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(o,t){return we(o.getHours()%12||12,t.length)},H(o,t){return we(o.getHours(),t.length)},m(o,t){return we(o.getMinutes(),t.length)},s(o,t){return we(o.getSeconds(),t.length)},S(o,t){let e=t.length,i=o.getMilliseconds(),n=Math.trunc(i*Math.pow(10,e-3));return we(n,t.length)}};var dr={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},md={G:function(o,t,e){let i=o.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(i,{width:"abbreviated"});case"GGGGG":return e.era(i,{width:"narrow"});case"GGGG":default:return e.era(i,{width:"wide"})}},y:function(o,t,e){if(t==="yo"){let i=o.getFullYear(),n=i>0?i:1-i;return e.ordinalNumber(n,{unit:"year"})}return _n.y(o,t)},Y:function(o,t,e,i){let n=nl(o,i),r=n>0?n:1-n;if(t==="YY"){let a=r%100;return we(a,2)}return t==="Yo"?e.ordinalNumber(r,{unit:"year"}):we(r,t.length)},R:function(o,t){let e=el(o);return we(e,t.length)},u:function(o,t){let e=o.getFullYear();return we(e,t.length)},Q:function(o,t,e){let i=Math.ceil((o.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return we(i,2);case"Qo":return e.ordinalNumber(i,{unit:"quarter"});case"QQQ":return e.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(i,{width:"wide",context:"formatting"})}},q:function(o,t,e){let i=Math.ceil((o.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return we(i,2);case"qo":return e.ordinalNumber(i,{unit:"quarter"});case"qqq":return e.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(i,{width:"wide",context:"standalone"})}},M:function(o,t,e){let i=o.getMonth();switch(t){case"M":case"MM":return _n.M(o,t);case"Mo":return e.ordinalNumber(i+1,{unit:"month"});case"MMM":return e.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(i,{width:"wide",context:"formatting"})}},L:function(o,t,e){let i=o.getMonth();switch(t){case"L":return String(i+1);case"LL":return we(i+1,2);case"Lo":return e.ordinalNumber(i+1,{unit:"month"});case"LLL":return e.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(i,{width:"wide",context:"standalone"})}},w:function(o,t,e,i){let n=hu(o,i);return t==="wo"?e.ordinalNumber(n,{unit:"week"}):we(n,t.length)},I:function(o,t,e){let i=mu(o);return t==="Io"?e.ordinalNumber(i,{unit:"week"}):we(i,t.length)},d:function(o,t,e){return t==="do"?e.ordinalNumber(o.getDate(),{unit:"date"}):_n.d(o,t)},D:function(o,t,e){let i=du(o);return t==="Do"?e.ordinalNumber(i,{unit:"dayOfYear"}):we(i,t.length)},E:function(o,t,e){let i=o.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(i,{width:"short",context:"formatting"});case"EEEE":default:return e.day(i,{width:"wide",context:"formatting"})}},e:function(o,t,e,i){let n=o.getDay(),r=(n-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return we(r,2);case"eo":return e.ordinalNumber(r,{unit:"day"});case"eee":return e.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(n,{width:"short",context:"formatting"});case"eeee":default:return e.day(n,{width:"wide",context:"formatting"})}},c:function(o,t,e,i){let n=o.getDay(),r=(n-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return we(r,t.length);case"co":return e.ordinalNumber(r,{unit:"day"});case"ccc":return e.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(n,{width:"narrow",context:"standalone"});case"cccccc":return e.day(n,{width:"short",context:"standalone"});case"cccc":default:return e.day(n,{width:"wide",context:"standalone"})}},i:function(o,t,e){let i=o.getDay(),n=i===0?7:i;switch(t){case"i":return String(n);case"ii":return we(n,t.length);case"io":return e.ordinalNumber(n,{unit:"day"});case"iii":return e.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(i,{width:"short",context:"formatting"});case"iiii":default:return e.day(i,{width:"wide",context:"formatting"})}},a:function(o,t,e){let n=o.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(o,t,e){let i=o.getHours(),n;switch(i===12?n=dr.noon:i===0?n=dr.midnight:n=i/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(o,t,e){let i=o.getHours(),n;switch(i>=17?n=dr.evening:i>=12?n=dr.afternoon:i>=4?n=dr.morning:n=dr.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(o,t,e){if(t==="ho"){let i=o.getHours()%12;return i===0&&(i=12),e.ordinalNumber(i,{unit:"hour"})}return _n.h(o,t)},H:function(o,t,e){return t==="Ho"?e.ordinalNumber(o.getHours(),{unit:"hour"}):_n.H(o,t)},K:function(o,t,e){let i=o.getHours()%12;return t==="Ko"?e.ordinalNumber(i,{unit:"hour"}):we(i,t.length)},k:function(o,t,e){let i=o.getHours();return i===0&&(i=24),t==="ko"?e.ordinalNumber(i,{unit:"hour"}):we(i,t.length)},m:function(o,t,e){return t==="mo"?e.ordinalNumber(o.getMinutes(),{unit:"minute"}):_n.m(o,t)},s:function(o,t,e){return t==="so"?e.ordinalNumber(o.getSeconds(),{unit:"second"}):_n.s(o,t)},S:function(o,t){return _n.S(o,t)},X:function(o,t,e){let i=o.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return gu(i);case"XXXX":case"XX":return mo(i);case"XXXXX":case"XXX":default:return mo(i,":")}},x:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"x":return gu(i);case"xxxx":case"xx":return mo(i);case"xxxxx":case"xxx":default:return mo(i,":")}},O:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+uu(i,":");case"OOOO":default:return"GMT"+mo(i,":")}},z:function(o,t,e){let i=o.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+uu(i,":");case"zzzz":default:return"GMT"+mo(i,":")}},t:function(o,t,e){let i=Math.trunc(+o/1e3);return we(i,t.length)},T:function(o,t,e){return we(+o,t.length)}};function uu(o,t=""){let e=o>0?"-":"+",i=Math.abs(o),n=Math.trunc(i/60),r=i%60;return r===0?e+String(n):e+String(n)+t+we(r,2)}function gu(o,t){return o%60===0?(o>0?"-":"+")+we(Math.abs(o)/60,2):mo(o,t)}function mo(o,t=""){let e=o>0?"-":"+",i=Math.abs(o),n=we(Math.trunc(i/60),2),r=we(i%60,2);return e+n+t+r}var fu=(o,t)=>{switch(o){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},_u=(o,t)=>{switch(o){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},X0=(o,t)=>{let e=o.match(/(P+)(p+)?/)||[],i=e[1],n=e[2];if(!n)return fu(o,t);let r;switch(i){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;case"PPPP":default:r=t.dateTime({width:"full"});break}return r.replace("{{date}}",fu(i,t)).replace("{{time}}",_u(n,t))},bu={p:_u,P:X0};var K0=/^D+$/,Z0=/^Y+$/,J0=["D","DD","YY","YYYY"];function vu(o){return K0.test(o)}function yu(o){return Z0.test(o)}function Cu(o,t,e){let i=ev(o,t,e);if(console.warn(i),J0.includes(o))throw new RangeError(i)}function ev(o,t,e){let i=o[0]==="Y"?"years":"days of the month";return`Use \`${o.toLowerCase()}\` instead of \`${o}\` (in \`${t}\`) for formatting ${i} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var tv=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,iv=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nv=/^'([^]*?)'?$/,ov=/''/g,rv=/[a-zA-Z]/;function pd(o,t,e){let i=Vn(),n=e?.locale??i.locale??dd,r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,c=Ge(o,e?.in);if(!eu(c))throw new RangeError("Invalid time value");let h=t.match(iv).map(b=>{let x=b[0];if(x==="p"||x==="P"){let E=bu[x];return E(b,n.formatLong)}return b}).join("").match(tv).map(b=>{if(b==="''")return{isToken:!1,value:"'"};let x=b[0];if(x==="'")return{isToken:!1,value:av(b)};if(md[x])return{isToken:!0,value:b};if(x.match(rv))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:b}});n.localize.preprocessor&&(h=n.localize.preprocessor(c,h));let u={firstWeekContainsDate:r,weekStartsOn:a,locale:n};return h.map(b=>{if(!b.isToken)return b.value;let x=b.value;(!e?.useAdditionalWeekYearTokens&&yu(x)||!e?.useAdditionalDayOfYearTokens&&vu(x))&&Cu(x,t,String(o));let E=md[x[0]];return E(c,x,n.localize,u)}).join("")}function av(o){let t=o.match(nv);return t?t[1].replace(ov,"'"):o}function xu(o,t,e){return Qh(o,-t,e)}function wu(o,t){return Zh(at(t?.in||o,o),xu(Kh(t?.in||o),1))}function Su(o){if(!o||isNaN(o.getTime()))return"unknown";let t=new Date,e=pd(o,"HH:mm:ss"),i=t.getTime()-o.getTime(),n=Math.floor(i/(1e3*60));if(n<1)return`just now (${e})`;if(n<60)return`${n} min ago (${e})`;let r=Math.floor(i/(1e3*60*60));if(r<24)return`${r}h ago (${e})`;if(wu(o))return`yesterday ${e}`;let a=iu(t,o);return a<7?`${a}d ago ${e}`:`${pd(o,"dd/MM/yyyy")} ${e}`}var sv=(o,t)=>t.filename;function lv(o,t){if(o&1){let e=T();s(0,"button",11),_("click",function(){v(e);let n=g(2);return y(n.downloadAll())}),s(1,"mat-icon"),p(2,"download_for_offline"),l()()}}function cv(o,t){o&1&&(s(0,"div",10),A(1,"span",12),s(2,"span",13),p(3,"Loading files..."),l()())}function dv(o,t){o&1&&(s(0,"div",14)(1,"mat-icon",15),p(2,"folder_open"),l(),s(3,"p",16),p(4,"No files in exchange space"),l(),s(5,"p",17),p(6,"Upload files to share with the agent"),l()())}function mv(o,t){if(o&1){let e=T();s(0,"button",28),_("click",function(){v(e);let n=g().$implicit,r=g(4);return y(r.viewFile(n))}),s(1,"mat-icon"),p(2,"visibility"),l()()}}function pv(o,t){if(o&1){let e=T();s(0,"div",18)(1,"div",19)(2,"mat-icon",20),p(3),l(),s(4,"div",21)(5,"span",22),p(6),l(),s(7,"span",23),p(8),l()()(),s(9,"div",24),w(10,mv,3,0,"button",25),s(11,"button",26),_("click",function(){let n=v(e).$implicit,r=g(4);return y(r.download(n))}),s(12,"mat-icon"),p(13,"download"),l()(),s(14,"button",27),_("click",function(){let n=v(e).$implicit,r=g(4);return y(r.delete(n))}),s(15,"mat-icon"),p(16,"delete"),l()()()()}if(o&2){let e=t.$implicit,i=g(4);d(3),B(i.getFileIcon(e.filename)),d(2),C("title",e.filename),d(),B(e.filename),d(2),xn("",i.formatSize(e.size)," \u2022 ",i.formatDate(e.lastModified)),d(2),S(i.canViewFile(e)?10:-1)}}function hv(o,t){if(o&1&&Se(0,pv,17,6,"div",18,sv),o&2){let e=g(3);ke(e.files())}}function uv(o,t){if(o&1&&w(0,dv,7,0,"div",14)(1,hv,2,0),o&2){let e=g(2);S(e.files().length===0?0:1)}}function gv(o,t){if(o&1){let e=T();s(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),p(4,"Exchange"),l(),s(5,"span",5),p(6),l()(),s(7,"div",6),w(8,lv,3,0,"button",7),s(9,"button",8),_("click",function(){v(e);let n=g();return y(n.close())}),s(10,"mat-icon"),p(11,"chevron_right"),l()()()(),s(12,"div",9),w(13,cv,4,0,"div",10)(14,uv,2,1),l()()}if(o&2){let e=g();d(6),ne("(",e.files().length,")"),d(2),S(e.files().length>0?8:-1),d(5),S(e.isLoading()?13:14)}}function fv(o,t){if(o&1){let e=T();s(0,"app-content-viewer",29),_("closeViewer",function(){v(e);let n=g();return y(n.backToList())}),l()}if(o&2){let e=g();C("file",e.currentFile)("projectName",e.projectName)("threadId",e.threadId)}}var ol=class o{projectName;threadId;closeDrawer=new q;fileExchangeState=m(or);contentViewerService=m(rr);files=this.fileExchangeState.files;isLoading=this.fileExchangeState.isLoading;viewerState="list";currentFile=null;close(){this.viewerState==="content"?this.backToList():this.closeDrawer.emit()}viewFile(t){this.currentFile=t,this.viewerState="content"}backToList(){this.viewerState="list",this.currentFile=null}downloadAll(){this.fileExchangeState.downloadAllFiles()}download(t){this.fileExchangeState.downloadFile(t.filename)}delete(t){return ee(this,null,function*(){if(!confirm(`Delete file "${t.filename}"?`))return;let i=yield this.fileExchangeState.deleteFile(t.filename);i.success||alert(`Failed to delete file: ${i.error}`)})}getFileIcon(t){switch(t.split(".").pop()?.toLowerCase()){case"pdf":return"picture_as_pdf";case"csv":case"xlsx":case"xls":return"table_chart";case"txt":case"md":return"description";case"jpg":case"jpeg":case"png":case"gif":case"webp":return"image";case"zip":case"tar":case"gz":return"folder_zip";default:return"insert_drive_file"}}formatSize(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}formatDate(t){return Su(t)}canViewFile(t){return this.contentViewerService.isFormatViewable(t.filename)&&this.contentViewerService.isViewable(t.size)}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-file-exchange-drawer"]],inputs:{projectName:"projectName",threadId:"threadId"},outputs:{closeDrawer:"closeDrawer"},decls:2,vars:2,consts:[[1,"file-drawer-container"],[3,"file","projectName","threadId"],[1,"drawer-header"],[1,"header-left"],[1,"drawer-title"],[1,"file-count"],[1,"header-actions"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"file-list"],[1,"file-loading"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn",3,"click"],[1,"loading-spinner"],[1,"loading-text"],[1,"file-empty"],[1,"empty-icon"],[1,"empty-text"],[1,"empty-hint"],[1,"file-item"],[1,"file-info"],[1,"file-icon"],[1,"file-details"],[1,"file-name",3,"title"],[1,"file-meta"],[1,"file-actions"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn"],["mat-icon-button","","title","Download","type","button",1,"action-btn","download-btn",3,"click"],["mat-icon-button","","title","Delete","type","button",1,"action-btn","delete-btn",3,"click"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn",3,"click"],[3,"closeViewer","file","projectName","threadId"]],template:function(e,i){e&1&&(w(0,gv,15,3,"div",0),w(1,fv,1,3,"app-content-viewer",1)),e&2&&(S(i.viewerState==="list"?0:-1),d(),S(i.viewerState==="content"&&i.currentFile?1:-1))},dependencies:[Me,Fe,_e,_t,gt,Zs],styles:[".file-drawer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.drawer-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--color-border);flex-shrink:0}.header-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.5rem}.header-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem}.drawer-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text)}.file-count[_ngcontent-%COMP%]{font-size:.9rem;color:var(--color-text-secondary)}.download-all-btn[_ngcontent-%COMP%]{color:var(--color-primary)}.download-all-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.file-list[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:.5rem}.file-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;gap:1rem;color:var(--color-text-secondary)}.loading-spinner[_ngcontent-%COMP%]{display:inline-block;width:32px;height:32px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.loading-text[_ngcontent-%COMP%]{font-size:.9rem}.file-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;text-align:center;color:var(--color-text-secondary)}.empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:1rem;opacity:.5}.empty-text[_ngcontent-%COMP%]{margin:0 0 .5rem;font-size:1rem;font-weight:500}.empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;opacity:.7}.file-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-radius:8px;transition:background .2s;gap:1rem}.file-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.file-item[_ngcontent-%COMP%]:hover .file-actions[_ngcontent-%COMP%]{opacity:1}.file-info[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-icon[_ngcontent-%COMP%]{flex-shrink:0;color:var(--color-primary);font-size:28px;width:28px;height:28px}.file-details[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;min-width:0}.file-name[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.file-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .2s}.action-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.action-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.action-btn.view-btn[_ngcontent-%COMP%]:hover, .action-btn.download-btn[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.action-btn.delete-btn[_ngcontent-%COMP%]:hover{color:var(--color-error)}@media (max-width: 768px){.file-actions[_ngcontent-%COMP%]{opacity:1}.file-item[_ngcontent-%COMP%]{padding:1rem .75rem}.drawer-header[_ngcontent-%COMP%]{padding:.75rem}}"]})};var al=["*"],_v=["content"],bv=[[["mat-drawer"]],[["mat-drawer-content"]],"*"],vv=["mat-drawer","mat-drawer-content","*"];function yv(o,t){if(o&1){let e=T();s(0,"div",1),_("click",function(){v(e);let n=g();return y(n._onBackdropClicked())}),l()}if(o&2){let e=g();I("mat-drawer-shown",e._isShowingBackdrop())}}function Cv(o,t){o&1&&(s(0,"mat-drawer-content"),me(1,2),l())}var xv=[[["mat-sidenav"]],[["mat-sidenav-content"]],"*"],wv=["mat-sidenav","mat-sidenav-content","*"];function Sv(o,t){if(o&1){let e=T();s(0,"div",1),_("click",function(){v(e);let n=g();return y(n._onBackdropClicked())}),l()}if(o&2){let e=g();I("mat-drawer-shown",e._isShowingBackdrop())}}function kv(o,t){o&1&&(s(0,"mat-sidenav-content"),me(1,2),l())}var Mv=`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
363
363
  `;var Tv=new ie("MAT_DRAWER_DEFAULT_AUTOSIZE",{providedIn:"root",factory:Ev}),hd=new ie("MAT_DRAWER_CONTAINER");function Ev(){return!1}var mr=(()=>{class o extends sn{_platform=m(Ke);_changeDetectorRef=m(qe);_container=m(aa);constructor(){let e=m(te),i=m(an),n=m(de);super(e,i,n)}ngAfterContentInit(){this._container._contentMarginChanges.subscribe(()=>{this._changeDetectorRef.markForCheck()})}_shouldBeHidden(){if(this._platform.isBrowser)return!1;let{start:e,end:i}=this._container;return e!=null&&e.mode!=="over"&&e.opened||i!=null&&i.mode!=="over"&&i.opened}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=M({type:o,selectors:[["mat-drawer-content"]],hostAttrs:[1,"mat-drawer-content"],hostVars:6,hostBindings:function(i,n){i&2&&(Ii("margin-left",n._container._contentMargins.left,"px")("margin-right",n._container._contentMargins.right,"px"),I("mat-drawer-content-hidden",n._shouldBeHidden()))},features:[Ue([{provide:sn,useExisting:o}]),St],ngContentSelectors:al,decls:1,vars:0,template:function(i,n){i&1&&(je(),me(0))},encapsulation:2,changeDetection:0})}return o})(),ra=(()=>{class o{_elementRef=m(te);_focusTrapFactory=m(Va);_focusMonitor=m(Ri);_platform=m(Ke);_ngZone=m(de);_renderer=m(vt);_interactivityChecker=m(To);_doc=m(Xe);_container=m(hd,{optional:!0});_focusTrap=null;_elementFocusedBeforeDrawerWasOpened=null;_eventCleanups;_isAttached;_anchor;get position(){return this._position}set position(e){e=e==="end"?"end":"start",e!==this._position&&(this._isAttached&&this._updatePositionInParent(e),this._position=e,this.onPositionChanged.emit())}_position="start";get mode(){return this._mode}set mode(e){this._mode=e,this._updateFocusTrapState(),this._modeChanged.next()}_mode="over";get disableClose(){return this._disableClose}set disableClose(e){this._disableClose=kt(e)}_disableClose=!1;get autoFocus(){let e=this._autoFocus;return e??(this.mode==="side"?"dialog":"first-tabbable")}set autoFocus(e){(e==="true"||e==="false"||e==null)&&(e=kt(e)),this._autoFocus=e}_autoFocus;get opened(){return this._opened()}set opened(e){this.toggle(kt(e))}_opened=rt(!1);_openedVia;_animationStarted=new D;_animationEnd=new D;openedChange=new q(!0);_openedStream=this.openedChange.pipe(ce(e=>e),Oe(()=>{}));openedStart=this._animationStarted.pipe(ce(()=>this.opened),Hl(void 0));_closedStream=this.openedChange.pipe(ce(e=>!e),Oe(()=>{}));closedStart=this._animationStarted.pipe(ce(()=>!this.opened),Hl(void 0));_destroyed=new D;onPositionChanged=new q;_content;_modeChanged=new D;_injector=m(fe);_changeDetectorRef=m(qe);constructor(){this.openedChange.pipe(N(this._destroyed)).subscribe(e=>{e?(this._elementFocusedBeforeDrawerWasOpened=this._doc.activeElement,this._takeFocus()):this._isFocusWithinDrawer()&&this._restoreFocus(this._openedVia||"program")}),this._ngZone.runOutsideAngular(()=>{let e=this._elementRef.nativeElement;tm(e,"keydown").pipe(ce(i=>i.keyCode===27&&!this.disableClose&&!ut(i)),N(this._destroyed)).subscribe(i=>this._ngZone.run(()=>{this.close(),i.stopPropagation(),i.preventDefault()})),this._eventCleanups=[this._renderer.listen(e,"transitionrun",this._handleTransitionEvent),this._renderer.listen(e,"transitionend",this._handleTransitionEvent),this._renderer.listen(e,"transitioncancel",this._handleTransitionEvent)]}),this._animationEnd.subscribe(()=>{this.openedChange.emit(this.opened)})}_forceFocus(e,i){this._interactivityChecker.isFocusable(e)||(e.tabIndex=-1,this._ngZone.runOutsideAngular(()=>{let n=()=>{r(),a(),e.removeAttribute("tabindex")},r=this._renderer.listen(e,"blur",n),a=this._renderer.listen(e,"mousedown",n)})),e.focus(i)}_focusByCssSelector(e,i){let n=this._elementRef.nativeElement.querySelector(e);n&&this._forceFocus(n,i)}_takeFocus(){if(!this._focusTrap)return;let e=this._elementRef.nativeElement;switch(this.autoFocus){case!1:case"dialog":return;case!0:case"first-tabbable":It(()=>{!this._focusTrap.focusInitialElement()&&typeof e.focus=="function"&&e.focus()},{injector:this._injector});break;case"first-heading":this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');break;default:this._focusByCssSelector(this.autoFocus);break}}_restoreFocus(e){this.autoFocus!=="dialog"&&(this._elementFocusedBeforeDrawerWasOpened?this._focusMonitor.focusVia(this._elementFocusedBeforeDrawerWasOpened,e):this._elementRef.nativeElement.blur(),this._elementFocusedBeforeDrawerWasOpened=null)}_isFocusWithinDrawer(){let e=this._doc.activeElement;return!!e&&this._elementRef.nativeElement.contains(e)}ngAfterViewInit(){this._isAttached=!0,this._position==="end"&&this._updatePositionInParent("end"),this._platform.isBrowser&&(this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement),this._updateFocusTrapState())}ngOnDestroy(){this._eventCleanups.forEach(e=>e()),this._focusTrap?.destroy(),this._anchor?.remove(),this._anchor=null,this._animationStarted.complete(),this._animationEnd.complete(),this._modeChanged.complete(),this._destroyed.next(),this._destroyed.complete()}open(e){return this.toggle(!0,e)}close(){return this.toggle(!1)}_closeViaBackdropClick(){return this._setOpen(!1,!0,"mouse")}toggle(e=!this.opened,i){e&&i&&(this._openedVia=i);let n=this._setOpen(e,!e&&this._isFocusWithinDrawer(),this._openedVia||"program");return e||(this._openedVia=null),n}_setOpen(e,i,n){return e===this.opened?Promise.resolve(e?"open":"close"):(this._opened.set(e),this._container?._transitionsEnabled?this._setIsAnimating(!0):setTimeout(()=>{this._animationStarted.next(),this._animationEnd.next()}),this._elementRef.nativeElement.classList.toggle("mat-drawer-opened",e),!e&&i&&this._restoreFocus(n),this._changeDetectorRef.markForCheck(),this._updateFocusTrapState(),new Promise(r=>{this.openedChange.pipe(Ut(1)).subscribe(a=>r(a?"open":"close"))}))}_setIsAnimating(e){this._elementRef.nativeElement.classList.toggle("mat-drawer-animating",e)}_getWidth(){return this._elementRef.nativeElement.offsetWidth||0}_updateFocusTrapState(){this._focusTrap&&(this._focusTrap.enabled=!!this._container?.hasBackdrop&&this.opened)}_updatePositionInParent(e){if(!this._platform.isBrowser)return;let i=this._elementRef.nativeElement,n=i.parentNode;e==="end"?(this._anchor||(this._anchor=this._doc.createComment("mat-drawer-anchor"),n.insertBefore(this._anchor,i)),n.appendChild(i)):this._anchor&&this._anchor.parentNode.insertBefore(i,this._anchor)}_handleTransitionEvent=e=>{let i=this._elementRef.nativeElement;e.target===i&&this._ngZone.run(()=>{e.type==="transitionrun"?this._animationStarted.next(e):(e.type==="transitionend"&&this._setIsAnimating(!1),this._animationEnd.next(e))})};static \u0275fac=function(i){return new(i||o)};static \u0275cmp=M({type:o,selectors:[["mat-drawer"]],viewQuery:function(i,n){if(i&1&&X(_v,5),i&2){let r;H(r=W())&&(n._content=r.first)}},hostAttrs:[1,"mat-drawer"],hostVars:12,hostBindings:function(i,n){i&2&&(Q("align",null)("tabIndex",n.mode!=="side"?"-1":null),Ii("visibility",!n._container&&!n.opened?"hidden":null),I("mat-drawer-end",n.position==="end")("mat-drawer-over",n.mode==="over")("mat-drawer-push",n.mode==="push")("mat-drawer-side",n.mode==="side"))},inputs:{position:"position",mode:"mode",disableClose:"disableClose",autoFocus:"autoFocus",opened:"opened"},outputs:{openedChange:"openedChange",_openedStream:"opened",openedStart:"openedStart",_closedStream:"closed",closedStart:"closedStart",onPositionChanged:"positionChanged"},exportAs:["matDrawer"],ngContentSelectors:al,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(i,n){i&1&&(je(),s(0,"div",1,0),me(2),l())},dependencies:[sn],encapsulation:2,changeDetection:0})}return o})(),aa=(()=>{class o{_dir=m(ft,{optional:!0});_element=m(te);_ngZone=m(de);_changeDetectorRef=m(qe);_animationDisabled=Be();_transitionsEnabled=!1;_allDrawers;_drawers=new sm;_content;_userContent;get start(){return this._start}get end(){return this._end}get autosize(){return this._autosize}set autosize(e){this._autosize=kt(e)}_autosize=m(Tv);get hasBackdrop(){return this._drawerHasBackdrop(this._start)||this._drawerHasBackdrop(this._end)}set hasBackdrop(e){this._backdropOverride=e==null?null:kt(e)}_backdropOverride;backdropClick=new q;_start;_end;_left;_right;_destroyed=new D;_doCheckSubject=new D;_contentMargins={left:null,right:null};_contentMarginChanges=new D;get scrollable(){return this._userContent||this._content}_injector=m(fe);constructor(){let e=m(Ke),i=m(Vi);this._dir?.change.pipe(N(this._destroyed)).subscribe(()=>{this._validateDrawers(),this.updateContentMargins()}),i.change().pipe(N(this._destroyed)).subscribe(()=>this.updateContentMargins()),!this._animationDisabled&&e.isBrowser&&this._ngZone.runOutsideAngular(()=>{setTimeout(()=>{this._element.nativeElement.classList.add("mat-drawer-transition"),this._transitionsEnabled=!0},200)})}ngAfterContentInit(){this._allDrawers.changes.pipe(At(this._allDrawers),N(this._destroyed)).subscribe(e=>{this._drawers.reset(e.filter(i=>!i._container||i._container===this)),this._drawers.notifyOnChanges()}),this._drawers.changes.pipe(At(null)).subscribe(()=>{this._validateDrawers(),this._drawers.forEach(e=>{this._watchDrawerToggle(e),this._watchDrawerPosition(e),this._watchDrawerMode(e)}),(!this._drawers.length||this._isDrawerOpen(this._start)||this._isDrawerOpen(this._end))&&this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),this._ngZone.runOutsideAngular(()=>{this._doCheckSubject.pipe(im(10),N(this._destroyed)).subscribe(()=>this.updateContentMargins())})}ngOnDestroy(){this._contentMarginChanges.complete(),this._doCheckSubject.complete(),this._drawers.destroy(),this._destroyed.next(),this._destroyed.complete()}open(){this._drawers.forEach(e=>e.open())}close(){this._drawers.forEach(e=>e.close())}updateContentMargins(){let e=0,i=0;if(this._left&&this._left.opened){if(this._left.mode=="side")e+=this._left._getWidth();else if(this._left.mode=="push"){let n=this._left._getWidth();e+=n,i-=n}}if(this._right&&this._right.opened){if(this._right.mode=="side")i+=this._right._getWidth();else if(this._right.mode=="push"){let n=this._right._getWidth();i+=n,e-=n}}e=e||null,i=i||null,(e!==this._contentMargins.left||i!==this._contentMargins.right)&&(this._contentMargins={left:e,right:i},this._ngZone.run(()=>this._contentMarginChanges.next(this._contentMargins)))}ngDoCheck(){this._autosize&&this._isPushed()&&this._ngZone.runOutsideAngular(()=>this._doCheckSubject.next())}_watchDrawerToggle(e){e._animationStarted.pipe(N(this._drawers.changes)).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()}),e.mode!=="side"&&e.openedChange.pipe(N(this._drawers.changes)).subscribe(()=>this._setContainerClass(e.opened))}_watchDrawerPosition(e){e.onPositionChanged.pipe(N(this._drawers.changes)).subscribe(()=>{It({read:()=>this._validateDrawers()},{injector:this._injector})})}_watchDrawerMode(e){e._modeChanged.pipe(N(Ai(this._drawers.changes,this._destroyed))).subscribe(()=>{this.updateContentMargins(),this._changeDetectorRef.markForCheck()})}_setContainerClass(e){let i=this._element.nativeElement.classList,n="mat-drawer-container-has-open";e?i.add(n):i.remove(n)}_validateDrawers(){this._start=this._end=null,this._drawers.forEach(e=>{e.position=="end"?(this._end!=null,this._end=e):(this._start!=null,this._start=e)}),this._right=this._left=null,this._dir&&this._dir.value==="rtl"?(this._left=this._end,this._right=this._start):(this._left=this._start,this._right=this._end)}_isPushed(){return this._isDrawerOpen(this._start)&&this._start.mode!="over"||this._isDrawerOpen(this._end)&&this._end.mode!="over"}_onBackdropClicked(){this.backdropClick.emit(),this._closeModalDrawersViaBackdrop()}_closeModalDrawersViaBackdrop(){[this._start,this._end].filter(e=>e&&!e.disableClose&&this._drawerHasBackdrop(e)).forEach(e=>e._closeViaBackdropClick())}_isShowingBackdrop(){return this._isDrawerOpen(this._start)&&this._drawerHasBackdrop(this._start)||this._isDrawerOpen(this._end)&&this._drawerHasBackdrop(this._end)}_isDrawerOpen(e){return e!=null&&e.opened}_drawerHasBackdrop(e){return this._backdropOverride==null?!!e&&e.mode!=="side":this._backdropOverride}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=M({type:o,selectors:[["mat-drawer-container"]],contentQueries:function(i,n,r){if(i&1&&(yt(r,mr,5),yt(r,ra,5)),i&2){let a;H(a=W())&&(n._content=a.first),H(a=W())&&(n._allDrawers=a)}},viewQuery:function(i,n){if(i&1&&X(mr,5),i&2){let r;H(r=W())&&(n._userContent=r.first)}},hostAttrs:[1,"mat-drawer-container"],hostVars:2,hostBindings:function(i,n){i&2&&I("mat-drawer-container-explicit-backdrop",n._backdropOverride)},inputs:{autosize:"autosize",hasBackdrop:"hasBackdrop"},outputs:{backdropClick:"backdropClick"},exportAs:["matDrawerContainer"],features:[Ue([{provide:hd,useExisting:o}])],ngContentSelectors:vv,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(i,n){i&1&&(je(bv),w(0,yv,1,2,"div",0),me(1),me(2,1),w(3,Cv,2,0,"mat-drawer-content")),i&2&&(S(n.hasBackdrop?0:-1),d(3),S(n._content?-1:3))},dependencies:[mr],styles:[`.mat-drawer-container{position:relative;z-index:1;color:var(--mat-sidenav-content-text-color, var(--mat-sys-on-background));background-color:var(--mat-sidenav-content-background-color, var(--mat-sys-background));box-sizing:border-box;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible;background-color:var(--mat-sidenav-scrim-color, color-mix(in srgb, var(--mat-sys-neutral-variant20) 40%, transparent))}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}@media(forced-colors: active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-content.mat-drawer-content-hidden{opacity:0}.mat-drawer-transition .mat-drawer-content{transition-duration:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;color:var(--mat-sidenav-container-text-color, var(--mat-sys-on-surface-variant));box-shadow:var(--mat-sidenav-container-elevation-shadow, none);background-color:var(--mat-sidenav-container-background-color, var(--mat-sys-surface));border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));width:var(--mat-sidenav-container-width, 360px);display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%, 0, 0)}@media(forced-colors: active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media(forced-colors: active){[dir=rtl] .mat-drawer,.mat-drawer.mat-drawer-end{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%, 0, 0);border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .mat-drawer{border-top-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-left-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-right-radius:0;border-bottom-right-radius:0;transform:translate3d(100%, 0, 0)}[dir=rtl] .mat-drawer.mat-drawer-end{border-top-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large));border-top-left-radius:0;border-bottom-left-radius:0;left:0;right:auto;transform:translate3d(-100%, 0, 0)}.mat-drawer-transition .mat-drawer{transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating){visibility:hidden;box-shadow:none}.mat-drawer:not(.mat-drawer-opened):not(.mat-drawer-animating) .mat-drawer-inner-container{display:none}.mat-drawer.mat-drawer-opened.mat-drawer-opened{transform:none}.mat-drawer-side{box-shadow:none;border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid}.mat-drawer-side.mat-drawer-end{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side{border-left-color:var(--mat-sidenav-container-divider-color, transparent);border-left-width:1px;border-left-style:solid;border-right:none}[dir=rtl] .mat-drawer-side.mat-drawer-end{border-right-color:var(--mat-sidenav-container-divider-color, transparent);border-right-width:1px;border-right-style:solid;border-left:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto}.mat-sidenav-fixed{position:fixed}
364
364
  `],encapsulation:2,changeDetection:0})}return o})(),rl=(()=>{class o extends mr{static \u0275fac=(()=>{let e;return function(n){return(e||(e=ei(o)))(n||o)}})();static \u0275cmp=M({type:o,selectors:[["mat-sidenav-content"]],hostAttrs:[1,"mat-drawer-content","mat-sidenav-content"],features:[Ue([{provide:sn,useExisting:o}]),St],ngContentSelectors:al,decls:1,vars:0,template:function(i,n){i&1&&(je(),me(0))},encapsulation:2,changeDetection:0})}return o})(),ud=(()=>{class o extends ra{get fixedInViewport(){return this._fixedInViewport}set fixedInViewport(e){this._fixedInViewport=kt(e)}_fixedInViewport=!1;get fixedTopGap(){return this._fixedTopGap}set fixedTopGap(e){this._fixedTopGap=gi(e)}_fixedTopGap=0;get fixedBottomGap(){return this._fixedBottomGap}set fixedBottomGap(e){this._fixedBottomGap=gi(e)}_fixedBottomGap=0;static \u0275fac=(()=>{let e;return function(n){return(e||(e=ei(o)))(n||o)}})();static \u0275cmp=M({type:o,selectors:[["mat-sidenav"]],hostAttrs:[1,"mat-drawer","mat-sidenav"],hostVars:16,hostBindings:function(i,n){i&2&&(Q("tabIndex",n.mode!=="side"?"-1":null)("align",null),Ii("top",n.fixedInViewport?n.fixedTopGap:null,"px")("bottom",n.fixedInViewport?n.fixedBottomGap:null,"px"),I("mat-drawer-end",n.position==="end")("mat-drawer-over",n.mode==="over")("mat-drawer-push",n.mode==="push")("mat-drawer-side",n.mode==="side")("mat-sidenav-fixed",n.fixedInViewport))},inputs:{fixedInViewport:"fixedInViewport",fixedTopGap:"fixedTopGap",fixedBottomGap:"fixedBottomGap"},exportAs:["matSidenav"],features:[Ue([{provide:ra,useExisting:o}]),St],ngContentSelectors:al,decls:3,vars:0,consts:[["content",""],["cdkScrollable","",1,"mat-drawer-inner-container"]],template:function(i,n){i&1&&(je(),s(0,"div",1,0),me(2),l())},dependencies:[sn],encapsulation:2,changeDetection:0})}return o})(),ku=(()=>{class o extends aa{_allDrawers=void 0;_content=void 0;static \u0275fac=(()=>{let e;return function(n){return(e||(e=ei(o)))(n||o)}})();static \u0275cmp=M({type:o,selectors:[["mat-sidenav-container"]],contentQueries:function(i,n,r){if(i&1&&(yt(r,rl,5),yt(r,ud,5)),i&2){let a;H(a=W())&&(n._content=a.first),H(a=W())&&(n._allDrawers=a)}},hostAttrs:[1,"mat-drawer-container","mat-sidenav-container"],hostVars:2,hostBindings:function(i,n){i&2&&I("mat-drawer-container-explicit-backdrop",n._backdropOverride)},exportAs:["matSidenavContainer"],features:[Ue([{provide:hd,useExisting:o},{provide:aa,useExisting:o}]),St],ngContentSelectors:wv,decls:4,vars:2,consts:[[1,"mat-drawer-backdrop",3,"mat-drawer-shown"],[1,"mat-drawer-backdrop",3,"click"]],template:function(i,n){i&1&&(je(xv),w(0,Sv,1,2,"div",0),me(1),me(2,1),w(3,kv,2,0,"mat-sidenav-content")),i&2&&(S(n.hasBackdrop?0:-1),d(3),S(n._content?-1:3))},dependencies:[rl],styles:[Mv],encapsulation:2,changeDetection:0})}return o})(),sl=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275mod=re({type:o});static \u0275inj=oe({imports:[ae,Li,Li,ae]})}return o})();var Tu="mat-badge-content",Pv=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275cmp=M({type:o,selectors:[["ng-component"]],decls:0,vars:0,template:function(i,n){},styles:[`.mat-badge{position:relative}.mat-badge.mat-badge{overflow:visible}.mat-badge-content{position:absolute;text-align:center;display:inline-block;transition:transform 200ms ease-in-out;transform:scale(0.6);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;box-sizing:border-box;pointer-events:none;background-color:var(--mat-badge-background-color, var(--mat-sys-error));color:var(--mat-badge-text-color, var(--mat-sys-on-error));font-family:var(--mat-badge-text-font, var(--mat-sys-label-small-font));font-weight:var(--mat-badge-text-weight, var(--mat-sys-label-small-weight));border-radius:var(--mat-badge-container-shape, var(--mat-sys-corner-full))}.mat-badge-above .mat-badge-content{bottom:100%}.mat-badge-below .mat-badge-content{top:100%}.mat-badge-before .mat-badge-content{right:100%}[dir=rtl] .mat-badge-before .mat-badge-content{right:auto;left:100%}.mat-badge-after .mat-badge-content{left:100%}[dir=rtl] .mat-badge-after .mat-badge-content{left:auto;right:100%}@media(forced-colors: active){.mat-badge-content{outline:solid 1px;border-radius:0}}.mat-badge-disabled .mat-badge-content{background-color:var(--mat-badge-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-error) 38%, transparent));color:var(--mat-badge-disabled-state-text-color, var(--mat-sys-on-error))}.mat-badge-hidden .mat-badge-content{display:none}.ng-animate-disabled .mat-badge-content,.mat-badge-content._mat-animation-noopable{transition:none}.mat-badge-content.mat-badge-active{transform:none}.mat-badge-small .mat-badge-content{width:var(--mat-badge-legacy-small-size-container-size, unset);height:var(--mat-badge-legacy-small-size-container-size, unset);min-width:var(--mat-badge-small-size-container-size, 6px);min-height:var(--mat-badge-small-size-container-size, 6px);line-height:var(--mat-badge-small-size-line-height, 6px);padding:var(--mat-badge-small-size-container-padding, 0);font-size:var(--mat-badge-small-size-text-size, 0);margin:var(--mat-badge-small-size-container-offset, -6px 0)}.mat-badge-small.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-small-size-container-overlap-offset, -6px)}.mat-badge-medium .mat-badge-content{width:var(--mat-badge-legacy-container-size, unset);height:var(--mat-badge-legacy-container-size, unset);min-width:var(--mat-badge-container-size, 16px);min-height:var(--mat-badge-container-size, 16px);line-height:var(--mat-badge-line-height, 16px);padding:var(--mat-badge-container-padding, 0 4px);font-size:var(--mat-badge-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-container-offset, -12px 0)}.mat-badge-medium.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-container-overlap-offset, -12px)}.mat-badge-large .mat-badge-content{width:var(--mat-badge-legacy-large-size-container-size, unset);height:var(--mat-badge-legacy-large-size-container-size, unset);min-width:var(--mat-badge-large-size-container-size, 16px);min-height:var(--mat-badge-large-size-container-size, 16px);line-height:var(--mat-badge-large-size-line-height, 16px);padding:var(--mat-badge-large-size-container-padding, 0 4px);font-size:var(--mat-badge-large-size-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-large-size-container-offset, -12px 0)}.mat-badge-large.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-large-size-container-overlap-offset, -12px)}
365
365
  `],encapsulation:2,changeDetection:0})}return o})(),Eu=(()=>{class o{_ngZone=m(de);_elementRef=m(te);_ariaDescriber=m(ja);_renderer=m(vt);_animationsDisabled=Be();_idGenerator=m(Ae);get color(){return this._color}set color(e){this._setColor(e),this._color=e}_color="primary";overlap=!0;disabled;position="above after";get content(){return this._content}set content(e){this._updateRenderedContent(e)}_content;get description(){return this._description}set description(e){this._updateDescription(e)}_description;size="medium";hidden;_badgeElement;_inlineBadgeDescription;_isInitialized=!1;_interactivityChecker=m(To);_document=m(Xe);constructor(){let e=m(Dt);e.load(Pv),e.load(La)}isAbove(){return this.position.indexOf("below")===-1}isAfter(){return this.position.indexOf("before")===-1}getBadgeElement(){return this._badgeElement}ngOnInit(){this._clearExistingBadges(),this.content&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement(),this._updateRenderedContent(this.content)),this._isInitialized=!0}ngOnDestroy(){this._renderer.destroyNode&&(this._renderer.destroyNode(this._badgeElement),this._inlineBadgeDescription?.remove()),this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description)}_isHostInteractive(){return this._interactivityChecker.isFocusable(this._elementRef.nativeElement,{ignoreVisibility:!0})}_createBadgeElement(){let e=this._renderer.createElement("span"),i="mat-badge-active";return e.setAttribute("id",this._idGenerator.getId("mat-badge-content-")),e.setAttribute("aria-hidden","true"),e.classList.add(Tu),this._animationsDisabled&&e.classList.add("_mat-animation-noopable"),this._elementRef.nativeElement.appendChild(e),typeof requestAnimationFrame=="function"&&!this._animationsDisabled?this._ngZone.runOutsideAngular(()=>{requestAnimationFrame(()=>{e.classList.add(i)})}):e.classList.add(i),e}_updateRenderedContent(e){let i=`${e??""}`.trim();this._isInitialized&&i&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement()),this._badgeElement&&(this._badgeElement.textContent=i),this._content=i}_updateDescription(e){this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description),(!e||this._isHostInteractive())&&this._removeInlineDescription(),this._description=e,this._isHostInteractive()?this._ariaDescriber.describe(this._elementRef.nativeElement,e):this._updateInlineDescription()}_updateInlineDescription(){this._inlineBadgeDescription||(this._inlineBadgeDescription=this._document.createElement("span"),this._inlineBadgeDescription.classList.add("cdk-visually-hidden")),this._inlineBadgeDescription.textContent=this.description,this._badgeElement?.appendChild(this._inlineBadgeDescription)}_removeInlineDescription(){this._inlineBadgeDescription?.remove(),this._inlineBadgeDescription=void 0}_setColor(e){let i=this._elementRef.nativeElement.classList;i.remove(`mat-badge-${this._color}`),e&&i.add(`mat-badge-${e}`)}_clearExistingBadges(){let e=this._elementRef.nativeElement.querySelectorAll(`:scope > .${Tu}`);for(let i of Array.from(e))i!==this._badgeElement&&i.remove()}static \u0275fac=function(i){return new(i||o)};static \u0275dir=ye({type:o,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(i,n){i&2&&I("mat-badge-overlap",n.overlap)("mat-badge-above",n.isAbove())("mat-badge-below",!n.isAbove())("mat-badge-before",!n.isAfter())("mat-badge-after",n.isAfter())("mat-badge-small",n.size==="small")("mat-badge-medium",n.size==="medium")("mat-badge-large",n.size==="large")("mat-badge-hidden",n.hidden||!n.content)("mat-badge-disabled",n.disabled)},inputs:{color:[0,"matBadgeColor","color"],overlap:[2,"matBadgeOverlap","overlap",J],disabled:[2,"matBadgeDisabled","disabled",J],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",J]}})}return o})(),Pu=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275mod=re({type:o});static \u0275inj=oe({imports:[Eo,ae,ae]})}return o})();var pr=class o{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=m(ir);project=m(Te);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){Wn([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([t,e])=>{this.updateTitle(t?.name??"...",e)})}updateTitle(t,e){let i;this.isSystemActive?i=`\u23F3${e>0?` (${e}) `:" "}${t}`:e>0?i=`${this.ATTENTION_EMOJI} (${e}) ${t}`:i=t,document.title=i,console.log("[TAB-TITLE] Updated to:",i)}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=!0,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=!1,this.forceUpdateTitle()},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle()}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=!1,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle()}forceUpdateTitle(){let t=this.project.getSelectedProjectId()??"...",e=this.unreadService.getCurrentCount();this.updateTitle(t,e)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var ll=class o{http=m(Je);maxFileSize=5*1024*1024;supportedTypes=["image/png","image/jpeg","image/gif","image/webp"];validateFile(t){if(!this.supportedTypes.includes(t.type))throw new Error(`Unsupported file type: ${t.type}`);if(t.size>this.maxFileSize)throw new Error(`File too large: ${(t.size/1024/1024).toFixed(1)}MB exceeds 5MB limit`)}fileToBase64(t){return ee(this,null,function*(){return new Promise((e,i)=>{let n=new FileReader;n.onload=()=>{let r=n.result;if(!r){i(new Error("Failed to read file"));return}let a=r.split(",")[1];if(!a){i(new Error("Invalid file format"));return}e(a)},n.onerror=i,n.readAsDataURL(t)})})}getUploadUrl(t,e){return`/api/projects/${t}/threads/${e}/upload`}uploadImage(t,e,i){console.log("[IMAGE-UPLOAD] uploadImage - file:",t.name,t.type,t.size),console.log("[IMAGE-UPLOAD] uploadImage - project:",e,"thread:",i);try{console.log("[IMAGE-UPLOAD] Validating file..."),this.validateFile(t)}catch(n){return console.log("[IMAGE-UPLOAD] Validation failed:",n),Ot({success:!1,error:n instanceof Error?n.message:"Validation failed"})}return new Oi(n=>{console.log("[IMAGE-UPLOAD] Converting to base64..."),this.fileToBase64(t).then(r=>{console.log("[IMAGE-UPLOAD] Base64 length:",r.length),console.log("[IMAGE-UPLOAD] Sending upload request..."),this.http.post(this.getUploadUrl(e,i),{content:r,mimeType:t.type,filename:t.name}).pipe(Oe(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),$n(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let c=a.error?.error||a.message||"Upload failed";return Ot({success:!1,error:c})})).subscribe({next:a=>{n.next(a),n.complete()},error:a=>n.error(a)})}).catch(r=>{console.log("[IMAGE-UPLOAD] Base64 conversion failed:",r),n.next({success:!1,error:r instanceof Error?r.message:"Failed to read file"}),n.complete()})})}hasImageFiles(t){if(console.log("[IMAGE-UPLOAD] hasImageFiles - dataTransfer:",t),!t)return console.log("[IMAGE-UPLOAD] hasImageFiles - no dataTransfer"),!1;if(console.log("[IMAGE-UPLOAD] hasImageFiles - types:",Array.from(t.types)),!Array.from(t.types).includes("Files"))return console.log("[IMAGE-UPLOAD] hasImageFiles - no Files type"),!1;let e=Array.from(t.files||[]);console.log("[IMAGE-UPLOAD] hasImageFiles - files:",e.map(n=>({name:n.name,type:n.type})));let i=e.some(n=>this.supportedTypes.includes(n.type));return console.log("[IMAGE-UPLOAD] hasImageFiles - result:",i),i}filterImageFiles(t){return Array.from(t).filter(i=>this.supportedTypes.includes(i.type))}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var hr=class o{pendingFirstMessage=null;setPendingFirstMessage(t){console.log("[FIRST-MESSAGE-STATE] Storing pending first message:",t.substring(0,50)+"..."),this.pendingFirstMessage=t}consumePendingFirstMessage(){let t=this.pendingFirstMessage;return t?(console.log("[FIRST-MESSAGE-STATE] Consuming pending first message:",t.substring(0,50)+"..."),this.pendingFirstMessage=null):console.log("[FIRST-MESSAGE-STATE] No pending first message to consume"),t}hasPendingFirstMessage(){return this.pendingFirstMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Av=["inputSection"];function Iv(o,t){if(o&1){let e=T();s(0,"button",18),_("click",function(){v(e);let n=g();return y(n.toggleFileDrawer())}),s(1,"mat-icon"),p(2,"folder_open"),l()()}if(o&2){let e=g();I("has-files",e.fileCount>0),C("title",wn("Files Exchange",e.fileCount>0?" ("+e.fileCount+" file"+(e.fileCount>1?"s":"")+")":""))("matBadge",e.fileCount>0?e.fileCount:null)}}function Dv(o,t){if(o&1&&(s(0,"div",5),p(1),l()),o&2){let e=g();d(),xn(" \u26A0\uFE0F Connection lost. Reconnecting... (",e.connectionStatus.reconnectAttempts,"/",e.connectionStatus.maxAttempts,") ")}}function Rv(o,t){if(o&1&&(s(0,"div",19),p(1),l()),o&2){let e=g();I("error",e.uploadStatus.isError),d(),ne(" ",e.uploadStatus.message," ")}}function Fv(o,t){if(o&1){let e=T();s(0,"app-chat-textarea",20),_("messageSubmitted",function(n){v(e);let r=g();return y(r.onMessageSubmitted(n))})("voiceRecordingToggled",function(n){v(e);let r=g();return y(r.onVoiceToggled(n))})("heightChanged",function(n){v(e);let r=g();return y(r.onInputHeightChanged(n))})("stopRequested",function(){v(e);let n=g();return y(n.onStopRequested())})("filesPasted",function(n){v(e);let r=g();return y(r.onFilesPasted(n))}),l()}if(o&2){let e=g();C("isDisabled",!e.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",e.isThinking)("isStarting",!1)}}function Nv(o,t){if(o&1){let e=T();s(0,"app-choice-select",21),_("choiceSelected",function(n){v(e);let r=g();return y(r.onChoiceSelected(n))}),l()}if(o&2){let e=g();C("options",e.currentChoice.options)("labelHtml",e.currentChoice.label)("isVisible",!!e.currentChoice)("allowFreeText",e.currentChoice.allowFreeText)}}function Lv(o,t){o&1&&(s(0,"div",17)(1,"div",22)(2,"div",23),p(3,"\u{1F4CE}"),l(),s(4,"div",24),p(5,"Drop files here to upload"),l(),s(6,"div",25),p(7,"Images will be added to conversation, other files to exchange space"),l()()())}var cl=class o{projectName;threadId;destroy$=new D;inputSection;messages=[];streamingText="";isThinking=!1;currentChoice=null;connectionStatus=null;isConnected=!1;showConnectionStatus=!1;hasEverConnected=!1;inputSectionHeight=80;uploadStatus={message:"",isError:!1};isDragOver=!1;isFileDrawerOpen=!1;get fileCount(){return this.fileExchangeState.fileCount()}pendingFirstMessage=null;subscriptions=[];codayService=m(Yt);preferencesService=m(et);titleService=m(pr);elementRef=m(te);threadState=m(Tt);imageUploadService=m(ll);fileExchangeState=m(or);firstMessageState=m(hr);ngOnInit(){if(console.log("[THREAD] Initializing with project:",this.projectName,"thread:",this.threadId),!this.projectName||!this.threadId){console.error("[THREAD] Missing required inputs: projectName or threadId");return}this.setupPrintHandlers(),this.initializeThreadConnection()}ngOnChanges(t){console.log("[THREAD] ngOnChanges called",t),t.threadId&&(console.log("[THREAD] threadId changed:",{firstChange:t.threadId.firstChange,previousValue:t.threadId.previousValue,currentValue:t.threadId.currentValue}),t.threadId.firstChange||(console.log("[THREAD] Reconnecting to new thread"),this.initializeThreadConnection()))}initializeThreadConnection(){console.log("[THREAD] Initializing connection for thread:",this.threadId),this.fileExchangeState.initializeForThread(this.projectName,this.threadId),this.codayService.messages$.pipe(N(this.destroy$)).subscribe(e=>{console.log("[THREAD] Messages updated:",e.length),this.messages=e}),this.codayService.streamingText$.pipe(N(this.destroy$)).subscribe(e=>{this.streamingText=e}),this.codayService.isThinking$.pipe(N(this.destroy$)).subscribe(e=>{this.isThinking=e}),this.codayService.currentChoice$.pipe(N(this.destroy$)).subscribe(e=>{this.currentChoice=e}),this.codayService.connectionStatus$.pipe(N(this.destroy$)).subscribe(e=>{this.connectionStatus=e,this.isConnected=e.connected,e.connected&&!this.hasEverConnected&&(this.hasEverConnected=!0,this.showConnectionStatus=!0),!e.connected&&!this.hasEverConnected?setTimeout(()=>{!this.isConnected&&!this.hasEverConnected&&(this.showConnectionStatus=!0)},2e3):!e.connected&&this.hasEverConnected?this.showConnectionStatus=!0:e.connected&&(this.showConnectionStatus=!0)}),this.codayService.threadUpdateEvent$.pipe(N(this.destroy$)).subscribe(e=>{e&&(console.log("[THREAD] Thread update event received:",e),this.threadState.refreshThreadList())}),this.codayService.resetMessages(),this.codayService.setTabTitleService(this.titleService),console.log("[THREAD] Connecting to thread event stream"),this.codayService.connectToThread(this.projectName,this.threadId);let t=this.firstMessageState.consumePendingFirstMessage();t?(console.log("[THREAD] First message pending:",t.substring(0,50)+"..."),this.pendingFirstMessage=t,this.codayService.setThinkingForPendingMessage(),this.subscribeToFirstInvite()):console.log("[THREAD] No first message found in state service")}ngAfterViewChecked(){if(this.inputSection?.nativeElement){let t=this.inputSection.nativeElement.offsetHeight;t!==this.inputSectionHeight&&t>0&&(this.inputSectionHeight=t)}}ngOnDestroy(){console.log("[THREAD] Destroying component"),this.destroy$.next(),this.destroy$.complete(),this.fileExchangeState.clear(),this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions=[],window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(t){console.log("[THREAD] Sending message:",t),this.codayService.sendMessage(t)}onVoiceToggled(t){console.log("[VOICE] Recording:",t)}onChoiceSelected(t){console.log("[THREAD] Choice selected:",t),this.codayService.sendChoice(t)}onCopyMessage(t){console.log("[COPY] Message copied:",t.id)}onStopRequested(){this.threadState.stop()}onInputHeightChanged(t){console.log("[THREAD] Input height changed:",t),this.inputSectionHeight=t}onFilesPasted(t){console.log("[THREAD] File(s) pasted:",t.length);let e=this.imageUploadService.filterImageFiles(t),i=t.filter(n=>!n.type.startsWith("image/"));e.length&&this.uploadFilesSequentially(e,0),i.length&&this.uploadFilesToExchangeSpace(i),!e.length&&!i.length&&this.showUploadError("No supported files found")}toggleFileDrawer(){console.log("[THREAD] Toggling file drawer"),this.isFileDrawerOpen=!this.isFileDrawerOpen}closeFileDrawer(){console.log("[THREAD] Closing file drawer"),this.isFileDrawerOpen=!1}onDragEnter(t){t.preventDefault(),t.dataTransfer?.types.includes("Files")&&(console.log("[THREAD] Image files detected - showing drag overlay"),this.isDragOver=!0)}onDragOver(t){t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy")}onDragLeave(t){this.elementRef.nativeElement.contains(t.relatedTarget)||(console.log("[THREAD] Leaving component area - hiding drag overlay"),this.isDragOver=!1)}onDrop(t){t.preventDefault(),this.isDragOver=!1,console.log("[THREAD] Files dropped:",t.dataTransfer?.files?.length||0);let e=t.dataTransfer?.files;if(!e||e.length===0){console.log("[THREAD] No files in drop event");return}let i=this.imageUploadService.filterImageFiles(e),n=Array.from(e).filter(r=>!r.type.startsWith("image/"));console.log("[THREAD] Image files:",i.length,"Other files:",n.length),i.length>0&&this.uploadFilesSequentially(i,0),n.length>0&&this.uploadFilesToExchangeSpace(n),i.length===0&&n.length===0&&this.showUploadError("No supported files found")}uploadFilesSequentially(t,e){if(e>=t.length)return;let i=t[e];if(!i){console.error("[THREAD] File at index",e,"is undefined");return}console.log("[THREAD] Uploading file:",i.name),this.uploadStatus={message:`Uploading ${i.name}...`,isError:!1},this.imageUploadService.uploadImage(i,this.projectName,this.threadId).subscribe({next:n=>{n.success?(console.log("[THREAD] Upload successful:",i.name),this.uploadStatus={message:`\u2713 ${i.name} uploaded (${(n.processedSize/1024).toFixed(1)} KB)`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3),this.uploadFilesSequentially(t,e+1)):(console.error("[THREAD] Upload failed:",i.name,n.error),this.showUploadError(`Failed to upload ${i.name}: ${n.error}`))},error:n=>{console.error("[THREAD] Upload error:",i.name,n),this.showUploadError(`Failed to upload ${i.name}: ${n.message||"Unknown error"}`)}})}showUploadError(t){this.uploadStatus={message:t,isError:!0},setTimeout(()=>{this.uploadStatus={message:"",isError:!1}},5e3)}uploadFilesToExchangeSpace(t){return ee(this,null,function*(){for(let e of t){console.log("[THREAD] Uploading to exchange space:",e.name),this.uploadStatus={message:`Uploading ${e.name}...`,isError:!1};let i=yield this.fileExchangeState.uploadFile(e);if(i.success)console.log("[THREAD] Upload to exchange space successful:",e.name),this.uploadStatus={message:`\u2713 ${e.name} uploaded to exchange space`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3);else{console.error("[THREAD] Upload to exchange space failed:",e.name,i.error),this.showUploadError(`Failed to upload ${e.name}: ${i.error}`);break}}})}subscribeToFirstInvite(){console.log("[THREAD] Subscribing to wait for InviteEvent"),this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(t=>{if(t&&this.pendingFirstMessage){console.log("[THREAD] Received InviteEvent, sending pending message");let e=this.pendingFirstMessage;this.pendingFirstMessage=null,this.codayService.sendMessage(e)}}))}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let t=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",t),t?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(e){return new(e||o)};static \u0275cmp=M({type:o,selectors:[["app-thread"]],viewQuery:function(e,i){if(e&1&&X(Av,5),e&2){let n;H(n=W())&&(i.inputSection=n.first)}},inputs:{projectName:"projectName",threadId:"threadId"},features:[Ze],decls:19,vars:13,consts:[["inputSection",""],[1,"drag-drop-wrapper",3,"dragenter","dragover","dragleave","drop"],[1,"file-drawer-container",3,"hasBackdrop"],[1,"thread-container"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"has-files","matBadge","title"],[1,"connection-status"],[1,"chat-wrapper"],[1,"chat-center"],[3,"copyRequested","stopRequested","messages","streamingText","isThinking"],[1,"upload-status",3,"error"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"options","labelHtml","isVisible","allowFreeText"],["mode","side","position","end",3,"closed","opened"],[3,"closeDrawer","projectName","threadId"],[1,"drag-overlay"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"click","matBadge","title"],[1,"upload-status"],[3,"messageSubmitted","voiceRecordingToggled","heightChanged","stopRequested","filesPasted","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"choiceSelected","options","labelHtml","isVisible","allowFreeText"],[1,"drag-overlay-content"],[1,"drag-icon"],[1,"drag-text"],[1,"drag-hint"]],template:function(e,i){if(e&1){let n=T();s(0,"div",1),_("dragenter",function(a){return v(n),y(i.onDragEnter(a))})("dragover",function(a){return v(n),y(i.onDragOver(a))})("dragleave",function(a){return v(n),y(i.onDragLeave(a))})("drop",function(a){return v(n),y(i.onDrop(a))}),s(1,"mat-drawer-container",2)(2,"mat-drawer-content")(3,"div",3),w(4,Iv,3,5,"button",4),w(5,Dv,2,2,"div",5),s(6,"div",6)(7,"div",7)(8,"app-chat-history",8),_("copyRequested",function(a){return v(n),y(i.onCopyMessage(a))})("stopRequested",function(){return v(n),y(i.onStopRequested())}),l(),w(9,Rv,2,3,"div",9),l()(),s(10,"div",10,0)(12,"div",11)(13,"div",12),w(14,Fv,1,5,"app-chat-textarea",13),w(15,Nv,1,4,"app-choice-select",14),l()()()()(),s(16,"mat-drawer",15),_("closed",function(){return v(n),y(i.closeFileDrawer())}),s(17,"app-file-exchange-drawer",16),_("closeDrawer",function(){return v(n),y(i.closeFileDrawer())}),l()()(),w(18,Lv,8,0,"div",17),l()}e&2&&(d(),C("hasBackdrop",!1),d(3),S(i.isFileDrawerOpen?-1:4),d(),S(i.showConnectionStatus&&i.connectionStatus&&!i.connectionStatus.connected?5:-1),d(3),C("messages",i.messages)("streamingText",i.streamingText)("isThinking",i.isThinking),d(),S(i.uploadStatus.message?9:-1),d(5),S(i.currentChoice?-1:14),d(),S(i.currentChoice?15:-1),d(),C("opened",i.isFileDrawerOpen),d(),C("projectName",i.projectName)("threadId",i.threadId),d(),S(i.isDragOver?18:-1))},dependencies:[Qs,Zo,Uo,ol,sl,ra,aa,mr,Fe,_e,_t,Wa,Pu,Eu],styles:[".drag-drop-wrapper[_ngcontent-%COMP%]{height:100vh;width:100%;position:relative}.thread-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;width:100%;position:relative;background:transparent}.file-drawer-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;top:1rem!important;right:1rem!important;z-index:100!important}.file-drawer-toggle-btn.has-files[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse-subtle 3s infinite}@keyframes _ngcontent-%COMP%_pulse-subtle{0%,to{box-shadow:0 2px 8px #00000026}50%{box-shadow:0 4px 16px rgba(var(--color-primary-rgb, 25, 118, 210),.3)}}.file-drawer-container[_ngcontent-%COMP%]{height:100vh;width:100%;background:var(--color-bg)}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-content{display:flex;flex-direction:column;height:100%;overflow:hidden;background:transparent}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:35vw;max-width:90vw;box-shadow:-2px 0 8px #0000001a}@media (max-width: 768px){.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:100vw;max-width:100vw}}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-backdrop{display:none}.connection-status[_ngcontent-%COMP%]{position:fixed;top:0;left:0;right:0;z-index:1000;background:var(--color-warning);color:var(--color-text);padding:.5rem 1rem;text-align:center;font-size:.9rem;box-shadow:0 2px 4px #0000001a}.chat-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;width:100%;padding:1rem 0}.chat-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 1rem;display:flex;flex-direction:column;gap:1rem}.upload-status[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:8px;background:var(--color-primary-light);color:var(--color-text);text-align:center;font-size:.9rem;margin-top:1rem}.upload-status.error[_ngcontent-%COMP%]{background:var(--color-error);color:#fff}.input-section[_ngcontent-%COMP%]{flex-shrink:0;width:100%;padding:1rem 0;background:var(--color-background)}.input-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 1rem}.input-glass[_ngcontent-%COMP%]{position:relative;background:transparent;border-radius:12px;display:flex;flex-direction:column}.choice-overlay[_ngcontent-%COMP%]{width:100%;background:var(--color-bg-solid);border-radius:12px;padding:1.5rem;box-shadow:0 4px 12px #00000026}.drag-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;background:#000000b3;z-index:10000;display:flex;align-items:center;justify-content:center;pointer-events:none}.drag-overlay-content[_ngcontent-%COMP%]{text-align:center;color:#fff;padding:2rem;border:3px dashed white;border-radius:12px;background:#00000080}.drag-icon[_ngcontent-%COMP%]{font-size:4rem;margin-bottom:1rem}.drag-text[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:500}.drag-hint[_ngcontent-%COMP%]{font-size:.9rem;margin-top:.5rem;opacity:.8}@media (max-width: 768px){.chat-center[_ngcontent-%COMP%], .input-center[_ngcontent-%COMP%]{padding:0 .5rem}.drag-text[_ngcontent-%COMP%]{font-size:1.2rem}.drag-icon[_ngcontent-%COMP%]{font-size:3rem}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:100vw;max-width:100vw}.file-drawer-toggle-btn[_ngcontent-%COMP%]{top:.75rem!important;right:.75rem!important}}@media print{.connection-status[_ngcontent-%COMP%], .input-section[_ngcontent-%COMP%], .drag-overlay[_ngcontent-%COMP%], .file-drawer-toggle-btn[_ngcontent-%COMP%], .file-drawer-container[_ngcontent-%COMP%]{display:none!important}.chat-wrapper[_ngcontent-%COMP%]{overflow:visible;height:auto}.thread-container[_ngcontent-%COMP%]{height:auto}}"]})};var Ou=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275mod=re({type:o});static \u0275inj=oe({imports:[ae,ae]})}return o})();var Au=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275mod=re({type:o});static \u0275inj=oe({imports:[ae]})}return o})();var Qi=class o{http=m(Je);getUserConfig(){return this.http.get("/api/config/user").pipe(ht(t=>console.log("[CONFIG-API] User config retrieved:",t)))}updateUserConfig(t){return this.http.put("/api/config/user",t).pipe(ht(e=>console.log("[CONFIG-API] User config updated:",e)))}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var ur=class o{currentThemeSubject=new le("light");currentTheme$=this.currentThemeSubject.asObservable();preferences=m(et);constructor(){console.log("[THEME] Initializing theme service"),this.initializeTheme(),this.setupSystemThemeListener()}initializeTheme(){let t=this.preferences.getPreference("theme","light")??"light";console.log("[THEME] Loaded saved theme:",t),this.applyTheme(t),setTimeout(()=>{let e=this.preferences.getPreference("theme","light")??"light";e!==t&&(console.log("[THEME] Theme updated after async load:",e),this.applyTheme(e))},100)}setTheme(t){this.preferences.setPreference("theme",t),this.applyTheme(t)}getCurrentTheme(){return this.currentThemeSubject.value}applyTheme(t){if(console.log("[THEME] Applying theme:",t),this.currentThemeSubject.next(t),t==="system")if(typeof window<"u"&&window.matchMedia){let i=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";console.log("[THEME] System theme resolved to:",i),this.setDocumentTheme(i)}else console.log("[THEME] matchMedia not available, defaulting to light theme"),this.setDocumentTheme("light");else this.setDocumentTheme(t)}setDocumentTheme(t){console.log("[THEME] Setting document theme to:",t),typeof document<"u"&&document.documentElement&&(t==="dark"?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.removeAttribute("data-theme"))}setupSystemThemeListener(){typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t=>{this.getCurrentTheme()==="system"&&this.setDocumentTheme(t.matches?"dark":"light")})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=L({token:o,factory:o.\u0275fac,providedIn:"root"})};var Vv=["mat-internal-form-field",""],zv=["*"],dl=(()=>{class o{labelPosition;static \u0275fac=function(i){return new(i||o)};static \u0275cmp=M({type:o,selectors:[["div","mat-internal-form-field",""]],hostAttrs:[1,"mdc-form-field","mat-internal-form-field"],hostVars:2,hostBindings:function(i,n){i&2&&I("mdc-form-field--align-end",n.labelPosition==="before")},inputs:{labelPosition:"labelPosition"},attrs:Vv,ngContentSelectors:zv,decls:1,vars:0,template:function(i,n){i&1&&(je(),me(0))},styles:[`.mat-internal-form-field{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-flex;align-items:center;vertical-align:middle}.mat-internal-form-field>label{margin-left:0;margin-right:auto;padding-left:4px;padding-right:0;order:0}[dir=rtl] .mat-internal-form-field>label{margin-left:auto;margin-right:0;padding-left:0;padding-right:4px}.mdc-form-field--align-end>label{margin-left:auto;margin-right:0;padding-left:0;padding-right:4px;order:-1}[dir=rtl] .mdc-form-field--align-end .mdc-form-field--align-end label{margin-left:0;margin-right:auto;padding-left:4px;padding-right:0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whoz-oss/coday-client",
3
- "version": "0.88.0",
3
+ "version": "0.89.0",
4
4
  "repository": "https://github.com/whoz-oss/coday",
5
5
  "type": "module",
6
6
  "dependencies": {