1import{a as ge,b as je}from"./chunk-274OYHOQ.js";import"./chunk-DFPAUOHB.js";import{c as Be,d as pt}from"./chunk-AZS3QIZL.js";import"./chunk-UYRUDIUB.js";import{Db as z,Eb as B,Fb as j}from"./chunk-2JPNXA3J.js";import{A as he,C as xe,c as ue,k as Ce,p as fe}from"./chunk-PXI4RNCT.js";import{a as ze,b as lt}from"./chunk-KXNDLGYE.js";import{f as Ge,h as Le,i as de,m as me,n as _e}from"./chunk-MJC7NEL7.js";import{i as Ne,j as st}from"./chunk-G7CCAZ6K.js";import{b as Re,c as G,e as L,f as R}from"./chunk-P2NB64WX.js";import{G as De,M as ct,v as we,z as rt}from"./chunk-H3JKYH2Z.js";import{Ic as Ie,Jc as T,Kc as X,Lc as Ee,Mb as Q,Ob as h,Pb as x,Pc as l,Q as ke,Qb as Se,Qc as d,Rb as le,Rc as Z,Sb as W,Tb as H,Ub as p,V as se,Vb as r,Wb as a,Xb as C,Ya as Pe,Zc as q,_ as I,cc as N,ea as P,fa as S,gc as O,hb as o,ic as u,lb as ee,ma as oe,mb as te,n as ie,qa as E,ta as Oe,tc as pe,uc as J,ud as w,vb as D,xc as m,yc as A,za as Te,zc as b}from"./chunk-6ZKZEUGL.js";import{a as v,b as k,e as V,k as U}from"./chunk-J6LPXIX4.js";var be,Ae=V(()=>{"use strict";w();ct();lt();w();be=(()=>{class t{http=I(De);baseUrl=`${ze.apiUrl}/api/v1/academic-agent`;getAccess(){return this.http.get(`${this.baseUrl}/access`)}getProjects(){return this.http.get(`${this.baseUrl}/projects`)}resolveCheckpointStream(e,i,n,c){return this.stream(`${this.baseUrl}/checkpoints/${e}/resolve`,i,n,c)}getSession(e){return this.http.get(`${this.baseUrl}/projects/${e}/session`)}sendMessageStream(e,i,n,c){return this.stream(`${this.baseUrl}/projects/${e}/messages/stream`,{content:i},n,c)}stream(e,i,n,c){let g=localStorage.getItem("access_token")||sessionStorage.getItem("access_token");return fetch(e,{method:"POST",headers:v({"Content-Type":"application/json"},g?{Authorization:`Bearer ${g}`}:{}),body:JSON.stringify(i),signal:c}).then(M=>U(this,null,function*(){if(!M.ok||!M.body){let $;try{let K=yield M.json();$=typeof K?.detail=="string"?K.detail:K?.detail?.message}catch(K){}n.onError?.({status:M.status,code:$,message:$??`HTTP ${M.status}`});return}let _=M.body.getReader(),f=new TextDecoder,y="",F=({done:$,value:K})=>{if($)return Promise.resolve();y+=f.decode(K,{stream:!0});let ne=y.split(` 2 3`);y=ne.pop()??"";for(let at of ne){let ye=at.trim();if(ye.startsWith("data: "))try{this.dispatch(JSON.parse(ye.slice(6)),n)}catch(hn){}}return _.read().then(F)};return _.read().then(F)})).catch(M=>{M?.name!=="AbortError"&&n.onError?.({message:M?.message??"Network error"})})}dispatch(e,i){switch(e?.type){case"run_started":i.onRunStarted?.(e.run_id);break;case"text_delta":i.onTextDelta?.(e.text??"");break;case"tool_call_started":i.onToolStarted?.(e);break;case"tool_call_progress":i.onToolProgress?.(e);break;case"tool_call_result":i.onToolResult?.(e);break;case"checkpoint_required":i.onCheckpoint?.(e);break;case"done":i.onDone?.({stop_reason:e.stop_reason,state:e.state??null});break;case"error":i.onError?.({code:e.code,message:e.message??"Erreur"});break;default:break}}static \u0275fac=function(i){return new(i||t)};static \u0275prov=se({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})()});function Ct(t,s){t&1&&(m(0),l(1,"translate")),t&2&&b(" ",d(1,1,"ACADEMIC_AGENT.GATE.DISABLED")," ")}function ft(t,s){t&1&&(m(0),l(1,"translate")),t&2&&b(" ",d(1,1,"ACADEMIC_AGENT.GATE.LOGIN_REQUIRED")," ")}function ht(t,s){t&1&&(m(0),l(1,"translate")),t&2&&b(" ",d(1,1,"ACADEMIC_AGENT.GATE.PLAN_REQUIRED")," ")}function xt(t,s){t&1&&(r(0,"a",5),m(1),l(2,"translate"),a()),t&2&&(p("routerLink",T(5,_t))("queryParams",T(6,gt)),o(),b(" ",d(2,3,"ACADEMIC_AGENT.GATE.LOGIN_CTA")," "))}function bt(t,s){t&1&&(r(0,"a",6),l(1,"langLink"),m(2),l(3,"translate"),a()),t&2&&(p("routerLink",d(1,2,T(6,ut))),o(2),b(" ",d(3,4,"ACADEMIC_AGENT.GATE.CTA")," "))}var mt,_t,gt,ut,Ue,Fe=V(()=>{"use strict";_e();R();j();je();w();_e();j();R();mt=()=>["academic"],_t=()=>[],gt=()=>({modal:"login"}),ut=()=>["plans"];Ue=(()=>{class t{reason=null;static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-agent-beta-gate"]],inputs:{reason:"reason"},decls:16,vars:13,consts:[[1,"gate"],[1,"gate__icon"],["name","Sparkles",3,"size"],[1,"gate__title"],[1,"gate__text"],["queryParamsHandling","merge",1,"gate__cta",3,"routerLink","queryParams"],[1,"gate__cta",3,"routerLink"],[1,"gate__alt",3,"routerLink"]],template:function(i,n){i&1&&(r(0,"div",0)(1,"span",1),C(2,"lucide-icon",2),a(),r(3,"h1",3),m(4),l(5,"translate"),a(),r(6,"p",4),h(7,Ct,2,3)(8,ft,2,3)(9,ht,2,3),a(),h(10,xt,3,7,"a",5)(11,bt,4,7,"a",6),r(12,"a",7),l(13,"langLink"),m(14),l(15,"translate"),a()()),i&2&&(o(2),p("size",28),o(2),A(d(5,6,"ACADEMIC_AGENT.GATE.TITLE")),o(3),x(n.reason==="BETA_DISABLED"?7:n.reason==="LOGIN_REQUIRED"?8:9),o(3),x(n.reason==="LOGIN_REQUIRED"?10:n.reason!=="BETA_DISABLED"?11:-1),o(2),p("routerLink",d(13,8,T(12,mt))),o(2),b(" ",d(15,10,"ACADEMIC_AGENT.GATE.BACK_TO_WIZARD")," "))},dependencies:[me,de,L,B,z,G,ge],styles:[".gate[_ngcontent-%COMP%]{max-width:520px;margin:4rem auto;padding:0 1rem;text-align:center}.gate__icon[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:60px;height:60px;border-radius:50%;background:#6c44ff1f;color:var(--primary, #6c44ff);margin-bottom:1rem}.gate__title[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;margin-bottom:.6rem}.gate__text[_ngcontent-%COMP%]{color:var(--ag-muted);line-height:1.6;margin-bottom:1.5rem}.gate__cta[_ngcontent-%COMP%]{display:inline-block;background:var(--primary, #3273dc);color:#fff;padding:.65rem 1.4rem;border-radius:9999px;font-weight:600;text-decoration:none}.gate__alt[_ngcontent-%COMP%]{display:block;margin-top:1rem;font-size:.85rem;color:var(--ag-muted)}"]})}return t})()});function At(t,s){if(t&1&&(r(0,"div",1),C(1,"lucide-icon",7),m(2),l(3,"translate"),a()),t&2){let e=u();o(),p("size",13),o(),b(" ",d(3,2,e.progressLabelKey)," ")}}function Mt(t,s){if(t&1){let e=N();r(0,"button",8),l(1,"translate"),O("click",function(){P(e);let n=u();return S(n.stop.emit())}),C(2,"lucide-icon",9),a()}t&2&&(Q("aria-label",d(1,2,"ACADEMIC_AGENT.COMPOSER.STOP")),o(2),p("size",16))}function vt(t,s){if(t&1){let e=N();r(0,"button",10),l(1,"translate"),O("click",function(){P(e);let n=u();return S(n.submit())}),C(2,"lucide-icon",11),a()}if(t&2){let e=u();p("disabled",e.disabled||!e.draft().trim()),Q("aria-label",d(1,3,"ACADEMIC_AGENT.COMPOSER.SEND")),o(2),p("size",16)}}var $e,Ke=V(()=>{"use strict";w();xe();R();j();w();xe();j();R();$e=(()=>{class t{disabled=!1;running=!1;progressLabelKey=null;send=new oe;stop=new oe;draft=E("");submit(){let e=this.draft().trim();!e||this.disabled||(this.send.emit(e),this.draft.set(""))}onEnter(e){let i=e;i.shiftKey||(i.preventDefault(),this.submit())}static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-agent-composer"]],inputs:{disabled:"disabled",running:"running",progressLabelKey:"progressLabelKey"},outputs:{send:"send",stop:"stop"},decls:10,vars:10,consts:[[1,"cmp"],[1,"cmp__progress"],[1,"cmp__row"],["rows","1",1,"cmp__input",3,"ngModelChange","keydown.enter","ngModel","disabled","placeholder"],["type","button",1,"cmp__btn","cmp__btn--stop"],["type","button",1,"cmp__btn",3,"disabled"],[1,"cmp__hint"],["name","RefreshCw",1,"cmp__spin",3,"size"],["type","button",1,"cmp__btn","cmp__btn--stop",3,"click"],["name","Square",3,"size"],["type","button",1,"cmp__btn",3,"click","disabled"],["name","ArrowUp",3,"size"]],template:function(i,n){i&1&&(r(0,"div",0),h(1,At,4,4,"div",1),r(2,"div",2)(3,"textarea",3),l(4,"translate"),O("ngModelChange",function(g){return n.draft.set(g)})("keydown.enter",function(g){return n.onEnter(g)}),a(),ee(),h(5,Mt,3,4,"button",4)(6,vt,3,5,"button",5),a(),r(7,"p",6),m(8),l(9,"translate"),a()()),i&2&&(o(),x(n.progressLabelKey?1:-1),o(2),p("ngModel",n.draft())("disabled",n.disabled)("placeholder",d(4,6,"ACADEMIC_AGENT.COMPOSER.PLACEHOLDER")),te(),o(2),x(n.running?5:6),o(3),A(d(9,8,"ACADEMIC_AGENT.COMPOSER.HINT")))},dependencies:[he,ue,Ce,fe,L,B,z,G],styles:['@charset "UTF-8";.cmp[_ngcontent-%COMP%]{border-top:1px solid var(--ag-border);padding:.7rem 0 .4rem;background:inherit}.cmp__progress[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;font-size:.78rem;color:var(--ag-muted);padding-bottom:.45rem}.cmp__row[_ngcontent-%COMP%]{display:flex;align-items:flex-end;
3gap:.5rem;border:1px solid var(--ag-border);border-radius:14px;padding:.45rem .45rem .45rem .8rem;background:var(--ag-input-bg)}.cmp__row[_ngcontent-%COMP%]:focus-within{border-color:var(--primary, #3273dc)}.cmp__input[_ngcontent-%COMP%]{flex:1;border:0;outline:0;resize:none;background:transparent;color:inherit;font:inherit;font-size:.92rem;line-height:1.5;max-height:160px;min-height:24px;padding:.15rem 0}.cmp__btn[_ngcontent-%COMP%]{flex-shrink:0;width:34px;height:34px;border-radius:50%;border:0;display:inline-flex;align-items:center;justify-content:center;background:var(--primary, #3273dc);color:#fff;cursor:pointer}.cmp__btn[_ngcontent-%COMP%]:disabled{opacity:.4;cursor:not-allowed}.cmp__btn--stop[_ngcontent-%COMP%]{background:#dc2626}.cmp__hint[_ngcontent-%COMP%]{margin:.4rem 0 0;font-size:.72rem;color:var(--ag-muted);text-align:center}.cmp__spin[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_cmp-spin 1s linear infinite}@keyframes _ngcontent-%COMP%_cmp-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.cmp__spin[_ngcontent-%COMP%]{animation:none}}']})}return t})()});function Ot(t,s){if(t&1&&(r(0,"p",6),m(1),a()),t&2){let e=u();o(),A(e.checkpoint.payload.rationale)}}function Tt(t,s){if(t&1&&(r(0,"li"),m(1),a()),t&2){let e=s.$implicit;o(),A(e)}}function Pt(t,s){if(t&1&&(r(0,"ul",15),W(1,Tt,2,1,"li",null,le),a()),t&2){let e=u(2);o(),H(e.checkpoint.payload.sub_questions??T(0,yt))}}function St(t,s){if(t&1){let e=N();r(0,"div",7)(1,"textarea",14),O("ngModelChange",function(n){P(e);let c=u();return S(c.question.set(n))}),a(),ee(),h(2,Pt,3,1,"ul",15),a()}if(t&2){let e=u();o(),p("ngModel",e.question())("disabled",e.busy),te(),o(),x(e.checkpoint.payload.sub_questions?.length?2:-1)}}function It(t,s){if(t&1){let e=N();r(0,"li",19)(1,"input",20),O("ngModelChange",function(n){let c=P(e).$index,g=u(2);return S(g.updateTitle(c,n))}),a(),ee(),r(2,"button",21),l(3,"translate"),O("click",function(){let n=P(e).$index,c=u(2);return S(c.removeNode(n))}),C(4,"lucide-icon",22),a()()}if(t&2){let e=s.$implicit,i=u(2);pe("--depth",e.level-1),o(),p("ngModel",e.title)("disabled",i.busy),te(),o(),p("disabled",i.busy||i.nodes().length<=1),Q("aria-label",d(3,7,"ACADEMIC_AGENT.CHECKPOINT.REMOVE_SECTION")),o(2),p("size",14)}}function wt(t,s){if(t&1&&(r(0,"ol",16),W(1,It,5,9,"li",17,Se),a(),r(3,"p",18),m(4),l(5,"translate"),a()),t&2){let e=u();o(),H(e.nodes()),o(3),b(" ",Z(5,1,"ACADEMIC_AGENT.CHECKPOINT.SECTION_COUNT",X(4,kt,e.nodes().length))," ")}}function Dt(t,s){if(t&1&&(r(0,"div",8),C(1,"lucide-icon",3),m(2),l(3,"translate"),a()),t&2){let e=u();o(),p("size",14),o(),b(" ",d(3,2,"ACADEMIC_AGENT.CHECKPOINT.ERROR."+e.error)," ")}}function Nt(t,s){if(t&1){let e=N();r(0,"div",13)(1,"input",23),l(2,"translate"),O("ngModelChange",function(n){P(e);let c=u();return S(c.feedback.set(n))}),a(),ee(),r(3,"button",24),O("click",function(){P(e);let n=u();return S(n.reject())}),m(4),l(5,"translate"),a()()}if(t&2){let e=u();o(),p("ngModel",e.feedback())("placeholder",d(2,5,"ACADEMIC_AGENT.CHECKPOINT.REJECT_PLACEHOLDER"))("disabled",e.busy),te(),o(2),p("disabled",e.busy),o(),b(" ",d(5,7,"ACADEMIC_AGENT.CHECKPOINT.REJECT_CONFIRM")," ")}}var yt,kt,Ve,We=V(()=>{"use strict";w();xe();R();j();w();xe();j();R();yt=()=>[],kt=t=>({count:t});Ve=(()=>{class t{set checkpointInput(e){this._checkpoint=e,this.question.set(e.payload.question??""),this.nodes.set(this.flatten(e.payload.outline??[])),this.original.set(JSON.stringify(this.nodes())),this.rejecting.set(!1),this.feedback.set("")}_checkpoint;get checkpoint(){return this._checkpoint}busy=!1;error=null;decide=new oe;question=E("");nodes=E([]);rejecting=E(!1);feedback=E("");original=E("");kindKey=q(()=>this._checkpoint?.kind==="outline"?"OUTLINE":"RESEARCH_QUESTION");edited=q(()=>this._checkpoint?.kind==="research_question"?this.question().trim()!==(this._checkpoint.payload.question??"").trim():JSON.stringify(this.nodes())!==this.original());flatten(e,i=1){let n=[];for(let c of e)n.push({title:c.title,level:i,content:c.content}),n.push(...this.flatten(c.children??[],i+1));return n}nest(e){let i=[],n=[];for(let c of e){let g={title:c.title,content:c.content,children:[]};for(;n.length&&n[n.length-1].level>=c.level;)n.pop();n.length?n[n.length-1].node.children.push(g):i.push(g),n.push({level:c.level,no
3de:g})}return i}updateTitle(e,i){this.nodes.update(n=>n.map((c,g)=>g===e?k(v({},c),{title:i}):c))}removeNode(e){this.nodes.update(i=>i.filter((n,c)=>c!==e))}approve(){if(!this.edited()){this.decide.emit({decision:"approve"});return}let i=this._checkpoint.kind==="outline"?k(v({},this._checkpoint.payload),{outline:this.nest(this.nodes())}):k(v({},this._checkpoint.payload),{question:this.question().trim()});this.decide.emit({decision:"approve_with_edits",payload:i})}reject(){this.decide.emit({decision:"reject",feedback:this.feedback().trim()||void 0})}static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-agent-checkpoint-card"]],inputs:{checkpointInput:"checkpointInput",busy:"busy",error:"error"},outputs:{decide:"decide"},decls:24,vars:20,consts:[[1,"cp"],[1,"cp__head"],[1,"cp__icon"],["name","CircleAlert",3,"size"],[1,"cp__title"],[1,"cp__hint"],[1,"cp__rationale"],[1,"cp__block"],[1,"cp__error"],[1,"cp__actions"],["type","button",1,"cp__btn","cp__btn--approve",3,"click","disabled"],["name","CircleCheck",3,"size"],["type","button",1,"cp__btn",3,"click","disabled"],[1,"cp__reject"],["rows","3",1,"cp__textarea",3,"ngModelChange","ngModel","disabled"],[1,"cp__sub"],[1,"cp__outline"],[1,"cp__node",3,"--depth"],[1,"cp__count"],[1,"cp__node"],["type","text",1,"cp__node-input",3,"ngModelChange","ngModel","disabled"],["type","button",1,"cp__node-del",3,"click","disabled"],["name","Trash2",3,"size"],["type","text",1,"cp__reject-input",3,"ngModelChange","ngModel","placeholder","disabled"],["type","button",1,"cp__btn","cp__btn--reject",3,"click","disabled"]],template:function(i,n){i&1&&(r(0,"div",0)(1,"header",1)(2,"span",2),C(3,"lucide-icon",3),a(),r(4,"div")(5,"h3",4),m(6),l(7,"translate"),a(),r(8,"p",5),m(9),l(10,"translate"),a()()(),h(11,Ot,2,1,"p",6),h(12,St,3,3,"div",7)(13,wt,6,6),h(14,Dt,4,4,"div",8),r(15,"div",9)(16,"button",10),O("click",function(){return n.approve()}),C(17,"lucide-icon",11),m(18),l(19,"translate"),a(),r(20,"button",12),O("click",function(){return n.rejecting.set(!n.rejecting())}),m(21),l(22,"translate"),a()(),h(23,Nt,6,9,"div",13),a()),i&2&&(o(3),p("size",16),o(3),b(" ",d(7,12,"ACADEMIC_AGENT.CHECKPOINT."+n.kindKey()+".TITLE")," "),o(3),A(d(10,14,"ACADEMIC_AGENT.CHECKPOINT.NOT_SAVED")),o(2),x(n.checkpoint.payload.rationale?11:-1),o(),x(n.checkpoint.kind==="research_question"?12:13),o(2),x(n.error?14:-1),o(2),p("disabled",n.busy),o(),p("size",15),o(),b(" ",d(19,16,n.edited()?"ACADEMIC_AGENT.CHECKPOINT.APPROVE_EDITED":"ACADEMIC_AGENT.CHECKPOINT.APPROVE")," "),o(2),p("disabled",n.busy),o(),b(" ",d(22,18,"ACADEMIC_AGENT.CHECKPOINT.REJECT")," "),o(2),x(n.rejecting()?23:-1))},dependencies:[he,ue,Ce,fe,L,B,z,G],styles:['@charset "UTF-8";.cp[_ngcontent-%COMP%]{border:1px solid var(--ag-accent);border-radius:14px;padding:.9rem 1rem;margin:.75rem 0;background:var(--ag-surface)}.cp__head[_ngcontent-%COMP%]{display:flex;gap:.65rem;align-items:flex-start;margin-bottom:.6rem}.cp__icon[_ngcontent-%COMP%]{flex-shrink:0;width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:var(--ag-accent-soft);color:var(--ag-accent)}.cp__title[_ngcontent-%COMP%]{margin:0;font-size:.95rem;font-weight:700}.cp__hint[_ngcontent-%COMP%]{margin:.1rem 0 0;font-size:.76rem;color:var(--ag-muted)}.cp__rationale[_ngcontent-%COMP%]{font-size:.87rem;line-height:1.55;margin:0 0 .75rem}.cp__block[_ngcontent-%COMP%]{margin-bottom:.75rem}.cp__textarea[_ngcontent-%COMP%], .cp__node-input[_ngcontent-%COMP%], .cp__reject-input[_ngcontent-%COMP%]{width:100%;border:1px solid var(--ag-border);border-radius:9px;padding:.45rem .6rem;font:inherit;font-size:.87rem;background:var(--ag-input-bg);color:inherit;resize:vertical}.cp__textarea[_ngcontent-%COMP%]:focus, .cp__node-input[_ngcontent-%COMP%]:focus, .cp__reject-input[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--ag-accent)}.cp__sub[_ngcontent-%COMP%]{margin:.5rem 0 0 1.1rem;font-size:.82rem;color:var(--ag-muted)}.cp__sub[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{list-style:disc}.cp__outline[_ngcontent-%COMP%]{list-style:none;margin:0 0 .5rem;padding:0;max-height:340px;overflow-y:auto}.cp__node[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;margin-bottom:.3rem;padding-inline-start:calc(var(--depth, 0) * 1.1rem)}
3.cp__node-del[_ngcontent-%COMP%]{flex-shrink:0;border:0;background:transparent;color:var(--ag-muted);cursor:pointer;padding:.2rem}.cp__node-del[_ngcontent-%COMP%]:hover:not(:disabled){color:#dc2626}.cp__node-del[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.cp__count[_ngcontent-%COMP%]{margin:0 0 .6rem;font-size:.76rem;color:var(--ag-muted)}.cp__actions[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-wrap:wrap}.cp__btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.35rem;border:1px solid var(--ag-border);background:transparent;color:inherit;border-radius:9999px;padding:.45rem 1rem;font-size:.85rem;font-weight:600;cursor:pointer}.cp__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.cp__btn--approve[_ngcontent-%COMP%]{background:var(--ag-accent);border-color:var(--ag-accent);color:#fff}.cp__btn--reject[_ngcontent-%COMP%]{border-color:#dc2626;color:#dc2626}.cp__reject[_ngcontent-%COMP%]{display:flex;gap:.5rem;margin-top:.6rem;flex-wrap:wrap}.cp__reject-input[_ngcontent-%COMP%]{flex:1;min-width:180px}.cp__error[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;margin-bottom:.6rem;font-size:.82rem;color:#dc2626}@media(max-width:640px){.cp__actions[_ngcontent-%COMP%] .cp__btn[_ngcontent-%COMP%]{flex:1;justify-content:center}}']})}return t})()});function Gt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ce(t){return t.replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/(^|[\s(])(https?:\/\/[^\s<)]+)/g,'$1<a href="$2" target="_blank" rel="noopener noreferrer">$2</a>')}function He(t){if(!t)return"";let s=Gt(t).split(` 4`),e=[],i=null,n=!1,c=!1,g=!1,M=()=>{c&&(e.push("</ul>"),c=!1)},_=()=>{M(),n&&(e.push("</li>"),n=!1)},f=()=>{_(),i&&(e.push(`</${i}>`),i=null)};for(let y of s){if(y.trim().startsWith("```")){f(),e.push(g?"</code></pre>":"<pre><code>"),g=!g;continue}if(g){e.push(y+` 5`);continue}let F=y.match(/^(#{1,4})\s+(.*)$/);if(F){f();let ne=Math.min(F[1].length+2,6);e.push(`<h${ne}>${ce(F[2])}</h${ne}>`);continue}let $=y.match(/^\s*(\d+)[.)]\s+(.*)$/);if($){_(),i!=="ol"&&(f(),e.push(`<ol start="${parseInt($[1],10)||1}">`),i="ol"),e.push(`<li>${ce($[2])}`),n=!0;continue}let K=y.match(/^\s*[-*â¢]\s+(.*)$/);if(K){_(),i!=="ul"&&(f(),e.push("<ul>"),i="ul"),e.push(`<li>${ce(K[1])}`),n=!0;continue}if(!y.trim()){f();continue}if(n&&/^\s{2,}\S/.test(y)){c||(e.push("<ul>"),c=!0),e.push(`<li>${ce(y.trim())}</li>`);continue}f(),e.push(`<p>${ce(y)}</p>`)}return f(),g&&e.push("</code></pre>"),e.join("")}var qe=V(()=>{"use strict"});function Lt(t,s){t&1&&C(0,"lucide-icon",2),t&2&&p("size",14)}function Rt(t,s){t&1&&C(0,"lucide-icon",3),t&2&&p("size",14)}function zt(t,s){t&1&&C(0,"lucide-icon",4),t&2&&p("size",14)}function Bt(t,s){if(t&1&&(m(0),l(1,"translate")),t&2){let e=u();b(" ",d(1,1,e.call.labelKey||"ACADEMIC_AGENT.TOOL.RUNNING")," ")}}function jt(t,s){if(t&1&&m(0),t&2){let e=u();b(" ",e.call.summary," ")}}function Ut(t,s){if(t&1&&(m(0),l(1,"translate")),t&2){let e=u();b(" ",d(1,1,"ACADEMIC_AGENT.TOOL_ERROR."+(e.call.errorCode||"GENERIC"))," ")}}function Ft(t,s){if(t&1&&(r(0,"span",7),m(1),a()),t&2){let e=u();o(),b("",e.call.durationS,"s")}}var Qe,Je=V(()=>{"use strict";R();j();w();j();R();Qe=(()=>{class t{call;static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-agent-tool-call-card"]],inputs:{call:"call"},decls:13,vars:10,consts:[[1,"tc"],[1,"tc__icon"],["name","RefreshCw",1,"tc__spin",3,"size"],["name","CircleCheck",3,"size"],["name","CircleAlert",3,"size"],[1,"tc__label"],[1,"tc__detail"],[1,"tc__time"]],template:function(i,n){i&1&&(r(0,"div",0)(1,"span",1),h(2,Lt,1,1,"lucide-icon",2)(3,Rt,1,1,"lucide-icon",3)(4,zt,1,1,"lucide-icon",4),a(),r(5,"span",5),m(6),l(7,"translate"),a(),r(8,"span",6),h(9,Bt,2,3)(10,jt,1,1)(11,Ut,2,3),a(),h(12,Ft,2,1,"span",7),a()),i&2&&(J("is-running",n.call.status==="running")("is-error",n.call.status==="error"),o(2),x(n.call.status==="running"?2:n.call.status==="ok"?3:4),o(4),b(" ",d(7,8,"ACADEMIC_AGENT.TOOL_
5NAME."+n.call.tool.toUpperCase())," "),o(3),x(n.call.status==="running"?9:n.call.status==="ok"?10:11),o(3),x(n.call.durationS?12:-1))},dependencies:[L,B,z,G],styles:['@charset "UTF-8";.tc[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.45rem .7rem;margin:.35rem 0;border:1px solid var(--ag-border);border-radius:10px;background:var(--ag-surface);font-size:.8rem;min-width:0}.tc.is-running[_ngcontent-%COMP%]{border-color:#6c44ff59}.tc.is-error[_ngcontent-%COMP%]{border-color:#dc262659;background:#dc26260d}.tc__icon[_ngcontent-%COMP%]{display:inline-flex;flex-shrink:0;color:var(--primary, #3273dc)}.tc.is-error[_ngcontent-%COMP%] .tc__icon[_ngcontent-%COMP%]{color:#dc2626}.tc__label[_ngcontent-%COMP%]{font-weight:600;flex-shrink:0}.tc__detail[_ngcontent-%COMP%]{color:var(--ag-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.tc__time[_ngcontent-%COMP%]{margin-left:auto;flex-shrink:0;color:var(--ag-muted);font-variant-numeric:tabular-nums}.tc__spin[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_tc-spin 1s linear infinite}@keyframes _ngcontent-%COMP%_tc-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.tc__spin[_ngcontent-%COMP%]{animation:none}}']})}return t})()});function Kt(t,s){t&1&&(r(0,"span",1),C(1,"lucide-icon",7),a()),t&2&&(o(),p("size",16))}function Vt(t,s){if(t&1&&C(0,"app-agent-tool-call-card",3),t&2){let e=s.$implicit;p("call",e)}}function Wt(t,s){if(t&1&&C(0,"div",4),t&2){let e=u();p("innerHTML",e.html(),Pe)}}function Ht(t,s){t&1&&(r(0,"span",5),m(1),l(2,"translate"),a()),t&2&&(o(),A(d(2,1,"ACADEMIC_AGENT.THINKING")))}function qt(t,s){if(t&1&&(r(0,"div",6),C(1,"lucide-icon",8),m(2),l(3,"translate"),a()),t&2){let e=u();o(),p("size",14),o(),b(" ",d(3,2,"ACADEMIC_AGENT.ERROR."+e.message.error)," ")}}var Xe,$t,Ze,Ye=V(()=>{"use strict";w();st();R();j();qe();Je();w();j();R();Xe=()=>[],$t=(t,s)=>s.callId;Ze=(()=>{class t{sanitizer=I(Ne);_message=E(null);set message(e){this._message.set(e)}get message(){return this._message()}html=q(()=>this.sanitizer.bypassSecurityTrustHtml(He(this._message()?.content??"")));static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-agent-message-item"]],inputs:{message:"message"},decls:8,vars:7,consts:[[1,"msg"],[1,"msg__avatar"],[1,"msg__body"],[3,"call"],[1,"msg__content",3,"innerHTML"],[1,"msg__thinking"],[1,"msg__error"],["name","Bot",3,"size"],["name","CircleAlert",3,"size"]],template:function(i,n){i&1&&(r(0,"div",0),h(1,Kt,2,1,"span",1),r(2,"div",2),W(3,Vt,1,1,"app-agent-tool-call-card",3,$t),h(5,Wt,1,1,"div",4)(6,Ht,3,3,"span",5),h(7,qt,4,4,"div",6),a()()),i&2&&(J("msg--user",n.message.role==="user"),o(),x(n.message.role==="assistant"?1:-1),o(2),H(n.message.toolCalls??T(5,Xe)),o(2),x(n.message.content?5:n.message.streaming&&!(n.message.toolCalls??T(6,Xe)).length?6:-1),o(2),x(n.message.error?7:-1))},dependencies:[L,B,z,Qe,G],styles:['@charset "UTF-8";.msg[_ngcontent-%COMP%]{display:flex;gap:.65rem;padding:.6rem 0;align-items:flex-start}.msg--user[_ngcontent-%COMP%]{justify-content:flex-end}.msg__avatar[_ngcontent-%COMP%]{flex-shrink:0;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#6c44ff1f;color:var(--primary, #6c44ff);margin-top:2px}.msg__body[_ngcontent-%COMP%]{min-width:0;max-width:100%}.msg--user[_ngcontent-%COMP%] .msg__body[_ngcontent-%COMP%]{background:var(--primary, #3273dc);color:#fff;padding:.55rem .9rem;border-radius:14px 14px 4px;max-width:80%}.msg__content[_ngcontent-%COMP%]{font-size:.93rem;line-height:1.7;overflow-wrap:anywhere}.msg__content[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:first-child{margin-top:0}.msg__content[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:last-child{margin-bottom:0}.msg__content[_ngcontent-%COMP%] :is(h3[_ngcontent-%COMP%], h4[_ngcontent-%COMP%], h5[_ngcontent-%COMP%], h6[_ngcontent-%COMP%]){font-size:.95rem;font-weight:700;margin:1.1rem 0 .4rem;letter-spacing:-.01em}.msg__content[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 .75rem}.msg__content[_ngcontent-%COMP%] :is(ul[_ngcontent-%COMP%], ol[_ngcontent-%COMP%]){margin:0 0 .8rem;padding-inline-start:1.25rem;display:flex;flex-direction:column;gap:.3rem}.msg__content[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{list-style:revert;padding-inline-start:.15rem}.msg__content[_ngcontent-%COMP%] li[_ngcontent-%COMP%]::marker{color:var(--ag-muted)}.msg__content[_ngcontent-%COMP%] li[_ngcontent-%COMP%] > ul[_ngcontent-%COMP%]{margin:.3rem 0 0;gap:.15rem}.msg__content[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-weight:650;color:var(--ag-text)}.msg--user[_ngcontent-%COMP%] .msg__content[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{color:inherit}.msg__content[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:#0000000f;padding:.1rem .3rem;border-radius:4px;font-size:.85em}.msg__content[_ngcontent-%COMP%] pre[_ngcontent-%COMP%]{background:#0000000f;padding:.6rem .8rem;border-radius:8px;overflow-x:auto;margin:0 0 .5rem}.msg__content[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--primary, #3273dc);text-decoration:underline}.msg--user[_ngcontent-%COMP%] .msg__content[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#fff}.msg__thinking[_ngcontent-%COMP%]{font-size:.85rem;color:var(--ag-muted);font-style:italic}.msg__error[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;margin-top:.4rem;font-size:.82rem;color:#dc2626}[data-theme=dark][_nghost-%COMP%] .msg__content[_ngcontent-%COMP%] :is(code[_ngcontent-%COMP%], pre[_ngcontent-%COMP%]), [data-theme=dark] [_nghost-%COMP%] .msg__content[_ngcontent-%COMP%] :is(code[_ngcontent-%COMP%], pre[_ngcontent-%COMP%]){background:#ffffff14}']})}return t})()});var Me,et=V(()=>{"use strict";w();ke();Ae();w();Me=(()=>{class t{api=I(be);access=E(null);loadingAccess=E(!1);projectId=E(null);projectState=E(null);loadingSession=E(!1);sessionError=E(null);messages=E([]);runStatus=E("idle");progressLabelKey=E(null);pendingCheckpoint=E(null);checkpointError=E(null);abort=null;canSend=q(()=>this.runStatus()!=="running"&&!!this.projectId()&&!this.pendingCheckpoint());writtenRatio=q(()=>{let e=this.projectState();return!e||!e.chapters.total?0:Math.round(e.chapters.written/e.chapters.total*100)});suggestions=q(()=>{let e=this.projectState(),i=e?.missing??[],n=!!e?.source_doc?.has_text;
5return i.includes("context")?["SUGGEST.CONTEXT","SUGGEST.STATUS","SUGGEST.SOURCES"]:i.includes("research_question")?["SUGGEST.QUESTION","SUGGEST.SOURCES","SUGGEST.STATUS"]:i.includes("outline")?["SUGGEST.OUTLINE","SUGGEST.SOURCES","SUGGEST.STATUS"]:i.some(c=>c.startsWith("chapters:"))?["SUGGEST.NEXT_CHAPTER","SUGGEST.MISSING_SOURCES","SUGGEST.BALANCE","SUGGEST.SOURCES","SUGGEST.CHAPTER_REVIEW"]:["SUGGEST.REVIEW","SUGGEST.BALANCE","SUGGEST.RECENT_SOURCES","SUGGEST.BIBLIO",...n?["SUGGEST.SOURCE_DOC"]:["SUGGEST.IMPROVE_OUTLINE"]]});loadAccess(){return U(this,null,function*(){this.loadingAccess.set(!0);try{this.access.set(yield ie(this.api.getAccess()))}catch(e){let i=e?.status===401?"LOGIN_REQUIRED":"BETA_PLAN_REQUIRED";this.access.set({allowed:!1,plan:"free",reason:i})}finally{this.loadingAccess.set(!1)}})}loadSession(e){return U(this,null,function*(){this.projectId.set(e),this.loadingSession.set(!0),this.sessionError.set(null);try{let i=yield ie(this.api.getSession(e));this.projectState.set(i.state)}catch(i){this.sessionError.set(i?.status===404?"NOT_FOUND":"LOAD_FAILED")}finally{this.loadingSession.set(!1)}})}send(e){return U(this,null,function*(){let i=this.projectId();if(!i||!this.canSend())return;let n=e.trim();if(!n)return;this.messages.update(_=>[..._,{id:`u-${Date.now()}`,role:"user",content:n}]);let c=`a-${Date.now()}`;this.messages.update(_=>[..._,{id:c,role:"assistant",content:"",toolCalls:[],streaming:!0}]),this.runStatus.set("running"),this.progressLabelKey.set(null),this.abort=new AbortController;let g=_=>this.messages.update(f=>f.map(y=>y.id===c?_(y):y)),M=(_,f)=>g(y=>k(v({},y),{toolCalls:(y.toolCalls??[]).map(F=>F.callId===_?f(F):F)}));yield this.api.sendMessageStream(i,n,{onTextDelta:_=>g(f=>k(v({},f),{content:f.content+_})),onToolStarted:_=>g(f=>k(v({},f),{toolCalls:[...f.toolCalls??[],{callId:_.call_id,tool:_.tool,status:"running"}]})),onToolProgress:_=>{this.progressLabelKey.set(_.label_key),M(_.call_id,f=>k(v({},f),{labelKey:_.label_key}))},onToolResult:_=>{this.progressLabelKey.set(null),M(_.call_id,f=>k(v({},f),{status:_.ok?"ok":"error",summary:_.summary??null,errorCode:_.error_code??null,durationS:_.duration_s??null,labelKey:null}))},onCheckpoint:_=>this.pendingCheckpoint.set(_),onDone:_=>{_.state&&this.projectState.set(_.state),g(f=>k(v({},f),{streaming:!1})),this.runStatus.set("idle"),this.progressLabelKey.set(null)},onError:_=>{g(f=>k(v({},f),{streaming:!1,error:_.code??_.message})),this.runStatus.set("error"),this.progressLabelKey.set(null)}},this.abort.signal),this.runStatus()==="running"&&(g(_=>k(v({},_),{streaming:!1})),this.runStatus.set("idle"))})}resolveCheckpoint(n){return U(this,arguments,function*(e,i={}){let c=this.pendingCheckpoint();if(!c||this.runStatus()==="running")return;this.checkpointError.set(null);let g=`a-${Date.now()}`;this.messages.update(_=>[..._,{id:g,role:"assistant",content:"",toolCalls:[],streaming:!0}]),this.runStatus.set("running"),this.abort=new AbortController;let M=!1;yield this.api.resolveCheckpointStream(c.checkpoint_id,{decision:e,payload:i.payload,feedback:i.feedback},k(v({},this.streamCallbacks(g)),{onError:_=>{M=!0,this.checkpointError.set(_.code??"GENERIC"),this.messages.update(f=>f.filter(y=>y.id!==g)),this.runStatus.set("idle")}}),this.abort.signal),M||this.pendingCheckpoint.set(null),this.runStatus()==="running"&&(this.messages.update(_=>_.map(f=>f.id===g?k(v({},f),{streaming:!1}):f)),this.runStatus.set("idle"))})}streamCallbacks(e){let i=c=>this.messages.update(g=>g.map(M=>M.id===e?c(M):M)),n=(c,g)=>i(M=>k(v({},M),{toolCalls:(M.toolCalls??[]).map(_=>_.callId===c?g(_):_)}));return{onTextDelta:c=>i(g=>k(v({},g),{content:g.content+c})),onToolStarted:c=>i(g=>k(v({},g),{toolCalls:[...g.toolCalls??[],{callId:c.call_id,tool:c.tool,status:"running"}]})),onToolProgress:c=>{this.progressLabelKey.set(c.label_key),n(c.call_id,g=>k(v({},g),{labelKey:c.label_key}))},onToolResult:c=>{this.progressLabelKey.set(null),n(c.call_id,g=>k(v({},g),{status:c.ok?"ok":"error",summary:c.summary??null,errorCode:c.error_code??null,durationS:c.duration_s??null,labelKey:null}))},onCheckpoint:c=>this.pendingCheckpoint.set(c),onDone:c=>{c.state&&this.projectState.set(c.state),i(g=>k(v({},g),{streaming:!1})),this.runStatus.set("idle"),this.progressLabelKey.set(null)}}}stop(){this.abort?.abort(),this.abort=null,this.runStatus.set("idle"),this.progressLabelKey.set(null),this.messages.update(e=>e.map(i=>k(v({},i),{streaming:!1})))}reset(){this.stop(),this.messages.set([]),this.projectState.set(null),this.projectId.set(null),this.sessionError.
5set(null)}static \u0275fac=function(i){return new(i||t)};static \u0275prov=se({token:t,factory:t.\u0275fac})}return t})()});function Xt(t,s){t&1&&(r(0,"div",1),C(1,"lucide-icon",4),a()),t&2&&(o(),p("size",22))}function Zt(t,s){if(t&1&&C(0,"app-agent-beta-gate",2),t&2){let e=u();p("reason",e.store.access().reason)}}function Yt(t,s){t&1&&(r(0,"div",1),C(1,"lucide-icon",4),a()),t&2&&(o(),p("size",20))}function en(t,s){t&1&&(r(0,"div",12)(1,"p"),m(2),l(3,"translate"),a(),r(4,"a",14),l(5,"langLink"),m(6),l(7,"translate"),a()()),t&2&&(o(2),A(d(3,3,"ACADEMIC_AGENT.PICKER.NO_PROJECT")),o(2),p("routerLink",d(5,5,T(9,ve))),o(2),b(" ",d(7,7,"ACADEMIC_AGENT.PICKER.CREATE")," "))}function tn(t,s){if(t&1&&(r(0,"span",24),m(1,"\xB7"),a(),r(2,"span"),m(3),l(4,"translate"),a()),t&2){let e=u().$implicit;o(3),A(Z(4,1,"ACADEMIC_AGENT.PICKER.SECTIONS",Ee(4,tt,e.sections_written,e.sections_total)))}}function nn(t,s){if(t&1&&(r(0,"span",24),m(1,"\xB7"),a(),r(2,"span"),m(3),l(4,"translate"),a()),t&2){let e=u().$implicit;o(3),A(Z(4,1,"ACADEMIC_AGENT.REFS",X(4,nt,e.references_count)))}}function on(t,s){if(t&1){let e=N();r(0,"li")(1,"button",15),O("click",function(){let n=P(e).$implicit,c=u(3);return S(c.openProject(n.id))}),r(2,"span",16),C(3,"lucide-icon",17),a(),r(4,"span",18)(5,"span",19),m(6),a(),r(7,"span",20)(8,"span",21),m(9),l(10,"translate"),a(),r(11,"span",22),m(12),l(13,"translate"),a(),h(14,tn,5,7),h(15,nn,5,6),a()(),C(16,"lucide-icon",23),a()()}if(t&2){let e=s.$implicit,i=u(3);o(3),p("name",i.docIcon(e.doc_type))("size",18),o(3),A(e.title),o(3),A(d(10,12,"ACADEMIC.DOC_TYPE."+e.doc_type)),o(2),J("is-done",e.is_complete)("is-empty",!e.sections_total),o(),b(" ",d(13,14,e.is_complete?"ACADEMIC_AGENT.PICKER.DONE":e.sections_total?"ACADEMIC_AGENT.PICKER.IN_PROGRESS":"ACADEMIC_AGENT.PICKER.NO_OUTLINE")," "),o(2),x(e.sections_total?14:-1),o(),x(e.references_count?15:-1),o(),p("size",17)}}function an(t,s){if(t&1&&(r(0,"ul",13),W(1,on,17,16,"li",null,ot),a()),t&2){let e=u(2);o(),H(e.projects())}}function rn(t,s){if(t&1&&(r(0,"div",3)(1,"header",5)(2,"div",6)(3,"h1",7),m(4),l(5,"translate"),r(6,"span",8),m(7),l(8,"translate"),a()(),r(9,"p",9),m(10),l(11,"translate"),a()(),r(12,"a",10),l(13,"langLink"),C(14,"lucide-icon",11),r(15,"span"),m(16),l(17,"translate"),a()()(),h(18,Yt,2,1,"div",1)(19,en,8,10,"div",12)(20,an,3,0,"ul",13),a()),t&2){let e=u();o(4),b(" ",d(5,7,"ACADEMIC_AGENT.TITLE")," "),o(3),A(d(8,9,"ACADEMIC_AGENT.BETA")),o(3),A(d(11,11,"ACADEMIC_AGENT.PICKER.SUBTITLE")),o(2),p("routerLink",d(13,13,T(17,ve))),o(2),p("size",14),o(2),A(d(17,15,"ACADEMIC_AGENT.OPEN_WIZARD")),o(2),x(e.loadingProjects()?18:e.projects().length?20:19)}}function cn(t,s){if(t&1&&(r(0,"span",43),C(1,"span",44),a()),t&2){let e=u(3);Q("aria-hidden",!0),o(),pe("width",e.store.writtenRatio(),"%")}}function sn(t,s){if(t&1&&(r(0,"div",31)(1,"span",40),C(2,"lucide-icon",41),m(3),l(4,"translate"),a(),r(5,"span",40),C(6,"lucide-icon",42),m(7),l(8,"translate"),a(),h(9,cn,2,3,"span",43),a()),t&2){let e=s;o(2),p("size",13),o(),b(" ",Z(4,5,"ACADEMIC_AGENT.PROGRESS",Ee(11,tt,e.chapters.written,e.chapters.total))," "),o(3),p("size",13),o(),b(" ",Z(8,8,"ACADEMIC_AGENT.REFS",X(14,nt,e.references.count))," "),o(2),x(e.chapters.total?9:-1)}}function ln(t,s){if(t&1&&(r(0,"a",32),l(1,"langLink"),C(2,"lucide-icon",11),r(3,"span"),m(4),l(5,"translate"),a()()),t&2){let e=u(2);p("routerLink",d(1,4,T(8,Jt)))("queryParams",X(9,it,e.store.projectId())),o(2),p("size",14),o(2),A(d(5,6,"ACADEMIC_AGENT.WRITE_CHAPTERS"))}}function pn(t,s){if(t&1&&(r(0,"a",32),l(1,"langLink"),C(2,"lucide-icon",11),r(3,"span"),m(4),l(5,"translate"),a()()),t&2){let e=u(2);p("routerLink",d(1,4,T(8,ve)))("queryParams",X(9,it,e.store.projectId())),o(2),p("size",14),o(2),A(d(5,6,"ACADEMIC_AGENT.WRITE_CHAPTERS"))}}function dn(t,s){t&1&&(r(0,"div",33),m(1),l(2,"translate"),a()),t&2&&(o(),A(d(2,1,"ACADEMIC_AGENT.ERROR.LOAD_FAILED")))}function mn(t,s){if(t&1){let e=N();r(0,"button",50),O("click",function(){let n=P(e).$implicit,c=u(3);return S(c.onSuggestion(n))}),r(1,"span"),m(2),l(3,"translate"),a(),C(4,"lucide-icon",51),a()}if(t&2){let e=s.$implicit;o(2),A(d(3,2,"ACADEMIC_AGENT."+e)),o(2),p("size",13)}}function _n(t,s){if(t&1&&(r(0,"div",36)(1,"span",45),C(2,"lucide-icon",46),a(),r(3,"p",47),m(4),l(5,"translate"),a(),r(6,"div",48),W(7,mn,5,4,"button",49,le),a()()),t&2){let e=u(2);o(2),p("size",28),o(2),A(d(5,2,"ACADEMIC_AGENT.WELCOME")),o(3),H(e.store.suggestions())}}function gn(t,s){if(t&1&&C(0,"app-agent-message-item",37),t&2){let e=s.$implicit;p("message",e)}}function un(t,s){if(t&1){let e=N();r(0,"app-agent-checkpoint-card",52),O("decide",function(n){P(e);let c=u(2);return S(c.onCheckpointDecision(n))}),a()}if(t&2){let e=u(2);
5p("checkpointInput",s)("busy",e.store.runStatus()==="running")("error",e.store.checkpointError())}}function Cn(t,s){if(t&1){let e=N();r(0,"header",25)(1,"a",26),l(2,"langLink"),l(3,"translate"),C(4,"lucide-icon",27),a(),r(5,"div",28)(6,"h1",29)(7,"span",30),m(8),l(9,"translate"),a(),r(10,"span",8),m(11),l(12,"translate"),a()(),h(13,sn,10,16,"div",31),a(),h(14,ln,6,11,"a",32)(15,pn,6,11,"a",32),a(),h(16,dn,3,3,"div",33),r(17,"div",34)(18,"div",35),h(19,_n,9,4,"div",36),W(20,gn,1,1,"app-agent-message-item",37,ot),h(22,un,1,3,"app-agent-checkpoint-card",38),a(),r(23,"app-agent-composer",39),O("send",function(n){P(e);let c=u();return S(c.onSend(n))})("stop",function(){P(e);let n=u();return S(n.store.stop())}),a()()}if(t&2){let e,i,n=u();o(),p("routerLink",d(2,15,T(23,Qt))),Q("aria-label",d(3,17,"ACADEMIC_AGENT.BACK")),o(3),p("size",18),o(4),b(" ",n.store.projectState()?.meta?.title||d(9,19,"ACADEMIC_AGENT.TITLE")," "),o(3),A(d(12,21,"ACADEMIC_AGENT.BETA")),o(2),x((e=n.store.projectState())?13:-1,e),o(),x(n.cameFromChat()?14:15),o(2),x(n.store.sessionError()?16:-1),o(),J("is-empty",!n.store.messages().length),o(2),x(n.store.messages().length?-1:19),o(),H(n.store.messages()),o(2),x((i=n.store.pendingCheckpoint())?22:-1,i),o(),p("disabled",!n.store.canSend())("running",n.store.runStatus()==="running")("progressLabelKey",n.store.progressLabelKey())}}var ve,tt,nt,Qt,Jt,it,ot,Ii,fn=V(()=>{w();rt();_e();R();j();ke();pt();je();Ae();Fe();Ke();We();Ye();et();w();_e();j();R();ve=()=>["academic"],tt=(t,s)=>({written:t,total:s}),nt=t=>({count:t}),Qt=()=>["academic-agent"],Jt=()=>["academic-chat"],it=t=>({project:t}),ot=(t,s)=>s.id;Ii=(()=>{class t{store=I(Me);route=I(Ge);cameFromChat=E(!1);router=I(Le);api=I(be);translate=I(Re);auth=I(Be);platformId=I(Oe);projects=E([]);loadingProjects=E(!1);retriedAfterLogin=!1;constructor(){Te(()=>{let e=this.auth.isLoggedIn();!this.isBrowser||this.retriedAfterLogin||e&&this.store.access()?.reason==="LOGIN_REQUIRED"&&(this.retriedAfterLogin=!0,this.init())})}get isBrowser(){return we(this.platformId)}ngOnInit(){return U(this,null,function*(){this.isBrowser&&(this.cameFromChat.set(this.route.snapshot.queryParamMap.get("from")==="chat"),yield this.init())})}init(){return U(this,null,function*(){if(yield this.store.loadAccess(),!this.store.access()?.allowed)return;let e=this.route.snapshot.paramMap.get("projectId");e?yield this.store.loadSession(e):yield this.loadProjects()})}ngOnDestroy(){this.store.stop()}loadProjects(){return U(this,null,function*(){this.loadingProjects.set(!0);try{this.projects.set(yield ie(this.api.getProjects()))}catch(e){this.projects.set([])}finally{this.loadingProjects.set(!1)}})}docIcon(e){switch(e){case"these":return"GraduationCap";case"rapport":return"ScrollText";case"article":return"Newspaper";case"memoire":return"BookOpenText";default:return"FileText"}}openProject(e){this.router.navigate([e],{relativeTo:this.route})}onSend(e){this.store.send(e)}onCheckpointDecision(e){this.store.resolveCheckpoint(e.decision,{payload:e.payload,feedback:e.feedback})}onSuggestion(e){this.onSend(this.translate.instant(`ACADEMIC_AGENT.${e}`))}static \u0275fac=function(i){return new(i||t)};static \u0275cmp=D({type:t,selectors:[["app-academic-agent-workspace"]],features:[Ie([Me])],decls:5,vars:3,consts:[[1,"ag"],[1,"ag__center"],[3,"reason"],[1,"ag__picker"],["name","RefreshCw",1,"ag__spin",3,"size"],[1,"ag__picker-head"],[1,"ag__picker-main"],[1,"ag__title"],[1,"ag__beta"],[1,"ag__subtitle"],[1,"ag__wizard",3,"routerLink"],["name","Pencil",3,"size"],[1,"ag__empty"],[1,"ag__list"],[1,"ag__cta",3,"routerLink"],["type","button",1,"ag__item",3,"click"],[1,"ag__item-icon"],[3,"name","size"],[1,"ag__item-main"],[1,"ag__item-title"],[1,"ag__item-meta"],[1,"ag__tag"],[1,"ag__state"],["name","ChevronRight",1,"ag__item-chevron",3,"size"],["aria-hidden","true",1,"ag__dot"],[1,"ag__header"],[1,"ag__back",3,"routerLink"],["name","ChevronLeft",3,"size"],[1,"ag__head-main"],[1,"ag__head-title"],[1,"ag__head-text"],[1,"ag__head-meta"],[1,"ag__wizard",3,"routerLink","queryParams"],[1,"ag__alert"],[1,"ag__body"],[1,"ag__thread"],[1,"ag__welcome"],[3,"message"],[3,"checkpointInput","busy","error"],[3,"send","stop","disabled","running","progressLabelKey"],[1,"ag__stat"],["name","BookOpenText",3,"size"],["name","Quote",3,"size"],[1,"ag__bar"],[1,"ag__bar-fill"],[1,"ag__welcome-icon"],["name","Bot",3,"size"],[1,"ag__welcome-text"],[1,"ag__chips"],["type","button",1,"ag__chip"],["type","button",1,"ag__chip",3,"click"],["name","ArrowUp",1,"ag__chip-icon",3,"size"],[3,"decide","checkpointInput","busy","error"]],template:function(i,n){i&1&&(r(0,"div",0),h(1,Xt,2,1,"div",1)(2,Zt,1,1,"app-agent-beta-gate",2)(3,rn,21,18,"div",3)(4,Cn,24,24),a()),i&2&&(J("is-conversation",!!n.store.messages().length),o(),x(n.store.loadingAccess()?1:n.store.access()&&!n.store.access().allowed?2:n.store.projectId()?4:3))},dependencies:[me,de,L,B,z,Ue,$e,Ze,Ve,G,ge],styles:['@charset "UTF-8";[_nghost-%COMP%]{--ag-text: #111827;--ag-muted: #6b7280;--ag-border: #e5e7eb;--ag-border-strong: #d1d5db;--ag-surface: #f9fafb;--ag-surface-hover: #f3f4f6;--ag-input-bg: #ffffff;--ag-accent: var(--primary, #3273dc);--ag-accent-soft: rgba(108, 68, 255, .12);display:block;color:var(--ag-text)}[data-theme=dark][_nghost-%COMP%], [data-theme=dark] [_nghost-%COMP%]{--ag-text: #e5e7eb;--ag-muted: #9ca3af;--ag-border: rgba(255, 255, 255, .1);--ag-border-strong: rgba(255, 255, 255, .18);--ag-surface: rgba(255, 255, 255, .04);--ag-surface-hover: rgba(255, 255, 255, .07);--ag-input-bg: rgba(255, 255, 255, .04);--ag-accent-soft: rgba(147, 116, 255, .18)}.ag[_ngcontent-%COMP%]{width:100%;max-width:1440px;margin-inline:auto;padding:1.25rem 1.75rem 2rem;display:flex;flex-direction:column}.ag.is-conversation[_ngcontent-%COMP%]{min-height:calc(100vh - 120px)}.ag__thread[_ngcontent-%COMP%], .ag[_ngcontent-%COMP%] app-agent-composer[_ngcontent-%COMP%]{display:block;width:100%}.ag__center[_ngcontent-%COMP%]{display:flex;justify-content:center;padding:3rem 0;color:var(--ag-muted)}.ag__picker-head[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.85rem;padding:0 0 .9rem;margin-bottom:1.25rem;border-bottom:1px solid var(--ag-border)}.ag__picker-main[_ngcontent-%COMP%]{flex:1;min-width:0}.ag__title[_ngcontent-%COMP%]{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem;font-size:1.15rem;font-weight:700;line-height:1.3;margin:0}.ag__subtitle[_ngcontent-%COMP%]{color:var(--ag-muted);margin:.15rem 0 0;font-size:.85rem}.ag__beta[_ngcontent-%COMP%]{font-size:.65rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;padding:.12rem .4rem;border-radius:5px;background:#6c44ff24;color:var(--primary, #6c44ff)}.ag__list[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.55rem}.ag__item[_ngcontent-%COMP%]{width:100%;display:flex;align-items:center;gap:.85rem;padding:.85rem 1rem;border:1px solid var(--ag-border);border-radius:14px;background:var(--ag-surface);color:inherit;cursor:pointer;text-align:start;transition:border-color .15s ease,background-color .15s ease}.ag__item[_ngcontent-%COMP%]:hover{border-color:var(--ag-accent);background:var(--ag-surface-hover)}.ag__item[_ngcontent-%COMP%]:focus-visible{outline:2px solid var(--ag-accent);outline-offset:2px}.ag__item-icon[_ngcontent-%COMP%]{flex-shrink:0;width:38px;height:38px;border-radius:11px;display:inline-flex;align-items:center;justify-content:center;background:var(--ag-accent-soft);color:var(--primary, #6c44ff)}.ag__item-main[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.2rem}.ag__item-title[_ngcontent-%COMP%]{font-weight:600;font-size:.95rem;line-height:1.35;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.ag__item-meta[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;flex-wrap:wrap;font-size:.78rem;color:var(--ag-muted)}.ag__tag[_ngcontent-%COMP%]{border:1px solid var(--ag-border-strong);border-radius:6px;padding:.05rem .4rem;font-size:.72rem;font-weight:600;text-transform:uppercase;letter-spacing:.02em}.ag__dot[_ngcontent-%COMP%]{opacity:.5}.ag__state[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.3rem;font-size:.74rem;font-weight:600;border-radius:6px;padding:.05rem .45rem;background:#2563eb1a;color:#2563eb}.ag__state[_ngcontent-%COMP%]:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.ag__state.is-done[_ngcontent-%COMP%]{background:#16a34a1f;color:#16a34a}.ag__state.is-empty[_ngcontent-%COMP%]{background:#94a3b82e;color:var(--ag-muted)}.ag__item-chevron[_ngcontent-%COMP%]{flex-shrink:0;color:var(--ag-muted)}.ag__empty[_ngcontent-%COMP%]{text-align:center;padding:2rem 0;color:var(--ag-muted)}.ag__cta[_ngcontent-%COMP%]{display:inline-block;margin-top:.8rem;background:var(--primary, #3273dc);color:#fff;padding:.55rem 1.2rem;border-radius:9999px;font-weight:600;text-decoration:none}.ag__header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.85rem;padding:0 0 .85rem;border-bottom:1px solid var(--ag-border)}.ag__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:10px;border:1px solid var(--ag-border);color:var(--ag-muted);flex-shrink:0}.ag__back[_ngcontent-%COMP%]:hover{border-color:var(--ag-accent);color:var(--ag-accent)}.ag__head-main[_ngcontent-%COMP%]{flex:1;min-width:0}.ag__head-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.45rem;font-size:1rem;font-weight:700;margin:0;min-width:0}.ag__head-text[_ngcontent-%COMP%]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ag__head-meta[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.7rem;margin:.3rem 0 0;font-size:.76rem;color:var(--ag-muted)}.ag__stat[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.28rem;flex-shrink:0}.ag__bar[_ngcontent-%COMP%]{flex:1;max-width:160px;height:4px;border-radius:999px;background:var(--ag-border);overflow:hidden}.ag__bar-fill[_ngcontent-%COMP%]{display:block;height:100%;border-radius:inherit;background:var(--ag-accent);transition:width .3s ease}.ag__wizard[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.35rem;font-size:.78rem;font-weight:600;color:#fff;background:var(--ag-accent);border:1px solid var(--ag-accent);border-radius:5px;padding:.45rem .9rem;flex-shrink:0;text-decoration:none}.ag__wizard[_ngcontent-%COMP%]:hover{filter:brightness(.94);color:#fff}.ag__alert[_ngcontent-%COMP%]{margin-top:.7rem;padding:.6rem .9rem;border-radius:10px;background:#dc262614;color:#b91c1c;font-size:.85rem}.ag__body[_ngcontent-%COMP%]{flex:1;min-height:0;display:flex;flex-direction:column}.ag__body.is-empty[_ngcontent-%COMP%]{justify-content:flex-start;gap:1.1rem;padding-top:2.5rem}.ag__body.is-empty[_ngcontent-%COMP%] .ag__thread[_ngcontent-%COMP%]{flex:0 0 auto;overflow:visible;padding:0;display:flex;justify-content:center}.ag__thread[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:1rem 0}.ag__welcome[_ngcontent-%COMP%]{text-align:center;max-width:560px;padding:1rem 0}.ag__welcome-icon[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:60px;height:60px;border-radius:18px;background:var(--ag-accent-soft);color:var(--primary, #6c44ff);margin-bottom:1rem}.ag__welcome-text[_ngcontent-%COMP%]{color:var(--ag-muted);font-size:.95rem;line-height:1.6;margin:0 0 1.4rem}.ag__chips[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;align-items:stretch}.ag__chip[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:.75rem;border:1px solid var(--ag-border);background:var(--ag-surface);color:inherit;border-radius:12px;padding:.7rem .95rem;font-size:.88rem;text-align:start;cursor:pointer;transition:border-color .15s ease,background-color .15s ease}.ag__chip[_ngcontent-%COMP%]:hover{border-color:var(--ag-accent);background:var(--ag-surface-hover)}.ag__chip-icon[_ngcontent-%COMP%]{flex-shrink:0;
5opacity:0;color:var(--ag-accent);transform:rotate(45deg);transition:opacity .15s ease}.ag__chip[_ngcontent-%COMP%]:hover .ag__chip-icon[_ngcontent-%COMP%]{opacity:1}.ag__spin[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_ag-spin 1s linear infinite}@keyframes _ngcontent-%COMP%_ag-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.ag__spin[_ngcontent-%COMP%]{animation:none}}@media(max-width:640px){.ag[_ngcontent-%COMP%]{padding:.75rem .9rem 1.5rem;min-height:calc(100vh - 90px)}.ag__picker-head[_ngcontent-%COMP%]{gap:.6rem}.ag__title[_ngcontent-%COMP%]{font-size:1rem}.ag__subtitle[_ngcontent-%COMP%]{font-size:.8rem}.ag__wizard[_ngcontent-%COMP%]{width:34px;height:34px;padding:0;justify-content:center}.ag__wizard[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:none}.ag__item[_ngcontent-%COMP%]{padding:.75rem .8rem;gap:.7rem;border-radius:12px}.ag__item-icon[_ngcontent-%COMP%]{width:34px;height:34px;border-radius:10px}.ag__item-title[_ngcontent-%COMP%]{font-size:.9rem}.ag__welcome[_ngcontent-%COMP%]{padding:.5rem 0}.ag__header[_ngcontent-%COMP%]{gap:.6rem}.ag__bar[_ngcontent-%COMP%]{display:none}}']})}return t})()});fn();export{Ii as AcademicAgentWorkspaceComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.