chatbot-interface-ifi 1.2.2 → 1.2.4
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.
|
@@ -91,5 +91,5 @@ const theme2 = createTheme({ palette: {
|
|
|
91
91
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[Jo]=this[Jo]={accessors:{}}).accessors,o=this.prototype;function s(i){const c=$t(i);n[c]||(bl(o,i),n[c]=!0)}return b.isArray(t)?t.forEach(s):s(t),this}}Se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(Se.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),b.freezeMethods(Se);function tn(e,t){const r=this||kt,n=t||r,o=Se.from(n.headers);let s=n.data;return b.forEach(e,function(c){s=c.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Xo(e){return!!(e&&e.__CANCEL__)}function st(e,t,r){q.call(this,e??"canceled",q.ERR_CANCELED,t,r),this.name="CanceledError"}b.inherits(st,q,{__CANCEL__:!0});function Qo(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new q("Request failed with status code "+r.status,[q.ERR_BAD_REQUEST,q.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function xl(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function vl(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(h){const u=Date.now(),l=n[s];i||(i=u),r[o]=h,n[o]=u;let p=s,m=0;for(;p!==o;)m+=r[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const E=l&&u-l;return E?Math.round(m*1e3/E):void 0}}function El(e,t){let r=0,n=1e3/t,o,s;const i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),e.apply(null,u)};return[(...u)=>{const l=Date.now(),p=l-r;p>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-p)))},()=>o&&i(o)]}const hr=(e,t,r=3)=>{let n=0;const o=vl(50,250);return El(s=>{const i=s.loaded,c=s.lengthComputable?s.total:void 0,h=i-n,u=o(h),l=i<=c;n=i;const p={loaded:i,total:c,progress:c?i/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},r)},Zo=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},es=e=>(...t)=>b.asap(()=>e(...t)),Sl=be.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,be.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(be.origin),be.navigator&&/(msie|trident)/i.test(be.navigator.userAgent)):()=>!0,wl=be.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const i=[e+"="+encodeURIComponent(t)];b.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),b.isString(n)&&i.push("path="+n),b.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Rl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _l(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ts(e,t){return e&&!Rl(t)?_l(e,t):t}const rs=e=>e instanceof Se?{...e}:e;function Ye(e,t){t=t||{};const r={};function n(u,l,p,m){return b.isPlainObject(u)&&b.isPlainObject(l)?b.merge.call({caseless:m},u,l):b.isPlainObject(l)?b.merge({},l):b.isArray(l)?l.slice():l}function o(u,l,p,m){if(b.isUndefined(l)){if(!b.isUndefined(u))return n(void 0,u,p,m)}else return n(u,l,p,m)}function s(u,l){if(!b.isUndefined(l))return n(void 0,l)}function i(u,l){if(b.isUndefined(l)){if(!b.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function c(u,l,p){if(p in t)return n(u,l);if(p in e)return n(void 0,u)}const h={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,p)=>o(rs(u),rs(l),p,!0)};return b.forEach(Object.keys(Object.assign({},e,t)),function(l){const p=h[l]||o,m=p(e[l],t[l],l);b.isUndefined(m)&&p!==c||(r[l]=m)}),r}const ns=e=>{const t=Ye({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:c}=t;t.headers=i=Se.from(i),t.url=Ho(ts(t.baseURL,t.url),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let h;if(b.isFormData(r)){if(be.hasStandardBrowserEnv||be.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((h=i.getContentType())!==!1){const[u,...l]=h?h.split(";").map(p=>p.trim()).filter(Boolean):[];i.setContentType([u||"multipart/form-data",...l].join("; "))}}if(be.hasStandardBrowserEnv&&(n&&b.isFunction(n)&&(n=n(t)),n||n!==!1&&Sl(t.url))){const u=o&&s&&wl.read(s);u&&i.set(o,u)}return t},Tl=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=ns(e);let s=o.data;const i=Se.from(o.headers).normalize();let{responseType:c,onUploadProgress:h,onDownloadProgress:u}=o,l,p,m,E,y;function a(){E&&E(),y&&y(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function _(){if(!g)return;const j=Se.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),S={data:!c||c==="text"||c==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:j,config:e,request:g};Qo(function(d){r(d),a()},function(d){n(d),a()},S),g=null}"onloadend"in g?g.onloadend=_:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(_)},g.onabort=function(){g&&(n(new q("Request aborted",q.ECONNABORTED,e,g)),g=null)},g.onerror=function(){n(new q("Network Error",q.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let F=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||Go;o.timeoutErrorMessage&&(F=o.timeoutErrorMessage),n(new q(F,S.clarifyTimeoutError?q.ETIMEDOUT:q.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&b.forEach(i.toJSON(),function(F,S){g.setRequestHeader(S,F)}),b.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),c&&c!=="json"&&(g.responseType=o.responseType),u&&([m,y]=hr(u,!0),g.addEventListener("progress",m)),h&&g.upload&&([p,E]=hr(h),g.upload.addEventListener("progress",p),g.upload.addEventListener("loadend",E)),(o.cancelToken||o.signal)&&(l=j=>{g&&(n(!j||j.type?new st(null,e,g):j),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const $=xl(o.url);if($&&be.protocols.indexOf($)===-1){n(new q("Unsupported protocol "+$+":",q.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ol=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,c();const l=u instanceof Error?u:this.reason;n.abort(l instanceof q?l:new st(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,s(new q(`timeout ${t} of ms exceeded`,q.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:h}=n;return h.unsubscribe=()=>b.asap(c),h}},Cl=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},Al=async function*(e,t){for await(const r of Pl(e))yield*Cl(r,t)},Pl=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},os=(e,t,r,n)=>{const o=Al(e,t);let s=0,i,c=h=>{i||(i=!0,n&&n(h))};return new ReadableStream({async pull(h){try{const{done:u,value:l}=await o.next();if(u){c(),h.close();return}let p=l.byteLength;if(r){let m=s+=p;r(m)}h.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(h){return c(h),o.return()}},{highWaterMark:2})},mr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ss=mr&&typeof ReadableStream=="function",jl=mr&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),is=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kl=ss&&is(()=>{let e=!1;const t=new Request(be.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),as=64*1024,rn=ss&&is(()=>b.isReadableStream(new Response("").body)),yr={stream:rn&&(e=>e.body)};mr&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!yr[t]&&(yr[t]=b.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new q(`Response type '${t}' is not supported`,q.ERR_NOT_SUPPORT,n)})})})(new Response);const $l=async e=>{if(e==null)return 0;if(b.isBlob(e))return e.size;if(b.isSpecCompliantForm(e))return(await new Request(be.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(b.isArrayBufferView(e)||b.isArrayBuffer(e))return e.byteLength;if(b.isURLSearchParams(e)&&(e=e+""),b.isString(e))return(await jl(e)).byteLength},Il=async(e,t)=>{const r=b.toFiniteNumber(e.getContentLength());return r??$l(t)},nn={http:tl,xhr:Tl,fetch:mr&&(async e=>{let{url:t,method:r,data:n,signal:o,cancelToken:s,timeout:i,onDownloadProgress:c,onUploadProgress:h,responseType:u,headers:l,withCredentials:p="same-origin",fetchOptions:m}=ns(e);u=u?(u+"").toLowerCase():"text";let E=Ol([o,s&&s.toAbortSignal()],i),y;const a=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let g;try{if(h&&kl&&r!=="get"&&r!=="head"&&(g=await Il(l,n))!==0){let S=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(b.isFormData(n)&&(V=S.headers.get("content-type"))&&l.setContentType(V),S.body){const[d,R]=Zo(g,hr(es(h)));n=os(S.body,as,d,R)}}b.isString(p)||(p=p?"include":"omit");const _="credentials"in Request.prototype;y=new Request(t,{...m,signal:E,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:_?p:void 0});let $=await fetch(y);const j=rn&&(u==="stream"||u==="response");if(rn&&(c||j&&a)){const S={};["status","statusText","headers"].forEach(w=>{S[w]=$[w]});const V=b.toFiniteNumber($.headers.get("content-length")),[d,R]=c&&Zo(V,hr(es(c),!0))||[];$=new Response(os($.body,as,d,()=>{R&&R(),a&&a()}),S)}u=u||"text";let F=await yr[b.findKey(yr,u)||"text"]($,e);return!j&&a&&a(),await new Promise((S,V)=>{Qo(S,V,{data:F,headers:Se.from($.headers),status:$.status,statusText:$.statusText,config:e,request:y})})}catch(_){throw a&&a(),_&&_.name==="TypeError"&&/fetch/i.test(_.message)?Object.assign(new q("Network Error",q.ERR_NETWORK,e,y),{cause:_.cause||_}):q.from(_,_&&_.code,e,y)}})};b.forEach(nn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const cs=e=>`- ${e}`,Nl=e=>b.isFunction(e)||e===null||e===!1,us={getAdapter:e=>{e=b.isArray(e)?e:[e];const{length:t}=e;let r,n;const o={};for(let s=0;s<t;s++){r=e[s];let i;if(n=r,!Nl(r)&&(n=nn[(i=String(r)).toLowerCase()],n===void 0))throw new q(`Unknown adapter '${i}'`);if(n)break;o[i||"#"+s]=n}if(!n){const s=Object.entries(o).map(([c,h])=>`adapter ${c} `+(h===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since :
|
|
92
92
|
`+s.map(cs).join(`
|
|
93
93
|
`):" "+cs(s[0]):"as no adapter specified";throw new q("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:nn};function on(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new st(null,e)}function ls(e){return on(e),e.headers=Se.from(e.headers),e.data=tn.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),us.getAdapter(e.adapter||kt.adapter)(e).then(function(n){return on(e),n.data=tn.call(e,e.transformResponse,n),n.headers=Se.from(n.headers),n},function(n){return Xo(n)||(on(e),n&&n.response&&(n.response.data=tn.call(e,e.transformResponse,n.response),n.response.headers=Se.from(n.response.headers))),Promise.reject(n)})}const fs="1.7.9",gr={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{gr[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const ds={};gr.transitional=function(t,r,n){function o(s,i){return"[Axios v"+fs+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,c)=>{if(t===!1)throw new q(o(i," has been removed"+(r?" in "+r:"")),q.ERR_DEPRECATED);return r&&!ds[i]&&(ds[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,c):!0}},gr.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Dl(e,t,r){if(typeof e!="object")throw new q("options must be an object",q.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const c=e[s],h=c===void 0||i(c,s,e);if(h!==!0)throw new q("option "+s+" must be "+h,q.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new q("Unknown option "+s,q.ERR_BAD_OPTION)}}const br={assertOptions:Dl,validators:gr},Me=br.validators;class Ge{constructor(t){this.defaults=t,this.interceptors={request:new Yo,response:new Yo}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
94
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ye(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&br.assertOptions(n,{silentJSONParsing:Me.transitional(Me.boolean),forcedJSONParsing:Me.transitional(Me.boolean),clarifyTimeoutError:Me.transitional(Me.boolean)},!1),o!=null&&(b.isFunction(o)?r.paramsSerializer={serialize:o}:br.assertOptions(o,{encode:Me.function,serialize:Me.function},!0)),br.assertOptions(r,{baseUrl:Me.spelling("baseURL"),withXsrfToken:Me.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&b.merge(s.common,s[r.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),r.headers=Se.concat(i,s);const c=[];let h=!0;this.interceptors.request.forEach(function(a){typeof a.runWhen=="function"&&a.runWhen(r)===!1||(h=h&&a.synchronous,c.unshift(a.fulfilled,a.rejected))});const u=[];this.interceptors.response.forEach(function(a){u.push(a.fulfilled,a.rejected)});let l,p=0,m;if(!h){const y=[ls.bind(this),void 0];for(y.unshift.apply(y,c),y.push.apply(y,u),m=y.length,l=Promise.resolve(r);p<m;)l=l.then(y[p++],y[p++]);return l}m=c.length;let E=r;for(p=0;p<m;){const y=c[p++],a=c[p++];try{E=y(E)}catch(g){a.call(this,g);break}}try{l=ls.call(this,E)}catch(y){return Promise.reject(y)}for(p=0,m=u.length;p<m;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=Ye(this.defaults,t);const r=ts(t.baseURL,t.url);return Ho(r,t.params,t.paramsSerializer)}}b.forEach(["delete","get","head","options"],function(t){Ge.prototype[t]=function(r,n){return this.request(Ye(n||{},{method:t,url:r,data:(n||{}).data}))}}),b.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,c){return this.request(Ye(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Ge.prototype[t]=r(),Ge.prototype[t+"Form"]=r(!0)});class sn{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new st(s,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new sn(function(o){t=o}),cancel:t}}}function Fl(e){return function(r){return e.apply(null,r)}}function Ml(e){return b.isObject(e)&&e.isAxiosError===!0}const an={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(an).forEach(([e,t])=>{an[t]=e});function ps(e){const t=new Ge(e),r=Po(Ge.prototype.request,t);return b.extend(r,Ge.prototype,t,{allOwnKeys:!0}),b.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return ps(Ye(e,o))},r}const ae=ps(kt);ae.Axios=Ge,ae.CanceledError=st,ae.CancelToken=sn,ae.isCancel=Xo,ae.VERSION=fs,ae.toFormData=dr,ae.AxiosError=q,ae.Cancel=ae.CanceledError,ae.all=function(t){return Promise.all(t)},ae.spread=Fl,ae.isAxiosError=Ml,ae.mergeConfig=Ye,ae.AxiosHeaders=Se,ae.formToJSON=e=>Ko(b.isHTMLForm(e)?new FormData(e):e),ae.getAdapter=us.getAdapter,ae.HttpStatusCode=an,ae.default=ae;const Bl=async e=>{const t=new FormData;t.append("chatbot_id",e);try{const r=await ae.post("https://rag-flask-api.onrender.com/start_conversation",t,{headers:{"Content-Type":"multipart/form-data"}}),{conversation_id:n,intro_message:o}=r.data;if(!n)throw new Error("Failed to retrieve conversation ID from server.");return{conversationId:n,introMessage:o}}catch(r){throw console.error("Error starting conversation:",r),r}},Ll=async(e,t,r)=>{const n=new FormData;n.append("chatbot_id",e),n.append("conversation_id",t),n.append("question",r);try{return(await ae.post("https://rag-flask-api.onrender.com/ask",n,{headers:{"Content-Type":"multipart/form-data"}})).data}catch(o){throw console.error("Error sending message:",o),o}},hs=async(e,t)=>{const r=new FormData;r.append("chatbot_id",e),r.append("conversation_id",t);try{await ae.post("https://rag-flask-api.onrender.com/end_conversation",r,{headers:{"Content-Type":"multipart/form-data"}})}catch(n){throw console.error("Error ending conversation:",n),n}},ql=async e=>{try{const t=await ae.get(`https://rag-flask-api.onrender.com/summary/${e}`);if(t.status===200&&t.data.summary)return t.data.summary;throw new Error("Summary not found for this chatbot.")}catch(t){throw console.error("Error fetching summary:",t),t}},zl=async(e,t,r,n=[])=>{try{const o=await ae.post("https://rag-flask-api.onrender.com/generate_guided_questions",{chatbot_id:e,current_question:t,current_answer:r,conversation_history:n},{headers:{"Content-Type":"application/json"}});if(o.data.success&&o.data.guided_questions)return o.data.guided_questions;throw new Error(o.data.error||"Failed to generate guided questions.")}catch(o){throw console.error("Error generating guided questions:",o),o}},Ul=({chatbotId:e,open:t,onClose:r})=>{const[n,o]=ee.useState(null),[s,i]=ee.useState(!1),[c,h]=ee.useState(null),u=async()=>{i(!0),h(null);try{const l=await ql(e);o(l)}catch(l){h(l.message||"Failed to fetch summary. Please try again.")}finally{i(!1)}};return ee.useEffect(()=>{t&&u()},[t]),v.jsx(T.Modal,{open:t,onClose:r,"aria-labelledby":"summary-modal-title","aria-describedby":"summary-modal-description",children:v.jsxs(T.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"80%",maxWidth:600,bgcolor:"background.paper",borderRadius:4,boxShadow:24,p:4},children:[v.jsxs(T.Box,{sx:{display:"flex",justifyContent:"space-between",mb:2},children:[v.jsx(T.Typography,{id:"summary-modal-title",variant:"h6",component:"h2",children:"Document Summary"}),v.jsx(T.IconButton,{onClick:r,children:v.jsx(mu,{})})]}),s?v.jsx(T.Box,{sx:{display:"flex",justifyContent:"center",my:4},children:v.jsx(T.CircularProgress,{})}):c?v.jsx(T.Typography,{color:"error",children:c}):v.jsx(T.Box,{sx:{maxHeight:300,overflowY:"auto",padding:2,border:"1px solid #ddd",borderRadius:2,backgroundColor:"#f9f9f9"},children:v.jsx(cn,{children:n})}),v.jsx(T.Button,{variant:"contained",sx:{mt:2},onClick:r,fullWidth:!0,children:"Close"})]})})};var It={},ms;function Vl(){if(ms)return It;ms=1;var e=ve();Object.defineProperty(It,"__esModule",{value:!0}),It.default=void 0;var t=e(je()),r=Re();return It.default=(0,t.default)((0,r.jsx)("path",{d:"M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"}),"KeyboardArrowDownRounded"),It}var Wl=Vl();const ys=xe(Wl);var Nt={},gs;function Hl(){if(gs)return Nt;gs=1;var e=ve();Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.default=void 0;var t=e(je()),r=Re();return Nt.default=(0,t.default)((0,r.jsx)("path",{d:"M8.12 14.71 12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71a.9959.9959 0 0 0-1.41 0L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.38 1.03.39 1.42 0"}),"KeyboardArrowUpRounded"),Nt}var Yl=Hl();const bs=xe(Yl),Gl=({questions:e,loading:t,onQuestionClick:r})=>{const[n,o]=ee.useState(!1),[s,i]=ee.useState(!1);if(t)return v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:1,px:2,mx:2,mb:1},children:[v.jsx(So,{sx:{fontSize:"0.9rem",color:"#0B53C0",animation:"spin 2s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",color:"#0B53C0",fontSize:"0.8rem",fontWeight:500},children:"Thinking of follow-up questions..."})]});if(!e||e.length===0)return null;const c=e[0],h=e.slice(1),u=h.length>0;return v.jsxs(T.Box,{sx:{px:2,pb:1,pt:.5},children:[v.jsxs(T.Box,{onClick:()=>o(!n),sx:{display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#CDDAFF",borderRadius:"10px",py:.75,px:1.25,cursor:"pointer","&:hover":{backgroundColor:"#b8c9f7"}},children:[v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[v.jsx(So,{sx:{fontSize:"0.9rem",color:"#0B53C0"}}),v.jsxs(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",color:"#0B53C0",fontSize:"0.8rem",fontWeight:600},children:["Suggested follow-ups (",e.length,")"]})]}),v.jsx(T.Box,{sx:{display:"flex",alignItems:"center",color:"#0B53C0"},children:n?v.jsx(bs,{sx:{fontSize:"1.2rem"}}):v.jsx(ys,{sx:{fontSize:"1.2rem"}})})]}),n&&v.jsxs(T.Box,{sx:{mt:1,display:"flex",flexDirection:"column",gap:.75},children:[v.jsx(T.Box,{onClick:()=>r(c),sx:{backgroundColor:"white",border:"1px solid #CDDAFF",borderRadius:"10px",py:1,px:1.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#CDDAFF",borderColor:"#0B53C0",transform:"translateX(4px)"}},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#333",lineHeight:1.4},children:c})}),u&&s&&h.map((l,p)=>v.jsx(T.Box,{onClick:()=>r(l),sx:{backgroundColor:"white",border:"1px solid #CDDAFF",borderRadius:"10px",py:1,px:1.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#CDDAFF",borderColor:"#0B53C0",transform:"translateX(4px)"}},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#333",lineHeight:1.4},children:l})},p)),u&&v.jsxs(T.Box,{onClick:()=>i(!s),sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.5,cursor:"pointer",borderRadius:"8px","&:hover":{backgroundColor:"rgba(11, 83, 192, 0.05)"}},children:[s?v.jsx(bs,{sx:{fontSize:"1rem",color:"#0B53C0"}}):v.jsx(ys,{sx:{fontSize:"1rem",color:"#0B53C0"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.75rem",color:"#0B53C0",fontWeight:600},children:s?"Show less":`Show ${h.length} more`})]})]})]})},Kl=ee.forwardRef(({chatbotId:e,onConversationStart:t,enableGuidedQuestions:r=!1,customToggleButton:n=null},o)=>{const[s,i]=ee.useState(!1),[c,h]=ee.useState(!1),[u,l]=ee.useState(()=>{const W=localStorage.getItem("responses");return W?JSON.parse(W):[]}),[p,m]=ee.useState(()=>localStorage.getItem("conversationId")||null),[E,y]=ee.useState(!1),[a,g]=ee.useState(null),[_,$]=ee.useState(!1),[j,F]=ee.useState(r),[S,V]=ee.useState([]),[d,R]=ee.useState(!1),w=T.useMediaQuery("(max-width:600px)"),C=T.useMediaQuery("(min-width:601px) and (max-width:960px)"),M=ee.useRef(null);ee.useEffect(()=>{typeof t=="function"&&p&&t(p)},[p,t]),ee.useEffect(()=>{M.current&&M.current.scrollIntoView({behavior:"smooth"})},[u]),ee.useEffect(()=>{const W=f=>{f.key==="Escape"&&c&&h(!1)};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[c]);const H=async()=>{i(W=>!W),c&&h(!1),!s&&!p&&!E&&Y()},Y=async()=>{if(!p){y(!0),g(null);try{const W=await Bl(e),{conversationId:f,introMessage:x}=W;m(f),localStorage.setItem("conversationId",f),l(O=>{const P=[...O,{id:"intro",sender:"chatbot",text:x}];return localStorage.setItem("responses",JSON.stringify(P)),P})}catch(W){console.error("Error starting conversation:",W),g("Failed to start a conversation. Please try again.")}finally{y(!1)}}},oe=async(W,f=p)=>{g(null),V([]),l(x=>{const O=[...x,{question:W,answer:null}];return localStorage.setItem("responses",JSON.stringify(O)),O}),y(!0);try{const O=(await Ll(e,f,W)).answer;l(P=>{const I=[...P];return I[I.length-1]={question:W,answer:O},localStorage.setItem("responses",JSON.stringify(I)),I}),j&&G(W,O)}catch(x){console.error("Error sending message:",x),g("Failed to send the message. Please try again."),l(O=>{const P=O.slice(0,-1);return localStorage.setItem("responses",JSON.stringify(P)),P})}finally{y(!1)}},G=async(W,f)=>{R(!0);try{const x=u.filter(P=>P.question&&P.answer).map(P=>({question:P.question,answer:P.answer})),O=await zl(e,W,f,x);V(O)}catch(x){console.error("Error fetching guided questions:",x)}finally{R(!1)}},K=W=>{V([]),oe(W)},ce=async()=>{y(!0),g(null);try{p&&await hs(e,p),m(null),l([]),V([]),localStorage.removeItem("conversationId"),localStorage.removeItem("responses"),await Y()}catch(W){console.error("Error ending conversation:",W),g("Failed to end the conversation. Please try again.")}finally{y(!1)}},Ie=async()=>{y(!0),g(null);try{p&&await hs(e,p),m(null),l([]),V([]),localStorage.removeItem("conversationId"),localStorage.removeItem("responses")}catch(W){console.error("Error clearing conversation:",W),g("Failed to clear the conversation. Please try again.")}finally{y(!1),Y()}};return ee.useImperativeHandle(o,()=>({endConversation:ce})),v.jsx(v.Fragment,{children:s?v.jsxs(v.Fragment,{children:[c&&v.jsx(T.Box,{onClick:()=>h(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1299}}),v.jsxs(T.Paper,{elevation:0,sx:Wr.chatContainer(w,C,c),children:[v.jsxs(T.Box,{sx:{backgroundColor:"#CDDAFF",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[v.jsx(T.Box,{sx:{width:36,height:36,borderRadius:"50%",backgroundColor:"#0B53C0",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx(xo,{sx:{color:"white",fontSize:"1.25rem"}})}),v.jsxs(T.Box,{children:[v.jsx(T.Typography,{sx:Wr.chatHeader,children:"PAT"}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",color:"#555",marginTop:"-2px"},children:"Personalized Academic Tutor"})]})]}),v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[v.jsx(T.Tooltip,{title:"Toggle AI-suggested follow-up questions",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5,backgroundColor:"rgba(11, 83, 192, 0.1)",borderRadius:"20px",pl:1,pr:.5,py:.25},children:[v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600,color:"#0B53C0"},children:"Suggestions"}),v.jsx(T.Switch,{checked:j,onChange:W=>F(W.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#0B53C0",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16},"& .MuiSwitch-track":{borderRadius:10,backgroundColor:"rgba(11, 83, 192, 0.3)",opacity:1}}})]})}),p&&u.length>0&&v.jsx(T.Tooltip,{title:"View a summary of this conversation",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{onClick:()=>$(!0),sx:{display:"flex",alignItems:"center",gap:.5,color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",borderRadius:"16px",px:1,py:.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:[v.jsx(ou,{sx:{fontSize:"0.9rem"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600},children:"Summary"})]})}),p&&v.jsx(T.Tooltip,{title:"Start a new conversation",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{onClick:Ie,sx:{display:"flex",alignItems:"center",gap:.5,color:"#dc2626",backgroundColor:"rgba(220, 38, 38, 0.1)",borderRadius:"16px",px:1,py:.5,cursor:E?"not-allowed":"pointer",opacity:E?.5:1,transition:"all 0.2s ease","&:hover":{backgroundColor:E?"rgba(220, 38, 38, 0.1)":"#dc2626",color:E?"#dc2626":"white"}},children:[v.jsx(tu,{sx:{fontSize:"0.9rem"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600},children:"New Chat"})]})}),v.jsx(T.Tooltip,{title:c?"Exit fullscreen (Esc)":"Fullscreen",arrow:!0,placement:"bottom",children:v.jsx(T.IconButton,{onClick:()=>h(!c),sx:{color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",width:32,height:32,"&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:c?v.jsx(Qc,{sx:{fontSize:"1rem"}}):v.jsx(Kc,{sx:{fontSize:"1rem"}})})}),v.jsx(T.IconButton,{onClick:H,sx:{color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",width:32,height:32,"&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:v.jsx(Vc,{sx:{fontSize:"1.1rem"}})})]})]}),E&&v.jsx(T.LinearProgress,{sx:{height:3,backgroundColor:"rgba(205, 218, 255, 0.5)","& .MuiLinearProgress-bar":{backgroundColor:"#0B53C0"}}}),v.jsx(cu,{responses:u,messagesEndRef:M,loading:E}),j&&v.jsx(Gl,{questions:S,loading:d,onQuestionClick:K}),a&&v.jsx(T.Box,{sx:{mx:2,mb:1,p:1.5,backgroundColor:"#fef2f2",borderRadius:"10px",border:"1px solid #fecaca"},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#dc2626"},children:a})}),v.jsx(du,{onSendMessage:oe,onStartConversation:Y,onEndConversation:ce,conversationId:p}),v.jsx(Ul,{chatbotId:e,open:_,onClose:()=>$(!1)})]})]}):n?v.jsx(T.Box,{onClick:H,sx:{cursor:"pointer"},children:n}):v.jsx(T.IconButton,{onClick:H,sx:Wr.chatToggleButton,children:v.jsx(xo,{sx:{fontSize:"1.75rem"}})})})});ke.ChatbotInterface=Kl,Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"})});
|
|
94
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ye(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&br.assertOptions(n,{silentJSONParsing:Me.transitional(Me.boolean),forcedJSONParsing:Me.transitional(Me.boolean),clarifyTimeoutError:Me.transitional(Me.boolean)},!1),o!=null&&(b.isFunction(o)?r.paramsSerializer={serialize:o}:br.assertOptions(o,{encode:Me.function,serialize:Me.function},!0)),br.assertOptions(r,{baseUrl:Me.spelling("baseURL"),withXsrfToken:Me.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&b.merge(s.common,s[r.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),r.headers=Se.concat(i,s);const c=[];let h=!0;this.interceptors.request.forEach(function(a){typeof a.runWhen=="function"&&a.runWhen(r)===!1||(h=h&&a.synchronous,c.unshift(a.fulfilled,a.rejected))});const u=[];this.interceptors.response.forEach(function(a){u.push(a.fulfilled,a.rejected)});let l,p=0,m;if(!h){const y=[ls.bind(this),void 0];for(y.unshift.apply(y,c),y.push.apply(y,u),m=y.length,l=Promise.resolve(r);p<m;)l=l.then(y[p++],y[p++]);return l}m=c.length;let E=r;for(p=0;p<m;){const y=c[p++],a=c[p++];try{E=y(E)}catch(g){a.call(this,g);break}}try{l=ls.call(this,E)}catch(y){return Promise.reject(y)}for(p=0,m=u.length;p<m;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=Ye(this.defaults,t);const r=ts(t.baseURL,t.url);return Ho(r,t.params,t.paramsSerializer)}}b.forEach(["delete","get","head","options"],function(t){Ge.prototype[t]=function(r,n){return this.request(Ye(n||{},{method:t,url:r,data:(n||{}).data}))}}),b.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,c){return this.request(Ye(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Ge.prototype[t]=r(),Ge.prototype[t+"Form"]=r(!0)});class sn{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new st(s,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new sn(function(o){t=o}),cancel:t}}}function Fl(e){return function(r){return e.apply(null,r)}}function Ml(e){return b.isObject(e)&&e.isAxiosError===!0}const an={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(an).forEach(([e,t])=>{an[t]=e});function ps(e){const t=new Ge(e),r=Po(Ge.prototype.request,t);return b.extend(r,Ge.prototype,t,{allOwnKeys:!0}),b.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return ps(Ye(e,o))},r}const ae=ps(kt);ae.Axios=Ge,ae.CanceledError=st,ae.CancelToken=sn,ae.isCancel=Xo,ae.VERSION=fs,ae.toFormData=dr,ae.AxiosError=q,ae.Cancel=ae.CanceledError,ae.all=function(t){return Promise.all(t)},ae.spread=Fl,ae.isAxiosError=Ml,ae.mergeConfig=Ye,ae.AxiosHeaders=Se,ae.formToJSON=e=>Ko(b.isHTMLForm(e)?new FormData(e):e),ae.getAdapter=us.getAdapter,ae.HttpStatusCode=an,ae.default=ae;const Bl=async e=>{const t=new FormData;t.append("chatbot_id",e);try{const r=await ae.post("https://rag-flask-api.onrender.com/start_conversation",t,{headers:{"Content-Type":"multipart/form-data"}}),{conversation_id:n,intro_message:o}=r.data;if(!n)throw new Error("Failed to retrieve conversation ID from server.");return{conversationId:n,introMessage:o}}catch(r){throw console.error("Error starting conversation:",r),r}},Ll=async(e,t,r)=>{const n=new FormData;n.append("chatbot_id",e),n.append("conversation_id",t),n.append("question",r);try{return(await ae.post("https://rag-flask-api.onrender.com/ask",n,{headers:{"Content-Type":"multipart/form-data"}})).data}catch(o){throw console.error("Error sending message:",o),o}},hs=async(e,t)=>{const r=new FormData;r.append("chatbot_id",e),r.append("conversation_id",t);try{await ae.post("https://rag-flask-api.onrender.com/end_conversation",r,{headers:{"Content-Type":"multipart/form-data"}})}catch(n){throw console.error("Error ending conversation:",n),n}},ql=async(e,t)=>{const r=new FormData;r.append("chatbot_id",e),r.append("conversation_id",t);try{const n=await ae.post("https://rag-flask-api.onrender.com/summary",r,{headers:{"Content-Type":"multipart/form-data"}});if(n.status===200&&n.data.summary)return n.data.summary;throw new Error("Summary not found for this conversation.")}catch(n){throw console.error("Error fetching summary:",n),n}},zl=async(e,t,r,n=[])=>{try{const o=await ae.post("https://rag-flask-api.onrender.com/generate_guided_questions",{chatbot_id:e,current_question:t,current_answer:r,conversation_history:n},{headers:{"Content-Type":"application/json"}});if(o.data.success&&o.data.guided_questions)return o.data.guided_questions;throw new Error(o.data.error||"Failed to generate guided questions.")}catch(o){throw console.error("Error generating guided questions:",o),o}},Ul=({chatbotId:e,conversationId:t,open:r,onClose:n})=>{const[o,s]=ee.useState(null),[i,c]=ee.useState(!1),[h,u]=ee.useState(null),l=async()=>{if(!t){u("No active conversation to summarize.");return}c(!0),u(null);try{const p=await ql(e,t);s(p)}catch(p){u(p.message||"Failed to fetch summary. Please try again.")}finally{c(!1)}};return ee.useEffect(()=>{r&&l()},[r]),v.jsx(T.Modal,{open:r,onClose:n,"aria-labelledby":"summary-modal-title","aria-describedby":"summary-modal-description",children:v.jsxs(T.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"80%",maxWidth:600,bgcolor:"background.paper",borderRadius:4,boxShadow:24,p:4},children:[v.jsxs(T.Box,{sx:{display:"flex",justifyContent:"space-between",mb:2},children:[v.jsx(T.Typography,{id:"summary-modal-title",variant:"h6",component:"h2",children:"Document Summary"}),v.jsx(T.IconButton,{onClick:n,children:v.jsx(mu,{})})]}),i?v.jsx(T.Box,{sx:{display:"flex",justifyContent:"center",my:4},children:v.jsx(T.CircularProgress,{})}):h?v.jsx(T.Typography,{color:"error",children:h}):v.jsx(T.Box,{sx:{maxHeight:300,overflowY:"auto",padding:2,border:"1px solid #ddd",borderRadius:2,backgroundColor:"#f9f9f9"},children:v.jsx(cn,{children:o})}),v.jsx(T.Button,{variant:"contained",sx:{mt:2},onClick:n,fullWidth:!0,children:"Close"})]})})};var It={},ms;function Vl(){if(ms)return It;ms=1;var e=ve();Object.defineProperty(It,"__esModule",{value:!0}),It.default=void 0;var t=e(je()),r=Re();return It.default=(0,t.default)((0,r.jsx)("path",{d:"M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"}),"KeyboardArrowDownRounded"),It}var Wl=Vl();const ys=xe(Wl);var Nt={},gs;function Hl(){if(gs)return Nt;gs=1;var e=ve();Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.default=void 0;var t=e(je()),r=Re();return Nt.default=(0,t.default)((0,r.jsx)("path",{d:"M8.12 14.71 12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71a.9959.9959 0 0 0-1.41 0L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.38 1.03.39 1.42 0"}),"KeyboardArrowUpRounded"),Nt}var Yl=Hl();const bs=xe(Yl),Gl=({questions:e,loading:t,onQuestionClick:r})=>{const[n,o]=ee.useState(!1),[s,i]=ee.useState(!1);if(t)return v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:1,px:2,mx:2,mb:1},children:[v.jsx(So,{sx:{fontSize:"0.9rem",color:"#0B53C0",animation:"spin 2s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",color:"#0B53C0",fontSize:"0.8rem",fontWeight:500},children:"Thinking of follow-up questions..."})]});if(!e||e.length===0)return null;const c=e[0],h=e.slice(1),u=h.length>0;return v.jsxs(T.Box,{sx:{px:2,pb:1,pt:.5},children:[v.jsxs(T.Box,{onClick:()=>o(!n),sx:{display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#CDDAFF",borderRadius:"10px",py:.75,px:1.25,cursor:"pointer","&:hover":{backgroundColor:"#b8c9f7"}},children:[v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[v.jsx(So,{sx:{fontSize:"0.9rem",color:"#0B53C0"}}),v.jsxs(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",color:"#0B53C0",fontSize:"0.8rem",fontWeight:600},children:["Suggested follow-ups (",e.length,")"]})]}),v.jsx(T.Box,{sx:{display:"flex",alignItems:"center",color:"#0B53C0"},children:n?v.jsx(bs,{sx:{fontSize:"1.2rem"}}):v.jsx(ys,{sx:{fontSize:"1.2rem"}})})]}),n&&v.jsxs(T.Box,{sx:{mt:1,display:"flex",flexDirection:"column",gap:.75},children:[v.jsx(T.Box,{onClick:()=>r(c),sx:{backgroundColor:"white",border:"1px solid #CDDAFF",borderRadius:"10px",py:1,px:1.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#CDDAFF",borderColor:"#0B53C0",transform:"translateX(4px)"}},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#333",lineHeight:1.4},children:c})}),u&&s&&h.map((l,p)=>v.jsx(T.Box,{onClick:()=>r(l),sx:{backgroundColor:"white",border:"1px solid #CDDAFF",borderRadius:"10px",py:1,px:1.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#CDDAFF",borderColor:"#0B53C0",transform:"translateX(4px)"}},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#333",lineHeight:1.4},children:l})},p)),u&&v.jsxs(T.Box,{onClick:()=>i(!s),sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.5,cursor:"pointer",borderRadius:"8px","&:hover":{backgroundColor:"rgba(11, 83, 192, 0.05)"}},children:[s?v.jsx(bs,{sx:{fontSize:"1rem",color:"#0B53C0"}}):v.jsx(ys,{sx:{fontSize:"1rem",color:"#0B53C0"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.75rem",color:"#0B53C0",fontWeight:600},children:s?"Show less":`Show ${h.length} more`})]})]})]})},Kl=ee.forwardRef(({chatbotId:e,onConversationStart:t,enableGuidedQuestions:r=!1,customToggleButton:n=null},o)=>{const[s,i]=ee.useState(!1),[c,h]=ee.useState(!1),[u,l]=ee.useState(()=>{const W=localStorage.getItem("responses");return W?JSON.parse(W):[]}),[p,m]=ee.useState(()=>localStorage.getItem("conversationId")||null),[E,y]=ee.useState(!1),[a,g]=ee.useState(null),[_,$]=ee.useState(!1),[j,F]=ee.useState(r),[S,V]=ee.useState([]),[d,R]=ee.useState(!1),w=T.useMediaQuery("(max-width:600px)"),C=T.useMediaQuery("(min-width:601px) and (max-width:960px)"),M=ee.useRef(null);ee.useEffect(()=>{typeof t=="function"&&p&&t(p)},[p,t]),ee.useEffect(()=>{M.current&&M.current.scrollIntoView({behavior:"smooth"})},[u]),ee.useEffect(()=>{const W=f=>{f.key==="Escape"&&c&&h(!1)};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[c]);const H=async()=>{i(W=>!W),c&&h(!1),!s&&!p&&!E&&Y()},Y=async()=>{if(!p){y(!0),g(null);try{const W=await Bl(e),{conversationId:f,introMessage:x}=W;m(f),localStorage.setItem("conversationId",f),l(O=>{const P=[...O,{id:"intro",sender:"chatbot",text:x}];return localStorage.setItem("responses",JSON.stringify(P)),P})}catch(W){console.error("Error starting conversation:",W),g("Failed to start a conversation. Please try again.")}finally{y(!1)}}},oe=async(W,f=p)=>{g(null),V([]),l(x=>{const O=[...x,{question:W,answer:null}];return localStorage.setItem("responses",JSON.stringify(O)),O}),y(!0);try{const O=(await Ll(e,f,W)).answer;l(P=>{const I=[...P];return I[I.length-1]={question:W,answer:O},localStorage.setItem("responses",JSON.stringify(I)),I}),j&&G(W,O)}catch(x){console.error("Error sending message:",x),g("Failed to send the message. Please try again."),l(O=>{const P=O.slice(0,-1);return localStorage.setItem("responses",JSON.stringify(P)),P})}finally{y(!1)}},G=async(W,f)=>{R(!0);try{const x=u.filter(P=>P.question&&P.answer).map(P=>({question:P.question,answer:P.answer})),O=await zl(e,W,f,x);V(O)}catch(x){console.error("Error fetching guided questions:",x)}finally{R(!1)}},K=W=>{V([]),oe(W)},ce=async()=>{y(!0),g(null);try{p&&await hs(e,p),m(null),l([]),V([]),localStorage.removeItem("conversationId"),localStorage.removeItem("responses"),await Y()}catch(W){console.error("Error ending conversation:",W),g("Failed to end the conversation. Please try again.")}finally{y(!1)}},Ie=async()=>{y(!0),g(null);try{p&&await hs(e,p),m(null),l([]),V([]),localStorage.removeItem("conversationId"),localStorage.removeItem("responses")}catch(W){console.error("Error clearing conversation:",W),g("Failed to clear the conversation. Please try again.")}finally{y(!1),Y()}};return ee.useImperativeHandle(o,()=>({endConversation:ce})),v.jsx(v.Fragment,{children:s?v.jsxs(v.Fragment,{children:[c&&v.jsx(T.Box,{onClick:()=>h(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1299}}),v.jsxs(T.Paper,{elevation:0,sx:Wr.chatContainer(w,C,c),children:[v.jsxs(T.Box,{sx:{backgroundColor:"#CDDAFF",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[v.jsx(T.Box,{sx:{width:36,height:36,borderRadius:"50%",backgroundColor:"#0B53C0",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx(xo,{sx:{color:"white",fontSize:"1.25rem"}})}),v.jsxs(T.Box,{children:[v.jsx(T.Typography,{sx:Wr.chatHeader,children:"PAT"}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",color:"#555",marginTop:"-2px"},children:"Personalized Academic Tutor"})]})]}),v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[v.jsx(T.Tooltip,{title:"Toggle AI-suggested follow-up questions",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{sx:{display:"flex",alignItems:"center",gap:.5,backgroundColor:"rgba(11, 83, 192, 0.1)",borderRadius:"20px",pl:1,pr:.5,py:.25},children:[v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600,color:"#0B53C0"},children:"Suggestions"}),v.jsx(T.Switch,{checked:j,onChange:W=>F(W.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#0B53C0",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16},"& .MuiSwitch-track":{borderRadius:10,backgroundColor:"rgba(11, 83, 192, 0.3)",opacity:1}}})]})}),p&&u.length>0&&v.jsx(T.Tooltip,{title:"View a summary of this conversation",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{onClick:()=>$(!0),sx:{display:"flex",alignItems:"center",gap:.5,color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",borderRadius:"16px",px:1,py:.5,cursor:"pointer",transition:"all 0.2s ease","&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:[v.jsx(ou,{sx:{fontSize:"0.9rem"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600},children:"Summary"})]})}),p&&v.jsx(T.Tooltip,{title:"Start a new conversation",arrow:!0,placement:"bottom",children:v.jsxs(T.Box,{onClick:Ie,sx:{display:"flex",alignItems:"center",gap:.5,color:"#dc2626",backgroundColor:"rgba(220, 38, 38, 0.1)",borderRadius:"16px",px:1,py:.5,cursor:E?"not-allowed":"pointer",opacity:E?.5:1,transition:"all 0.2s ease","&:hover":{backgroundColor:E?"rgba(220, 38, 38, 0.1)":"#dc2626",color:E?"#dc2626":"white"}},children:[v.jsx(tu,{sx:{fontSize:"0.9rem"}}),v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.7rem",fontWeight:600},children:"New Chat"})]})}),v.jsx(T.Tooltip,{title:c?"Exit fullscreen (Esc)":"Fullscreen",arrow:!0,placement:"bottom",children:v.jsx(T.IconButton,{onClick:()=>h(!c),sx:{color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",width:32,height:32,"&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:c?v.jsx(Qc,{sx:{fontSize:"1rem"}}):v.jsx(Kc,{sx:{fontSize:"1rem"}})})}),v.jsx(T.IconButton,{onClick:H,sx:{color:"#0B53C0",backgroundColor:"rgba(11, 83, 192, 0.1)",width:32,height:32,"&:hover":{backgroundColor:"#0B53C0",color:"white"}},children:v.jsx(Vc,{sx:{fontSize:"1.1rem"}})})]})]}),E&&v.jsx(T.LinearProgress,{sx:{height:3,backgroundColor:"rgba(205, 218, 255, 0.5)","& .MuiLinearProgress-bar":{backgroundColor:"#0B53C0"}}}),v.jsx(cu,{responses:u,messagesEndRef:M,loading:E}),j&&v.jsx(Gl,{questions:S,loading:d,onQuestionClick:K}),a&&v.jsx(T.Box,{sx:{mx:2,mb:1,p:1.5,backgroundColor:"#fef2f2",borderRadius:"10px",border:"1px solid #fecaca"},children:v.jsx(T.Typography,{sx:{fontFamily:"Gabarito, Arial, sans-serif",fontSize:"0.85rem",color:"#dc2626"},children:a})}),v.jsx(du,{onSendMessage:oe,onStartConversation:Y,onEndConversation:ce,conversationId:p}),v.jsx(Ul,{chatbotId:e,conversationId:p,open:_,onClose:()=>$(!1)})]})]}):n?v.jsx(T.Box,{onClick:H,sx:{cursor:"pointer"},children:n}):v.jsx(T.IconButton,{onClick:H,sx:Wr.chatToggleButton,children:v.jsx(xo,{sx:{fontSize:"1.75rem"}})})})});ke.ChatbotInterface=Kl,Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"})});
|
|
95
95
|
//# sourceMappingURL=chatbot-interface.umd.js.map
|