react-aichatbot-widget 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +6 -11
- package/dist/index.js +894 -746
- package/package.json +1 -1
- package/dist/style.css +0 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
"use strict";const m=require("react/jsx-runtime"),N=require("react"),M=require("lucide-react"),wt=require("uuid"),gt=({onClick:e})=>m.jsxs("button",{onClick:e,"aria-label":"Open chat support",className:"fixed bottom-8 right-8 z-50 w-14 h-14 bg-gradient-to-br from-sky-500 to-sky-600 hover:from-sky-600 hover:to-sky-700 text-white rounded-full shadow-2xl flex items-center justify-center transition-all duration-300 hover:scale-110 focus:outline-none focus:ring-4 focus:ring-sky-400/50",children:[m.jsx(M.MessageCircle,{size:30,strokeWidth:2.2}),m.jsx("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-emerald-400 rounded-full border-2 border-white animate-pulse shadow-lg"})]}),xt=({onSendMessage:e,isLoading:t})=>{const[n,r]=N.useState(""),s=()=>{!n.trim()||t||(e(n.trim()),r(""))},i=o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),s())};return m.jsx("div",{className:"p-4 border-t bg-white flex-shrink-0",children:m.jsxs("div",{className:"flex gap-3",children:[m.jsx("input",{type:"text",placeholder:"Type a message...",value:n,onChange:o=>r(o.target.value),onKeyPress:i,disabled:t,className:"flex-1 px-4 py-3 border border-neutral-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent transition-shadow placeholder-neutral-400 text-sm disabled:opacity-50 disabled:cursor-not-allowed"}),m.jsx("button",{onClick:s,disabled:t||!n.trim(),className:"bg-sky-600 hover:bg-sky-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-5 py-3 rounded-xl font-medium transition-colors shadow-md hover:shadow-lg flex items-center gap-2","aria-label":"Send message",children:m.jsx(M.Send,{size:18})})]})})},Et=({messages:e,isLoading:t})=>{const n=N.useRef(null),r=()=>{var s;(s=n.current)==null||s.scrollIntoView({behavior:"smooth"})};return N.useEffect(()=>{r()},[e,t]),m.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4 bg-neutral-50",children:[e.map((s,i)=>m.jsx("div",{className:`flex ${s.type==="user"?"justify-end":""}`,children:m.jsx("div",{className:`px-4 py-3 rounded-2xl shadow-sm border border-neutral-200 max-w-[80%] text-sm leading-relaxed ${s.type==="user"?"bg-sky-600 text-white rounded-br-none":"bg-white text-neutral-800 rounded-bl-none"}`,children:s.text})},i)),t&&m.jsx("div",{className:"flex",children:m.jsx("div",{className:"bg-white text-neutral-800 px-4 py-3 rounded-2xl rounded-bl-none shadow-sm border border-neutral-200 max-w-[80%] text-sm leading-relaxed",children:m.jsx(M.Ellipsis,{className:"animate-pulse"})})}),m.jsx("div",{ref:n})]})};function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:St}=Object.prototype,{getPrototypeOf:xe}=Object,{iterator:ie,toStringTag:We}=Symbol,ae=(e=>t=>{const n=St.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),F=e=>(e=e.toLowerCase(),t=>ae(t)===e),le=e=>t=>typeof t===e,{isArray:z}=Array,$=le("undefined");function K(e){return e!==null&&!$(e)&&e.constructor!==null&&!$(e.constructor)&&T(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=F("ArrayBuffer");function Rt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Ot=le("string"),T=le("function"),Xe=le("number"),X=e=>e!==null&&typeof e=="object",Tt=e=>e===!0||e===!1,ne=e=>{if(ae(e)!=="object")return!1;const t=xe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(We in e)&&!(ie in e)},At=e=>{if(!X(e)||K(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Nt=F("Date"),Ct=F("File"),jt=F("Blob"),Pt=F("FileList"),Ft=e=>X(e)&&T(e.pipe),kt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||T(e.append)&&((t=ae(e))==="formdata"||t==="object"&&T(e.toString)&&e.toString()==="[object FormData]"))},Ut=F("URLSearchParams"),[_t,Lt,Dt,Bt]=["ReadableStream","Request","Response","Headers"].map(F),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function G(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),z(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(K(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let l;for(r=0;r<o;r++)l=i[r],t.call(null,e[l],l,e)}}function Ge(e,t){if(K(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qe=e=>!$(e)&&e!==q;function be(){const{caseless:e,skipUndefined:t}=Qe(this)&&this||{},n={},r=(s,i)=>{const o=e&&Ge(n,i)||i;ne(n[o])&&ne(s)?n[o]=be(n[o],s):ne(s)?n[o]=be({},s):z(s)?n[o]=s.slice():(!t||!$(s))&&(n[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&G(arguments[s],r);return n}const It=(e,t,n,{allOwnKeys:r}={})=>(G(t,(s,i)=>{n&&T(s)?e[i]=Ve(s,n):e[i]=s},{allOwnKeys:r}),e),vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ht=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Mt=(e,t,n,r)=>{let s,i,o;const l={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!l[o]&&(t[o]=e[o],l[o]=!0);e=n!==!1&&xe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},zt=e=>{if(!e)return null;if(z(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xe(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[ie]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Wt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Kt=F("HTMLFormElement"),Xt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Pe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Gt=F("RegExp"),Ze=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};G(n,(s,i)=>{let o;(o=t(s,i,e))!==!1&&(r[i]=o||s)}),Object.defineProperties(e,r)},Qt=e=>{Ze(e,(t,n)=>{if(T(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(T(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Zt=(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return z(e)?r(e):r(String(e).split(t)),n},Yt=()=>{},en=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function tn(e){return!!(e&&T(e.append)&&e[We]==="FormData"&&e[ie])}const nn=e=>{const t=new Array(10),n=(r,s)=>{if(X(r)){if(t.indexOf(r)>=0)return;if(K(r))return r;if(!("toJSON"in r)){t[s]=r;const i=z(r)?[]:{};return G(r,(o,l)=>{const f=n(o,s+1);!$(f)&&(i[l]=f)}),t[s]=void 0,i}}return r};return n(e,0)},rn=F("AsyncFunction"),sn=e=>e&&(X(e)||T(e))&&T(e.then)&&T(e.catch),Ye=((e,t)=>e?setImmediate:t?((n,r)=>(q.addEventListener("message",({source:s,data:i})=>{s===q&&i===n&&r.length&&r.shift()()},!1),s=>{r.push(s),q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",T(q.postMessage)),on=typeof queueMicrotask<"u"?queueMicrotask.bind(q):typeof process<"u"&&process.nextTick||Ye,an=e=>e!=null&&T(e[ie]),a={isArray:z,isArrayBuffer:Ke,isBuffer:K,isFormData:kt,isArrayBufferView:Rt,isString:Ot,isNumber:Xe,isBoolean:Tt,isObject:X,isPlainObject:ne,isEmptyObject:At,isReadableStream:_t,isRequest:Lt,isResponse:Dt,isHeaders:Bt,isUndefined:$,isDate:Nt,isFile:Ct,isBlob:jt,isRegExp:Gt,isFunction:T,isStream:Ft,isURLSearchParams:Ut,isTypedArray:Jt,isFileList:Pt,forEach:G,merge:be,extend:It,trim:qt,stripBOM:vt,inherits:Ht,toFlatObject:Mt,kindOf:ae,kindOfTest:F,endsWith:$t,toArray:zt,forEachEntry:Vt,matchAll:Wt,isHTMLForm:Kt,hasOwnProperty:Pe,hasOwnProp:Pe,reduceDescriptors:Ze,freezeMethods:Qt,toObjectSet:Zt,toCamelCase:Xt,noop:Yt,toFiniteNumber:en,findKey:Ge,global:q,isContextDefined:Qe,isSpecCompliantForm:tn,toJSONObject:nn,isAsyncFn:rn,isThenable:sn,setImmediate:Ye,asap:on,isIterable:an};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const et=y.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}});Object.defineProperties(y,tt);Object.defineProperty(et,"isAxiosError",{value:!0});y.from=(e,t,n,r,s,i)=>{const o=Object.create(et);a.toFlatObject(e,o,function(c){return c!==Error.prototype},u=>u!=="isAxiosError");const l=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return y.call(o,l,f,n,r,s),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",i&&Object.assign(o,i),o};const ln=null;function ye(e){return a.isPlainObject(e)||a.isArray(e)}function nt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Fe(e,t,n){return e?e.concat(t).map(function(s,i){return s=nt(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function cn(e){return a.isArray(e)&&!e.some(ye)}const un=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function ce(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,h){return!a.isUndefined(h[b])});const r=n.metaTokens,s=n.visitor||c,i=n.dots,o=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(a.isBoolean(d))return d.toString();if(!f&&a.isBlob(d))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,b,h){let E=d;if(d&&!h&&typeof d=="object"){if(a.endsWith(b,"{}"))b=r?b:b.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&cn(d)||(a.isFileList(d)||a.endsWith(b,"[]"))&&(E=a.toArray(d)))return b=nt(b),E.forEach(function(S,O){!(a.isUndefined(S)||S===null)&&t.append(o===!0?Fe([b],O,i):o===null?b:b+"[]",u(S))}),!1}return ye(d)?!0:(t.append(Fe(h,b,i),u(d)),!1)}const p=[],w=Object.assign(un,{defaultVisitor:c,convertValue:u,isVisitable:ye});function g(d,b){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+b.join("."));p.push(d),a.forEach(d,function(E,C){(!(a.isUndefined(E)||E===null)&&s.call(t,E,a.isString(C)?C.trim():C,b,w))===!0&&g(E,b?b.concat(C):[C])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}function ke(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ee(e,t){this._pairs=[],e&&ce(e,this,t)}const rt=Ee.prototype;rt.append=function(t,n){this._pairs.push([t,n])};rt.toString=function(t){const n=t?function(r){return t.call(this,r,ke)}:ke;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function dn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||dn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let i;if(s?i=s(t,n):i=a.isURLSearchParams(t)?t.toString():new Ee(t,n).toString(r),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Ue{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:Ee,hn=typeof FormData<"u"?FormData:null,pn=typeof Blob<"u"?Blob:null,mn={isBrowser:!0,classes:{URLSearchParams:fn,FormData:hn,Blob:pn},protocols:["http","https","file","blob","url","data"]},Se=typeof window<"u"&&typeof document<"u",we=typeof navigator=="object"&&navigator||void 0,bn=Se&&(!we||["ReactNative","NativeScript","NS"].indexOf(we.product)<0),yn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wn=Se&&window.location.href||"http://localhost",gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Se,hasStandardBrowserEnv:bn,hasStandardBrowserWebWorkerEnv:yn,navigator:we,origin:wn},Symbol.toStringTag,{value:"Module"})),R={...gn,...mn};function xn(e,t){return ce(e,new R.classes.URLSearchParams,{visitor:function(n,r,s,i){return R.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function En(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sn(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],t[i]=e[i];return t}function it(e){function t(n,r,s,i){let o=n[i++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),f=i>=n.length;return o=!o&&a.isArray(s)?s.length:o,f?(a.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!l):((!s[o]||!a.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&a.isArray(s[o])&&(s[o]=Sn(s[o])),!l)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(En(r),s,n,0)}),n}return null}function Rn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Q={transitional:ot,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(it(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return xn(t,this.formSerializer).toString();if((l=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return ce(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),Rn(t)):t}],transformResponse:[function(t){const n=this.transitional||Q.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(l){if(o)throw l.name==="SyntaxError"?y.from(l,y.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{Q.headers[e]={}});const On=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Tn=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[_e]=this[_e]={accessors:{}}).accessors,s=this.prototype;function i(o){const l=W(o);r[l]||(jn(s,o),r[l]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(A.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(A);function pe(e,t){const n=this||Q,r=t||n,s=A.from(r.headers);let i=r.data;return a.forEach(e,function(l){i=l.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function at(e){return!!(e&&e.__CANCEL__)}function J(e,t,n){y.call(this,e??"canceled",y.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(J,y,{__CANCEL__:!0});function lt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Pn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(f){const u=Date.now(),c=r[i];o||(o=u),n[s]=f,r[s]=u;let p=i,w=0;for(;p!==s;)w+=n[p++],p=p%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-o<t)return;const g=c&&u-c;return g?Math.round(w*1e3/g):void 0}}function kn(e,t){let n=0,r=1e3/t,s,i;const o=(u,c=Date.now())=>{n=c,s=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const c=Date.now(),p=c-n;p>=r?o(u,c):(s=u,i||(i=setTimeout(()=>{i=null,o(s)},r-p)))},()=>s&&o(s)]}const oe=(e,t,n=3)=>{let r=0;const s=Fn(50,250);return kn(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,f=o-r,u=s(f),c=o<=l;r=o;const p={loaded:o,total:l,progress:l?o/l:void 0,bytes:f,rate:u||void 0,estimated:u&&l&&c?(l-o)/u:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(p)},n)},Le=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},De=e=>(...t)=>a.asap(()=>e(...t)),Un=R.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,R.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(R.origin),R.navigator&&/(msie|trident)/i.test(R.navigator.userAgent)):()=>!0,_n=R.hasStandardBrowserEnv?{write(e,t,n,r,s,i,o){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&l.push(`path=${r}`),a.isString(s)&&l.push(`domain=${s}`),i===!0&&l.push("secure"),a.isString(o)&&l.push(`SameSite=${o}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ln(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ct(e,t,n){let r=!Ln(t);return e&&(r||n==!1)?Dn(e,t):t}const Be=e=>e instanceof A?{...e}:e;function v(e,t){t=t||{};const n={};function r(u,c,p,w){return a.isPlainObject(u)&&a.isPlainObject(c)?a.merge.call({caseless:w},u,c):a.isPlainObject(c)?a.merge({},c):a.isArray(c)?c.slice():c}function s(u,c,p,w){if(a.isUndefined(c)){if(!a.isUndefined(u))return r(void 0,u,p,w)}else return r(u,c,p,w)}function i(u,c){if(!a.isUndefined(c))return r(void 0,c)}function o(u,c){if(a.isUndefined(c)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,c)}function l(u,c,p){if(p in t)return r(u,c);if(p in e)return r(void 0,u)}const f={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(u,c,p)=>s(Be(u),Be(c),p,!0)};return a.forEach(Object.keys({...e,...t}),function(c){const p=f[c]||s,w=p(e[c],t[c],c);a.isUndefined(w)&&p!==l||(n[c]=w)}),n}const ut=e=>{const t=v({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:l}=t;if(t.headers=o=A.from(o),t.url=st(ct(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),a.isFormData(n)){if(R.hasStandardBrowserEnv||R.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const f=n.getHeaders(),u=["content-type","content-length"];Object.entries(f).forEach(([c,p])=>{u.includes(c.toLowerCase())&&o.set(c,p)})}}if(R.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Un(t.url))){const f=s&&i&&_n.read(i);f&&o.set(s,f)}return t},Bn=typeof XMLHttpRequest<"u",qn=Bn&&function(e){return new Promise(function(n,r){const s=ut(e);let i=s.data;const o=A.from(s.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:u}=s,c,p,w,g,d;function b(){g&&g(),d&&d(),s.cancelToken&&s.cancelToken.unsubscribe(c),s.signal&&s.signal.removeEventListener("abort",c)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function E(){if(!h)return;const S=A.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),P={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:S,config:e,request:h};lt(function(j){n(j),b()},function(j){r(j),b()},P),h=null}"onloadend"in h?h.onloadend=E:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(E)},h.onabort=function(){h&&(r(new y("Request aborted",y.ECONNABORTED,e,h)),h=null)},h.onerror=function(O){const P=O&&O.message?O.message:"Network Error",D=new y(P,y.ERR_NETWORK,e,h);D.event=O||null,r(D),h=null},h.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const P=s.transitional||ot;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new y(O,P.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,h)),h=null},i===void 0&&o.setContentType(null),"setRequestHeader"in h&&a.forEach(o.toJSON(),function(O,P){h.setRequestHeader(P,O)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),l&&l!=="json"&&(h.responseType=s.responseType),u&&([w,d]=oe(u,!0),h.addEventListener("progress",w)),f&&h.upload&&([p,g]=oe(f),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",g)),(s.cancelToken||s.signal)&&(c=S=>{h&&(r(!S||S.type?new J(null,e,h):S),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(c),s.signal&&(s.signal.aborted?c():s.signal.addEventListener("abort",c)));const C=Pn(s.url);if(C&&R.protocols.indexOf(C)===-1){r(new y("Unsupported protocol "+C+":",y.ERR_BAD_REQUEST,e));return}h.send(i||null)})},In=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const i=function(u){if(!s){s=!0,l();const c=u instanceof Error?u:this.reason;r.abort(c instanceof y?c:new J(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,i(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const l=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:f}=r;return f.unsubscribe=()=>a.asap(l),f}},vn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Hn=async function*(e,t){for await(const n of Mn(e))yield*vn(n,t)},Mn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},qe=(e,t,n,r)=>{const s=Hn(e,t);let i=0,o,l=f=>{o||(o=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:u,value:c}=await s.next();if(u){l(),f.close();return}let p=c.byteLength;if(n){let w=i+=p;n(w)}f.enqueue(new Uint8Array(c))}catch(u){throw l(u),u}},cancel(f){return l(f),s.return()}},{highWaterMark:2})},Ie=64*1024,{isFunction:te}=a,$n=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:ve,TextEncoder:He}=a.global,Me=(e,...t)=>{try{return!!e(...t)}catch{return!1}},zn=e=>{e=a.merge.call({skipUndefined:!0},$n,e);const{fetch:t,Request:n,Response:r}=e,s=t?te(t):typeof fetch=="function",i=te(n),o=te(r);if(!s)return!1;const l=s&&te(ve),f=s&&(typeof He=="function"?(d=>b=>d.encode(b))(new He):async d=>new Uint8Array(await new n(d).arrayBuffer())),u=i&&l&&Me(()=>{let d=!1;const b=new n(R.origin,{body:new ve,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!b}),c=o&&l&&Me(()=>a.isReadableStream(new r("").body)),p={stream:c&&(d=>d.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!p[d]&&(p[d]=(b,h)=>{let E=b&&b[d];if(E)return E.call(b);throw new y(`Response type '${d}' is not supported`,y.ERR_NOT_SUPPORT,h)})});const w=async d=>{if(d==null)return 0;if(a.isBlob(d))return d.size;if(a.isSpecCompliantForm(d))return(await new n(R.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(a.isArrayBufferView(d)||a.isArrayBuffer(d))return d.byteLength;if(a.isURLSearchParams(d)&&(d=d+""),a.isString(d))return(await f(d)).byteLength},g=async(d,b)=>{const h=a.toFiniteNumber(d.getContentLength());return h??w(b)};return async d=>{let{url:b,method:h,data:E,signal:C,cancelToken:S,timeout:O,onDownloadProgress:P,onUploadProgress:D,responseType:j,headers:de,withCredentials:Z="same-origin",fetchOptions:Oe}=ut(d),Te=t||fetch;j=j?(j+"").toLowerCase():"text";let Y=In([C,S&&S.toAbortSignal()],O),V=null;const B=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let Ae;try{if(D&&u&&h!=="get"&&h!=="head"&&(Ae=await g(de,E))!==0){let L=new n(b,{method:"POST",body:E,duplex:"half"}),H;if(a.isFormData(E)&&(H=L.headers.get("content-type"))&&de.setContentType(H),L.body){const[fe,ee]=Le(Ae,oe(De(D)));E=qe(L.body,Ie,fe,ee)}}a.isString(Z)||(Z=Z?"include":"omit");const k=i&&"credentials"in n.prototype,Ne={...Oe,signal:Y,method:h.toUpperCase(),headers:de.normalize().toJSON(),body:E,duplex:"half",credentials:k?Z:void 0};V=i&&new n(b,Ne);let _=await(i?Te(V,Oe):Te(b,Ne));const Ce=c&&(j==="stream"||j==="response");if(c&&(P||Ce&&B)){const L={};["status","statusText","headers"].forEach(je=>{L[je]=_[je]});const H=a.toFiniteNumber(_.headers.get("content-length")),[fe,ee]=P&&Le(H,oe(De(P),!0))||[];_=new r(qe(_.body,Ie,fe,()=>{ee&&ee(),B&&B()}),L)}j=j||"text";let yt=await p[a.findKey(p,j)||"text"](_,d);return!Ce&&B&&B(),await new Promise((L,H)=>{lt(L,H,{data:yt,headers:A.from(_.headers),status:_.status,statusText:_.statusText,config:d,request:V})})}catch(k){throw B&&B(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,d,V),{cause:k.cause||k}):y.from(k,k&&k.code,d,V)}}},Jn=new Map,dt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,i=[r,s,n];let o=i.length,l=o,f,u,c=Jn;for(;l--;)f=i[l],u=c.get(f),u===void 0&&c.set(f,u=l?new Map:zn(t)),c=u;return u};dt();const Re={http:ln,xhr:qn,fetch:{get:dt}};a.forEach(Re,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const $e=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Wn(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const i={};for(let o=0;o<n;o++){r=e[o];let l;if(s=r,!Vn(r)&&(s=Re[(l=String(r)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${l}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;i[l||"#"+o]=s}if(!s){const o=Object.entries(i).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build"));let l=n?o.length>1?`since :
|
|
4
|
-
`+
|
|
5
|
-
`):" "
|
|
6
|
-
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=v(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&se.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:se.assertOptions(s,{encode:U.function,serialize:U.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),se.assertOptions(n,{baseUrl:U.spelling("baseURL"),withXsrfToken:U.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),n.headers=A.concat(o,i);const l=[];let f=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(f=f&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let c,p=0,w;if(!f){const d=[ze.bind(this),void 0];for(d.unshift(...l),d.push(...u),w=d.length,c=Promise.resolve(n);p<w;)c=c.then(d[p++],d[p++]);return c}w=l.length;let g=n;for(;p<w;){const d=l[p++],b=l[p++];try{g=d(g)}catch(h){b.call(this,h);break}}try{c=ze.call(this,g)}catch(d){return Promise.reject(d)}for(p=0,w=u.length;p<w;)c=c.then(u[p++],u[p++]);return c}getUri(t){t=v(this.defaults,t);const n=ct(t.baseURL,t.url,t.allowAbsoluteUrls);return st(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){I.prototype[t]=function(n,r){return this.request(v(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,l){return this.request(v(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}I.prototype[t]=n(),I.prototype[t+"Form"]=n(!0)});let Xn=class pt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{r.subscribe(l),i=l}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,l){r.reason||(r.reason=new J(i,o,l),n(r.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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new pt(function(s){t=s}),cancel:t}}};function Gn(e){return function(n){return e.apply(null,n)}}function Qn(e){return a.isObject(e)&&e.isAxiosError===!0}const ge={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ge).forEach(([e,t])=>{ge[t]=e});function mt(e){const t=new I(e),n=Ve(I.prototype.request,t);return a.extend(n,I.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return mt(v(e,s))},n}const x=mt(Q);x.Axios=I;x.CanceledError=J;x.CancelToken=Xn;x.isCancel=at;x.VERSION=ht;x.toFormData=ce;x.AxiosError=y;x.Cancel=x.CanceledError;x.all=function(t){return Promise.all(t)};x.spread=Gn;x.isAxiosError=Qn;x.mergeConfig=v;x.AxiosHeaders=A;x.formToJSON=e=>it(a.isHTMLForm(e)?new FormData(e):e);x.getAdapter=ft.getAdapter;x.HttpStatusCode=ge;x.default=x;const{Axios:rr,AxiosError:sr,CanceledError:or,isCancel:ir,CancelToken:ar,VERSION:lr,all:cr,Cancel:ur,isAxiosError:dr,spread:fr,toFormData:hr,AxiosHeaders:pr,HttpStatusCode:mr,formToJSON:br,getAdapter:yr,mergeConfig:wr}=x,bt=async(e,t,n,r)=>{const s={chatInput:e,sessionId:t,metadata:{pinecone_namespace:n}};try{return(await x.post(r,s,{headers:{"Content-Type":"application/json"}})).data.output}catch(i){throw console.error("Error communicating with chat API:",i),i}},Zn=({handleMessageFromForm:e,sessionId:t,pineconeNamespace:n,chatbotHostURL:r})=>{const[s,i]=N.useState(""),[o,l]=N.useState(""),[f,u]=N.useState(""),[c,p]=N.useState(!1),w=async g=>{if(g.preventDefault(),p(!0),u(""),!s.trim()||!o.trim()){u("Name and email are required");return}const d=`Hi, I am ${s} and my email is ${o}`;try{const h=(await bt(d,t,n,r)).response;e([{type:"user",text:d},{type:"bot",text:h}])}catch(b){console.log("error sending user details",b),u("Failed to submit. Please try again.")}finally{p(!1)}i(""),l("")};return m.jsx("div",{className:"p-5 border-t bg-white flex-shrink-0",children:m.jsxs("form",{onSubmit:w,className:"flex flex-col gap-6",children:[f&&m.jsx("div",{className:"bg-red-100 text-neutral-800 p-2 rounded relative text-center text-sm",role:"alert",children:f}),m.jsx("p",{className:"text-neutral-700 text-sm font-medium",children:"Please enter your details to get started."}),m.jsxs("div",{className:"flex flex-col gap-5",children:[m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("label",{className:"text-sm text-neutral-700",children:"Full Name"}),m.jsx("input",{type:"text",placeholder:"Enter your full name",value:s,onChange:g=>{i(g.target.value),u("")},className:"w-full px-3 py-2 border border-neutral-300 rounded-xl bg-neutral-50",required:!0})]}),m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("label",{className:"text-sm text-neutral-700",children:"Email Address"}),m.jsx("input",{type:"email",placeholder:"Enter your email",value:o,onChange:g=>{l(g.target.value),u("")},className:"w-full px-3 py-2 border border-neutral-300 rounded-xl bg-neutral-50",required:!0})]})]}),m.jsx("button",{type:"submit",disabled:!s.trim()||!o.trim()||c,className:`bg-sky-600 hover:bg-sky-700 disabled:opacity-50
|
|
7
|
-
disabled:cursor-not-allowed text-white px-5 py-3
|
|
8
|
-
rounded-xl font-medium flex items-center justify-center gap-2 mt-20`,children:c?"Submitting...":m.jsxs(m.Fragment,{children:[m.jsx(M.Send,{size:18})," Submit"]})})]})})},Yn=({onClose:e,sessionId:t,pineconeNamespace:n,chatbotHostURL:r})=>{const[s,i]=N.useState([]),[o,l]=N.useState(!1),[f,u]=N.useState(!1),c=w=>{i(w),u(!0)},p=async w=>{l(!0),i(g=>[...g,{type:"user",text:w}]);try{const d=(await bt(w,t,n,r)).response;i(b=>[...b,{type:"bot",text:d}])}catch(g){console.error("Chat error:",g),i(d=>[...d,{type:"bot",text:"Sorry, something went wrong."}])}finally{l(!1)}};return m.jsxs("div",{className:`fixed bottom-28 shadow-xl right-8 z-50 w-96 h-[520px] bg-white/90
|
|
9
|
-
backdrop-blur-xl rounded-2xl border border-neutral-100
|
|
10
|
-
flex flex-col overflow-hidden`,children:[m.jsxs("div",{className:`bg-gradient-to-r from-sky-500 to-sky-600 text-white px-5 py-4
|
|
11
|
-
rounded-t-2xl flex items-center justify-between shadow-sm`,children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"w-11 h-11 bg-white/25 rounded-full flex items-center justify-center",children:m.jsx(M.MessageCircle,{size:22})}),m.jsx("span",{className:"absolute bottom-0 right-0 w-3.5 h-3.5 bg-emerald-400 rounded-full border-2 border-white"})]}),m.jsxs("div",{children:[m.jsx("h3",{className:"font-semibold text-lg",children:"Swiggy"}),m.jsx("p",{className:"text-xs opacity-90",children:"Virtual assistance"})]})]}),m.jsx("button",{onClick:e,"aria-label":"Close chat",className:"p-2 hover:bg-white/20 rounded-full",children:m.jsx(M.X,{size:20})})]}),!f&&m.jsx(Zn,{handleMessageFromForm:c,sessionId:t,pineconeNamespace:n,chatbotHostURL:r}),f&&m.jsxs(m.Fragment,{children:[m.jsx(Et,{messages:s,isLoading:o}),m.jsx(xt,{onSendMessage:p,isLoading:o})]}),m.jsx("div",{className:"bg-neutral-50 border-t border-neutral-200 px-5 py-3 text-center",children:m.jsxs("p",{className:"text-[11px] text-neutral-500 tracking-wide",children:["powered by ",m.jsx("span",{className:"font-semibold text-neutral-600",children:"clone67.com"})]})})]})};function er({pineconeNamespace:e,chatbotHostURL:t}){const[n,r]=N.useState(!1),[s,i]=N.useState("");N.useEffect(()=>{const l=wt.v4();i(l)},[]);const o=()=>{r(l=>!l)};return m.jsxs("div",{className:"fixed bottom-7 right-7",children:[n&&m.jsx(Yn,{onClose:o,sessionId:s,pineconeNamespace:e,chatbotHostURL:t}),m.jsx(gt,{onClick:o})]})}module.exports=er;
|
|
1
|
+
"use strict";const b=require("react/jsx-runtime"),N=require("react"),q=require("lucide-react"),gt=require("uuid"),wt=({onClick:e,isOpen:t,theme:n,chatBotData:r})=>{const s=r.position==="left"?"left-8":"right-8",o={background:`linear-gradient(135deg, ${n.primaryColor}, ${n.secondaryColor})`,color:n.fontColor,boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15)"};return b.jsxs("button",{onClick:e,className:`fixed bottom-8 ${s} hover:cursor-pointer pointer-events-auto w-16 h-16 rounded-full shadow-2xl flex items-center justify-center transition-all duration-300 hover:scale-110 focus:outline-none focus:ring-4 focus:ring-offset-2`,style:o,children:[t?b.jsx(q.X,{size:30,strokeWidth:2.5}):b.jsx(q.MessageCircle,{size:30,strokeWidth:2.5}),!t&&b.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-emerald-400 rounded-full border-4 border-white animate-pulse"})]})},xt=({onSendMessage:e,isLoading:t,theme:n})=>{const[r,s]=N.useState(""),o=()=>{!r.trim()||t||(e(r.trim()),s(""))},i=l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),o())};return b.jsx("div",{className:"p-4 border-t border-white flex-shrink-0",style:{background:n.backgroundColor},children:b.jsxs("div",{className:"flex gap-3",children:[b.jsx("input",{type:"text",placeholder:"Type a message...",value:r,onChange:l=>s(l.target.value),onKeyPress:i,disabled:t,className:"flex-1 px-4 py-3 border rounded-xl focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent transition-shadow text-sm disabled:opacity-50 disabled:cursor-not-allowed",style:{background:n.inputBackgroundColor,color:n.fontColor,borderColor:n.fontColor}}),b.jsx("button",{onClick:o,disabled:t||!r.trim(),className:"disabled:opacity-50 disabled:cursor-not-allowed px-5 py-3 rounded-xl font-medium transition-colors flex items-center gap-2 hover:cursor-pointer",style:{background:`linear-gradient(135deg, ${n.primaryColor}, ${n.secondaryColor})`,color:n.fontColor},"aria-label":"Send message",children:b.jsx(q.Send,{size:18})})]})})},Et=({messages:e,isLoading:t,theme:n})=>{const r=N.useRef(null),s=()=>{var o;(o=r.current)==null||o.scrollIntoView({behavior:"smooth"})};return N.useEffect(()=>{s()},[e,t]),b.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4 border-t border-white",style:{background:n.backgroundColor,color:n.fontColor},children:[e.map((o,i)=>b.jsx("div",{className:`flex ${o.type==="user"?"justify-end":""}`,children:b.jsx("div",{className:"px-4 py-3 rounded-2xl shadow-sm border border-neutral-200 max-w-[80%] text-sm leading-relaxed",style:{background:o.type==="user"?n.primaryColor:n.backgroundColor,color:(o.type==="bot",n.fontColor)},children:o.text})},i)),t&&b.jsx("div",{className:"flex",children:b.jsx("div",{className:"px-4 py-3 rounded-2xl rounded-bl-none shadow-sm border border-neutral-200 max-w-[80%] text-sm leading-relaxed",style:{background:n.backgroundColor,color:n.fontColor},children:b.jsx(q.Ellipsis,{className:"animate-pulse"})})}),b.jsx("div",{ref:r})]})};function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:St}=Object.prototype,{getPrototypeOf:xe}=Object,{iterator:ie,toStringTag:We}=Symbol,ae=(e=>t=>{const n=St.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>ae(t)===e),le=e=>t=>typeof t===e,{isArray:z}=Array,M=le("undefined");function K(e){return e!==null&&!M(e)&&e.constructor!==null&&!M(e.constructor)&&T(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=P("ArrayBuffer");function Rt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Ct=le("string"),T=le("function"),Xe=le("number"),X=e=>e!==null&&typeof e=="object",Ot=e=>e===!0||e===!1,ne=e=>{if(ae(e)!=="object")return!1;const t=xe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(We in e)&&!(ie in e)},Tt=e=>{if(!X(e)||K(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},At=P("Date"),Nt=P("File"),jt=P("Blob"),kt=P("FileList"),Pt=e=>X(e)&&T(e.pipe),Ft=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||T(e.append)&&((t=ae(e))==="formdata"||t==="object"&&T(e.toString)&&e.toString()==="[object FormData]"))},Ut=P("URLSearchParams"),[_t,Lt,Bt,Dt]=["ReadableStream","Request","Response","Headers"].map(P),$t=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function G(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),z(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(K(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(r=0;r<i;r++)l=o[r],t.call(null,e[l],l,e)}}function Ge(e,t){if(K(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const $=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qe=e=>!M(e)&&e!==$;function be(){const{caseless:e,skipUndefined:t}=Qe(this)&&this||{},n={},r=(s,o)=>{const i=e&&Ge(n,o)||o;ne(n[i])&&ne(s)?n[i]=be(n[i],s):ne(s)?n[i]=be({},s):z(s)?n[i]=s.slice():(!t||!M(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&G(arguments[s],r);return n}const It=(e,t,n,{allOwnKeys:r}={})=>(G(t,(s,o)=>{n&&T(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),vt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Ht=(e,t,n,r)=>{let s,o,i;const l={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&xe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Mt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},zt=e=>{if(!e)return null;if(z(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xe(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[ie]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Wt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Kt=P("HTMLFormElement"),Xt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),ke=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Gt=P("RegExp"),Ze=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};G(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},Qt=e=>{Ze(e,(t,n)=>{if(T(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(T(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Zt=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return z(e)?r(e):r(String(e).split(t)),n},Yt=()=>{},en=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function tn(e){return!!(e&&T(e.append)&&e[We]==="FormData"&&e[ie])}const nn=e=>{const t=new Array(10),n=(r,s)=>{if(X(r)){if(t.indexOf(r)>=0)return;if(K(r))return r;if(!("toJSON"in r)){t[s]=r;const o=z(r)?[]:{};return G(r,(i,l)=>{const f=n(i,s+1);!M(f)&&(o[l]=f)}),t[s]=void 0,o}}return r};return n(e,0)},rn=P("AsyncFunction"),sn=e=>e&&(X(e)||T(e))&&T(e.then)&&T(e.catch),Ye=((e,t)=>e?setImmediate:t?((n,r)=>($.addEventListener("message",({source:s,data:o})=>{s===$&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),$.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",T($.postMessage)),on=typeof queueMicrotask<"u"?queueMicrotask.bind($):typeof process<"u"&&process.nextTick||Ye,an=e=>e!=null&&T(e[ie]),a={isArray:z,isArrayBuffer:Ke,isBuffer:K,isFormData:Ft,isArrayBufferView:Rt,isString:Ct,isNumber:Xe,isBoolean:Ot,isObject:X,isPlainObject:ne,isEmptyObject:Tt,isReadableStream:_t,isRequest:Lt,isResponse:Bt,isHeaders:Dt,isUndefined:M,isDate:At,isFile:Nt,isBlob:jt,isRegExp:Gt,isFunction:T,isStream:Pt,isURLSearchParams:Ut,isTypedArray:Jt,isFileList:kt,forEach:G,merge:be,extend:It,trim:$t,stripBOM:qt,inherits:vt,toFlatObject:Ht,kindOf:ae,kindOfTest:P,endsWith:Mt,toArray:zt,forEachEntry:Vt,matchAll:Wt,isHTMLForm:Kt,hasOwnProperty:ke,hasOwnProp:ke,reduceDescriptors:Ze,freezeMethods:Qt,toObjectSet:Zt,toCamelCase:Xt,noop:Yt,toFiniteNumber:en,findKey:Ge,global:$,isContextDefined:Qe,isSpecCompliantForm:tn,toJSONObject:nn,isAsyncFn:rn,isThenable:sn,setImmediate:Ye,asap:on,isIterable:an};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const et=y.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}});Object.defineProperties(y,tt);Object.defineProperty(et,"isAxiosError",{value:!0});y.from=(e,t,n,r,s,o)=>{const i=Object.create(et);a.toFlatObject(e,i,function(c){return c!==Error.prototype},d=>d!=="isAxiosError");const l=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return y.call(i,l,f,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const ln=null;function ye(e){return a.isPlainObject(e)||a.isArray(e)}function nt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Pe(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return a.isArray(e)&&!e.some(ye)}const un=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function ce(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function d(u){if(u===null)return"";if(a.isDate(u))return u.toISOString();if(a.isBoolean(u))return u.toString();if(!f&&a.isBlob(u))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(u)||a.isTypedArray(u)?f&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function c(u,m,p){let w=u;if(u&&!p&&typeof u=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),u=JSON.stringify(u);else if(a.isArray(u)&&cn(u)||(a.isFileList(u)||a.endsWith(m,"[]"))&&(w=a.toArray(u)))return m=nt(m),w.forEach(function(S,O){!(a.isUndefined(S)||S===null)&&t.append(i===!0?Pe([m],O,o):i===null?m:m+"[]",d(S))}),!1}return ye(u)?!0:(t.append(Pe(p,m,o),d(u)),!1)}const h=[],g=Object.assign(un,{defaultVisitor:c,convertValue:d,isVisitable:ye});function x(u,m){if(!a.isUndefined(u)){if(h.indexOf(u)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(u),a.forEach(u,function(w,R){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(R)?R.trim():R,m,g))===!0&&x(w,m?m.concat(R):[R])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return x(e),t}function Fe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ee(e,t){this._pairs=[],e&&ce(e,this,t)}const rt=Ee.prototype;rt.append=function(t,n){this._pairs.push([t,n])};rt.toString=function(t){const n=t?function(r){return t.call(this,r,Fe)}:Fe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function dn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||dn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ee(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ue{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:Ee,pn=typeof FormData<"u"?FormData:null,hn=typeof Blob<"u"?Blob:null,mn={isBrowser:!0,classes:{URLSearchParams:fn,FormData:pn,Blob:hn},protocols:["http","https","file","blob","url","data"]},Se=typeof window<"u"&&typeof document<"u",ge=typeof navigator=="object"&&navigator||void 0,bn=Se&&(!ge||["ReactNative","NativeScript","NS"].indexOf(ge.product)<0),yn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gn=Se&&window.location.href||"http://localhost",wn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Se,hasStandardBrowserEnv:bn,hasStandardBrowserWebWorkerEnv:yn,navigator:ge,origin:gn},Symbol.toStringTag,{value:"Module"})),C={...wn,...mn};function xn(e,t){return ce(e,new C.classes.URLSearchParams,{visitor:function(n,r,s,o){return C.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function En(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function it(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),f=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!l):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Sn(s[i])),!l)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(En(r),s,n,0)}),n}return null}function Rn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Q={transitional:ot,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(it(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return xn(t,this.formSerializer).toString();if((l=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return ce(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Rn(t)):t}],transformResponse:[function(t){const n=this.transitional||Q.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?y.from(l,y.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{Q.headers[e]={}});const Cn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),On=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Cn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},_e=Symbol("internals");function W(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:a.isArray(e)?e.map(re):String(e)}function Tn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const An=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function pe(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function Nn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function jn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let A=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(l,f,d){const c=W(f);if(!c)throw new Error("header name must be a non-empty string");const h=a.findKey(s,c);(!h||s[h]===void 0||d===!0||d===void 0&&s[h]!==!1)&&(s[h||f]=re(l))}const i=(l,f)=>a.forEach(l,(d,c)=>o(d,c,f));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!An(t))i(On(t),n);else if(a.isObject(t)&&a.isIterable(t)){let l={},f,d;for(const c of t){if(!a.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[d=c[0]]=(f=l[d])?a.isArray(f)?[...f,c[1]]:[f,c[1]]:c[1]}i(l,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=W(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Tn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=W(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||pe(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=W(i),i){const l=a.findKey(r,i);l&&(!n||pe(r,r[l],l,n))&&(delete r[l],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||pe(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=re(s),delete n[o];return}const l=t?Nn(o):String(o).trim();l!==o&&delete n[o],n[l]=re(s),r[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[_e]=this[_e]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=W(i);r[l]||(jn(s,i),r[l]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(A.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(A);function he(e,t){const n=this||Q,r=t||n,s=A.from(r.headers);let o=r.data;return a.forEach(e,function(l){o=l.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function at(e){return!!(e&&e.__CANCEL__)}function J(e,t,n){y.call(this,e??"canceled",y.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(J,y,{__CANCEL__:!0});function lt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Pn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const d=Date.now(),c=r[o];i||(i=d),n[s]=f,r[s]=d;let h=o,g=0;for(;h!==s;)g+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),d-i<t)return;const x=c&&d-c;return x?Math.round(g*1e3/x):void 0}}function Fn(e,t){let n=0,r=1e3/t,s,o;const i=(d,c=Date.now())=>{n=c,s=null,o&&(clearTimeout(o),o=null),e(...d)};return[(...d)=>{const c=Date.now(),h=c-n;h>=r?i(d,c):(s=d,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const oe=(e,t,n=3)=>{let r=0;const s=Pn(50,250);return Fn(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,f=i-r,d=s(f),c=i<=l;r=i;const h={loaded:i,total:l,progress:l?i/l:void 0,bytes:f,rate:d||void 0,estimated:d&&l&&c?(l-i)/d:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},Le=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Be=e=>(...t)=>a.asap(()=>e(...t)),Un=C.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,C.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,_n=C.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&l.push(`path=${r}`),a.isString(s)&&l.push(`domain=${s}`),o===!0&&l.push("secure"),a.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ln(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ct(e,t,n){let r=!Ln(t);return e&&(r||n==!1)?Bn(e,t):t}const De=e=>e instanceof A?{...e}:e;function v(e,t){t=t||{};const n={};function r(d,c,h,g){return a.isPlainObject(d)&&a.isPlainObject(c)?a.merge.call({caseless:g},d,c):a.isPlainObject(c)?a.merge({},c):a.isArray(c)?c.slice():c}function s(d,c,h,g){if(a.isUndefined(c)){if(!a.isUndefined(d))return r(void 0,d,h,g)}else return r(d,c,h,g)}function o(d,c){if(!a.isUndefined(c))return r(void 0,c)}function i(d,c){if(a.isUndefined(c)){if(!a.isUndefined(d))return r(void 0,d)}else return r(void 0,c)}function l(d,c,h){if(h in t)return r(d,c);if(h in e)return r(void 0,d)}const f={url:o,method:o,data:o,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:l,headers:(d,c,h)=>s(De(d),De(c),h,!0)};return a.forEach(Object.keys({...e,...t}),function(c){const h=f[c]||s,g=h(e[c],t[c],c);a.isUndefined(g)&&h!==l||(n[c]=g)}),n}const ut=e=>{const t=v({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:l}=t;if(t.headers=i=A.from(i),t.url=st(ct(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),a.isFormData(n)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const f=n.getHeaders(),d=["content-type","content-length"];Object.entries(f).forEach(([c,h])=>{d.includes(c.toLowerCase())&&i.set(c,h)})}}if(C.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Un(t.url))){const f=s&&o&&_n.read(o);f&&i.set(s,f)}return t},Dn=typeof XMLHttpRequest<"u",$n=Dn&&function(e){return new Promise(function(n,r){const s=ut(e);let o=s.data;const i=A.from(s.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:d}=s,c,h,g,x,u;function m(){x&&x(),u&&u(),s.cancelToken&&s.cancelToken.unsubscribe(c),s.signal&&s.signal.removeEventListener("abort",c)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const S=A.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),k={data:!l||l==="text"||l==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:e,request:p};lt(function(j){n(j),m()},function(j){r(j),m()},k),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new y("Request aborted",y.ECONNABORTED,e,p)),p=null)},p.onerror=function(O){const k=O&&O.message?O.message:"Network Error",B=new y(k,y.ERR_NETWORK,e,p);B.event=O||null,r(B),p=null},p.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const k=s.transitional||ot;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new y(O,k.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(O,k){p.setRequestHeader(k,O)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),l&&l!=="json"&&(p.responseType=s.responseType),d&&([g,u]=oe(d,!0),p.addEventListener("progress",g)),f&&p.upload&&([h,x]=oe(f),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",x)),(s.cancelToken||s.signal)&&(c=S=>{p&&(r(!S||S.type?new J(null,e,p):S),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(c),s.signal&&(s.signal.aborted?c():s.signal.addEventListener("abort",c)));const R=kn(s.url);if(R&&C.protocols.indexOf(R)===-1){r(new y("Unsupported protocol "+R+":",y.ERR_BAD_REQUEST,e));return}p.send(o||null)})},In=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(d){if(!s){s=!0,l();const c=d instanceof Error?d:this.reason;r.abort(c instanceof y?c:new J(c instanceof Error?c.message:c))}};let i=t&&setTimeout(()=>{i=null,o(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(o):d.removeEventListener("abort",o)}),e=null)};e.forEach(d=>d.addEventListener("abort",o));const{signal:f}=r;return f.unsubscribe=()=>a.asap(l),f}},qn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},vn=async function*(e,t){for await(const n of Hn(e))yield*qn(n,t)},Hn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},$e=(e,t,n,r)=>{const s=vn(e,t);let o=0,i,l=f=>{i||(i=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:d,value:c}=await s.next();if(d){l(),f.close();return}let h=c.byteLength;if(n){let g=o+=h;n(g)}f.enqueue(new Uint8Array(c))}catch(d){throw l(d),d}},cancel(f){return l(f),s.return()}},{highWaterMark:2})},Ie=64*1024,{isFunction:te}=a,Mn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:qe,TextEncoder:ve}=a.global,He=(e,...t)=>{try{return!!e(...t)}catch{return!1}},zn=e=>{e=a.merge.call({skipUndefined:!0},Mn,e);const{fetch:t,Request:n,Response:r}=e,s=t?te(t):typeof fetch=="function",o=te(n),i=te(r);if(!s)return!1;const l=s&&te(qe),f=s&&(typeof ve=="function"?(u=>m=>u.encode(m))(new ve):async u=>new Uint8Array(await new n(u).arrayBuffer())),d=o&&l&&He(()=>{let u=!1;const m=new n(C.origin,{body:new qe,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!m}),c=i&&l&&He(()=>a.isReadableStream(new r("").body)),h={stream:c&&(u=>u.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!h[u]&&(h[u]=(m,p)=>{let w=m&&m[u];if(w)return w.call(m);throw new y(`Response type '${u}' is not supported`,y.ERR_NOT_SUPPORT,p)})});const g=async u=>{if(u==null)return 0;if(a.isBlob(u))return u.size;if(a.isSpecCompliantForm(u))return(await new n(C.origin,{method:"POST",body:u}).arrayBuffer()).byteLength;if(a.isArrayBufferView(u)||a.isArrayBuffer(u))return u.byteLength;if(a.isURLSearchParams(u)&&(u=u+""),a.isString(u))return(await f(u)).byteLength},x=async(u,m)=>{const p=a.toFiniteNumber(u.getContentLength());return p??g(m)};return async u=>{let{url:m,method:p,data:w,signal:R,cancelToken:S,timeout:O,onDownloadProgress:k,onUploadProgress:B,responseType:j,headers:de,withCredentials:Z="same-origin",fetchOptions:Ce}=ut(u),Oe=t||fetch;j=j?(j+"").toLowerCase():"text";let Y=In([R,S&&S.toAbortSignal()],O),V=null;const D=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let Te;try{if(B&&d&&p!=="get"&&p!=="head"&&(Te=await x(de,w))!==0){let L=new n(m,{method:"POST",body:w,duplex:"half"}),H;if(a.isFormData(w)&&(H=L.headers.get("content-type"))&&de.setContentType(H),L.body){const[fe,ee]=Le(Te,oe(Be(B)));w=$e(L.body,Ie,fe,ee)}}a.isString(Z)||(Z=Z?"include":"omit");const F=o&&"credentials"in n.prototype,Ae={...Ce,signal:Y,method:p.toUpperCase(),headers:de.normalize().toJSON(),body:w,duplex:"half",credentials:F?Z:void 0};V=o&&new n(m,Ae);let _=await(o?Oe(V,Ce):Oe(m,Ae));const Ne=c&&(j==="stream"||j==="response");if(c&&(k||Ne&&D)){const L={};["status","statusText","headers"].forEach(je=>{L[je]=_[je]});const H=a.toFiniteNumber(_.headers.get("content-length")),[fe,ee]=k&&Le(H,oe(Be(k),!0))||[];_=new r($e(_.body,Ie,fe,()=>{ee&&ee(),D&&D()}),L)}j=j||"text";let yt=await h[a.findKey(h,j)||"text"](_,u);return!Ne&&D&&D(),await new Promise((L,H)=>{lt(L,H,{data:yt,headers:A.from(_.headers),status:_.status,statusText:_.statusText,config:u,request:V})})}catch(F){throw D&&D(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,u,V),{cause:F.cause||F}):y.from(F,F&&F.code,u,V)}}},Jn=new Map,dt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,l=i,f,d,c=Jn;for(;l--;)f=o[l],d=c.get(f),d===void 0&&c.set(f,d=l?new Map:zn(t)),c=d;return d};dt();const Re={http:ln,xhr:$n,fetch:{get:dt}};a.forEach(Re,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Me=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Wn(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let l;if(s=r,!Vn(r)&&(s=Re[(l=String(r)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${l}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[l||"#"+i]=s}if(!s){const i=Object.entries(o).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
|
+
`+i.map(Me).join(`
|
|
5
|
+
`):" "+Me(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return s}const ft={getAdapter:Wn,adapters:Re};function me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new J(null,e)}function ze(e){return me(e),e.headers=A.from(e.headers),e.data=he.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ft.getAdapter(e.adapter||Q.adapter,e)(e).then(function(r){return me(e),r.data=he.call(e,e.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return at(r)||(me(e),r&&r.response&&(r.response.data=he.call(e,e.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const pt="1.13.2",ue={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ue[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Je={};ue.transitional=function(t,n,r){function s(o,i){return"[Axios v"+pt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,l)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!Je[i]&&(Je[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}};ue.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Kn(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const l=e[o],f=l===void 0||i(l,o,e);if(f!==!0)throw new y("option "+o+" must be "+f,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const se={assertOptions:Kn,validators:ue},U=se.validators;let I=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ue,response:new Ue}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
6
|
+
`+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=v(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&se.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:se.assertOptions(s,{encode:U.function,serialize:U.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),se.assertOptions(n,{baseUrl:U.spelling("baseURL"),withXsrfToken:U.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],u=>{delete o[u]}),n.headers=A.concat(i,o);const l=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(f=f&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const d=[];this.interceptors.response.forEach(function(m){d.push(m.fulfilled,m.rejected)});let c,h=0,g;if(!f){const u=[ze.bind(this),void 0];for(u.unshift(...l),u.push(...d),g=u.length,c=Promise.resolve(n);h<g;)c=c.then(u[h++],u[h++]);return c}g=l.length;let x=n;for(;h<g;){const u=l[h++],m=l[h++];try{x=u(x)}catch(p){m.call(this,p);break}}try{c=ze.call(this,x)}catch(u){return Promise.reject(u)}for(h=0,g=d.length;h<g;)c=c.then(d[h++],d[h++]);return c}getUri(t){t=v(this.defaults,t);const n=ct(t.baseURL,t.url,t.allowAbsoluteUrls);return st(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){I.prototype[t]=function(n,r){return this.request(v(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,l){return this.request(v(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}I.prototype[t]=n(),I.prototype[t+"Form"]=n(!0)});let Xn=class ht{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,l){r.reason||(r.reason=new J(o,i,l),n(r.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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ht(function(s){t=s}),cancel:t}}};function Gn(e){return function(n){return e.apply(null,n)}}function Qn(e){return a.isObject(e)&&e.isAxiosError===!0}const we={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(we).forEach(([e,t])=>{we[t]=e});function mt(e){const t=new I(e),n=Ve(I.prototype.request,t);return a.extend(n,I.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return mt(v(e,s))},n}const E=mt(Q);E.Axios=I;E.CanceledError=J;E.CancelToken=Xn;E.isCancel=at;E.VERSION=pt;E.toFormData=ce;E.AxiosError=y;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Gn;E.isAxiosError=Qn;E.mergeConfig=v;E.AxiosHeaders=A;E.formToJSON=e=>it(a.isHTMLForm(e)?new FormData(e):e);E.getAdapter=ft.getAdapter;E.HttpStatusCode=we;E.default=E;const{Axios:rr,AxiosError:sr,CanceledError:or,isCancel:ir,CancelToken:ar,VERSION:lr,all:cr,Cancel:ur,isAxiosError:dr,spread:fr,toFormData:pr,AxiosHeaders:hr,HttpStatusCode:mr,formToJSON:br,getAdapter:yr,mergeConfig:gr}=E,bt=async(e,t,n,r)=>{const s={chatInput:e,sessionId:t,metadata:{pinecone_namespace:n}};try{return(await E.post(r,s,{headers:{"Content-Type":"application/json"}})).data.output}catch(o){throw console.error("Error communicating with chat API:",o),o}},Zn=({handleMessageFromForm:e,theme:t,chatBotData:n})=>{const[r,s]=N.useState(""),[o,i]=N.useState(""),[l,f]=N.useState(""),[d,c]=N.useState(!1),h=async g=>{if(g.preventDefault(),c(!0),f(""),!r.trim()||!o.trim()){f("Name and email are required");return}const x=`Hi, I am ${r} and my email is ${o}`;try{const m=(await bt(x,n.sessionId,n.pineconeNamespace,n.url)).response;e([{type:"user",text:x},{type:"bot",text:m}])}catch(u){console.log("error sending user details",u),f("Failed to submit. Please try again.")}finally{c(!1)}s(""),i("")};return b.jsx("div",{className:"p-5 flex-shrink-0",style:{background:t.backgroundColor},children:b.jsxs("form",{onSubmit:h,className:"flex flex-col gap-6",children:[l&&b.jsx("div",{className:"bg-red-100 text-neutral-800 p-2 rounded relative text-center text-sm",role:"alert",children:l}),b.jsx("p",{className:" text-sm font-medium",style:{color:`${t.fontColor}`},children:n.welcomeText}),b.jsxs("div",{className:"flex flex-col gap-5",children:[b.jsxs("div",{className:"flex flex-col gap-1",children:[b.jsx("label",{className:"text-sm",style:{color:`${t.fontColor}`},children:"Full Name"}),b.jsx("input",{type:"text",placeholder:"Enter your full name",value:r,onChange:g=>{s(g.target.value),f("")},className:"w-full px-3 py-2 border border-neutral-300 rounded-xl",style:{background:`${t.backgroundColor}`,color:`${t.fontColor}`},required:!0})]}),b.jsxs("div",{className:"flex flex-col gap-1",children:[b.jsx("label",{className:"text-sm",style:{color:`${t.fontColor}`},children:"Email Address"}),b.jsx("input",{type:"email",placeholder:"Enter your email",value:o,onChange:g=>{i(g.target.value),f("")},className:"w-full px-3 py-2 border border-neutral-300 rounded-xl",style:{background:`${t.backgroundColor}`,color:`${t.fontColor}`},required:!0})]})]}),b.jsx("button",{type:"submit",disabled:!r.trim()||!o.trim()||d,className:"disabled:opacity-50 disabled:cursor-not-allowed px-5 py-3 rounded-xl font-medium flex items-center justify-center gap-2 mt-20",style:{background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor},children:d?"Submitting...":b.jsxs(b.Fragment,{children:[b.jsx(q.Send,{size:18})," Submit"]})})]})})},Yn=({onClose:e,theme:t,chatBotData:n})=>{const[r,s]=N.useState([]),[o,i]=N.useState(!1),[l,f]=N.useState(!1),d=n.position==="left"?"left-8":"right-8",c={boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15)",background:t.backgroundColor},h={background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor},g={background:t.backgroundColor,color:t.fontColor},x=m=>{s(m),f(!0)},u=async m=>{i(!0),s(p=>[...p,{type:"user",text:m}]);try{const w=(await bt(m,n.sessionId,n.pineconeNamespace,n.url)).response;s(R=>[...R,{type:"bot",text:w}])}catch(p){console.error("Chat error:",p),s(w=>[...w,{type:"bot",text:"Sorry, something went wrong."}])}finally{i(!1)}};return b.jsxs("div",{className:`fixed bottom-28 ${d} z-50 w-96 h-[520px] bg-white/90 backdrop-blur-xl rounded-2xl border border-white flex flex-col overflow-hidden`,style:c,children:[b.jsxs("div",{className:"bg-gradient-to-r px-5 py-4 rounded-t-2xl flex items-center justify-between shadow-md",style:h,children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsxs("div",{className:"relative",children:[b.jsx("div",{className:"w-11 h-11 rounded-full flex items-center justify-center",children:b.jsx(q.MessageCircle,{size:22})}),b.jsx("span",{className:"absolute bottom-0 right-0 w-3.5 h-3.5 bg-emerald-400 rounded-full border-1 border-white"})]}),b.jsxs("div",{children:[b.jsx("h3",{className:"font-semibold text-lg",children:n.name}),b.jsx("p",{className:"text-xs opacity-90",children:n.subTitle})]})]}),b.jsx("button",{onClick:e,"aria-label":"Close chat",className:"p-2 hover:bg-white/20 rounded-full",children:b.jsx(q.X,{size:20})})]}),!l&&b.jsx(Zn,{handleMessageFromForm:x,theme:t,chatBotData:n}),l&&b.jsxs(b.Fragment,{children:[b.jsx(Et,{messages:r,isLoading:o,theme:t}),b.jsx(xt,{onSendMessage:u,isLoading:o,theme:t})]}),b.jsx("div",{className:"border-t border-neutral-200 px-5 py-3 text-center",style:g,children:b.jsxs("p",{className:"text-[11px] tracking-wide",style:{color:`${t.fontColor}`},children:["powered by ",b.jsx("span",{className:"font-semibold ",style:{color:`${t.fontColor}`},children:"clone67.com"})]})})]})},er=({pineconeNamespace:e,url:t,primaryColor:n,secondaryColor:r,backgroundColor:s,fontColor:o,placeholderColor:i,position:l,name:f,subTitle:d,welcomeText:c})=>{const[h,g]=N.useState(!1),[x,u]=N.useState("");N.useEffect(()=>{u(gt.v4())},[]);const m=()=>g(R=>!R),p={primaryColor:n,secondaryColor:r,backgroundColor:s,fontColor:o,placeholderColor:i},w={name:f,subTitle:d,welcomeText:c,url:t,pineconeNamespace:e,position:l,sessionId:x};return b.jsxs("div",{className:"fixed inset-0 pointer-events-auto z-[9999]",children:[h&&b.jsx(Yn,{onClose:m,sessionId:x,pineconeNamespace:e,url:t,theme:p,chatBotData:w}),b.jsx(wt,{onClick:m,isOpen:h,theme:p,chatBotData:w})]})};module.exports=er;
|