1"use strict";(self.webpackChunkthnk_client=self.webpackChunkthnk_client||[]).push([[1524],{2456(e,t,s){s.r(t),s.d(t,{default:()=>w});var a=s(9379),l=s(5544),n=s(7565),r=s(4416),c=(s(7878),s(4921),s(4399)),i=s(6515),o=s(2865),d=s(4358),u=s(9847),h=s(9482),m=s(7849);var p=s(3679),v=s(1683),x=s(217),_=s(5085),f=s(2665),g=s(7929);const j=function(e){let t=e.publicToken,s=e.appId;const a=(0,h.o)().isMobile,l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!l.current)return;const e=e=>{let a=e.data;if("@@mindstudio/LOADED"===a._MindStudioEvent){var n,r;const e=window.localStorage.getItem("@@mindstudio-sdk/userIds/".concat(s))||"";null===(n=l.current)||void 0===n||null===(r=n.contentWindow)||void 0===r||r.postMessage({_MindStudioEvent:"@@mindstudio/INITIALIZE",payload:{appId:s,publicToken:t,userIdOrNull:e||null,options:null,parentUrl:document.URL}},"*")}if("@@mindstudio/USER_ID_UPDATED"===a._MindStudioEvent)try{window.localStorage.setItem("@@mindstudio-sdk/userIds/".concat(s),a.payload.userId)}catch(c){console.log(c)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[s,t]),(0,g.jsx)("iframe",{ref:l,referrerPolicy:"origin",style:{width:"100%",height:a?"60vh":"580px",border:"0",borderRadius:"8px",outline:"none"},title:"AI Embed",src:"https://app.mindstudio.ai/_embeds/app?__displayContext=embedded&__controlledAuth=1"})};var b=s(9881),y=s(4225);const N=(0,n.forwardRef)((e,t)=>{let s=e.title,a=e.desc,l=e.img,r=e.mindstudio,c=e.openai,N=e.anthropicai,w=e.vertexai,k=e.highestTitle,A=e.cta;const C=(0,n.useRef)(null),I=(0,n.useRef)(null),S=(0,n.useRef)(null),T=(0,h.o)().width,D=(0,x.A)({ai:N||c||w,btnRef:C}),M=D.closeModal,E=D.startTimer,R=D.feedbackCookie,L=D.Modal,P=(0,n.useMemo)(()=>({closeCallback:M}),[M]),O=(0,_.A)(P),H=O.modal,J=O.open,V=O.close,Y=(0,n.useCallback)(()=>{C.current&&(J(C.current),R||E())},[R,J,E]);return(0,n.useImperativeHandle)(t,()=>S.current,[]),(0,n.useEffect)(()=>{if(!I.current||!S.current)return;const e=S.current.scrollHeight,t=(k||0)-e;I.current.style.marginTop="".concat(t,"px")},[k,T]),(0,g.jsxs)("div",{className:"flex gap-sm",children:[(0,g.jsx)("div",{className:"ai-carousel__slide-img-container",children:l?(0,g.jsx)(v.A,{className:"ai-carousel__slide-img cover-img",img:l,size:"small"}):null}),(0,g.jsxs)("div",{className:"ai-carousel__slide-content flex gap-sm",children:[s?(0,g.jsxs)("h3",{className:"h3",ref:S,children:[" ",(0,g.jsx)(d.A,{components:{p:u.A},children:s})]}):null,a?(0,g.jsx)("div",{ref:I,children:(0,g.jsx)(d.A,{className:"markdown",children:a})}):null,(0,g.jsxs)("div",{className:"ai-carousel__slide-actions",children:[c||r||N||w?(0,g.jsx)(i.A,{className:"btn btn--secondary",onClick:Y,type:"button",ref:C,id:(null===c||void 0===c?void 0:c.btnId)||(null===r||void 0===r?void 0:r.btnId)||(null===N||void 0===N?void 0:N.btnId)||(null===w||void 0===w?void 0:w.btnId),children:(null===c||void 0===c?void 0:c.btnLabel)||(null===r||void 0===r?void 0:r.btnLabel)||(null===N||void 0===N?void 0:N.btnLabel)||(null===w||void 0===w?void 0:w.btnLabel)||"Open"}):null,A?(0,g.jsx)(p.A,{link:A}):null]})]}),c?H({side:"right",keepMounted:!0,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(i.A,{className:"modal__close",onClick:V,type:"button",id:"".concat((0,m.Yv)(s||""),"-modal-close"),children:[(0,g.jsx)(o.I.Plus,{className:"icon-large"}),(0,g.jsx)("span",{className:"sr-only",children:"Close modal"})]}),null!==c&&void 0!==c&&c.assistantID?(0,g.jsx)(b.A,{ai:c}):null]})}):null,r?H({children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(i.A,{className:"modal__close",onClick:V,type:"button",id:"".concat(s?(0,m.Yv)(s):"ai-item","-modal-close"),children:[(0,g.jsx)(o.I.Plus,{className:"icon-large"}),(0,g.jsx)("span",{className:"sr-only",children:"Close modal"})]}),null!==r&&void 0!==r&&r.appId&&r.publicToken?(0,g.jsx)("div",{className:"ai-carousel__chat-container",children:(0,g.jsx)(j,{publicToken:r.publicToken,appId:r.appId})}):null]})}):null,N?H({side:"right",keepMounted:!0,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(i.A,{className:"modal__close",onClick:V,type:"button",id:"".concat((0,m.Yv)((null===N||void 0===N?void 0:N.title)||""),"-modal-close"),children:[(0,g.jsx)(o.I.Plus,{className:"icon-large"}),(0,g.jsx)("span",{className:"sr-only",children:"Close modal"})]}),N?(0,g.jsx)(f.A,{ai:N}):null]})}):null,w?H({side:"right",keepMounted:!0,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(i.A,{className:"modal__close",onClick:V,type:"button",id:"".concat((0,m.Yv)((null===w||void 0===w?void 0:w.title)||""),"-modal-close"),children:[(0,g.jsx)(o.I.Plus,{className:"icon-large"}),(0,g.jsx)("span",{className:"sr-only",children:"Close modal"})]}),w?(0,g.jsx)(y.A,{ai:w}):null]})}):null,(0,g.jsx)(L,{})]})});const w=function(e){let t=e.componentId,s=e.title,p=e.items,v=e.slug;const x=(0,h.o)(),_=x.isMobile,f=x.width,j=(0,n.useRef)(null),b=(0,n.useRef)(null),y=(0,n.useRef)([]),w=(0,n.use
1State)(!1),k=(0,l.A)(w,2),A=k[0],C=k[1],I=(0,n.useState)(!1),S=(0,l.A)(I,2),T=(S[0],S[1]),D=(0,n.useState)(null),M=(0,l.A)(D,2),E=M[0],R=M[1];(0,n.useEffect)(()=>{if(!y.current.length)return;const e=y.current.map(e=>null===e||void 0===e?void 0:e.scrollHeight);e.max=function(){return Math.max.apply(null,this)},R(e.max())},[f]);const L=(0,n.useMemo)(()=>{var e,t;return null===p||void 0===p||null===(e=p.filter(e=>!e.mindstudio))||void 0===e||null===(t=e.filter(e=>!e.hidden))||void 0===t?void 0:t.map((e,t)=>(0,g.jsx)(c.qr,{className:"ai-carousel__slide",children:(0,g.jsx)(N,(0,a.A)((0,a.A)({},e),{},{ref:e=>{y.current[t]=e},highestTitle:E}))},e.title))},[p,E]);return(0,g.jsx)("section",(0,a.A)((0,a.A)({className:"ai-carousel section"},t?{id:t}:{}),{},{children:(0,g.jsxs)("div",{className:"wrap",children:[(0,g.jsxs)("div",{className:"ai-carousel__header gap-md",children:[s?(0,g.jsxs)("h2",{className:"ai-carousel__title h2",children:[" ",(0,g.jsx)(d.A,{components:{p:u.A},children:s})]}):null,(0,g.jsxs)("div",{className:"ai-carousel__nav slider__nav",hidden:A,children:[(0,g.jsxs)(i.A,{className:"slider__arrow slider__arrow--prev",id:"".concat(v,"-").concat((0,m.Yv)(s||""),"-prev"),type:"button",ref:j,children:[(0,g.jsx)("span",{className:"sr-only",children:"Previous slide"}),(0,g.jsx)(o.I.Chevron,{className:"icon"})]}),(0,g.jsxs)(i.A,{className:"slider__arrow slider__arrow--next",id:"".concat(v,"-").concat((0,m.Yv)(s||""),"-next"),type:"button",ref:b,children:[(0,g.jsx)("span",{className:"sr-only",children:"Next slide"}),(0,g.jsx)(o.I.Chevron,{className:"icon"})]})]})]}),(0,g.jsx)(c.RC,{className:"ai-carousel__slider".concat(A?" locked":""),slidesPerView:"auto",watchOverflow:!0,modules:[r.Vx,r.FJ,r.Jq],grabCursor:!0,mousewheel:{forceToAxis:!0},spaceBetween:_?24:40,navigation:{prevEl:j.current,nextEl:b.current},onSwiper:()=>T(!0),onLock:()=>C(!0),onUnlock:()=>C(!1),children:L})]})}))}},2665(e,t,s){var a=s(9379),l=s(5544),n=s(7565),r=s(6515),c=s(5823),i=s(3173),o=s(2865),d=s(4358),u=s(3983),h=s(2917),m=s(5776),p=s(9482),v=s(7849),x=s(4912),_=s(7929);const f="".concat("https://www.thnk.org/api");const g=function(e){var t;let s=e.ai;const g=(0,p.o)().isMobile,j=(0,x.M)("",e=>!(0,v.Im)(e)),b=(0,n.useState)([]),y=(0,l.A)(b,2),N=y[0],w=y[1],k=(0,n.useState)(!1),A=(0,l.A)(k,2),C=A[0],I=A[1],S=(0,n.useRef)(null),T=(0,m.f)().data,D=(0,h.M)().setAlert,M=(0,n.useCallback)(e=>{switch(e.type){case"message_start":w(t=>[{id:e.message.id,text:"",role:"assistant",created_at:(new Date).toLocaleString()},...t]);break;case"content_block_delta":w(t=>{const s=t.map(e=>(0,a.A)({},e));if(s.length){var l;const t=0;return null!==(l=s[t])&&void 0!==l&&l.text||(s[t].text=""),s[t].text+=e.delta.text||"",s}return s})}},[]),E=(0,n.useCallback)(async e=>{if(!C){var t,a;if(g)null===(t=j.ref)||void 0===t||null===(a=t.current)||void 0===a||a.blur();I(!0),null!==S&&void 0!==S&&S.current&&(S.current.scrollTop=S.current.scrollHeight),e||w(e=>[{id:Date.now().toString(),text:j.value,role:"user",created_at:(new Date).toLocaleString()},...e]);try{var l,n;j.setValue("");const t=null===(n=(await fetch("".concat(f,"/ai_chat/anthropic/stream-message"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s.model||(null===T||void 0===T||null===(l=T.generalData)||void 0===l?void 0:l.anthropicModel)||"claude-sonnet-4-5-20250929",max_tokens:s.maxTokens||1e3,messages:[...[...N].reverse().map(e=>({role:e.role,content:e.text})),{role:"user",content:[{type:"text",text:e||j.value,cache_control:{type:"ephemeral"}}]}],system:[...s.systemPrompt?[{type:"text",text:s.systemPrompt,cache_control:{type:"ephemeral"}}]:[],{type:"text",text:(new Date).toDateString(),cache_control:{type:"ephemeral"}}],stream:!0,temperature:s.temperature||0})})).body)||void 0===n?void 0:n.getReader();if(!t)return;const a=new TextDecoder;let c="";for(;;)try{const e=await t.read(),s=e.done,l=e.value;if(s)break;c+=a.decode(l,{stream:!0});const n=c.split("\n");c=n.pop();for(const t of n)if(t.trim()){const e=JSON.parse(t);M(e)}if(c.trim()){const e=JSON.parse(c);if(e.error||500===e.statusCode)throw new Error}}catch(r){throw new Error}I(!1)}catch(c){I(!1),w(e=>[{id:Date.now().toString(),text:"This AI coach is currently experiencing technical difficulties. Please try again in a few minutes. If the issue persists, contact [[email protected]](mailto:[email protected]).",role:"assistant",created_at:(new Date).toLocaleStr
1ing()},...e])}}},[s,g,j,M,null===T||void 0===T||null===(t=T.generalData)||void 0===t?void 0:t.anthropicModel,N,C]),R=(0,n.useCallback)(()=>{const e=[...N].reverse().map(e=>"".concat((0,v.ZH)(e.role),": ").concat(e.text)).join("\n");navigator.clipboard.writeText(e),D({message:"Chat copied to clipboard"})},[N,D]);(0,n.useEffect)(()=>{s.initialMsg&&E(s.initialMsg)},[]),(0,n.useEffect)(()=>{null!==S&&void 0!==S&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[N]);const L=(0,n.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),g||e.shiftKey?j.setValue(e=>"".concat(e,"\n")):j.isValid&&E())},[j,g,E]);return(0,_.jsx)("div",{className:"chat",children:(0,_.jsx)("div",{className:"chat__container",children:(0,_.jsx)("div",{className:"chat__content",children:(0,_.jsxs)("div",{className:"chat__chat",children:[(0,_.jsx)("div",{className:"chat__header",children:s.title?(0,_.jsx)("h2",{className:"h3",children:s.title}):null}),(0,_.jsx)("div",{className:"chat__messages",ref:S,children:null===N||void 0===N?void 0:N.map(e=>(0,_.jsx)("div",{className:"chat__message-container".concat("user"===e.role?" chat__message-container--user":""),children:(0,_.jsx)(d.A,{className:"chat__message body-regular markdown",children:e.text.replaceAll("\u2022","-")})},e.id))}),(0,_.jsx)(c.A,{className:"chat__form",inputs:[j],onSubmit:E,children:(0,_.jsxs)("div",{className:"chat__input-container",children:[(0,_.jsx)(i.A,{className:"chat__input",input:j,id:"chat-".concat((0,v.Yv)(s.title||"")),name:"chat",placeholder:"Type message",onKeyDown:L}),(0,_.jsxs)(r.A,{className:"chat__control",type:"button",title:"Copy chat",onClick:R,children:[(0,_.jsx)(o.I.Copy,{}),(0,_.jsx)("span",{className:"sr-only",children:"Copy chat"})]}),(0,_.jsx)(r.A,{className:"chat__btn chat-btn",type:"submit",disabled:C,children:C?(0,_.jsx)(u.A,{}):(0,_.jsx)(o.I.Arrow,{})})]})})]})})})})};s.d(t,["A",0,g])},4225(e,t,s){var a=s(9379),l=s(5544),n=s(7565),r=s(6515),c=s(5823),i=s(3173),o=s(2865),d=s(4358),u=s(3983),h=s(2917),m=s(5776),p=s(9482),v=s(7849),x=s(4912),_=s(7929);const f="".concat("https://www.thnk.org/api");const g=function(e){var t;let s=e.ai;const g=(0,m.f)().data,j=(0,p.o)().isMobile,b=(0,x.M)("",e=>!(0,v.Im)(e)),y=(0,n.useState)([]),N=(0,l.A)(y,2),w=N[0],k=N[1],A=(0,n.useState)(!1),C=(0,l.A)(A,2),I=C[0],S=C[1],T=(0,n.useRef)(null),D=(0,h.M)().setAlert,M=(0,n.useCallback)(e=>{if(e)switch(e.type){case"start":k(t=>[{id:e.id,text:"",role:"assistant",created_at:(new Date).toLocaleString()},...t]);break;case"text":k(t=>{const s=t.map(e=>(0,a.A)({},e));if(s.length){var l;const t=0;return null!==(l=s[t])&&void 0!==l&&l.text||(s[t].text=""),s[t].text+=(null===e||void 0===e?void 0:e.text)||"",s}return s})}},[]),E=(0,n.useCallback)(async e=>{if(!I){var t,a;if(j)null===(t=b.ref)||void 0===t||null===(a=t.current)||void 0===a||a.blur();S(!0),null!==T&&void 0!==T&&T.current&&(T.current.scrollTop=T.current.scrollHeight),e||k(e=>[{id:Date.now().toString(),text:b.value,role:"user",created_at:(new Date).toLocaleString()},...e]);try{var l,n;b.setValue("");const t=null===(n=(await fetch("".concat(f,"/ai_chat/vertex/stream-message"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s.model||(null===g||void 0===g||null===(l=g.generalData)||void 0===l?void 0:l.vertexModel),systemInstructions:s.systemPrompt||"",generationConfig:{maxOutputTokens:s.maxTokens||1e3,temperature:s.temperature||0},message:e||b.value,history:[...w].reverse().map(e=>({role:e.role,parts:[{text:e.text}]}))})})).body)||void 0===n?void 0:n.getReader();if(!t)return;const a=new TextDecoder;let c="";for(;;)try{const e=await t.read(),s=e.done,l=e.value;if(s)break;c+=a.decode(l,{stream:!0});const n=c.split("\n");c=n.pop();for(const t of n)if(t.trim()){const e=JSON.parse(t);M(e)}if(c.trim()){const e=JSON.parse(c);if(e.error||500===e.statusCode)throw new Error}}catch(r){throw new Error}S(!1)}catch(r){S(!1),k(e=>[{id:Date.now().toString(),text:"This AI coach is currently experiencing technical difficulties. Please try again in a few minutes. If the issue persists, contact [[email protected]](mailto:[email protected]).",role:"assistant",created_at:(new Date).toLocaleStr
1ing()},...e])}}},[I,j,b,s.model,s.systemPrompt,s.maxTokens,s.temperature,w,M,null===g||void 0===g||null===(t=g.generalData)||void 0===t?void 0:t.vertexModel]),R=(0,n.useCallback)(()=>{const e=[...w].reverse().map(e=>"".concat((0,v.ZH)(e.role),": ").concat(e.text)).join("\n");navigator.clipboard.writeText(e),D({message:"Chat copied to clipboard"})},[w,D]);(0,n.useEffect)(()=>{s.initialMsg&&E(s.initialMsg)},[]),(0,n.useEffect)(()=>{null!==T&&void 0!==T&&T.current&&(T.current.scrollTop=T.current.scrollHeight)},[w]);const L=(0,n.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),j||e.shiftKey?b.setValue(e=>"".concat(e,"\n")):b.isValid&&E())},[b,j,E]);return(0,_.jsx)("div",{className:"chat",children:s?(0,_.jsx)("div",{className:"chat__container",children:(0,_.jsx)("div",{className:"chat__content",children:(0,_.jsxs)("div",{className:"chat__chat",children:[(0,_.jsx)("div",{className:"chat__header",children:s.title?(0,_.jsx)("h2",{className:"h3",children:s.title}):null}),(0,_.jsx)("div",{className:"chat__messages",ref:T,children:null===w||void 0===w?void 0:w.map(e=>(0,_.jsx)("div",{className:"chat__message-container".concat("user"===e.role?" chat__message-container--user":""),children:(0,_.jsx)(d.A,{className:"chat__message body-regular markdown",children:e.text.replaceAll("\u2022","-")})},e.id))}),(0,_.jsx)(c.A,{className:"chat__form",inputs:[b],onSubmit:E,children:(0,_.jsxs)("div",{className:"chat__input-container",children:[(0,_.jsx)(i.A,{className:"chat__input",input:b,
1id:"chat-".concat((0,v.Yv)(s.title||"")),name:"chat",placeholder:"Type message",onKeyDown:L}),(0,_.jsxs)(r.A,{className:"chat__control",type:"button",title:"Copy chat",onClick:R,children:[(0,_.jsx)(o.I.Copy,{}),(0,_.jsx)("span",{className:"sr-only",children:"Copy chat"})]}),(0,_.jsx)(r.A,{className:"chat__btn chat-btn",type:"submit",disabled:I,children:I?(0,_.jsx)(u.A,{}):(0,_.jsx)(o.I.Arrow,{})})]})})]})})}):null})};s.d(t,["A",0,g])}}]); 2//# sourceMappingURL=1524.be08af3a.chunk.js.map
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.