@mitodl/smoot-design 6.2.1 → 6.2.2

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.
@@ -37091,7 +37091,10 @@ const iM = (e) => e, uM = (e) => async (t, r) => {
37091
37091
  flex: 1,
37092
37092
  padding: "14px 0",
37093
37093
  overflow: e ? "visible" : "auto",
37094
- gap: "16px"
37094
+ gap: "16px",
37095
+ [`> .${Tn.messageRowAssistant}:first-child`]: {
37096
+ marginTop: "16px"
37097
+ }
37095
37098
  })
37096
37099
  ), ny = Ye.div({
37097
37100
  display: "flex",
@@ -37107,7 +37110,6 @@ const iM = (e) => e, uM = (e) => async (t, r) => {
37107
37110
  }), ry = Ye.div(({ theme: e }) => ({
37108
37111
  color: e.custom.colors.darkGray2,
37109
37112
  backgroundColor: e.custom.colors.white,
37110
- padding: "12px 16px",
37111
37113
  ...e.typography.body2,
37112
37114
  "p:first-of-type": {
37113
37115
  marginTop: 0
@@ -37130,10 +37132,8 @@ const iM = (e) => e, uM = (e) => async (t, r) => {
37130
37132
  fontWeight: "normal"
37131
37133
  },
37132
37134
  borderRadius: "12px",
37133
- [`.${Tn.messageRowAssistant} &`]: {
37134
- padding: "12px 16px 12px 0"
37135
- },
37136
37135
  [`.${Tn.messageRowUser} &`]: {
37136
+ padding: "12px 16px",
37137
37137
  borderRadius: "8px 0px 8px 8px",
37138
37138
  backgroundColor: e.custom.colors.lightGray1
37139
37139
  }
@@ -37730,9 +37730,11 @@ const RM = ({
37730
37730
  },
37731
37731
  anchor: "right",
37732
37732
  open: s,
37733
- onClose: () => c(!1)
37733
+ onClose: () => c(!1),
37734
+ role: "dialog",
37735
+ "aria-modal": "true"
37734
37736
  },
37735
- /* @__PURE__ */ x.createElement(OM, null, /* @__PURE__ */ x.createElement(NM, null, d.title ? /* @__PURE__ */ x.createElement(Sp, null) : null, /* @__PURE__ */ x.createElement(Di, { variant: "body1", component: "h2" }, (V = d.title) != null && V.includes("AskTIM") ? /* @__PURE__ */ x.createElement(x.Fragment, null, "Ask", /* @__PURE__ */ x.createElement("strong", null, "TIM"), d.title.replace("AskTIM", "")) : d.title)), /* @__PURE__ */ x.createElement(
37737
+ /* @__PURE__ */ x.createElement(OM, null, /* @__PURE__ */ x.createElement(NM, null, d.title ? /* @__PURE__ */ x.createElement(Sp, null) : null, /* @__PURE__ */ x.createElement(Di, { variant: "body1", component: "h1" }, (V = d.title) != null && V.includes("AskTIM") ? /* @__PURE__ */ x.createElement(x.Fragment, null, "Ask", /* @__PURE__ */ x.createElement("strong", null, "TIM"), d.title.replace("AskTIM", "")) : d.title)), /* @__PURE__ */ x.createElement(
37736
37738
  kM,
37737
37739
  {
37738
37740
  variant: "text",
@@ -204,4 +204,4 @@ Error message: ${C2(r)}`,cause:r}),this[L2]=!0,this.value=t}static isInstance(t)
204
204
  *
205
205
  * This source code is licensed under the MIT license found in the
206
206
  * LICENSE file in the root directory of this source tree.
207
- */var U2;function QD(){if(U2)return C0;U2=1;var e=as();function t(E,S){return E===S&&(E!==0||1/E===1/S)||E!==E&&S!==S}var r=typeof Object.is=="function"?Object.is:t,i=e.useState,l=e.useEffect,s=e.useLayoutEffect,c=e.useDebugValue;function d(E,S){var y=S(),N=i({inst:{value:y,getSnapshot:S}}),_=N[0].inst,L=N[1];return s(function(){_.value=y,_.getSnapshot=S,p(_)&&L({inst:_})},[E,y,S]),l(function(){return p(_)&&L({inst:_}),E(function(){p(_)&&L({inst:_})})},[E]),c(y),y}function p(E){var S=E.getSnapshot;E=E.value;try{var y=S();return!r(E,y)}catch{return!0}}function m(E,S){return S()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:d;return C0.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b,C0}var H2;function KD(){return H2||(H2=1,S0.exports=QD()),S0.exports}var WD=KD();const Ia=()=>{},Yn=Ia(),A0=Object,mt=e=>e===Yn,Gr=e=>typeof e=="function",wa=(e,t)=>({...e,...t}),ZD=e=>Gr(e.then),sc=new WeakMap;let JD=0;const ro=e=>{const t=typeof e,r=e&&e.constructor,i=r==Date;let l,s;if(A0(e)===e&&!i&&r!=RegExp){if(l=sc.get(e),l)return l;if(l=++JD+"~",sc.set(e,l),r==Array){for(l="@",s=0;s<e.length;s++)l+=ro(e[s])+",";sc.set(e,l)}if(r==A0){l="#";const c=A0.keys(e).sort();for(;!mt(s=c.pop());)mt(e[s])||(l+=s+":"+ro(e[s])+",");sc.set(e,l)}}else l=i?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return l},ua=new WeakMap,x0={},cc={},_0="undefined",fc=typeof window!=_0,v0=typeof document!=_0,eL=()=>fc&&typeof window.requestAnimationFrame!=_0,F2=(e,t)=>{const r=ua.get(e);return[()=>!mt(t)&&e.get(t)||x0,i=>{if(!mt(t)){const l=e.get(t);t in cc||(cc[t]=l),r[5](t,wa(l,i),l||x0)}},r[6],()=>!mt(t)&&t in cc?cc[t]:!mt(t)&&e.get(t)||x0]};let R0=!0;const tL=()=>R0,[O0,N0]=fc&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ia,Ia],nL=()=>{const e=v0&&document.visibilityState;return mt(e)||e!=="hidden"},rL=e=>(v0&&document.addEventListener("visibilitychange",e),O0("focus",e),()=>{v0&&document.removeEventListener("visibilitychange",e),N0("focus",e)}),aL=e=>{const t=()=>{R0=!0,e()},r=()=>{R0=!1};return O0("online",t),O0("offline",r),()=>{N0("online",t),N0("offline",r)}},iL={isOnline:tL,isVisible:nL},uL={initFocus:rL,initReconnect:aL},z2=!xt.useId,ao=!fc||"Deno"in window,lL=e=>eL()?window.requestAnimationFrame(e):setTimeout(e,1),k0=ao?A.useEffect:A.useLayoutEffect,D0=typeof navigator<"u"&&navigator.connection,Y2=!ao&&D0&&(["slow-2g","2g"].includes(D0.effectiveType)||D0.saveData),L0=e=>{if(Gr(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?ro(e):"",[e,t]};let oL=0;const I0=()=>++oL,j2=0,V2=1,$2=2;var io={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:j2,MUTATE_EVENT:$2,RECONNECT_EVENT:V2};async function q2(...e){const[t,r,i,l]=e,s=wa({populateCache:!0,throwOnError:!0},typeof l=="boolean"?{revalidate:l}:l||{});let c=s.populateCache;const d=s.rollbackOnError;let p=s.optimisticData;const m=S=>typeof d=="function"?d(S):d!==!1,b=s.throwOnError;if(Gr(r)){const S=r,y=[],N=t.keys();for(const _ of N)!/^\$(inf|sub)\$/.test(_)&&S(t.get(_)._k)&&y.push(_);return Promise.all(y.map(E))}return E(r);async function E(S){const[y]=L0(S);if(!y)return;const[N,_]=F2(t,y),[L,v,H,D]=ua.get(t),P=()=>{const W=L[y];return(Gr(s.revalidate)?s.revalidate(N().data,S):s.revalidate!==!1)&&(delete H[y],delete D[y],W&&W[0])?W[0]($2).then(()=>N().data):N().data};if(e.length<3)return P();let I=i,M;const j=I0();v[y]=[j,0];const ie=!mt(p),V=N(),x=V.data,Y=V._c,K=mt(Y)?x:Y;if(ie&&(p=Gr(p)?p(K,x):p,_({data:p,_c:K})),Gr(I))try{I=I(K)}catch(W){M=W}if(I&&ZD(I))if(I=await I.catch(W=>{M=W}),j!==v[y][0]){if(M)throw M;return I}else M&&ie&&m(M)&&(c=!0,_({data:K,_c:Yn}));if(c&&!M)if(Gr(c)){const W=c(I,K);_({data:W,error:Yn,_c:Yn})}else _({data:I,error:Yn,_c:Yn});if(v[y][1]=I0(),Promise.resolve(P()).then(()=>{_({_c:Yn})}),M){if(b)throw M;return}return I}}const G2=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},sL=(e,t)=>{if(!ua.has(e)){const r=wa(uL,t),i={},l=q2.bind(Yn,e);let s=Ia;const c={},d=(b,E)=>{const S=c[b]||[];return c[b]=S,S.push(E),()=>S.splice(S.indexOf(E),1)},p=(b,E,S)=>{e.set(b,E);const y=c[b];if(y)for(const N of y)N(E,S)},m=()=>{if(!ua.has(e)&&(ua.set(e,[i,{},{},{},l,p,d]),!ao)){const b=r.initFocus(setTimeout.bind(Yn,G2.bind(Yn,i,j2))),E=r.initReconnect(setTimeout.bind(Yn,G2.bind(Yn,i,V2)));s=()=>{b&&b(),E&&E(),ua.delete(e)}}};return m(),[e,l,m,s]}return[e,ua.get(e)[4]]},cL=(e,t,r,i,l)=>{const s=r.errorRetryCount,c=l.retryCount,d=~~((Math.random()+.5)*(1<<(c<8?c:8)))*r.errorRetryInterval;!mt(s)&&c>s||setTimeout(i,d,l)},fL=(e,t)=>ro(e)==ro(t),[X2,dL]=sL(new Map),hL=wa({onLoadingSlow:Ia,onSuccess:Ia,onError:Ia,onErrorRetry:cL,onDiscarded:Ia,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Y2?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Y2?5e3:3e3,compare:fL,isPaused:()=>!1,cache:X2,mutate:dL,fallback:{}},iL),pL=(e,t)=>{const r=wa(e,t);if(t){const{use:i,fallback:l}=e,{use:s,fallback:c}=t;i&&s&&(r.use=i.concat(s)),l&&c&&(r.fallback=wa(l,c))}return r},mL=A.createContext({}),gL="$inf$",Q2=fc&&window.__SWR_DEVTOOLS_USE__,bL=Q2?window.__SWR_DEVTOOLS_USE__:[],EL=()=>{Q2&&(window.__SWR_DEVTOOLS_REACT__=xt)},yL=e=>Gr(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],TL=()=>wa(hL,A.useContext(mL)),SL=e=>(t,r,i)=>e(t,r&&((...s)=>{const[c]=L0(t),[,,,d]=ua.get(X2);if(c.startsWith(gL))return r(...s);const p=d[c];return mt(p)?r(...s):(delete d[c],p)}),i),CL=bL.concat(SL),AL=e=>function(...r){const i=TL(),[l,s,c]=yL(r),d=pL(i,c);let p=e;const{use:m}=d,b=(m||[]).concat(CL);for(let E=b.length;E--;)p=b[E](p);return p(l,s||d.fetcher||null,d)},xL=(e,t,r)=>{const i=t[e]||(t[e]=[]);return i.push(r),()=>{const l=i.indexOf(r);l>=0&&(i[l]=i[i.length-1],i.pop())}};EL();const K2=xt.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),w0={dedupe:!0},dc=AL((e,t,r)=>{const{cache:i,compare:l,suspense:s,fallbackData:c,revalidateOnMount:d,revalidateIfStale:p,refreshInterval:m,refreshWhenHidden:b,refreshWhenOffline:E,keepPreviousData:S}=r,[y,N,_,L]=ua.get(i),[v,H]=L0(e),D=A.useRef(!1),P=A.useRef(!1),I=A.useRef(v),M=A.useRef(t),j=A.useRef(r),ie=()=>j.current,V=()=>ie().isVisible()&&ie().isOnline(),[x,Y,K,W]=F2(i,v),q=A.useRef({}).current,ee=mt(c)?r.fallback[v]:c,Q=(ve,Oe)=>{for(const Ce in q){const Be=Ce;if(Be==="data"){if(!l(ve[Be],Oe[Be])&&(!mt(ve[Be])||!l(Re,Oe[Be])))return!1}else if(Oe[Be]!==ve[Be])return!1}return!0},se=A.useMemo(()=>{const ve=!v||!t?!1:mt(d)?ie().isPaused()||s?!1:mt(p)?!0:p:d,Oe=ct=>{const St=wa(ct);return delete St._k,ve?{isValidating:!0,isLoading:!0,...St}:St},Ce=x(),Be=W(),it=Oe(Ce),je=Ce===Be?it:Oe(Be);let Ue=it;return[()=>{const ct=Oe(x());return Q(ct,Ue)?(Ue.data=ct.data,Ue.isLoading=ct.isLoading,Ue.isValidating=ct.isValidating,Ue.error=ct.error,Ue):(Ue=ct,ct)},()=>je]},[i,v]),re=WD.useSyncExternalStore(A.useCallback(ve=>K(v,(Oe,Ce)=>{Q(Ce,Oe)||ve()}),[i,v]),se[0],se[1]),ge=!D.current,C=y[v]&&y[v].length>0,J=re.data,Te=mt(J)?ee:J,O=re.error,ue=A.useRef(Te),Re=S?mt(J)?ue.current:J:Te,Se=C&&!mt(O)?!1:ge&&!mt(d)?d:ie().isPaused()?!1:s?mt(Te)?!1:p:mt(Te)||p,tt=!!(v&&t&&ge&&Se),Me=mt(re.isValidating)?tt:re.isValidating,$e=mt(re.isLoading)?tt:re.isLoading,xe=A.useCallback(async ve=>{const Oe=M.current;if(!v||!Oe||P.current||ie().isPaused())return!1;let Ce,Be,it=!0;const je=ve||{},Ue=!_[v]||!je.dedupe,ct=()=>z2?!P.current&&v===I.current&&D.current:v===I.current,St={isValidating:!1,isLoading:!1},rn=()=>{Y(St)},_n=()=>{const Xe=_[v];Xe&&Xe[1]===Be&&delete _[v]},we={isValidating:!0};mt(x().data)&&(we.isLoading=!0);try{if(Ue&&(Y(we),r.loadingTimeout&&mt(x().data)&&setTimeout(()=>{it&&ct()&&ie().onLoadingSlow(v,r)},r.loadingTimeout),_[v]=[Oe(H),I0()]),[Ce,Be]=_[v],Ce=await Ce,Ue&&setTimeout(_n,r.dedupingInterval),!_[v]||_[v][1]!==Be)return Ue&&ct()&&ie().onDiscarded(v),!1;St.error=Yn;const Xe=N[v];if(!mt(Xe)&&(Be<=Xe[0]||Be<=Xe[1]||Xe[1]===0))return rn(),Ue&&ct()&&ie().onDiscarded(v),!1;const $t=x().data;St.data=l($t,Ce)?$t:Ce,Ue&&ct()&&ie().onSuccess(Ce,v,r)}catch(Xe){_n();const $t=ie(),{shouldRetryOnError:te}=$t;$t.isPaused()||(St.error=Xe,Ue&&ct()&&($t.onError(Xe,v,$t),(te===!0||Gr(te)&&te(Xe))&&(!ie().revalidateOnFocus||!ie().revalidateOnReconnect||V())&&$t.onErrorRetry(Xe,v,$t,fe=>{const Ae=y[v];Ae&&Ae[0]&&Ae[0](io.ERROR_REVALIDATE_EVENT,fe)},{retryCount:(je.retryCount||0)+1,dedupe:!0})))}return it=!1,rn(),!0},[v,i]),Ge=A.useCallback((...ve)=>q2(i,I.current,...ve),[]);if(k0(()=>{M.current=t,j.current=r,mt(J)||(ue.current=J)}),k0(()=>{if(!v)return;const ve=xe.bind(Yn,w0);let Oe=0;const Be=xL(v,y,(it,je={})=>{if(it==io.FOCUS_EVENT){const Ue=Date.now();ie().revalidateOnFocus&&Ue>Oe&&V()&&(Oe=Ue+ie().focusThrottleInterval,ve())}else if(it==io.RECONNECT_EVENT)ie().revalidateOnReconnect&&V()&&ve();else{if(it==io.MUTATE_EVENT)return xe();if(it==io.ERROR_REVALIDATE_EVENT)return xe(je)}});return P.current=!1,I.current=v,D.current=!0,Y({_k:H}),Se&&(mt(Te)||ao?ve():lL(ve)),()=>{P.current=!0,Be()}},[v]),k0(()=>{let ve;function Oe(){const Be=Gr(m)?m(x().data):m;Be&&ve!==-1&&(ve=setTimeout(Ce,Be))}function Ce(){!x().error&&(b||ie().isVisible())&&(E||ie().isOnline())?xe(w0).then(Oe):Oe()}return Oe(),()=>{ve&&(clearTimeout(ve),ve=-1)}},[m,b,E,v]),A.useDebugValue(Re),s&&mt(Te)&&v){if(!z2&&ao)throw new Error("Fallback data is required when using suspense in SSR.");M.current=t,j.current=r,P.current=!1;const ve=L[v];if(!mt(ve)){const Oe=Ge(ve);K2(Oe)}if(mt(O)){const Oe=xe(w0);mt(Re)||(Oe.status="fulfilled",Oe.value=!0),K2(Oe)}else throw O}return{mutate:Ge,get data(){return q.data=!0,Re},get error(){return q.error=!0,O},get isValidating(){return q.isValidating=!0,Me},get isLoading(){return q.isLoading=!0,$e}}});var M0,W2;function _L(){if(W2)return M0;W2=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let i,l=0;return function(...c){clearTimeout(i);const d=Date.now(),p=d-l,m=r-p;m<=0?(l=d,t.apply(this,c)):i=setTimeout(()=>{l=Date.now(),t.apply(this,c)},m)}}return M0=e,M0}var vL=_L();const RL=ur(vL);function Z2(e,t){return t!=null?RL(e,t):e}var OL=async(e,t,r,i,l,s,c,d,p,m,b,E,S,y,N,_,L)=>{var v;const H=c.current;r(t.messages,!1);const D=y?t.messages:t.messages.map(({role:I,content:M,experimental_attachments:j,data:ie,annotations:V,toolInvocations:x})=>({role:I,content:M,...j!==void 0&&{experimental_attachments:j},...ie!==void 0&&{data:ie},...V!==void 0&&{annotations:V},...x!==void 0&&{toolInvocations:x}})),P=l.current;return await XD({api:e,body:(v=N==null?void 0:N({messages:t.messages,requestData:t.data,requestBody:t.body}))!=null?v:{messages:D,data:t.data,...s.current.body,...t.body},streamProtocol:m,credentials:s.current.credentials,headers:{...s.current.headers,...t.headers},abortController:()=>d.current,restoreMessagesOnFailure(){L||r(H,!1)},onResponse:E,onUpdate(I,M){r([...t.messages,...I],!1),M!=null&&M.length&&i([...P??[],...M],!1)},onToolCall:S,onFinish:b,generateId:p,fetch:_})};function NL({api:e="/api/chat",id:t,initialMessages:r,initialInput:i="",sendExtraMessageFields:l,onToolCall:s,experimental_prepareRequestBody:c,maxSteps:d=1,streamProtocol:p="data",onResponse:m,onFinish:b,onError:E,credentials:S,headers:y,body:N,generateId:_=M2,fetch:L,keepLastMessageOnError:v=!0,experimental_throttle:H}={}){const D=A.useId(),P=t??D,I=typeof e=="string"?[e,P]:P,[M]=A.useState([]),{data:j,mutate:ie}=dc([I,"messages"],null,{fallbackData:r??M}),V=A.useRef(j||[]);A.useEffect(()=>{V.current=j||[]},[j]);const{data:x,mutate:Y}=dc([I,"streamData"],null),K=A.useRef(x);A.useEffect(()=>{K.current=x},[x]);const{data:W=!1,mutate:q}=dc([I,"loading"],null),{data:ee=void 0,mutate:Q}=dc([I,"error"],null),se=A.useRef(null),re=A.useRef({credentials:S,headers:y,body:N});A.useEffect(()=>{re.current={credentials:S,headers:y,body:N}},[S,y,N]);const ge=A.useCallback(async xe=>{const Ge=V.current.length;try{q(!0),Q(void 0);const Ce=new AbortController;se.current=Ce,await OL(e,xe,Z2(ie,H),Z2(Y,H),K,re,V,se,_,p,b,m,s,l,c,L,v),se.current=null}catch(Ce){if(Ce.name==="AbortError")return se.current=null,null;E&&Ce instanceof Error&&E(Ce),Q(Ce)}finally{q(!1)}const ve=V.current,Oe=ve[ve.length-1];ve.length>Ge&&Oe!=null&&d>1&&J2(Oe)&&kL(ve)<d&&await ge({messages:ve})},[ie,q,e,re,m,b,E,Q,Y,K,p,l,c,s,d,V,se,_,L,v,H]),C=A.useCallback(async(xe,{data:Ge,headers:ve,body:Oe,experimental_attachments:Ce}={})=>{var Be,it;const je=await P2(Ce),Ue=V.current.concat({...xe,id:(Be=xe.id)!=null?Be:_(),createdAt:(it=xe.createdAt)!=null?it:new Date,experimental_attachments:je.length>0?je:void 0});return ge({messages:Ue,headers:ve,body:Oe,data:Ge})},[ge,_]),J=A.useCallback(async({data:xe,headers:Ge,body:ve}={})=>{const Oe=V.current;if(Oe.length===0)return null;const Ce=Oe[Oe.length-1];return ge({messages:Ce.role==="assistant"?Oe.slice(0,-1):Oe,headers:Ge,body:ve,data:xe})},[ge]),Te=A.useCallback(()=>{se.current&&(se.current.abort(),se.current=null)},[]),O=A.useCallback(xe=>{typeof xe=="function"&&(xe=xe(V.current)),ie(xe,!1),V.current=xe},[ie]),ue=A.useCallback(xe=>{typeof xe=="function"&&(xe=xe(K.current)),Y(xe,!1),K.current=xe},[Y]),[Re,Se]=A.useState(i),tt=A.useCallback(async(xe,Ge={},ve)=>{var Oe;if((Oe=xe==null?void 0:xe.preventDefault)==null||Oe.call(xe),!Re&&!Ge.allowEmptySubmit)return;ve&&(re.current={...re.current,...ve});const Ce=await P2(Ge.experimental_attachments),it={messages:!Re&&!Ce.length&&Ge.allowEmptySubmit?V.current:V.current.concat({id:_(),createdAt:new Date,role:"user",content:Re,experimental_attachments:Ce.length>0?Ce:void 0}),headers:Ge.headers,body:Ge.body,data:Ge.data};ge(it),Se("")},[Re,_,ge]);return{messages:j||[],setMessages:O,data:x,setData:ue,error:ee,append:C,reload:J,stop:Te,input:Re,setInput:Se,handleInputChange:xe=>{Se(xe.target.value)},handleSubmit:tt,isLoading:W,addToolResult:({toolCallId:xe,result:Ge})=>{const ve=V.current.map((Ce,Be,it)=>Be===it.length-1&&Ce.role==="assistant"&&Ce.toolInvocations?{...Ce,toolInvocations:Ce.toolInvocations.map(je=>je.toolCallId===xe?{...je,result:Ge,state:"result"}:je)}:Ce);ie(ve,!1);const Oe=ve[ve.length-1];J2(Oe)&&ge({messages:ve})}}}function J2(e){return e.role==="assistant"&&e.toolInvocations&&e.toolInvocations.length>0&&e.toolInvocations.every(t=>"result"in t)}function kL(e){let t=0;for(let r=e.length-1;r>=0&&e[r].role==="assistant";r--)t++;return t}var DL=NL;const LL=e=>e,IL=e=>async(t,r)=>{var c;if(typeof(r==null?void 0:r.body)!="string")return console.error("Unexpected body type."),window.fetch(t,r);const i=JSON.parse(r==null?void 0:r.body).messages,l=e.transformBody??LL,s={...r,body:JSON.stringify(l(i)),...e.fetchOpts,headers:{...r==null?void 0:r.headers,"Content-Type":"application/json",...(c=e.fetchOpts)==null?void 0:c.headers}};return fetch(t,s)},wL=(e,t)=>{const r=A.useMemo(()=>IL(e),[e]);return DL({api:e.apiUrl,streamProtocol:"text",fetch:r,onFinish:i=>{var l;e.onFinish&&(i.role==="assistant"||i.role==="user"?(l=e.onFinish)==null||l.call(e,i):console.info("Unexpected message role.",i))},...t})},ML=e=>e.scrollHeight-e.clientHeight-e.scrollTop,BL=e=>{e.scrollTop=e.scrollHeight},PL=({scrollElement:e,contentElement:t,threshold:r=2})=>{A.useEffect(()=>{const i=()=>{e&&ML(e)<r&&BL(e)};i();const l=new ResizeObserver(i);return t&&l.observe(t),()=>{l.disconnect()}},[e,t,r])},bn={root:"MitAiChat--root",title:"MitAiChat--title",entryScreenContainer:"MitAiChat--entryScreenContainer",conversationStarter:"MitAiChat--conversationStarter",chatScreenContainer:"MitAiChat--chatScreenContainer",messagesContainer:"MitAiChat--messagesContainer",messageRow:"MitAiChat--messageRow",messageRowUser:"MitAiChat--messageRowUser",messageRowAssistant:"MitAiChat--messageRowAssistant",message:"MitAiChat--message",input:"MitAiChat--input",bottomSection:"MitAiChat--bottomSection"},UL=Fe.div(),HL=Fe.div(({externalScroll:e,theme:t})=>({padding:"16px 32px 0",[t.breakpoints.down("md")]:{padding:"16px 16px 0"},boxSizing:"border-box",background:"white",position:"absolute",bottom:0,top:0,left:0,right:0,zIndex:1,...e&&{padding:"0 32px",[t.breakpoints.down("md")]:{padding:"0 16px"}}})),FL=Fe.div(({externalScroll:e})=>({width:"100%",height:e?"auto":"100%",minHeight:e?"100%":"auto",display:"flex",flexDirection:"column"})),zL=Fe(qk)(({externalScroll:e})=>({display:"flex",flexDirection:"column",flex:1,padding:"14px 0",overflow:e?"visible":"auto",gap:"16px"})),ey=Fe.div({display:"flex",width:"100%",gap:"10px",[`&.${bn.messageRowUser}`]:{flexDirection:"row-reverse"},"> *":{minWidth:0},position:"relative"}),ty=Fe.div(({theme:e})=>({color:e.custom.colors.darkGray2,backgroundColor:e.custom.colors.white,padding:"12px 16px",...e.typography.body2,"p:first-of-type":{marginTop:0},"p:last-of-type":{marginBottom:0},"ol, ul":{paddingInlineStart:"16px",marginLeft:"6px","ol, ul":{marginLeft:0},li:{margin:"16px 0"}},a:{color:e.custom.colors.red,fontWeight:"normal"},borderRadius:"12px",[`.${bn.messageRowAssistant} &`]:{padding:"12px 16px 12px 0"},[`.${bn.messageRowUser} &`]:{borderRadius:"8px 0px 8px 8px",backgroundColor:e.custom.colors.lightGray1}})),YL=Fe.div({alignSelf:"flex-end",alignItems:"end",display:"flex",flexDirection:"column",gap:"12px"}),jL=Fe.button(({theme:e})=>({border:`1px solid ${e.custom.colors.lightGray2}`,backgroundColor:e.custom.colors.white,padding:"8px 16px",...e.typography.body3,cursor:"pointer",boxSizing:"border-box","&:hover":{color:e.custom.colors.white,backgroundColor:e.custom.colors.silverGrayDark,borderColor:"transparent"},borderRadius:"8px"})),VL=Fe(Ob)(({theme:e})=>({fill:e.custom.colors.red})),$L=Fe(v8)(({theme:e})=>({fill:e.custom.colors.red})),qL=Fe.div(({externalScroll:e,theme:t})=>({padding:"12px 0 16px",...e&&{position:"sticky",bottom:0,background:t.custom.colors.white},"button:focus-visible":{outlineOffset:"-1px",borderRadius:"7px"}})),GL=Fe(bi)(({theme:e})=>({color:e.custom.colors.silverGrayDark,marginTop:"16px",textAlign:"center"})),XL=({entryScreenTitle:e,entryScreenEnabled:t=!0,conversationStarters:r,initialMessages:i,askTimTitle:l,requestOpts:s,parseContent:c,srLoadingMessages:d,placeholder:p="",className:m,scrollElement:b,chatId:E,ref:S,...y})=>{var J,Te;const N=A.useRef(null),_=A.useRef(null),[L,v]=A.useState(t),H=A.useRef(null),[D,P]=A.useState(),I=A.useRef(null),{messages:M,input:j,handleInputChange:ie,handleSubmit:V,append:x,isLoading:Y,stop:K,error:W}=wL(s,{initialMessages:D,id:E});PL({scrollElement:b||_.current,contentElement:b?_.current:null,threshold:200}),A.useEffect(()=>{if(i){const O=Math.random().toString().slice(2);P(i.map((ue,Re)=>({...ue,id:`initial-${O}-${Re}`})))}},[i]),A.useEffect(()=>{var O,ue;L||(ue=(O=I.current)==null?void 0:O.querySelector("input"))==null||ue.focus()},[L]);const q=A.useMemo(()=>{const O=D==null?void 0:D.map(ue=>ue.id);return M.map(ue=>{if(ue.role==="assistant"&&!(O!=null&&O.includes(ue.id))){const Re=c?c(ue.content):ue.content;return{...ue,content:Re}}return ue})},[c,M,D]),ee=q.length===((D==null?void 0:D.length)||0),Q=!ee&&!W&&((J=q[q.length-1])==null?void 0:J.role)==="user",se=Y&&((Te=q[q.length-1])==null?void 0:Te.role)!=="user",re=()=>{const O=b||_.current;O==null||O.scrollBy({behavior:"instant",top:O==null?void 0:O.scrollHeight})},ge=q[q.length-1],C=!!b;return A.createElement(UL,{className:m,ref:N,key:E},L?A.createElement(Yk,{className:bn.entryScreenContainer,title:e,conversationStarters:r,onPromptSubmit:O=>{O.trim()!==""&&(v(!1),x({role:"user",content:O}))}}):A.createElement(HL,{className:bn.chatScreenContainer,"data-testid":"ai-chat-screen",externalScroll:C,ref:H},A.createElement(FL,{className:zl(m,bn.root),externalScroll:C,...y},A.createElement(gD,{askTimTitle:l,externalScroll:C,className:zl(m,bn.title)}),A.createElement(zL,{className:bn.messagesContainer,externalScroll:C,ref:_},q.map(O=>A.createElement(ey,{key:O.id,"data-chat-role":O.role,className:zl(bn.messageRow,{[bn.messageRowUser]:O.role==="user",[bn.messageRowAssistant]:O.role==="assistant"})},A.createElement(ty,{className:bn.message},A.createElement(m2,{as:O.role==="user"?"h5":"h6"},O.role==="user"?"You said: ":"Assistant said: "),A.createElement(tg,{skipHtml:!0},O.content)))),ee?A.createElement(YL,null,r==null?void 0:r.map(O=>A.createElement(jL,{className:bn.conversationStarter,key:O.content,onClick:()=>{re(),x({role:"user",content:O.content})}},O.content))):null,Q?A.createElement(ey,{className:zl(bn.messageRow,bn.messageRowAssistant),key:"loading"},A.createElement(ty,null,A.createElement(_8,null))):null,W?A.createElement(hD,{severity:"error",closable:!0},"An unexpected error has occurred."):null),A.createElement(qL,{externalScroll:C,className:bn.bottomSection},A.createElement("form",{onSubmit:O=>{O.preventDefault(),Y&&se?K():(re(),V(O))}},A.createElement(h2,{ref:I,fullWidth:!0,size:"chat",className:bn.input,placeholder:p,name:"message",sx:{flex:1},value:j,onChange:ie,inputProps:{"aria-label":"Ask a question"},endAdornment:Y?A.createElement(y0,{"aria-label":"Stop",onClick:K,disabled:!se},A.createElement($L,null)):A.createElement(y0,{"aria-label":"Send",type:"submit",onClick:O=>{if(j.trim()===""){O.preventDefault();return}re(),V(O)}},A.createElement(VL,null))})),A.createElement(GL,{variant:"body3"},"AI-generated content may be incorrect.")),A.createElement(Xk,{isLoading:Y,loadingMessages:d,message:(ge==null?void 0:ge.role)==="assistant"?ge==null?void 0:ge.content:""}))))},ny=e=>({minWidth:"auto",padding:0,height:{small:"32px",medium:"40px",large:"48px"}[e],width:{small:"32px",medium:"40px",large:"48px"}[e],"& svg, & .MuiSvgIcon-root":{width:"1em",height:"1em",fontSize:dt({small:20,medium:24,large:32}[e])}}),uo=Fe(A.forwardRef(function(t,r){return A.createElement(XE,{ref:r,type:"button",...t})}))(({size:e=m0.size,responsive:t,theme:r})=>[ny(e),t&&{[r.breakpoints.down("sm")]:ny($E[e])}]);uo.displayName="ActionButton";const QL=uo.withComponent(({Component:e,...t})=>A.createElement(QE,{Component:e,...t}));QL.displayName="ActionButtonLink";const KL=Fe.div``,WL=Fe.div(({theme:e})=>({display:"flex",height:300,padding:40,flexDirection:"column",justifyContent:"center",alignItems:"center",alignSelf:"stretch",borderRadius:8,border:`1px solid ${e.custom.colors.lightGray2}`,marginTop:"8px",cursor:"pointer",textAlign:"center"})),ZL=Fe.div({display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",marginTop:"24px"}),JL=Fe.div(({theme:e})=>({color:e.custom.colors.silverGrayDark,...e.typography.body2})),ry=A.forwardRef(({content:e,"aria-label":t},r)=>{const[i,l]=A.useState(0);A.useEffect(()=>l(0),[e]);const s=c=>{(c.key==="Enter"||c.key===" ")&&l(i===0?1:0)};return A.createElement(WL,{ref:r,onClick:()=>l(i===0?1:0),onKeyDown:s,tabIndex:0,"aria-label":t},A.createElement(bi,{variant:"h5"},i===0?`Q: ${e.question}`:`Answer: ${e.answer}`))});ry.displayName="Flashcard";const eI=({flashcards:e,wasKeyboardFocus:t})=>{const[r,i]=A.useState(0),l=A.useRef(null),s=A.useRef(null),c=A.useCallback(d=>{var p;e&&(!((p=l.current)!=null&&p.contains(document.activeElement))&&t||(d.key==="ArrowRight"?i(m=>(m+1)%e.length):d.key==="ArrowLeft"&&i(m=>(m-1+e.length)%e.length)))},[e,t]);return A.useEffect(()=>{var d;(d=s.current)==null||d.focus()},[r]),A.useEffect(()=>(window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)),[c]),e!=null&&e.length?A.createElement(KL,{ref:l},A.createElement(ry,{ref:s,content:e[r],"aria-label":`Flashcard ${r+1} of ${e.length}`}),A.createElement(ZL,null,A.createElement(uo,{onClick:()=>i(r-1),disabled:r===0,variant:"secondary",color:"secondary",size:"small","aria-label":"Previous card"},A.createElement(A8,{"aria-hidden":!0})),A.createElement(JL,null,r+1," / ",e.length),A.createElement(uo,{onClick:()=>i(r+1),disabled:r===e.length-1,variant:"secondary",color:"secondary",size:"small","aria-label":"Next card"},A.createElement(x8,{"aria-hidden":!0})))):null},tI=Fe.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px",color:e.custom.colors.white,position:"sticky",top:0,padding:"32px 0 16px 0",zIndex:2,backgroundColor:e.custom.colors.white,borderRadius:0})),nI=Fe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",color:e.custom.colors.darkGray2,img:{width:"24px",height:"24px"},svg:{fill:e.custom.colors.red,width:"24px",height:"24px",flexShrink:0},overflow:"hidden",p:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"}})),rI=Fe(uo)(({theme:e})=>({backgroundColor:e.custom.colors.lightGray2,"&&:hover":{backgroundColor:e.custom.colors.red,color:e.custom.colors.white},zIndex:3,flexShrink:0})),aI=Fe(G9)(({theme:e})=>({padding:"0 0 16px",backgroundColor:e.custom.colors.white,position:"sticky",top:"88px",zIndex:2,overflow:"visible"})),B0=Fe(fk)({padding:"0",height:"calc(100% - 138px)",position:"relative"}),iI=Fe(XL)(({hasTabs:e,theme:t})=>({".MitAiChat--entryScreenContainer":{padding:e?"114px 0 24px":"168px 32px 24px",[t.breakpoints.down("md")]:{padding:e?"114px 0 24px":"168px 16px 24px"}},".MitAiChat--chatScreenContainer":{padding:e?0:"0 32px",[t.breakpoints.down("md")]:{padding:e?0:"0 16px"}},".MitAiChat--messagesContainer":{paddingTop:e?"8px":"88px"}})),uI=Fe.div(({theme:e})=>({color:e.custom.colors.darkGray2,backgroundColor:e.custom.colors.white,padding:"12px 0 100px",...e.typography.body2,"p:first-of-type":{marginTop:0},"p:last-of-type":{marginBottom:0},"ol, ul":{paddingInlineStart:"32px",li:{margin:"16px 0"}},ul:{marginInlineStart:"-16px"},a:{color:e.custom.colors.red,fontWeight:"normal"}})),lI=e=>e,oI={credentials:"include"},sI=e=>{const[t,r]=A.useState(null),[i,l]=A.useState(!1);return A.useEffect(()=>{if(!e)return;(async()=>{l(!0);try{const d=await(await fetch(e)).json();if(!d.results)throw new Error("Unexpected response");const[p]=d.results;if(!p)throw new Error("No result found");r({summary:p.summary,flashcards:p.flashcards})}catch(c){console.error("Error fetching content",c)}finally{l(!1)}})()},[e]),{response:t,loading:i}},cI="What do you want to know about this video?",fI=[{content:"What are the most important concepts introduced in the video?"},{content:"What examples are used to illustrate concepts covered in the video?"},{content:"What are the key terms introduced in this video?"}],ay=({payload:e,transformBody:t,fetchOpts:r,scrollElement:i,entryScreenEnabled:l,entryScreenTitle:s,conversationStarters:c,hasTabs:d})=>e?A.createElement(iI,{chatId:e.chatId,conversationStarters:c,initialMessages:e.initialMessages,scrollElement:i,entryScreenEnabled:l,entryScreenTitle:s,requestOpts:{transformBody:p=>({...e.requestBody,...t==null?void 0:t(p)}),apiUrl:e.apiUrl,fetchOpts:{...oI,...r}},hasTabs:d}):null,dI=(e,t)=>[...e].sort(()=>.5-Math.random()).slice(0,t),hI=({messageOrigin:e,transformBody:t=lI,className:r,fetchOpts:i,target:l})=>{var ie,V,x,Y,K,W;const[s,c]=A.useState(!1),[d,p]=A.useState(null),[m,b]=A.useState("chat"),{response:E}=sI((ie=d==null?void 0:d.summary)==null?void 0:ie.apiUrl),[S,y]=A.useState(!1),N=A.useRef(!1),_=()=>{N.current=!0},L=()=>{N.current||y(!0),N.current=!1},[v,H]=A.useState(null),D=q=>{q&&H(q)};A.useEffect(()=>{const q=ee=>{ee.origin===e&&ee.data.type==="smoot-design::tutor-drawer-open"&&ee.data.payload.target===l&&(c(!0),p(ee.data.payload))};return window.addEventListener("message",q),()=>{window.removeEventListener("message",q)}},[e,l]),A.useEffect(()=>{var q;(q=v==null?void 0:v.scrollTo)==null||q.call(v,{top:m==="chat"?v.scrollHeight:0})},[m,v]);const P=A.useMemo(()=>{var q;return d?d.chat.conversationStarters||((q=E==null?void 0:E.flashcards)!=null&&q.length&&E.flashcards.length>=3?dI(E.flashcards,3).map(ee=>({content:ee.question})):fI):[]},[d,E]);if(!d)return A.createElement("div",{"data-testid":"remote-tutor-drawer-waiting"});const{blockType:I,chat:M}=d,j=I==="video";return A.createElement(WN,{"data-testid":"remote-tutor-drawer",className:r,PaperProps:{ref:D,sx:{width:"900px",maxWidth:"100%",boxSizing:"border-box",padding:{xs:"0 16px",md:"0 32px"}}},anchor:"right",open:s,onClose:()=>c(!1)},A.createElement(tI,null,A.createElement(nI,null,d.title?A.createElement(Ud,null):null,A.createElement(bi,{variant:"body1",component:"h2"},(V=d.title)!=null&&V.includes("AskTIM")?A.createElement(A.Fragment,null,"Ask",A.createElement("strong",null,"TIM"),d.title.replace("AskTIM","")):d.title)),A.createElement(rI,{variant:"text",size:"medium",onClick:()=>c(!1),"aria-label":"Close"},A.createElement(Rb,null))),I==="problem"?A.createElement(ay,{payload:M,transformBody:t,fetchOpts:i,scrollElement:v,entryScreenEnabled:((x=d.chat)==null?void 0:x.entryScreenEnabled)??!1,entryScreenTitle:d.chat.entryScreenTitle,hasTabs:j}):null,I==="video"?A.createElement(B9,{value:m},A.createElement(aI,{styleVariant:"chat",onChange:(q,ee)=>b(ee)},A.createElement(g0,{value:"chat",label:"Chat"}),(Y=E==null?void 0:E.flashcards)!=null&&Y.length?A.createElement(g0,{value:"flashcards",label:"Flashcards",onMouseDown:_,onFocus:L}):null,A.createElement(g0,{value:"summary",label:"Summary"})),A.createElement(B0,{value:"chat",keepMounted:!0},A.createElement(ay,{payload:{...M},transformBody:t,fetchOpts:i,scrollElement:v,entryScreenEnabled:((K=d.chat)==null?void 0:K.entryScreenEnabled)??!0,entryScreenTitle:d.chat.entryScreenTitle??cI,conversationStarters:P,hasTabs:j})),(W=E==null?void 0:E.flashcards)!=null&&W.length?A.createElement(B0,{value:"flashcards"},A.createElement(eI,{flashcards:E==null?void 0:E.flashcards,wasKeyboardFocus:S})):null,A.createElement(B0,{value:"summary"},A.createElement(bi,{variant:"h4",component:"h4"}),A.createElement(uI,null,A.createElement(tg,{rehypePlugins:[C8]},(E==null?void 0:E.summary)??"")))):null)},pI={defaultProps:{disableRipple:!0},styleOverrides:{root:{":focus-visible":{outline:"revert"}}}},ot={mitRed:"#750014",brightRed:"#FF1423",black:"#000000",white:"#FFFFFF",darkGray2:"#212326",darkGray1:"#40464C",silverGrayDark:"#626A73",silverGray:"#8B959E",silverGrayLight:"#B8C2CC",lightGray2:"#DDE1E6",lightGray1:"#F3F4F8",navGray:"#303337",darkPink:"#750062",pink:"#FF14F0",lightPink:"#FFB3FF",darkPurple:"#3E006B",purple:"#93F",lightPurple:"#BFB3FF",darkBlue:"#002896",blue:"#1966FF",lightBlue:"#99EBFF",darkGreen:"#004D1A",green:"#00AD00",lightGreen:"#AF3",darkRed:"#83192A",red:"#A31F34",lightRed:"#D02E44",orange:"#FAB005",yellow:"#FFEB00"},mI={defaultProps:{size:"medium",color:"default",variant:"outlined",deleteIcon:A.createElement(Rb,{"aria-hidden":"true"})},styleOverrides:{root:{borderRadius:"100vh",borderWidth:"1px"},deleteIcon:{"&:hover":{color:"inherit"},"&.MuiChip-deleteIconLarge":{width:"16px",height:"16px"},"&.MuiChip-deleteIconMedium":{width:"14px",height:"14px"},margin:"0 -2px 0 8px",color:"inherit"},icon:{margin:"0 8px 0 -2px",color:"inherit","&.MuiChip-iconLarge":{width:"16px",height:"16px"},"&.MuiChip-iconMedium":{width:"14px",height:"14px"}}},variants:[{props:{size:"medium"},style:({theme:e})=>({...e.typography.body3,boxSizing:"border-box",height:"24px",paddingRight:"12px",paddingLeft:"12px",".MuiChip-label":{paddingLeft:"0px",paddingRight:"0px"}})},{props:{size:"large"},style:({theme:e})=>({...e.typography.body2,height:"32px",paddingLeft:"16px",paddingRight:"16px",".MuiChip-label":{paddingLeft:"0px",paddingRight:"0px"}})},{props:{variant:"outlined"},style:{borderColor:ot.silverGrayLight,color:ot.darkGray1,"&.Mui-focusVisible":{backgroundColor:"transparent"},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,borderColor:ot.silverGrayDark,backgroundColor:"transparent"}}},{props:{variant:"outlinedWhite"},style:{backgroundColor:"white",border:"1px solid",borderColor:ot.silverGrayLight,color:ot.darkGray1,"&.Mui-focusVisible":{backgroundColor:"white"},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,borderColor:ot.silverGrayDark,backgroundColor:"white"}}},{props:{variant:"gray"},style:{backgroundColor:ot.lightGray2,border:"none",color:ot.darkGray2,"&.Mui-focusVisible":{backgroundColor:ot.lightGray2},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,backgroundColor:ot.silverGrayLight}}},{props:{variant:"dark"},style:{backgroundColor:ot.silverGrayDark,border:"none",color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.silverGrayDark},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.darkGray1}}},{props:{variant:"darker"},style:{backgroundColor:ot.darkGray2,border:`1px solid ${ot.darkGray1}`,color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.darkGray2},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.black,border:`1px solid ${ot.silverGray}`}}},{props:{variant:"filled"},style:{backgroundColor:ot.mitRed,border:"none",color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.mitRed},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.red}}}]},gI={colors:ot,dimensions:{headerHeight:"72px",headerHeightSm:"60px"}},bI={values:{xs:0,sm:600,md:900,lg:1320,xl:1536}},EI={custom:gI,palette:{primary:{main:ot.mitRed,light:ot.lightRed,active:ot.red,contrastText:ot.white},secondary:{light:ot.darkGray2,active:ot.silverGrayDark,main:ot.black,contrastText:ot.white}},shape:{borderRadius:8},spacing:8,typography:YE,breakpoints:bI,components:{MuiButtonBase:pI,MuiTypography:Y9,MuiMenu:{styleOverrides:{paper:{borderRadius:"4px"}}},MuiAutocomplete:{styleOverrides:{paper:{borderRadius:"4px"},popupIndicator:{paddingRight:0,marginRight:0}}},MuiChip:mI}},iy=e=>Zs(Pn(EI,e)),yI=iy(),TI=({children:e,theme:t=yI})=>A.createElement(z9,{theme:t},e);var SI=function(t,r,i){for(var l=0,s=0;l=s,s=Gn(),l===38&&s===12&&(r[i]=1),!ai(s);)Nn();return Yi(t,Cn)},CI=function(t,r){var i=-1,l=44;do switch(ai(l)){case 0:l===38&&Gn()===12&&(r[i]=1),t[i]+=SI(Cn-1,r,i);break;case 2:t[i]+=tl(l);break;case 4:if(l===44){t[++i]=Gn()===58?"&\f":"",r[i]=t[i].length;break}default:t[i]+=Zu(l)}while(l=Nn());return t},AI=function(t,r){return Nf(CI(Of(t),r))},uy=new WeakMap,xI=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var r=t.value,i=t.parent,l=t.column===i.column&&t.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(t.props.length===1&&r.charCodeAt(0)!==58&&!uy.get(i))&&!l){uy.set(t,!0);for(var s=[],c=AI(r,s),d=i.props,p=0,m=0;p<c.length;p++)for(var b=0;b<d.length;b++,m++)t.props[m]=s[p]?c[p].replace(/&\f/g,d[b]):d[b]+" "+c[p]}}},_I=function(t){if(t.type==="decl"){var r=t.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(t.return="",t.value="")}};function ly(e,t){switch(nm(e,t)){case 5103:return De+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return De+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return De+e+xa+e+pt+e+e;case 6828:case 4268:return De+e+pt+e+e;case 6165:return De+e+pt+"flex-"+e+e;case 5187:return De+e+Ie(e,/(\w+).+(:[^]+)/,De+"box-$1$2"+pt+"flex-$1$2")+e;case 5443:return De+e+pt+"flex-item-"+Ie(e,/flex-|-self/,"")+e;case 4675:return De+e+pt+"flex-line-pack"+Ie(e,/align-content|flex-|-self/,"")+e;case 5548:return De+e+pt+Ie(e,"shrink","negative")+e;case 5292:return De+e+pt+Ie(e,"basis","preferred-size")+e;case 6060:return De+"box-"+Ie(e,"-grow","")+De+e+pt+Ie(e,"grow","positive")+e;case 4554:return De+Ie(e,/([^-])(transform)/g,"$1"+De+"$2")+e;case 6187:return Ie(Ie(Ie(e,/(zoom-|grab)/,De+"$1"),/(image-set)/,De+"$1"),e,"")+e;case 5495:case 3959:return Ie(e,/(image-set\([^]*)/,De+"$1$`$1");case 4968:return Ie(Ie(e,/(.+:)(flex-)?(.*)/,De+"box-pack:$3"+pt+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+De+e+e;case 4095:case 3583:case 4068:case 2532:return Ie(e,/(.+)-inline(.+)/,De+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(lr(e)-1-t>6)switch(Bt(e,t+1)){case 109:if(Bt(e,t+4)!==45)break;case 102:return Ie(e,/(.+:)(.+)-([^]+)/,"$1"+De+"$2-$3$1"+xa+(Bt(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~Ju(e,"stretch")?ly(Ie(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(Bt(e,t+1)!==115)break;case 6444:switch(Bt(e,lr(e)-3-(~Ju(e,"!important")&&10))){case 107:return Ie(e,":",":"+De)+e;case 101:return Ie(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+De+(Bt(e,14)===45?"inline-":"")+"box$3$1"+De+"$2$3$1"+pt+"$2box$3")+e}break;case 5936:switch(Bt(e,t+11)){case 114:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return De+e+pt+e+e}return e}var vI=function(t,r,i,l){if(t.length>-1&&!t.return)switch(t.type){case ls:t.return=ly(t.value,t.length);break;case vf:return Br([Mr(t,{value:Ie(t.value,"@","@"+De)})],l);case us:if(t.length)return im(t.props,function(s){switch(am(s,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Br([Mr(t,{props:[Ie(s,/:(read-\w+)/,":"+xa+"$1")]})],l);case"::placeholder":return Br([Mr(t,{props:[Ie(s,/:(plac\w+)/,":"+De+"input-$1")]}),Mr(t,{props:[Ie(s,/:(plac\w+)/,":"+xa+"$1")]}),Mr(t,{props:[Ie(s,/:(plac\w+)/,pt+"input-$1")]})],l)}return""})}},RI=[vI],OI=function(t){var r=t.key;if(r==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(_){var L=_.getAttribute("data-emotion");L.indexOf(" ")!==-1&&(document.head.appendChild(_),_.setAttribute("data-s",""))})}var l=t.stylisPlugins||RI,s={},c,d=[];c=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(_){for(var L=_.getAttribute("data-emotion").split(" "),v=1;v<L.length;v++)s[L[v]]=!0;d.push(_)});var p,m=[xI,_I];{var b,E=[cm,dm(function(_){b.insert(_)})],S=fm(m.concat(l,E)),y=function(L){return Br(lm(L),S)};p=function(L,v,H,D){b=H,y(L?L+"{"+v.styles+"}":v.styles),D&&(N.inserted[v.name]=!0)}}var N={key:r,sheet:new em({key:r,container:c,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:s,registered:{},insert:p};return N.sheet.hydrate(d),N};const NI=e=>{const t=document.createElement("div");document.body.appendChild(t);const r=t.attachShadow({mode:"open"}),i=document.createElement("div");i.id="smoot-chat-drawer-root",r.append(i);const l=OI({key:"css",prepend:!0,container:r}),s=iy({components:{MuiPopover:{defaultProps:{container:i}},MuiPopper:{defaultProps:{container:i}},MuiModal:{defaultProps:{container:i}}}});X3.createRoot(i).render(A.createElement(kC,{value:l},A.createElement(TI,{theme:s},A.createElement(hI,{...e}))))};ir.init=NI,Object.defineProperty(ir,Symbol.toStringTag,{value:"Module"})});
207
+ */var U2;function QD(){if(U2)return C0;U2=1;var e=as();function t(E,S){return E===S&&(E!==0||1/E===1/S)||E!==E&&S!==S}var r=typeof Object.is=="function"?Object.is:t,i=e.useState,l=e.useEffect,s=e.useLayoutEffect,c=e.useDebugValue;function d(E,S){var y=S(),N=i({inst:{value:y,getSnapshot:S}}),_=N[0].inst,L=N[1];return s(function(){_.value=y,_.getSnapshot=S,p(_)&&L({inst:_})},[E,y,S]),l(function(){return p(_)&&L({inst:_}),E(function(){p(_)&&L({inst:_})})},[E]),c(y),y}function p(E){var S=E.getSnapshot;E=E.value;try{var y=S();return!r(E,y)}catch{return!0}}function m(E,S){return S()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:d;return C0.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b,C0}var H2;function KD(){return H2||(H2=1,S0.exports=QD()),S0.exports}var WD=KD();const Ia=()=>{},Yn=Ia(),A0=Object,mt=e=>e===Yn,Gr=e=>typeof e=="function",wa=(e,t)=>({...e,...t}),ZD=e=>Gr(e.then),sc=new WeakMap;let JD=0;const ro=e=>{const t=typeof e,r=e&&e.constructor,i=r==Date;let l,s;if(A0(e)===e&&!i&&r!=RegExp){if(l=sc.get(e),l)return l;if(l=++JD+"~",sc.set(e,l),r==Array){for(l="@",s=0;s<e.length;s++)l+=ro(e[s])+",";sc.set(e,l)}if(r==A0){l="#";const c=A0.keys(e).sort();for(;!mt(s=c.pop());)mt(e[s])||(l+=s+":"+ro(e[s])+",");sc.set(e,l)}}else l=i?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return l},ua=new WeakMap,x0={},cc={},_0="undefined",fc=typeof window!=_0,v0=typeof document!=_0,eL=()=>fc&&typeof window.requestAnimationFrame!=_0,F2=(e,t)=>{const r=ua.get(e);return[()=>!mt(t)&&e.get(t)||x0,i=>{if(!mt(t)){const l=e.get(t);t in cc||(cc[t]=l),r[5](t,wa(l,i),l||x0)}},r[6],()=>!mt(t)&&t in cc?cc[t]:!mt(t)&&e.get(t)||x0]};let R0=!0;const tL=()=>R0,[O0,N0]=fc&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ia,Ia],nL=()=>{const e=v0&&document.visibilityState;return mt(e)||e!=="hidden"},rL=e=>(v0&&document.addEventListener("visibilitychange",e),O0("focus",e),()=>{v0&&document.removeEventListener("visibilitychange",e),N0("focus",e)}),aL=e=>{const t=()=>{R0=!0,e()},r=()=>{R0=!1};return O0("online",t),O0("offline",r),()=>{N0("online",t),N0("offline",r)}},iL={isOnline:tL,isVisible:nL},uL={initFocus:rL,initReconnect:aL},z2=!xt.useId,ao=!fc||"Deno"in window,lL=e=>eL()?window.requestAnimationFrame(e):setTimeout(e,1),k0=ao?A.useEffect:A.useLayoutEffect,D0=typeof navigator<"u"&&navigator.connection,Y2=!ao&&D0&&(["slow-2g","2g"].includes(D0.effectiveType)||D0.saveData),L0=e=>{if(Gr(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?ro(e):"",[e,t]};let oL=0;const I0=()=>++oL,j2=0,V2=1,$2=2;var io={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:j2,MUTATE_EVENT:$2,RECONNECT_EVENT:V2};async function q2(...e){const[t,r,i,l]=e,s=wa({populateCache:!0,throwOnError:!0},typeof l=="boolean"?{revalidate:l}:l||{});let c=s.populateCache;const d=s.rollbackOnError;let p=s.optimisticData;const m=S=>typeof d=="function"?d(S):d!==!1,b=s.throwOnError;if(Gr(r)){const S=r,y=[],N=t.keys();for(const _ of N)!/^\$(inf|sub)\$/.test(_)&&S(t.get(_)._k)&&y.push(_);return Promise.all(y.map(E))}return E(r);async function E(S){const[y]=L0(S);if(!y)return;const[N,_]=F2(t,y),[L,v,H,D]=ua.get(t),P=()=>{const W=L[y];return(Gr(s.revalidate)?s.revalidate(N().data,S):s.revalidate!==!1)&&(delete H[y],delete D[y],W&&W[0])?W[0]($2).then(()=>N().data):N().data};if(e.length<3)return P();let I=i,M;const j=I0();v[y]=[j,0];const ie=!mt(p),V=N(),x=V.data,Y=V._c,K=mt(Y)?x:Y;if(ie&&(p=Gr(p)?p(K,x):p,_({data:p,_c:K})),Gr(I))try{I=I(K)}catch(W){M=W}if(I&&ZD(I))if(I=await I.catch(W=>{M=W}),j!==v[y][0]){if(M)throw M;return I}else M&&ie&&m(M)&&(c=!0,_({data:K,_c:Yn}));if(c&&!M)if(Gr(c)){const W=c(I,K);_({data:W,error:Yn,_c:Yn})}else _({data:I,error:Yn,_c:Yn});if(v[y][1]=I0(),Promise.resolve(P()).then(()=>{_({_c:Yn})}),M){if(b)throw M;return}return I}}const G2=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},sL=(e,t)=>{if(!ua.has(e)){const r=wa(uL,t),i={},l=q2.bind(Yn,e);let s=Ia;const c={},d=(b,E)=>{const S=c[b]||[];return c[b]=S,S.push(E),()=>S.splice(S.indexOf(E),1)},p=(b,E,S)=>{e.set(b,E);const y=c[b];if(y)for(const N of y)N(E,S)},m=()=>{if(!ua.has(e)&&(ua.set(e,[i,{},{},{},l,p,d]),!ao)){const b=r.initFocus(setTimeout.bind(Yn,G2.bind(Yn,i,j2))),E=r.initReconnect(setTimeout.bind(Yn,G2.bind(Yn,i,V2)));s=()=>{b&&b(),E&&E(),ua.delete(e)}}};return m(),[e,l,m,s]}return[e,ua.get(e)[4]]},cL=(e,t,r,i,l)=>{const s=r.errorRetryCount,c=l.retryCount,d=~~((Math.random()+.5)*(1<<(c<8?c:8)))*r.errorRetryInterval;!mt(s)&&c>s||setTimeout(i,d,l)},fL=(e,t)=>ro(e)==ro(t),[X2,dL]=sL(new Map),hL=wa({onLoadingSlow:Ia,onSuccess:Ia,onError:Ia,onErrorRetry:cL,onDiscarded:Ia,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Y2?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Y2?5e3:3e3,compare:fL,isPaused:()=>!1,cache:X2,mutate:dL,fallback:{}},iL),pL=(e,t)=>{const r=wa(e,t);if(t){const{use:i,fallback:l}=e,{use:s,fallback:c}=t;i&&s&&(r.use=i.concat(s)),l&&c&&(r.fallback=wa(l,c))}return r},mL=A.createContext({}),gL="$inf$",Q2=fc&&window.__SWR_DEVTOOLS_USE__,bL=Q2?window.__SWR_DEVTOOLS_USE__:[],EL=()=>{Q2&&(window.__SWR_DEVTOOLS_REACT__=xt)},yL=e=>Gr(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],TL=()=>wa(hL,A.useContext(mL)),SL=e=>(t,r,i)=>e(t,r&&((...s)=>{const[c]=L0(t),[,,,d]=ua.get(X2);if(c.startsWith(gL))return r(...s);const p=d[c];return mt(p)?r(...s):(delete d[c],p)}),i),CL=bL.concat(SL),AL=e=>function(...r){const i=TL(),[l,s,c]=yL(r),d=pL(i,c);let p=e;const{use:m}=d,b=(m||[]).concat(CL);for(let E=b.length;E--;)p=b[E](p);return p(l,s||d.fetcher||null,d)},xL=(e,t,r)=>{const i=t[e]||(t[e]=[]);return i.push(r),()=>{const l=i.indexOf(r);l>=0&&(i[l]=i[i.length-1],i.pop())}};EL();const K2=xt.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),w0={dedupe:!0},dc=AL((e,t,r)=>{const{cache:i,compare:l,suspense:s,fallbackData:c,revalidateOnMount:d,revalidateIfStale:p,refreshInterval:m,refreshWhenHidden:b,refreshWhenOffline:E,keepPreviousData:S}=r,[y,N,_,L]=ua.get(i),[v,H]=L0(e),D=A.useRef(!1),P=A.useRef(!1),I=A.useRef(v),M=A.useRef(t),j=A.useRef(r),ie=()=>j.current,V=()=>ie().isVisible()&&ie().isOnline(),[x,Y,K,W]=F2(i,v),q=A.useRef({}).current,ee=mt(c)?r.fallback[v]:c,Q=(ve,Oe)=>{for(const Ce in q){const Be=Ce;if(Be==="data"){if(!l(ve[Be],Oe[Be])&&(!mt(ve[Be])||!l(Re,Oe[Be])))return!1}else if(Oe[Be]!==ve[Be])return!1}return!0},se=A.useMemo(()=>{const ve=!v||!t?!1:mt(d)?ie().isPaused()||s?!1:mt(p)?!0:p:d,Oe=ct=>{const St=wa(ct);return delete St._k,ve?{isValidating:!0,isLoading:!0,...St}:St},Ce=x(),Be=W(),it=Oe(Ce),je=Ce===Be?it:Oe(Be);let Ue=it;return[()=>{const ct=Oe(x());return Q(ct,Ue)?(Ue.data=ct.data,Ue.isLoading=ct.isLoading,Ue.isValidating=ct.isValidating,Ue.error=ct.error,Ue):(Ue=ct,ct)},()=>je]},[i,v]),re=WD.useSyncExternalStore(A.useCallback(ve=>K(v,(Oe,Ce)=>{Q(Ce,Oe)||ve()}),[i,v]),se[0],se[1]),ge=!D.current,C=y[v]&&y[v].length>0,J=re.data,Te=mt(J)?ee:J,O=re.error,ue=A.useRef(Te),Re=S?mt(J)?ue.current:J:Te,Se=C&&!mt(O)?!1:ge&&!mt(d)?d:ie().isPaused()?!1:s?mt(Te)?!1:p:mt(Te)||p,tt=!!(v&&t&&ge&&Se),Me=mt(re.isValidating)?tt:re.isValidating,$e=mt(re.isLoading)?tt:re.isLoading,xe=A.useCallback(async ve=>{const Oe=M.current;if(!v||!Oe||P.current||ie().isPaused())return!1;let Ce,Be,it=!0;const je=ve||{},Ue=!_[v]||!je.dedupe,ct=()=>z2?!P.current&&v===I.current&&D.current:v===I.current,St={isValidating:!1,isLoading:!1},rn=()=>{Y(St)},_n=()=>{const Xe=_[v];Xe&&Xe[1]===Be&&delete _[v]},we={isValidating:!0};mt(x().data)&&(we.isLoading=!0);try{if(Ue&&(Y(we),r.loadingTimeout&&mt(x().data)&&setTimeout(()=>{it&&ct()&&ie().onLoadingSlow(v,r)},r.loadingTimeout),_[v]=[Oe(H),I0()]),[Ce,Be]=_[v],Ce=await Ce,Ue&&setTimeout(_n,r.dedupingInterval),!_[v]||_[v][1]!==Be)return Ue&&ct()&&ie().onDiscarded(v),!1;St.error=Yn;const Xe=N[v];if(!mt(Xe)&&(Be<=Xe[0]||Be<=Xe[1]||Xe[1]===0))return rn(),Ue&&ct()&&ie().onDiscarded(v),!1;const $t=x().data;St.data=l($t,Ce)?$t:Ce,Ue&&ct()&&ie().onSuccess(Ce,v,r)}catch(Xe){_n();const $t=ie(),{shouldRetryOnError:te}=$t;$t.isPaused()||(St.error=Xe,Ue&&ct()&&($t.onError(Xe,v,$t),(te===!0||Gr(te)&&te(Xe))&&(!ie().revalidateOnFocus||!ie().revalidateOnReconnect||V())&&$t.onErrorRetry(Xe,v,$t,fe=>{const Ae=y[v];Ae&&Ae[0]&&Ae[0](io.ERROR_REVALIDATE_EVENT,fe)},{retryCount:(je.retryCount||0)+1,dedupe:!0})))}return it=!1,rn(),!0},[v,i]),Ge=A.useCallback((...ve)=>q2(i,I.current,...ve),[]);if(k0(()=>{M.current=t,j.current=r,mt(J)||(ue.current=J)}),k0(()=>{if(!v)return;const ve=xe.bind(Yn,w0);let Oe=0;const Be=xL(v,y,(it,je={})=>{if(it==io.FOCUS_EVENT){const Ue=Date.now();ie().revalidateOnFocus&&Ue>Oe&&V()&&(Oe=Ue+ie().focusThrottleInterval,ve())}else if(it==io.RECONNECT_EVENT)ie().revalidateOnReconnect&&V()&&ve();else{if(it==io.MUTATE_EVENT)return xe();if(it==io.ERROR_REVALIDATE_EVENT)return xe(je)}});return P.current=!1,I.current=v,D.current=!0,Y({_k:H}),Se&&(mt(Te)||ao?ve():lL(ve)),()=>{P.current=!0,Be()}},[v]),k0(()=>{let ve;function Oe(){const Be=Gr(m)?m(x().data):m;Be&&ve!==-1&&(ve=setTimeout(Ce,Be))}function Ce(){!x().error&&(b||ie().isVisible())&&(E||ie().isOnline())?xe(w0).then(Oe):Oe()}return Oe(),()=>{ve&&(clearTimeout(ve),ve=-1)}},[m,b,E,v]),A.useDebugValue(Re),s&&mt(Te)&&v){if(!z2&&ao)throw new Error("Fallback data is required when using suspense in SSR.");M.current=t,j.current=r,P.current=!1;const ve=L[v];if(!mt(ve)){const Oe=Ge(ve);K2(Oe)}if(mt(O)){const Oe=xe(w0);mt(Re)||(Oe.status="fulfilled",Oe.value=!0),K2(Oe)}else throw O}return{mutate:Ge,get data(){return q.data=!0,Re},get error(){return q.error=!0,O},get isValidating(){return q.isValidating=!0,Me},get isLoading(){return q.isLoading=!0,$e}}});var M0,W2;function _L(){if(W2)return M0;W2=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let i,l=0;return function(...c){clearTimeout(i);const d=Date.now(),p=d-l,m=r-p;m<=0?(l=d,t.apply(this,c)):i=setTimeout(()=>{l=Date.now(),t.apply(this,c)},m)}}return M0=e,M0}var vL=_L();const RL=ur(vL);function Z2(e,t){return t!=null?RL(e,t):e}var OL=async(e,t,r,i,l,s,c,d,p,m,b,E,S,y,N,_,L)=>{var v;const H=c.current;r(t.messages,!1);const D=y?t.messages:t.messages.map(({role:I,content:M,experimental_attachments:j,data:ie,annotations:V,toolInvocations:x})=>({role:I,content:M,...j!==void 0&&{experimental_attachments:j},...ie!==void 0&&{data:ie},...V!==void 0&&{annotations:V},...x!==void 0&&{toolInvocations:x}})),P=l.current;return await XD({api:e,body:(v=N==null?void 0:N({messages:t.messages,requestData:t.data,requestBody:t.body}))!=null?v:{messages:D,data:t.data,...s.current.body,...t.body},streamProtocol:m,credentials:s.current.credentials,headers:{...s.current.headers,...t.headers},abortController:()=>d.current,restoreMessagesOnFailure(){L||r(H,!1)},onResponse:E,onUpdate(I,M){r([...t.messages,...I],!1),M!=null&&M.length&&i([...P??[],...M],!1)},onToolCall:S,onFinish:b,generateId:p,fetch:_})};function NL({api:e="/api/chat",id:t,initialMessages:r,initialInput:i="",sendExtraMessageFields:l,onToolCall:s,experimental_prepareRequestBody:c,maxSteps:d=1,streamProtocol:p="data",onResponse:m,onFinish:b,onError:E,credentials:S,headers:y,body:N,generateId:_=M2,fetch:L,keepLastMessageOnError:v=!0,experimental_throttle:H}={}){const D=A.useId(),P=t??D,I=typeof e=="string"?[e,P]:P,[M]=A.useState([]),{data:j,mutate:ie}=dc([I,"messages"],null,{fallbackData:r??M}),V=A.useRef(j||[]);A.useEffect(()=>{V.current=j||[]},[j]);const{data:x,mutate:Y}=dc([I,"streamData"],null),K=A.useRef(x);A.useEffect(()=>{K.current=x},[x]);const{data:W=!1,mutate:q}=dc([I,"loading"],null),{data:ee=void 0,mutate:Q}=dc([I,"error"],null),se=A.useRef(null),re=A.useRef({credentials:S,headers:y,body:N});A.useEffect(()=>{re.current={credentials:S,headers:y,body:N}},[S,y,N]);const ge=A.useCallback(async xe=>{const Ge=V.current.length;try{q(!0),Q(void 0);const Ce=new AbortController;se.current=Ce,await OL(e,xe,Z2(ie,H),Z2(Y,H),K,re,V,se,_,p,b,m,s,l,c,L,v),se.current=null}catch(Ce){if(Ce.name==="AbortError")return se.current=null,null;E&&Ce instanceof Error&&E(Ce),Q(Ce)}finally{q(!1)}const ve=V.current,Oe=ve[ve.length-1];ve.length>Ge&&Oe!=null&&d>1&&J2(Oe)&&kL(ve)<d&&await ge({messages:ve})},[ie,q,e,re,m,b,E,Q,Y,K,p,l,c,s,d,V,se,_,L,v,H]),C=A.useCallback(async(xe,{data:Ge,headers:ve,body:Oe,experimental_attachments:Ce}={})=>{var Be,it;const je=await P2(Ce),Ue=V.current.concat({...xe,id:(Be=xe.id)!=null?Be:_(),createdAt:(it=xe.createdAt)!=null?it:new Date,experimental_attachments:je.length>0?je:void 0});return ge({messages:Ue,headers:ve,body:Oe,data:Ge})},[ge,_]),J=A.useCallback(async({data:xe,headers:Ge,body:ve}={})=>{const Oe=V.current;if(Oe.length===0)return null;const Ce=Oe[Oe.length-1];return ge({messages:Ce.role==="assistant"?Oe.slice(0,-1):Oe,headers:Ge,body:ve,data:xe})},[ge]),Te=A.useCallback(()=>{se.current&&(se.current.abort(),se.current=null)},[]),O=A.useCallback(xe=>{typeof xe=="function"&&(xe=xe(V.current)),ie(xe,!1),V.current=xe},[ie]),ue=A.useCallback(xe=>{typeof xe=="function"&&(xe=xe(K.current)),Y(xe,!1),K.current=xe},[Y]),[Re,Se]=A.useState(i),tt=A.useCallback(async(xe,Ge={},ve)=>{var Oe;if((Oe=xe==null?void 0:xe.preventDefault)==null||Oe.call(xe),!Re&&!Ge.allowEmptySubmit)return;ve&&(re.current={...re.current,...ve});const Ce=await P2(Ge.experimental_attachments),it={messages:!Re&&!Ce.length&&Ge.allowEmptySubmit?V.current:V.current.concat({id:_(),createdAt:new Date,role:"user",content:Re,experimental_attachments:Ce.length>0?Ce:void 0}),headers:Ge.headers,body:Ge.body,data:Ge.data};ge(it),Se("")},[Re,_,ge]);return{messages:j||[],setMessages:O,data:x,setData:ue,error:ee,append:C,reload:J,stop:Te,input:Re,setInput:Se,handleInputChange:xe=>{Se(xe.target.value)},handleSubmit:tt,isLoading:W,addToolResult:({toolCallId:xe,result:Ge})=>{const ve=V.current.map((Ce,Be,it)=>Be===it.length-1&&Ce.role==="assistant"&&Ce.toolInvocations?{...Ce,toolInvocations:Ce.toolInvocations.map(je=>je.toolCallId===xe?{...je,result:Ge,state:"result"}:je)}:Ce);ie(ve,!1);const Oe=ve[ve.length-1];J2(Oe)&&ge({messages:ve})}}}function J2(e){return e.role==="assistant"&&e.toolInvocations&&e.toolInvocations.length>0&&e.toolInvocations.every(t=>"result"in t)}function kL(e){let t=0;for(let r=e.length-1;r>=0&&e[r].role==="assistant";r--)t++;return t}var DL=NL;const LL=e=>e,IL=e=>async(t,r)=>{var c;if(typeof(r==null?void 0:r.body)!="string")return console.error("Unexpected body type."),window.fetch(t,r);const i=JSON.parse(r==null?void 0:r.body).messages,l=e.transformBody??LL,s={...r,body:JSON.stringify(l(i)),...e.fetchOpts,headers:{...r==null?void 0:r.headers,"Content-Type":"application/json",...(c=e.fetchOpts)==null?void 0:c.headers}};return fetch(t,s)},wL=(e,t)=>{const r=A.useMemo(()=>IL(e),[e]);return DL({api:e.apiUrl,streamProtocol:"text",fetch:r,onFinish:i=>{var l;e.onFinish&&(i.role==="assistant"||i.role==="user"?(l=e.onFinish)==null||l.call(e,i):console.info("Unexpected message role.",i))},...t})},ML=e=>e.scrollHeight-e.clientHeight-e.scrollTop,BL=e=>{e.scrollTop=e.scrollHeight},PL=({scrollElement:e,contentElement:t,threshold:r=2})=>{A.useEffect(()=>{const i=()=>{e&&ML(e)<r&&BL(e)};i();const l=new ResizeObserver(i);return t&&l.observe(t),()=>{l.disconnect()}},[e,t,r])},bn={root:"MitAiChat--root",title:"MitAiChat--title",entryScreenContainer:"MitAiChat--entryScreenContainer",conversationStarter:"MitAiChat--conversationStarter",chatScreenContainer:"MitAiChat--chatScreenContainer",messagesContainer:"MitAiChat--messagesContainer",messageRow:"MitAiChat--messageRow",messageRowUser:"MitAiChat--messageRowUser",messageRowAssistant:"MitAiChat--messageRowAssistant",message:"MitAiChat--message",input:"MitAiChat--input",bottomSection:"MitAiChat--bottomSection"},UL=Fe.div(),HL=Fe.div(({externalScroll:e,theme:t})=>({padding:"16px 32px 0",[t.breakpoints.down("md")]:{padding:"16px 16px 0"},boxSizing:"border-box",background:"white",position:"absolute",bottom:0,top:0,left:0,right:0,zIndex:1,...e&&{padding:"0 32px",[t.breakpoints.down("md")]:{padding:"0 16px"}}})),FL=Fe.div(({externalScroll:e})=>({width:"100%",height:e?"auto":"100%",minHeight:e?"100%":"auto",display:"flex",flexDirection:"column"})),zL=Fe(qk)(({externalScroll:e})=>({display:"flex",flexDirection:"column",flex:1,padding:"14px 0",overflow:e?"visible":"auto",gap:"16px",[`> .${bn.messageRowAssistant}:first-child`]:{marginTop:"16px"}})),ey=Fe.div({display:"flex",width:"100%",gap:"10px",[`&.${bn.messageRowUser}`]:{flexDirection:"row-reverse"},"> *":{minWidth:0},position:"relative"}),ty=Fe.div(({theme:e})=>({color:e.custom.colors.darkGray2,backgroundColor:e.custom.colors.white,...e.typography.body2,"p:first-of-type":{marginTop:0},"p:last-of-type":{marginBottom:0},"ol, ul":{paddingInlineStart:"16px",marginLeft:"6px","ol, ul":{marginLeft:0},li:{margin:"16px 0"}},a:{color:e.custom.colors.red,fontWeight:"normal"},borderRadius:"12px",[`.${bn.messageRowUser} &`]:{padding:"12px 16px",borderRadius:"8px 0px 8px 8px",backgroundColor:e.custom.colors.lightGray1}})),YL=Fe.div({alignSelf:"flex-end",alignItems:"end",display:"flex",flexDirection:"column",gap:"12px"}),jL=Fe.button(({theme:e})=>({border:`1px solid ${e.custom.colors.lightGray2}`,backgroundColor:e.custom.colors.white,padding:"8px 16px",...e.typography.body3,cursor:"pointer",boxSizing:"border-box","&:hover":{color:e.custom.colors.white,backgroundColor:e.custom.colors.silverGrayDark,borderColor:"transparent"},borderRadius:"8px"})),VL=Fe(Ob)(({theme:e})=>({fill:e.custom.colors.red})),$L=Fe(v8)(({theme:e})=>({fill:e.custom.colors.red})),qL=Fe.div(({externalScroll:e,theme:t})=>({padding:"12px 0 16px",...e&&{position:"sticky",bottom:0,background:t.custom.colors.white},"button:focus-visible":{outlineOffset:"-1px",borderRadius:"7px"}})),GL=Fe(bi)(({theme:e})=>({color:e.custom.colors.silverGrayDark,marginTop:"16px",textAlign:"center"})),XL=({entryScreenTitle:e,entryScreenEnabled:t=!0,conversationStarters:r,initialMessages:i,askTimTitle:l,requestOpts:s,parseContent:c,srLoadingMessages:d,placeholder:p="",className:m,scrollElement:b,chatId:E,ref:S,...y})=>{var J,Te;const N=A.useRef(null),_=A.useRef(null),[L,v]=A.useState(t),H=A.useRef(null),[D,P]=A.useState(),I=A.useRef(null),{messages:M,input:j,handleInputChange:ie,handleSubmit:V,append:x,isLoading:Y,stop:K,error:W}=wL(s,{initialMessages:D,id:E});PL({scrollElement:b||_.current,contentElement:b?_.current:null,threshold:200}),A.useEffect(()=>{if(i){const O=Math.random().toString().slice(2);P(i.map((ue,Re)=>({...ue,id:`initial-${O}-${Re}`})))}},[i]),A.useEffect(()=>{var O,ue;L||(ue=(O=I.current)==null?void 0:O.querySelector("input"))==null||ue.focus()},[L]);const q=A.useMemo(()=>{const O=D==null?void 0:D.map(ue=>ue.id);return M.map(ue=>{if(ue.role==="assistant"&&!(O!=null&&O.includes(ue.id))){const Re=c?c(ue.content):ue.content;return{...ue,content:Re}}return ue})},[c,M,D]),ee=q.length===((D==null?void 0:D.length)||0),Q=!ee&&!W&&((J=q[q.length-1])==null?void 0:J.role)==="user",se=Y&&((Te=q[q.length-1])==null?void 0:Te.role)!=="user",re=()=>{const O=b||_.current;O==null||O.scrollBy({behavior:"instant",top:O==null?void 0:O.scrollHeight})},ge=q[q.length-1],C=!!b;return A.createElement(UL,{className:m,ref:N,key:E},L?A.createElement(Yk,{className:bn.entryScreenContainer,title:e,conversationStarters:r,onPromptSubmit:O=>{O.trim()!==""&&(v(!1),x({role:"user",content:O}))}}):A.createElement(HL,{className:bn.chatScreenContainer,"data-testid":"ai-chat-screen",externalScroll:C,ref:H},A.createElement(FL,{className:zl(m,bn.root),externalScroll:C,...y},A.createElement(gD,{askTimTitle:l,externalScroll:C,className:zl(m,bn.title)}),A.createElement(zL,{className:bn.messagesContainer,externalScroll:C,ref:_},q.map(O=>A.createElement(ey,{key:O.id,"data-chat-role":O.role,className:zl(bn.messageRow,{[bn.messageRowUser]:O.role==="user",[bn.messageRowAssistant]:O.role==="assistant"})},A.createElement(ty,{className:bn.message},A.createElement(m2,{as:O.role==="user"?"h5":"h6"},O.role==="user"?"You said: ":"Assistant said: "),A.createElement(tg,{skipHtml:!0},O.content)))),ee?A.createElement(YL,null,r==null?void 0:r.map(O=>A.createElement(jL,{className:bn.conversationStarter,key:O.content,onClick:()=>{re(),x({role:"user",content:O.content})}},O.content))):null,Q?A.createElement(ey,{className:zl(bn.messageRow,bn.messageRowAssistant),key:"loading"},A.createElement(ty,null,A.createElement(_8,null))):null,W?A.createElement(hD,{severity:"error",closable:!0},"An unexpected error has occurred."):null),A.createElement(qL,{externalScroll:C,className:bn.bottomSection},A.createElement("form",{onSubmit:O=>{O.preventDefault(),Y&&se?K():(re(),V(O))}},A.createElement(h2,{ref:I,fullWidth:!0,size:"chat",className:bn.input,placeholder:p,name:"message",sx:{flex:1},value:j,onChange:ie,inputProps:{"aria-label":"Ask a question"},endAdornment:Y?A.createElement(y0,{"aria-label":"Stop",onClick:K,disabled:!se},A.createElement($L,null)):A.createElement(y0,{"aria-label":"Send",type:"submit",onClick:O=>{if(j.trim()===""){O.preventDefault();return}re(),V(O)}},A.createElement(VL,null))})),A.createElement(GL,{variant:"body3"},"AI-generated content may be incorrect.")),A.createElement(Xk,{isLoading:Y,loadingMessages:d,message:(ge==null?void 0:ge.role)==="assistant"?ge==null?void 0:ge.content:""}))))},ny=e=>({minWidth:"auto",padding:0,height:{small:"32px",medium:"40px",large:"48px"}[e],width:{small:"32px",medium:"40px",large:"48px"}[e],"& svg, & .MuiSvgIcon-root":{width:"1em",height:"1em",fontSize:dt({small:20,medium:24,large:32}[e])}}),uo=Fe(A.forwardRef(function(t,r){return A.createElement(XE,{ref:r,type:"button",...t})}))(({size:e=m0.size,responsive:t,theme:r})=>[ny(e),t&&{[r.breakpoints.down("sm")]:ny($E[e])}]);uo.displayName="ActionButton";const QL=uo.withComponent(({Component:e,...t})=>A.createElement(QE,{Component:e,...t}));QL.displayName="ActionButtonLink";const KL=Fe.div``,WL=Fe.div(({theme:e})=>({display:"flex",height:300,padding:40,flexDirection:"column",justifyContent:"center",alignItems:"center",alignSelf:"stretch",borderRadius:8,border:`1px solid ${e.custom.colors.lightGray2}`,marginTop:"8px",cursor:"pointer",textAlign:"center"})),ZL=Fe.div({display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",marginTop:"24px"}),JL=Fe.div(({theme:e})=>({color:e.custom.colors.silverGrayDark,...e.typography.body2})),ry=A.forwardRef(({content:e,"aria-label":t},r)=>{const[i,l]=A.useState(0);A.useEffect(()=>l(0),[e]);const s=c=>{(c.key==="Enter"||c.key===" ")&&l(i===0?1:0)};return A.createElement(WL,{ref:r,onClick:()=>l(i===0?1:0),onKeyDown:s,tabIndex:0,"aria-label":t},A.createElement(bi,{variant:"h5"},i===0?`Q: ${e.question}`:`Answer: ${e.answer}`))});ry.displayName="Flashcard";const eI=({flashcards:e,wasKeyboardFocus:t})=>{const[r,i]=A.useState(0),l=A.useRef(null),s=A.useRef(null),c=A.useCallback(d=>{var p;e&&(!((p=l.current)!=null&&p.contains(document.activeElement))&&t||(d.key==="ArrowRight"?i(m=>(m+1)%e.length):d.key==="ArrowLeft"&&i(m=>(m-1+e.length)%e.length)))},[e,t]);return A.useEffect(()=>{var d;(d=s.current)==null||d.focus()},[r]),A.useEffect(()=>(window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)),[c]),e!=null&&e.length?A.createElement(KL,{ref:l},A.createElement(ry,{ref:s,content:e[r],"aria-label":`Flashcard ${r+1} of ${e.length}`}),A.createElement(ZL,null,A.createElement(uo,{onClick:()=>i(r-1),disabled:r===0,variant:"secondary",color:"secondary",size:"small","aria-label":"Previous card"},A.createElement(A8,{"aria-hidden":!0})),A.createElement(JL,null,r+1," / ",e.length),A.createElement(uo,{onClick:()=>i(r+1),disabled:r===e.length-1,variant:"secondary",color:"secondary",size:"small","aria-label":"Next card"},A.createElement(x8,{"aria-hidden":!0})))):null},tI=Fe.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px",color:e.custom.colors.white,position:"sticky",top:0,padding:"32px 0 16px 0",zIndex:2,backgroundColor:e.custom.colors.white,borderRadius:0})),nI=Fe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",color:e.custom.colors.darkGray2,img:{width:"24px",height:"24px"},svg:{fill:e.custom.colors.red,width:"24px",height:"24px",flexShrink:0},overflow:"hidden",p:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"}})),rI=Fe(uo)(({theme:e})=>({backgroundColor:e.custom.colors.lightGray2,"&&:hover":{backgroundColor:e.custom.colors.red,color:e.custom.colors.white},zIndex:3,flexShrink:0})),aI=Fe(G9)(({theme:e})=>({padding:"0 0 16px",backgroundColor:e.custom.colors.white,position:"sticky",top:"88px",zIndex:2,overflow:"visible"})),B0=Fe(fk)({padding:"0",height:"calc(100% - 138px)",position:"relative"}),iI=Fe(XL)(({hasTabs:e,theme:t})=>({".MitAiChat--entryScreenContainer":{padding:e?"114px 0 24px":"168px 32px 24px",[t.breakpoints.down("md")]:{padding:e?"114px 0 24px":"168px 16px 24px"}},".MitAiChat--chatScreenContainer":{padding:e?0:"0 32px",[t.breakpoints.down("md")]:{padding:e?0:"0 16px"}},".MitAiChat--messagesContainer":{paddingTop:e?"8px":"88px"}})),uI=Fe.div(({theme:e})=>({color:e.custom.colors.darkGray2,backgroundColor:e.custom.colors.white,padding:"12px 0 100px",...e.typography.body2,"p:first-of-type":{marginTop:0},"p:last-of-type":{marginBottom:0},"ol, ul":{paddingInlineStart:"32px",li:{margin:"16px 0"}},ul:{marginInlineStart:"-16px"},a:{color:e.custom.colors.red,fontWeight:"normal"}})),lI=e=>e,oI={credentials:"include"},sI=e=>{const[t,r]=A.useState(null),[i,l]=A.useState(!1);return A.useEffect(()=>{if(!e)return;(async()=>{l(!0);try{const d=await(await fetch(e)).json();if(!d.results)throw new Error("Unexpected response");const[p]=d.results;if(!p)throw new Error("No result found");r({summary:p.summary,flashcards:p.flashcards})}catch(c){console.error("Error fetching content",c)}finally{l(!1)}})()},[e]),{response:t,loading:i}},cI="What do you want to know about this video?",fI=[{content:"What are the most important concepts introduced in the video?"},{content:"What examples are used to illustrate concepts covered in the video?"},{content:"What are the key terms introduced in this video?"}],ay=({payload:e,transformBody:t,fetchOpts:r,scrollElement:i,entryScreenEnabled:l,entryScreenTitle:s,conversationStarters:c,hasTabs:d})=>e?A.createElement(iI,{chatId:e.chatId,conversationStarters:c,initialMessages:e.initialMessages,scrollElement:i,entryScreenEnabled:l,entryScreenTitle:s,requestOpts:{transformBody:p=>({...e.requestBody,...t==null?void 0:t(p)}),apiUrl:e.apiUrl,fetchOpts:{...oI,...r}},hasTabs:d}):null,dI=(e,t)=>[...e].sort(()=>.5-Math.random()).slice(0,t),hI=({messageOrigin:e,transformBody:t=lI,className:r,fetchOpts:i,target:l})=>{var ie,V,x,Y,K,W;const[s,c]=A.useState(!1),[d,p]=A.useState(null),[m,b]=A.useState("chat"),{response:E}=sI((ie=d==null?void 0:d.summary)==null?void 0:ie.apiUrl),[S,y]=A.useState(!1),N=A.useRef(!1),_=()=>{N.current=!0},L=()=>{N.current||y(!0),N.current=!1},[v,H]=A.useState(null),D=q=>{q&&H(q)};A.useEffect(()=>{const q=ee=>{ee.origin===e&&ee.data.type==="smoot-design::tutor-drawer-open"&&ee.data.payload.target===l&&(c(!0),p(ee.data.payload))};return window.addEventListener("message",q),()=>{window.removeEventListener("message",q)}},[e,l]),A.useEffect(()=>{var q;(q=v==null?void 0:v.scrollTo)==null||q.call(v,{top:m==="chat"?v.scrollHeight:0})},[m,v]);const P=A.useMemo(()=>{var q;return d?d.chat.conversationStarters||((q=E==null?void 0:E.flashcards)!=null&&q.length&&E.flashcards.length>=3?dI(E.flashcards,3).map(ee=>({content:ee.question})):fI):[]},[d,E]);if(!d)return A.createElement("div",{"data-testid":"remote-tutor-drawer-waiting"});const{blockType:I,chat:M}=d,j=I==="video";return A.createElement(WN,{"data-testid":"remote-tutor-drawer",className:r,PaperProps:{ref:D,sx:{width:"900px",maxWidth:"100%",boxSizing:"border-box",padding:{xs:"0 16px",md:"0 32px"}}},anchor:"right",open:s,onClose:()=>c(!1),role:"dialog","aria-modal":"true"},A.createElement(tI,null,A.createElement(nI,null,d.title?A.createElement(Ud,null):null,A.createElement(bi,{variant:"body1",component:"h1"},(V=d.title)!=null&&V.includes("AskTIM")?A.createElement(A.Fragment,null,"Ask",A.createElement("strong",null,"TIM"),d.title.replace("AskTIM","")):d.title)),A.createElement(rI,{variant:"text",size:"medium",onClick:()=>c(!1),"aria-label":"Close"},A.createElement(Rb,null))),I==="problem"?A.createElement(ay,{payload:M,transformBody:t,fetchOpts:i,scrollElement:v,entryScreenEnabled:((x=d.chat)==null?void 0:x.entryScreenEnabled)??!1,entryScreenTitle:d.chat.entryScreenTitle,hasTabs:j}):null,I==="video"?A.createElement(B9,{value:m},A.createElement(aI,{styleVariant:"chat",onChange:(q,ee)=>b(ee)},A.createElement(g0,{value:"chat",label:"Chat"}),(Y=E==null?void 0:E.flashcards)!=null&&Y.length?A.createElement(g0,{value:"flashcards",label:"Flashcards",onMouseDown:_,onFocus:L}):null,A.createElement(g0,{value:"summary",label:"Summary"})),A.createElement(B0,{value:"chat",keepMounted:!0},A.createElement(ay,{payload:{...M},transformBody:t,fetchOpts:i,scrollElement:v,entryScreenEnabled:((K=d.chat)==null?void 0:K.entryScreenEnabled)??!0,entryScreenTitle:d.chat.entryScreenTitle??cI,conversationStarters:P,hasTabs:j})),(W=E==null?void 0:E.flashcards)!=null&&W.length?A.createElement(B0,{value:"flashcards"},A.createElement(eI,{flashcards:E==null?void 0:E.flashcards,wasKeyboardFocus:S})):null,A.createElement(B0,{value:"summary"},A.createElement(bi,{variant:"h4",component:"h4"}),A.createElement(uI,null,A.createElement(tg,{rehypePlugins:[C8]},(E==null?void 0:E.summary)??"")))):null)},pI={defaultProps:{disableRipple:!0},styleOverrides:{root:{":focus-visible":{outline:"revert"}}}},ot={mitRed:"#750014",brightRed:"#FF1423",black:"#000000",white:"#FFFFFF",darkGray2:"#212326",darkGray1:"#40464C",silverGrayDark:"#626A73",silverGray:"#8B959E",silverGrayLight:"#B8C2CC",lightGray2:"#DDE1E6",lightGray1:"#F3F4F8",navGray:"#303337",darkPink:"#750062",pink:"#FF14F0",lightPink:"#FFB3FF",darkPurple:"#3E006B",purple:"#93F",lightPurple:"#BFB3FF",darkBlue:"#002896",blue:"#1966FF",lightBlue:"#99EBFF",darkGreen:"#004D1A",green:"#00AD00",lightGreen:"#AF3",darkRed:"#83192A",red:"#A31F34",lightRed:"#D02E44",orange:"#FAB005",yellow:"#FFEB00"},mI={defaultProps:{size:"medium",color:"default",variant:"outlined",deleteIcon:A.createElement(Rb,{"aria-hidden":"true"})},styleOverrides:{root:{borderRadius:"100vh",borderWidth:"1px"},deleteIcon:{"&:hover":{color:"inherit"},"&.MuiChip-deleteIconLarge":{width:"16px",height:"16px"},"&.MuiChip-deleteIconMedium":{width:"14px",height:"14px"},margin:"0 -2px 0 8px",color:"inherit"},icon:{margin:"0 8px 0 -2px",color:"inherit","&.MuiChip-iconLarge":{width:"16px",height:"16px"},"&.MuiChip-iconMedium":{width:"14px",height:"14px"}}},variants:[{props:{size:"medium"},style:({theme:e})=>({...e.typography.body3,boxSizing:"border-box",height:"24px",paddingRight:"12px",paddingLeft:"12px",".MuiChip-label":{paddingLeft:"0px",paddingRight:"0px"}})},{props:{size:"large"},style:({theme:e})=>({...e.typography.body2,height:"32px",paddingLeft:"16px",paddingRight:"16px",".MuiChip-label":{paddingLeft:"0px",paddingRight:"0px"}})},{props:{variant:"outlined"},style:{borderColor:ot.silverGrayLight,color:ot.darkGray1,"&.Mui-focusVisible":{backgroundColor:"transparent"},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,borderColor:ot.silverGrayDark,backgroundColor:"transparent"}}},{props:{variant:"outlinedWhite"},style:{backgroundColor:"white",border:"1px solid",borderColor:ot.silverGrayLight,color:ot.darkGray1,"&.Mui-focusVisible":{backgroundColor:"white"},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,borderColor:ot.silverGrayDark,backgroundColor:"white"}}},{props:{variant:"gray"},style:{backgroundColor:ot.lightGray2,border:"none",color:ot.darkGray2,"&.Mui-focusVisible":{backgroundColor:ot.lightGray2},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{color:ot.darkGray1,backgroundColor:ot.silverGrayLight}}},{props:{variant:"dark"},style:{backgroundColor:ot.silverGrayDark,border:"none",color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.silverGrayDark},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.darkGray1}}},{props:{variant:"darker"},style:{backgroundColor:ot.darkGray2,border:`1px solid ${ot.darkGray1}`,color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.darkGray2},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.black,border:`1px solid ${ot.silverGray}`}}},{props:{variant:"filled"},style:{backgroundColor:ot.mitRed,border:"none",color:ot.white,"&.Mui-focusVisible":{backgroundColor:ot.mitRed},"&.MuiChip-clickable:hover, &.MuiChip-deletable:hover":{backgroundColor:ot.red}}}]},gI={colors:ot,dimensions:{headerHeight:"72px",headerHeightSm:"60px"}},bI={values:{xs:0,sm:600,md:900,lg:1320,xl:1536}},EI={custom:gI,palette:{primary:{main:ot.mitRed,light:ot.lightRed,active:ot.red,contrastText:ot.white},secondary:{light:ot.darkGray2,active:ot.silverGrayDark,main:ot.black,contrastText:ot.white}},shape:{borderRadius:8},spacing:8,typography:YE,breakpoints:bI,components:{MuiButtonBase:pI,MuiTypography:Y9,MuiMenu:{styleOverrides:{paper:{borderRadius:"4px"}}},MuiAutocomplete:{styleOverrides:{paper:{borderRadius:"4px"},popupIndicator:{paddingRight:0,marginRight:0}}},MuiChip:mI}},iy=e=>Zs(Pn(EI,e)),yI=iy(),TI=({children:e,theme:t=yI})=>A.createElement(z9,{theme:t},e);var SI=function(t,r,i){for(var l=0,s=0;l=s,s=Gn(),l===38&&s===12&&(r[i]=1),!ai(s);)Nn();return Yi(t,Cn)},CI=function(t,r){var i=-1,l=44;do switch(ai(l)){case 0:l===38&&Gn()===12&&(r[i]=1),t[i]+=SI(Cn-1,r,i);break;case 2:t[i]+=tl(l);break;case 4:if(l===44){t[++i]=Gn()===58?"&\f":"",r[i]=t[i].length;break}default:t[i]+=Zu(l)}while(l=Nn());return t},AI=function(t,r){return Nf(CI(Of(t),r))},uy=new WeakMap,xI=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var r=t.value,i=t.parent,l=t.column===i.column&&t.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(t.props.length===1&&r.charCodeAt(0)!==58&&!uy.get(i))&&!l){uy.set(t,!0);for(var s=[],c=AI(r,s),d=i.props,p=0,m=0;p<c.length;p++)for(var b=0;b<d.length;b++,m++)t.props[m]=s[p]?c[p].replace(/&\f/g,d[b]):d[b]+" "+c[p]}}},_I=function(t){if(t.type==="decl"){var r=t.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(t.return="",t.value="")}};function ly(e,t){switch(nm(e,t)){case 5103:return De+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return De+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return De+e+xa+e+pt+e+e;case 6828:case 4268:return De+e+pt+e+e;case 6165:return De+e+pt+"flex-"+e+e;case 5187:return De+e+Ie(e,/(\w+).+(:[^]+)/,De+"box-$1$2"+pt+"flex-$1$2")+e;case 5443:return De+e+pt+"flex-item-"+Ie(e,/flex-|-self/,"")+e;case 4675:return De+e+pt+"flex-line-pack"+Ie(e,/align-content|flex-|-self/,"")+e;case 5548:return De+e+pt+Ie(e,"shrink","negative")+e;case 5292:return De+e+pt+Ie(e,"basis","preferred-size")+e;case 6060:return De+"box-"+Ie(e,"-grow","")+De+e+pt+Ie(e,"grow","positive")+e;case 4554:return De+Ie(e,/([^-])(transform)/g,"$1"+De+"$2")+e;case 6187:return Ie(Ie(Ie(e,/(zoom-|grab)/,De+"$1"),/(image-set)/,De+"$1"),e,"")+e;case 5495:case 3959:return Ie(e,/(image-set\([^]*)/,De+"$1$`$1");case 4968:return Ie(Ie(e,/(.+:)(flex-)?(.*)/,De+"box-pack:$3"+pt+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+De+e+e;case 4095:case 3583:case 4068:case 2532:return Ie(e,/(.+)-inline(.+)/,De+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(lr(e)-1-t>6)switch(Bt(e,t+1)){case 109:if(Bt(e,t+4)!==45)break;case 102:return Ie(e,/(.+:)(.+)-([^]+)/,"$1"+De+"$2-$3$1"+xa+(Bt(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~Ju(e,"stretch")?ly(Ie(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(Bt(e,t+1)!==115)break;case 6444:switch(Bt(e,lr(e)-3-(~Ju(e,"!important")&&10))){case 107:return Ie(e,":",":"+De)+e;case 101:return Ie(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+De+(Bt(e,14)===45?"inline-":"")+"box$3$1"+De+"$2$3$1"+pt+"$2box$3")+e}break;case 5936:switch(Bt(e,t+11)){case 114:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return De+e+pt+Ie(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return De+e+pt+e+e}return e}var vI=function(t,r,i,l){if(t.length>-1&&!t.return)switch(t.type){case ls:t.return=ly(t.value,t.length);break;case vf:return Br([Mr(t,{value:Ie(t.value,"@","@"+De)})],l);case us:if(t.length)return im(t.props,function(s){switch(am(s,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Br([Mr(t,{props:[Ie(s,/:(read-\w+)/,":"+xa+"$1")]})],l);case"::placeholder":return Br([Mr(t,{props:[Ie(s,/:(plac\w+)/,":"+De+"input-$1")]}),Mr(t,{props:[Ie(s,/:(plac\w+)/,":"+xa+"$1")]}),Mr(t,{props:[Ie(s,/:(plac\w+)/,pt+"input-$1")]})],l)}return""})}},RI=[vI],OI=function(t){var r=t.key;if(r==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(_){var L=_.getAttribute("data-emotion");L.indexOf(" ")!==-1&&(document.head.appendChild(_),_.setAttribute("data-s",""))})}var l=t.stylisPlugins||RI,s={},c,d=[];c=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(_){for(var L=_.getAttribute("data-emotion").split(" "),v=1;v<L.length;v++)s[L[v]]=!0;d.push(_)});var p,m=[xI,_I];{var b,E=[cm,dm(function(_){b.insert(_)})],S=fm(m.concat(l,E)),y=function(L){return Br(lm(L),S)};p=function(L,v,H,D){b=H,y(L?L+"{"+v.styles+"}":v.styles),D&&(N.inserted[v.name]=!0)}}var N={key:r,sheet:new em({key:r,container:c,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:s,registered:{},insert:p};return N.sheet.hydrate(d),N};const NI=e=>{const t=document.createElement("div");document.body.appendChild(t);const r=t.attachShadow({mode:"open"}),i=document.createElement("div");i.id="smoot-chat-drawer-root",r.append(i);const l=OI({key:"css",prepend:!0,container:r}),s=iy({components:{MuiPopover:{defaultProps:{container:i}},MuiPopper:{defaultProps:{container:i}},MuiModal:{defaultProps:{container:i}}}});X3.createRoot(i).render(A.createElement(kC,{value:l},A.createElement(TI,{theme:s},A.createElement(hI,{...e}))))};ir.init=NI,Object.defineProperty(ir,Symbol.toStringTag,{value:"Module"})});
@@ -248,11 +248,11 @@ const RemoteTutorDrawer = ({ messageOrigin, transformBody = identity, className,
248
248
  md: "0 32px",
249
249
  },
250
250
  },
251
- }, anchor: "right", open: open, onClose: () => setOpen(false) },
251
+ }, anchor: "right", open: open, onClose: () => setOpen(false), role: "dialog", "aria-modal": "true" },
252
252
  React.createElement(Header, null,
253
253
  React.createElement(Title, null,
254
254
  payload.title ? React.createElement(react_2.RiSparkling2Line, null) : null,
255
- React.createElement(Typography_1.default, { variant: "body1", component: "h2" }, ((_b = payload.title) === null || _b === void 0 ? void 0 : _b.includes("AskTIM")) ? (React.createElement(React.Fragment, null,
255
+ React.createElement(Typography_1.default, { variant: "body1", component: "h1" }, ((_b = payload.title) === null || _b === void 0 ? void 0 : _b.includes("AskTIM")) ? (React.createElement(React.Fragment, null,
256
256
  "Ask",
257
257
  React.createElement("strong", null, "TIM"),
258
258
  payload.title.replace("AskTIM", ""))) : (payload.title))),
@@ -65,6 +65,9 @@ const MessagesContainer = (0, styled_1.default)(ScrollSnap_1.ScrollSnap)(({ exte
65
65
  padding: "14px 0",
66
66
  overflow: externalScroll ? "visible" : "auto",
67
67
  gap: "16px",
68
+ [`> .${classes.messageRowAssistant}:first-child`]: {
69
+ marginTop: "16px",
70
+ },
68
71
  }));
69
72
  const MessageRow = styled_1.default.div({
70
73
  display: "flex",
@@ -78,7 +81,7 @@ const MessageRow = styled_1.default.div({
78
81
  },
79
82
  position: "relative",
80
83
  });
81
- const Message = styled_1.default.div(({ theme }) => (Object.assign(Object.assign({ color: theme.custom.colors.darkGray2, backgroundColor: theme.custom.colors.white, padding: "12px 16px" }, theme.typography.body2), { "p:first-of-type": {
84
+ const Message = styled_1.default.div(({ theme }) => (Object.assign(Object.assign({ color: theme.custom.colors.darkGray2, backgroundColor: theme.custom.colors.white }, theme.typography.body2), { "p:first-of-type": {
82
85
  marginTop: 0,
83
86
  }, "p:last-of-type": {
84
87
  marginBottom: 0,
@@ -94,9 +97,8 @@ const Message = styled_1.default.div(({ theme }) => (Object.assign(Object.assign
94
97
  }, a: {
95
98
  color: theme.custom.colors.red,
96
99
  fontWeight: "normal",
97
- }, borderRadius: "12px", [`.${classes.messageRowAssistant} &`]: {
98
- padding: "12px 16px 12px 0",
99
- }, [`.${classes.messageRowUser} &`]: {
100
+ }, borderRadius: "12px", [`.${classes.messageRowUser} &`]: {
101
+ padding: "12px 16px",
100
102
  borderRadius: "8px 0px 8px 8px",
101
103
  backgroundColor: theme.custom.colors.lightGray1,
102
104
  } })));
@@ -245,11 +245,11 @@ const RemoteTutorDrawer = ({ messageOrigin, transformBody = identity, className,
245
245
  md: "0 32px",
246
246
  },
247
247
  },
248
- }, anchor: "right", open: open, onClose: () => setOpen(false) },
248
+ }, anchor: "right", open: open, onClose: () => setOpen(false), role: "dialog", "aria-modal": "true" },
249
249
  React.createElement(Header, null,
250
250
  React.createElement(Title, null,
251
251
  payload.title ? React.createElement(RiSparkling2Line, null) : null,
252
- React.createElement(Typography, { variant: "body1", component: "h2" }, ((_b = payload.title) === null || _b === void 0 ? void 0 : _b.includes("AskTIM")) ? (React.createElement(React.Fragment, null,
252
+ React.createElement(Typography, { variant: "body1", component: "h1" }, ((_b = payload.title) === null || _b === void 0 ? void 0 : _b.includes("AskTIM")) ? (React.createElement(React.Fragment, null,
253
253
  "Ask",
254
254
  React.createElement("strong", null, "TIM"),
255
255
  payload.title.replace("AskTIM", ""))) : (payload.title))),
@@ -62,6 +62,9 @@ const MessagesContainer = styled(ScrollSnap)(({ externalScroll }) => ({
62
62
  padding: "14px 0",
63
63
  overflow: externalScroll ? "visible" : "auto",
64
64
  gap: "16px",
65
+ [`> .${classes.messageRowAssistant}:first-child`]: {
66
+ marginTop: "16px",
67
+ },
65
68
  }));
66
69
  const MessageRow = styled.div({
67
70
  display: "flex",
@@ -75,7 +78,7 @@ const MessageRow = styled.div({
75
78
  },
76
79
  position: "relative",
77
80
  });
78
- const Message = styled.div(({ theme }) => (Object.assign(Object.assign({ color: theme.custom.colors.darkGray2, backgroundColor: theme.custom.colors.white, padding: "12px 16px" }, theme.typography.body2), { "p:first-of-type": {
81
+ const Message = styled.div(({ theme }) => (Object.assign(Object.assign({ color: theme.custom.colors.darkGray2, backgroundColor: theme.custom.colors.white }, theme.typography.body2), { "p:first-of-type": {
79
82
  marginTop: 0,
80
83
  }, "p:last-of-type": {
81
84
  marginBottom: 0,
@@ -91,9 +94,8 @@ const Message = styled.div(({ theme }) => (Object.assign(Object.assign({ color:
91
94
  }, a: {
92
95
  color: theme.custom.colors.red,
93
96
  fontWeight: "normal",
94
- }, borderRadius: "12px", [`.${classes.messageRowAssistant} &`]: {
95
- padding: "12px 16px 12px 0",
96
- }, [`.${classes.messageRowUser} &`]: {
97
+ }, borderRadius: "12px", [`.${classes.messageRowUser} &`]: {
98
+ padding: "12px 16px",
97
99
  borderRadius: "8px 0px 8px 8px",
98
100
  backgroundColor: theme.custom.colors.lightGray1,
99
101
  } })));