chainlit 1.1.401__py3-none-any.whl → 1.1.402__py3-none-any.whl
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.
Potentially problematic release.
This version of chainlit might be problematic. Click here for more details.
- chainlit/copilot/dist/index.js +2 -2
- chainlit/frontend/dist/assets/{DailyMotion-43d85492.js → DailyMotion-f314e070.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-6a04b850.js → Facebook-8ccafb69.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-fb9f99cd.js → FilePlayer-278edbf8.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-169c6632.js → Kaltura-ae0d33ee.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-b8fb3f23.js → Mixcloud-8cf7a152.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-988b7afc.js → Mux-7a9417e1.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-a63aa60e.js → Preview-7932fd5a.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-c736deeb.js → SoundCloud-a6b17460.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-b26e619e.js → Streamable-bdaaac70.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-ddffc17f.js → Twitch-5c0aa780.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-8ef8b6d3.js → Vidyard-8927f435.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-2cbc8a27.js → Vimeo-715c5361.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-e54183b6.js → Wistia-8b2b2dba.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-9e388229.js → YouTube-77d859f9.js} +1 -1
- chainlit/frontend/dist/assets/{index-df419486.js → index-f35e8b65.js} +75 -75
- chainlit/frontend/dist/assets/{react-plotly-66ae619a.js → react-plotly-9938b97b.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/user.py +3 -1
- {chainlit-1.1.401.dist-info → chainlit-1.1.402.dist-info}/METADATA +1 -1
- {chainlit-1.1.401.dist-info → chainlit-1.1.402.dist-info}/RECORD +23 -23
- {chainlit-1.1.401.dist-info → chainlit-1.1.402.dist-info}/WHEEL +0 -0
- {chainlit-1.1.401.dist-info → chainlit-1.1.402.dist-info}/entry_points.txt +0 -0
chainlit/copilot/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
85
85
|
*
|
|
86
86
|
* This source code is licensed under the MIT license found in the
|
|
87
87
|
* LICENSE file in the root directory of this source tree.
|
|
88
|
-
*/var r_=pt;function B6e(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var z6e=typeof Object.is=="function"?Object.is:B6e,U6e=r_.useState,H6e=r_.useEffect,$6e=r_.useLayoutEffect,G6e=r_.useDebugValue;function V6e(e,t){var r=t(),a=U6e({inst:{value:r,getSnapshot:t}}),u=a[0].inst,A=a[1];return $6e(function(){u.value=r,u.getSnapshot=t,y7(u)&&A({inst:u})},[e,r,t]),H6e(function(){return y7(u)&&A({inst:u}),e(function(){y7(u)&&A({inst:u})})},[e]),G6e(r),r}function y7(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!z6e(e,r)}catch{return!0}}function Y6e(e,t){return t()}var W6e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Y6e:V6e;dee.useSyncExternalStore=r_.useSyncExternalStore!==void 0?r_.useSyncExternalStore:W6e,fee.exports=dee;var j6e=fee.exports;const L1=()=>{},Xd=L1(),b7=Object,Es=e=>e===Xd,ng=e=>typeof e=="function",D1=(e,t)=>({...e,...t}),K6e=e=>ng(e.then),rR=new WeakMap;let X6e=0;const kT=e=>{const t=typeof e,r=e&&e.constructor,a=r==Date;let u,A;if(b7(e)===e&&!a&&r!=RegExp){if(u=rR.get(e),u)return u;if(u=++X6e+"~",rR.set(e,u),r==Array){for(u="@",A=0;A<e.length;A++)u+=kT(e[A])+",";rR.set(e,u)}if(r==b7){u="#";const c=b7.keys(e).sort();for(;!Es(A=c.pop());)Es(e[A])||(u+=A+":"+kT(e[A])+",");rR.set(e,u)}}else u=a?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return u},ag=new WeakMap,x7={},nR={},_7="undefined",aR=typeof window!=_7,E7=typeof document!=_7,Z6e=()=>aR&&typeof window.requestAnimationFrame!=_7,hee=(e,t)=>{const r=ag.get(e);return[()=>!Es(t)&&e.get(t)||x7,a=>{if(!Es(t)){const u=e.get(t);t in nR||(nR[t]=u),r[5](t,D1(u,a),u||x7)}},r[6],()=>!Es(t)&&t in nR?nR[t]:!Es(t)&&e.get(t)||x7]};let S7=!0;const Q6e=()=>S7,[T7,w7]=aR&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[L1,L1],J6e=()=>{const e=E7&&document.visibilityState;return Es(e)||e!=="hidden"},q6e=e=>(E7&&document.addEventListener("visibilitychange",e),T7("focus",e),()=>{E7&&document.removeEventListener("visibilitychange",e),w7("focus",e)}),eMe=e=>{const t=()=>{S7=!0,e()},r=()=>{S7=!1};return T7("online",t),T7("offline",r),()=>{w7("online",t),w7("offline",r)}},tMe={isOnline:Q6e,isVisible:J6e},rMe={initFocus:q6e,initReconnect:eMe},pee=!Qn.useId,FT=!aR||"Deno"in window,nMe=e=>Z6e()?window.requestAnimationFrame(e):setTimeout(e,1),A7=FT?pt.useEffect:pt.useLayoutEffect,C7=typeof navigator<"u"&&navigator.connection,vee=!FT&&C7&&(["slow-2g","2g"].includes(C7.effectiveType)||C7.saveData),R7=e=>{if(ng(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?kT(e):"",[e,t]};let aMe=0;const M7=()=>++aMe,mee=0,gee=1,yee=2;var BT={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:mee,MUTATE_EVENT:yee,RECONNECT_EVENT:gee};async function bee(...e){const[t,r,a,u]=e,A=D1({populateCache:!0,throwOnError:!0},typeof u=="boolean"?{revalidate:u}:u||{});let c=A.populateCache;const y=A.rollbackOnError;let n=A.optimisticData;const s=A.revalidate!==!1,b=E=>typeof y=="function"?y(E):y!==!1,i=A.throwOnError;if(ng(r)){const E=r,p=[],_=t.keys();for(const l of _)!/^\$(inf|sub)\$/.test(l)&&E(t.get(l)._k)&&p.push(l);return Promise.all(p.map(w))}return w(r);async function w(E){const[p]=R7(E);if(!p)return;const[_,l]=hee(t,p),[o,d,f,h]=ag.get(t),g=()=>{const L=o[p];return s&&(delete f[p],delete h[p],L&&L[0])?L[0](yee).then(()=>_().data):_().data};if(e.length<3)return g();let v=a,C;const S=M7();d[p]=[S,0];const I=!Es(n),T=_(),x=T.data,R=T._c,P=Es(R)?x:R;if(I&&(n=ng(n)?n(P,x):n,l({data:n,_c:P})),ng(v))try{v=v(P)}catch(L){C=L}if(v&&K6e(v))if(v=await v.catch(L=>{C=L}),S!==d[p][0]){if(C)throw C;return v}else C&&I&&b(C)&&(c=!0,l({data:P,_c:Xd}));if(c&&!C)if(ng(c)){const L=c(v,P);l({data:L,error:Xd,_c:Xd})}else l({data:v,error:Xd,_c:Xd});if(d[p][1]=M7(),Promise.resolve(g()).then(()=>{l({_c:Xd})}),C){if(i)throw C;return}return v}}const xee=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},iMe=(e,t)=>{if(!ag.has(e)){const r=D1(rMe,t),a={},u=bee.bind(Xd,e);let A=L1;const c={},y=(b,i)=>{const w=c[b]||[];return c[b]=w,w.push(i),()=>w.splice(w.indexOf(i),1)},n=(b,i,w)=>{e.set(b,i);const E=c[b];if(E)for(const p of E)p(i,w)},s=()=>{if(!ag.has(e)&&(ag.set(e,[a,{},{},{},u,n,y]),!FT)){const b=r.initFocus(setTimeout.bind(Xd,xee.bind(Xd,a,mee))),i=r.initReconnect(setTimeout.bind(Xd,xee.bind(Xd,a,gee)));A=()=>{b&&b(),i&&i(),ag.delete(e)}}};return s(),[e,u,s,A]}return[e,ag.get(e)[4]]},oMe=(e,t,r,a,u)=>{const A=r.errorRetryCount,c=u.retryCount,y=~~((Math.random()+.5)*(1<<(c<8?c:8)))*r.errorRetryInterval;!Es(A)&&c>A||setTimeout(a,y,u)},sMe=(e,t)=>kT(e)==kT(t),[_ee,lMe]=iMe(new Map),uMe=D1({onLoadingSlow:L1,onSuccess:L1,onError:L1,onErrorRetry:oMe,onDiscarded:L1,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:vee?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:vee?5e3:3e3,compare:sMe,isPaused:()=>!1,cache:_ee,mutate:lMe,fallback:{}},tMe),cMe=(e,t)=>{const r=D1(e,t);if(t){const{use:a,fallback:u}=e,{use:A,fallback:c}=t;a&&A&&(r.use=a.concat(A)),u&&c&&(r.fallback=D1(u,c))}return r},fMe=pt.createContext({}),dMe="$inf$",Eee=aR&&window.__SWR_DEVTOOLS_USE__,hMe=Eee?window.__SWR_DEVTOOLS_USE__:[],pMe=()=>{Eee&&(window.__SWR_DEVTOOLS_REACT__=Qn)},vMe=e=>ng(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],mMe=()=>D1(uMe,pt.useContext(fMe)),gMe=e=>(t,r,a)=>e(t,r&&((...A)=>{const[c]=R7(t),[,,,y]=ag.get(_ee);if(c.startsWith(dMe))return r(...A);const n=y[c];return Es(n)?r(...A):(delete y[c],n)}),a),yMe=hMe.concat(gMe),bMe=e=>function(...r){const a=mMe(),[u,A,c]=vMe(r),y=cMe(a,c);let n=e;const{use:s}=y,b=(s||[]).concat(yMe);for(let i=b.length;i--;)n=b[i](n);return n(u,A||y.fetcher||null,y)},xMe=(e,t,r)=>{const a=t[e]||(t[e]=[]);return a.push(r),()=>{const u=a.indexOf(r);u>=0&&(a[u]=a[a.length-1],a.pop())}};pMe();const See=Qn.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),I7={dedupe:!0},_Me=bMe((e,t,r)=>{const{cache:a,compare:u,suspense:A,fallbackData:c,revalidateOnMount:y,revalidateIfStale:n,refreshInterval:s,refreshWhenHidden:b,refreshWhenOffline:i,keepPreviousData:w}=r,[E,p,_,l]=ag.get(a),[o,d]=R7(e),f=pt.useRef(!1),h=pt.useRef(!1),g=pt.useRef(o),v=pt.useRef(t),C=pt.useRef(r),S=()=>C.current,I=()=>S().isVisible()&&S().isOnline(),[T,x,R,P]=hee(a,o),L=pt.useRef({}).current,F=Es(c)?r.fallback[o]:c,N=(ie,se)=>{for(const he in L){const te=he;if(te==="data"){if(!u(ie[te],se[te])&&(!Es(ie[te])||!u($,se[te])))return!1}else if(se[te]!==ie[te])return!1}return!0},k=pt.useMemo(()=>{const ie=(()=>!o||!t?!1:Es(y)?S().isPaused()||A?!1:Es(n)?!0:n:y)(),se=ae=>{const ce=D1(ae);return delete ce._k,ie?{isValidating:!0,isLoading:!0,...ce}:ce},he=T(),te=P(),Z=se(he),J=he===te?Z:se(te);let re=Z;return[()=>{const ae=se(T());return N(ae,re)?(re.data=ae.data,re.isLoading=ae.isLoading,re.isValidating=ae.isValidating,re.error=ae.error,re):(re=ae,ae)},()=>J]},[a,o]),O=j6e.useSyncExternalStore(pt.useCallback(ie=>R(o,(se,he)=>{N(he,se)||ie()}),[a,o]),k[0],k[1]),m=!f.current,D=E[o]&&E[o].length>0,M=O.data,H=Es(M)?F:M,B=O.error,Y=pt.useRef(H),$=w?Es(M)?Y.current:M:H,V=(()=>D&&!Es(B)?!1:m&&!Es(y)?y:S().isPaused()?!1:A?Es(H)?!1:n:Es(H)||n)(),W=!!(o&&t&&m&&V),G=Es(O.isValidating)?W:O.isValidating,j=Es(O.isLoading)?W:O.isLoading,X=pt.useCallback(async ie=>{const se=v.current;if(!o||!se||h.current||S().isPaused())return!1;let he,te,Z=!0;const J=ie||{},re=!_[o]||!J.dedupe,ae=()=>pee?!h.current&&o===g.current&&f.current:o===g.current,ce={isValidating:!1,isLoading:!1},ne=()=>{x(ce)},Q=()=>{const oe=_[o];oe&&oe[1]===te&&delete _[o]},fe={isValidating:!0};Es(T().data)&&(fe.isLoading=!0);try{if(re&&(x(fe),r.loadingTimeout&&Es(T().data)&&setTimeout(()=>{Z&&ae()&&S().onLoadingSlow(o,r)},r.loadingTimeout),_[o]=[se(d),M7()]),[he,te]=_[o],he=await he,re&&setTimeout(Q,r.dedupingInterval),!_[o]||_[o][1]!==te)return re&&ae()&&S().onDiscarded(o),!1;ce.error=Xd;const oe=p[o];if(!Es(oe)&&(te<=oe[0]||te<=oe[1]||oe[1]===0))return ne(),re&&ae()&&S().onDiscarded(o),!1;const de=T().data;ce.data=u(de,he)?de:he,re&&ae()&&S().onSuccess(he,o,r)}catch(oe){Q();const de=S(),{shouldRetryOnError:me}=de;de.isPaused()||(ce.error=oe,re&&ae()&&(de.onError(oe,o,de),(me===!0||ng(me)&&me(oe))&&I()&&de.onErrorRetry(oe,o,de,xe=>{const Se=E[o];Se&&Se[0]&&Se[0](BT.ERROR_REVALIDATE_EVENT,xe)},{retryCount:(J.retryCount||0)+1,dedupe:!0})))}return Z=!1,ne(),!0},[o,a]),q=pt.useCallback((...ie)=>bee(a,g.current,...ie),[]);if(A7(()=>{v.current=t,C.current=r,Es(M)||(Y.current=M)}),A7(()=>{if(!o)return;const ie=X.bind(Xd,I7);let se=0;const te=xMe(o,E,(Z,J={})=>{if(Z==BT.FOCUS_EVENT){const re=Date.now();S().revalidateOnFocus&&re>se&&I()&&(se=re+S().focusThrottleInterval,ie())}else if(Z==BT.RECONNECT_EVENT)S().revalidateOnReconnect&&I()&&ie();else{if(Z==BT.MUTATE_EVENT)return X();if(Z==BT.ERROR_REVALIDATE_EVENT)return X(J)}});return h.current=!1,g.current=o,f.current=!0,x({_k:d}),V&&(Es(H)||FT?ie():nMe(ie)),()=>{h.current=!0,te()}},[o]),A7(()=>{let ie;function se(){const te=ng(s)?s(T().data):s;te&&ie!==-1&&(ie=setTimeout(he,te))}function he(){!T().error&&(b||S().isVisible())&&(i||S().isOnline())?X(I7).then(se):se()}return se(),()=>{ie&&(clearTimeout(ie),ie=-1)}},[s,b,i,o]),pt.useDebugValue($),A&&Es(H)&&o){if(!pee&&FT)throw new Error("Fallback data is required when using suspense in SSR.");v.current=t,C.current=r,h.current=!1;const ie=l[o];if(!Es(ie)){const se=q(ie);See(se)}if(Es(B)){const se=X(I7);Es($)||(se.status="fulfilled",se.value=!0),See(se)}else throw B}return{mutate:q,get data(){return L.data=!0,$},get error(){return L.error=!0,B},get isValidating(){return L.isValidating=!0,G},get isLoading(){return L.isLoading=!0,j}}}),qv=Object.create(null);qv.open="0",qv.close="1",qv.ping="2",qv.pong="3",qv.message="4",qv.upgrade="5",qv.noop="6";const iR=Object.create(null);Object.keys(qv).forEach(e=>{iR[qv[e]]=e});const O7={type:"error",data:"parser error"},Tee=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",wee=typeof ArrayBuffer=="function",Aee=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,N7=({type:e,data:t},r,a)=>Tee&&t instanceof Blob?r?a(t):Cee(t,a):wee&&(t instanceof ArrayBuffer||Aee(t))?r?a(t):Cee(new Blob([t]),a):a(qv[e]+(t||"")),Cee=(e,t)=>{const r=new FileReader;return r.onload=function(){const a=r.result.split(",")[1];t("b"+(a||""))},r.readAsDataURL(e)};function Ree(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let L7;function EMe(e,t){if(Tee&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ree).then(t);if(wee&&(e.data instanceof ArrayBuffer||Aee(e.data)))return t(Ree(e.data));N7(e,!1,r=>{L7||(L7=new TextEncoder),t(L7.encode(r))})}const Mee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zT=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Mee.length;e++)zT[Mee.charCodeAt(e)]=e;const SMe=e=>{let t=e.length*.75,r=e.length,a,u=0,A,c,y,n;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const s=new ArrayBuffer(t),b=new Uint8Array(s);for(a=0;a<r;a+=4)A=zT[e.charCodeAt(a)],c=zT[e.charCodeAt(a+1)],y=zT[e.charCodeAt(a+2)],n=zT[e.charCodeAt(a+3)],b[u++]=A<<2|c>>4,b[u++]=(c&15)<<4|y>>2,b[u++]=(y&3)<<6|n&63;return s},TMe=typeof ArrayBuffer=="function",D7=(e,t)=>{if(typeof e!="string")return{type:"message",data:Iee(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:wMe(e.substring(1),t)}:iR[r]?e.length>1?{type:iR[r],data:e.substring(1)}:{type:iR[r]}:O7},wMe=(e,t)=>{if(TMe){const r=SMe(e);return Iee(r,t)}else return{base64:!0,data:e}},Iee=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Oee=String.fromCharCode(30),AMe=(e,t)=>{const r=e.length,a=new Array(r);let u=0;e.forEach((A,c)=>{N7(A,!1,y=>{a[c]=y,++u===r&&t(a.join(Oee))})})},CMe=(e,t)=>{const r=e.split(Oee),a=[];for(let u=0;u<r.length;u++){const A=D7(r[u],t);if(a.push(A),A.type==="error")break}return a};function RMe(){return new TransformStream({transform(e,t){EMe(e,r=>{const a=r.length;let u;if(a<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,a);else if(a<65536){u=new Uint8Array(3);const A=new DataView(u.buffer);A.setUint8(0,126),A.setUint16(1,a)}else{u=new Uint8Array(9);const A=new DataView(u.buffer);A.setUint8(0,127),A.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(u[0]|=128),t.enqueue(u),t.enqueue(r)})}})}let P7;function oR(e){return e.reduce((t,r)=>t+r.length,0)}function sR(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let a=0;for(let u=0;u<t;u++)r[u]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),r}function MMe(e,t){P7||(P7=new TextDecoder);const r=[];let a=0,u=-1,A=!1;return new TransformStream({transform(c,y){for(r.push(c);;){if(a===0){if(oR(r)<1)break;const n=sR(r,1);A=(n[0]&128)===128,u=n[0]&127,u<126?a=3:u===126?a=1:a=2}else if(a===1){if(oR(r)<2)break;const n=sR(r,2);u=new DataView(n.buffer,n.byteOffset,n.length).getUint16(0),a=3}else if(a===2){if(oR(r)<8)break;const n=sR(r,8),s=new DataView(n.buffer,n.byteOffset,n.length),b=s.getUint32(0);if(b>Math.pow(2,53-32)-1){y.enqueue(O7);break}u=b*Math.pow(2,32)+s.getUint32(4),a=3}else{if(oR(r)<u)break;const n=sR(r,u);y.enqueue(D7(A?n:P7.decode(n),t)),a=0}if(u===0||u>e){y.enqueue(O7);break}}}})}const Nee=4;function Ku(e){if(e)return IMe(e)}function IMe(e){for(var t in Ku.prototype)e[t]=Ku.prototype[t];return e}Ku.prototype.on=Ku.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ku.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},Ku.prototype.off=Ku.prototype.removeListener=Ku.prototype.removeAllListeners=Ku.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,u=0;u<r.length;u++)if(a=r[u],a===t||a.fn===t){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+e],this},Ku.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(r){r=r.slice(0);for(var a=0,u=r.length;a<u;++a)r[a].apply(this,t)}return this},Ku.prototype.emitReserved=Ku.prototype.emit,Ku.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ku.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Gp=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Lee(e,...t){return t.reduce((r,a)=>(e.hasOwnProperty(a)&&(r[a]=e[a]),r),{})}const OMe=Gp.setTimeout,NMe=Gp.clearTimeout;function lR(e,t){t.useNativeTimers?(e.setTimeoutFn=OMe.bind(Gp),e.clearTimeoutFn=NMe.bind(Gp)):(e.setTimeoutFn=Gp.setTimeout.bind(Gp),e.clearTimeoutFn=Gp.clearTimeout.bind(Gp))}const LMe=1.33;function DMe(e){return typeof e=="string"?PMe(e):Math.ceil((e.byteLength||e.size)*LMe)}function PMe(e){let t=0,r=0;for(let a=0,u=e.length;a<u;a++)t=e.charCodeAt(a),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(a++,r+=4);return r}function kMe(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function FMe(e){let t={},r=e.split("&");for(let a=0,u=r.length;a<u;a++){let A=r[a].split("=");t[decodeURIComponent(A[0])]=decodeURIComponent(A[1])}return t}class BMe extends Error{constructor(t,r,a){super(t),this.description=r,this.context=a,this.type="TransportError"}}class k7 extends Ku{constructor(t){super(),this.writable=!1,lR(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,r,a){return super.emitReserved("error",new BMe(t,r,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const r=D7(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const r=kMe(t);return r.length?"?"+r:""}}const Dee="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),F7=64,zMe={};let Pee=0,uR=0,kee;function Fee(e){let t="";do t=Dee[e%F7]+t,e=Math.floor(e/F7);while(e>0);return t}function Bee(){const e=Fee(+new Date);return e!==kee?(Pee=0,kee=e):e+"."+Fee(Pee++)}for(;uR<F7;uR++)zMe[Dee[uR]]=uR;let zee=!1;try{zee=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const UMe=zee;function Uee(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||UMe))return new XMLHttpRequest}catch{}if(!t)try{return new Gp[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function GNt(){}function HMe(){}const $Me=function(){return new Uee({xdomain:!1}).responseType!=null}();class GMe extends k7{constructor(t){if(super(t),this.polling=!1,typeof location<"u"){const a=location.protocol==="https:";let u=location.port;u||(u=a?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||u!==t.port}const r=t&&t.forceBase64;this.supportsBinary=$Me&&!r,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let a=0;this.polling&&(a++,this.once("pollComplete",function(){--a||r()})),this.writable||(a++,this.once("drain",function(){--a||r()}))}else r()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};CMe(t,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,AMe(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=Bee()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new n_(this.uri(),t)}doWrite(t,r){const a=this.request({method:"POST",data:t});a.on("success",r),a.on("error",(u,A)=>{this.onError("xhr post error",u,A)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,a)=>{this.onError("xhr poll error",r,a)}),this.pollXhr=t}}let n_=class fN extends Ku{constructor(t,r){super(),lR(this,r),this.opts=r,this.method=r.method||"GET",this.uri=t,this.data=r.data!==void 0?r.data:null,this.create()}create(){var t;const r=Lee(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;const a=this.xhr=new Uee(r);try{a.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let u in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(u)&&a.setRequestHeader(u,this.opts.extraHeaders[u])}}catch{}if(this.method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(t=this.opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(a.timeout=this.opts.requestTimeout),a.onreadystatechange=()=>{var u;a.readyState===3&&((u=this.opts.cookieJar)===null||u===void 0||u.parseCookies(a)),a.readyState===4&&(a.status===200||a.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof a.status=="number"?a.status:0)},0))},a.send(this.data)}catch(u){this.setTimeoutFn(()=>{this.onError(u)},0);return}typeof document<"u"&&(this.index=fN.requestsCount++,fN.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=HMe,t)try{this.xhr.abort()}catch{}typeof document<"u"&&delete fN.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};if(n_.requestsCount=0,n_.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Hee);else if(typeof addEventListener=="function"){const e="onpagehide"in Gp?"pagehide":"unload";addEventListener(e,Hee,!1)}}function Hee(){for(let e in n_.requests)n_.requests.hasOwnProperty(e)&&n_.requests[e].abort()}const B7=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0))(),cR=Gp.WebSocket||Gp.MozWebSocket,$ee=!0,VMe="arraybuffer",Gee=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class YMe extends k7{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),r=this.opts.protocols,a=Gee?{}:Lee(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=$ee&&!Gee?r?new cR(t,r):new cR(t):new cR(t,r,a)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const a=t[r],u=r===t.length-1;N7(a,this.supportsBinary,A=>{const c={};try{$ee&&this.ws.send(A)}catch{}u&&B7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=Bee()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}check(){return!!cR}}class WMe extends k7{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(t=>{const r=MMe(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(r).getReader(),u=RMe();u.readable.pipeTo(t.writable),this.writer=u.writable.getWriter();const A=()=>{a.read().then(({done:y,value:n})=>{y||(this.onPacket(n),A())}).catch(y=>{})};A();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this.writer.write(c).then(()=>this.onOpen())})}))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const a=t[r],u=r===t.length-1;this.writer.write(a).then(()=>{u&&B7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this.transport)===null||t===void 0||t.close()}}const jMe={websocket:YMe,webtransport:WMe,polling:GMe},KMe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,XMe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function z7(e){if(e.length>2e3)throw"URI too long";const t=e,r=e.indexOf("["),a=e.indexOf("]");r!=-1&&a!=-1&&(e=e.substring(0,r)+e.substring(r,a).replace(/:/g,";")+e.substring(a,e.length));let u=KMe.exec(e||""),A={},c=14;for(;c--;)A[XMe[c]]=u[c]||"";return r!=-1&&a!=-1&&(A.source=t,A.host=A.host.substring(1,A.host.length-1).replace(/;/g,":"),A.authority=A.authority.replace("[","").replace("]","").replace(/;/g,":"),A.ipv6uri=!0),A.pathNames=ZMe(A,A.path),A.queryKey=QMe(A,A.query),A}function ZMe(e,t){const r=/\/{2,9}/g,a=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function QMe(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,u,A){u&&(r[u]=A)}),r}let Vee=class wS extends Ku{constructor(t,r={}){super(),this.binaryType=VMe,this.writeBuffer=[],t&&typeof t=="object"&&(r=t,t=null),t?(t=z7(t),r.hostname=t.host,r.secure=t.protocol==="https"||t.protocol==="wss",r.port=t.port,t.query&&(r.query=t.query)):r.host&&(r.hostname=z7(r.host).host),lR(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=r.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=FMe(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=Nee,r.transport=t,this.id&&(r.sid=this.id);const a=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new jMe[t](a)}open(){let t;if(this.opts.rememberUpgrade&&wS.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else t=this.transports[0];this.readyState="opening";try{t=this.createTransport(t)}catch{this.transports.shift(),this.open();return}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",r=>this.onClose("transport close",r))}probe(t){let r=this.createTransport(t),a=!1;wS.priorWebsocketSuccess=!1;const u=()=>{a||(r.send([{type:"ping",data:"probe"}]),r.once("packet",i=>{if(!a)if(i.type==="pong"&&i.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;wS.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(b(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const w=new Error("probe error");w.transport=r.name,this.emitReserved("upgradeError",w)}}))};function A(){a||(a=!0,b(),r.close(),r=null)}const c=i=>{const w=new Error("probe error: "+i);w.transport=r.name,A(),this.emitReserved("upgradeError",w)};function y(){c("transport closed")}function n(){c("socket closed")}function s(i){r&&i.name!==r.name&&A()}const b=()=>{r.removeListener("open",u),r.removeListener("error",c),r.removeListener("close",y),this.off("close",n),this.off("upgrading",s)};r.once("open",u),r.once("error",c),r.once("close",y),this.once("close",n),this.once("upgrading",s),this.upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||r.open()},200):r.open()}onOpen(){if(this.readyState="open",wS.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let t=0;const r=this.upgrades.length;for(;t<r;t++)this.probe(this.upgrades[t])}}onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const r=new Error("server error");r.code=t.data,this.onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let a=0;a<this.writeBuffer.length;a++){const u=this.writeBuffer[a].data;if(u&&(r+=DMe(u)),a>0&&r>this.maxPayload)return this.writeBuffer.slice(0,a);r+=2}return this.writeBuffer}write(t,r,a){return this.sendPacket("message",t,r,a),this}send(t,r,a){return this.sendPacket("message",t,r,a),this}sendPacket(t,r,a,u){if(typeof r=="function"&&(u=r,r=void 0),typeof a=="function"&&(u=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const A={type:t,data:r,options:a};this.emitReserved("packetCreate",A),this.writeBuffer.push(A),u&&this.once("flush",u),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},a=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():t()}):this.upgrading?a():t()),this}onError(t){wS.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,r){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const r=[];let a=0;const u=t.length;for(;a<u;a++)~this.transports.indexOf(t[a])&&r.push(t[a]);return r}};Vee.protocol=Nee;function JMe(e,t="",r){let a=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),a=z7(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const A=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+A+":"+a.port+t,a.href=a.protocol+"://"+A+(r&&r.port===a.port?"":":"+a.port),a}const qMe=typeof ArrayBuffer=="function",eIe=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Yee=Object.prototype.toString,tIe=typeof Blob=="function"||typeof Blob<"u"&&Yee.call(Blob)==="[object BlobConstructor]",rIe=typeof File=="function"||typeof File<"u"&&Yee.call(File)==="[object FileConstructor]";function U7(e){return qMe&&(e instanceof ArrayBuffer||eIe(e))||tIe&&e instanceof Blob||rIe&&e instanceof File}function fR(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,a=e.length;r<a;r++)if(fR(e[r]))return!0;return!1}if(U7(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return fR(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&fR(e[r]))return!0;return!1}function nIe(e){const t=[],r=e.data,a=e;return a.data=H7(r,t),a.attachments=t.length,{packet:a,buffers:t}}function H7(e,t){if(!e)return e;if(U7(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let a=0;a<e.length;a++)r[a]=H7(e[a],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=H7(e[a],t));return r}return e}function aIe(e,t){return e.data=$7(e.data,t),delete e.attachments,e}function $7(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=$7(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=$7(e[r],t));return e}const iIe=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],oIe=5;var as;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(as||(as={}));class sIe{constructor(t){this.replacer=t}encode(t){return(t.type===as.EVENT||t.type===as.ACK)&&fR(t)?this.encodeAsBinary({type:t.type===as.EVENT?as.BINARY_EVENT:as.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===as.BINARY_EVENT||t.type===as.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=nIe(t),a=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(a),u}}function Wee(e){return Object.prototype.toString.call(e)==="[object Object]"}class G7 extends Ku{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const a=r.type===as.BINARY_EVENT;a||r.type===as.BINARY_ACK?(r.type=a?as.EVENT:as.ACK,this.reconstructor=new lIe(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(U7(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const a={type:Number(t.charAt(0))};if(as[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===as.BINARY_EVENT||a.type===as.BINARY_ACK){const A=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const c=t.substring(A,r);if(c!=Number(c)||t.charAt(r)!=="-")throw new Error("Illegal attachments");a.attachments=Number(c)}if(t.charAt(r+1)==="/"){const A=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););a.nsp=t.substring(A,r)}else a.nsp="/";const u=t.charAt(r+1);if(u!==""&&Number(u)==u){const A=r+1;for(;++r;){const c=t.charAt(r);if(c==null||Number(c)!=c){--r;break}if(r===t.length)break}a.id=Number(t.substring(A,r+1))}if(t.charAt(++r)){const A=this.tryParse(t.substr(r));if(G7.isPayloadValid(a.type,A))a.data=A;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case as.CONNECT:return Wee(r);case as.DISCONNECT:return r===void 0;case as.CONNECT_ERROR:return typeof r=="string"||Wee(r);case as.EVENT:case as.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&iIe.indexOf(r[0])===-1);case as.ACK:case as.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lIe{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=aIe(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const uIe=Object.freeze(Object.defineProperty({__proto__:null,Decoder:G7,Encoder:sIe,get PacketType(){return as},protocol:oIe},Symbol.toStringTag,{value:"Module"}));function J0(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const cIe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class jee extends Ku{constructor(t,r,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=r,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[J0(t,"open",this.onopen.bind(this)),J0(t,"packet",this.onpacket.bind(this)),J0(t,"error",this.onerror.bind(this)),J0(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){if(cIe.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const a={type:as.EVENT,data:r};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const c=this.ids++,y=r.pop();this._registerAckCallback(c,y),a.id=c}const u=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!u||!this.connected)||(this.connected?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(t,r){var a;const u=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(u===void 0){this.acks[t]=r;return}const A=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let c=0;c<this.sendBuffer.length;c++)this.sendBuffer[c].id===t&&this.sendBuffer.splice(c,1);r.call(this,new Error("operation has timed out"))},u);this.acks[t]=(...c)=>{this.io.clearTimeoutFn(A),r.apply(this,[null,...c])}}emitWithAck(t,...r){const a=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((u,A)=>{r.push((c,y)=>a?c?A(c):u(y):u(c)),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((u,...A)=>a!==this._queue[0]?void 0:(u!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...A)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:as.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case as.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case as.EVENT:case as.BINARY_EVENT:this.onevent(t);break;case as.ACK:case as.BINARY_ACK:this.onack(t);break;case as.DISCONNECT:this.ondisconnect();break;case as.CONNECT_ERROR:this.destroy();const a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const a of r)a.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const r=this;let a=!1;return function(...u){a||(a=!0,r.packet({type:as.ACK,id:t,data:u}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(r.apply(this,t.data),delete this.acks[t.id])}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:as.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const r=this._anyListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const r=this._anyOutgoingListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const a of r)a.apply(this,t.data)}}}function a_(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}a_.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0},a_.prototype.reset=function(){this.attempts=0},a_.prototype.setMin=function(e){this.ms=e},a_.prototype.setMax=function(e){this.max=e},a_.prototype.setJitter=function(e){this.jitter=e};class V7 extends Ku{constructor(t,r){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,lR(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((a=r.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new a_({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const u=r.parser||uIe;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Vee(this.uri,this.opts);const r=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const u=J0(r,"open",function(){a.onopen(),t&&t()}),A=y=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},c=J0(r,"error",A);if(this._timeout!==!1){const y=this._timeout,n=this.setTimeoutFn(()=>{u(),A(new Error("timeout")),r.close()},y);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(u),this.subs.push(c),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(J0(t,"ping",this.onping.bind(this)),J0(t,"data",this.ondata.bind(this)),J0(t,"error",this.onerror.bind(this)),J0(t,"close",this.onclose.bind(this)),J0(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){B7(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new jee(this,t,r),this.nsps[t]=a),a}_destroy(t){const r=Object.keys(this.nsps);for(const a of r)if(this.nsps[a].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let a=0;a<r.length;a++)this.engine.write(r[a],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,r){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(u=>{u?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",u)):t.onreconnect()}))},r);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const UT={};function dR(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=JMe(e,t.path||"/socket.io"),a=r.source,u=r.id,A=r.path,c=UT[u]&&A in UT[u].nsps,y=t.forceNew||t["force new connection"]||t.multiplex===!1||c;let n;return y?n=new V7(a,t):(UT[u]||(UT[u]=new V7(a,t)),n=UT[u]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(dR,{Manager:V7,Socket:jee,io:dR,connect:dR});var fIe=e=>{let t={},r=new Date,a=new Date;a.setDate(r.getDate()-1);let u=new Date;u.setDate(r.getDate()-7);let A=new Date;return A.setDate(r.getDate()-30),e.forEach(c=>{let y=new Date(c.createdAt),n=y.toDateString()===r.toDateString(),s=y.toDateString()===a.toDateString(),b=y>=u,i=y>=A,w;n?w="Today":s?w="Yesterday":b?w="Previous 7 days":i?w="Previous 30 days":w=y.toLocaleString("default",{month:"long",year:"numeric"}).split(" ").slice(0,1).join(" "),t[w]||(t[w]=[]),t[w].push(c)}),t},Kee=zs({key:"ThreadIdToResume",default:void 0}),dIe=zs({key:"ChatProfile",default:void 0}),Xee=zs({key:"SessionId",default:m7()}),Y7=lee({key:"SessionIdSelector",get:({get:e})=>e(Xee),set:({set:e},t)=>e(Xee,t instanceof O6e?m7():t)}),W7=zs({key:"Session",dangerouslyAllowMutability:!0,default:void 0}),j7=zs({key:"Actions",default:[]}),i_=zs({key:"Messages",dangerouslyAllowMutability:!0,default:[]}),Zee=zs({key:"TokenCount",default:0}),K7=zs({key:"Loading",default:!1}),hR=zs({key:"AskUser",default:void 0}),Qee=zs({key:"CallFn",default:void 0}),pR=zs({key:"ChatSettings",default:[]}),Jee=lee({key:"ChatSettingsValue/Default",get:({get:e})=>e(pR).reduce((t,r)=>(t[r.id]=r.initial,t),{})}),X7=zs({key:"ChatSettingsValue",default:Jee}),Z7=zs({key:"DisplayElements",default:[]}),Q7=zs({key:"TasklistElements",default:[]}),vR=zs({key:"FirstUserInteraction",default:void 0}),N2=zs({key:"AccessToken",default:void 0}),hIe=zs({key:"User",default:null}),pIe=zs({key:"ChainlitConfig",default:void 0}),vIe=zs({key:"AuthConfig",default:void 0}),HT=zs({key:"ThreadHistory",default:{threads:void 0,currentThreadId:void 0,timeGroupedThreads:void 0,pageInfo:void 0},effects:[({setSelf:e,onSet:t})=>{t((r,a)=>{let u=r==null?void 0:r.timeGroupedThreads;r!=null&&r.threads&&!t_.isEqual(r.threads,a==null?void 0:a.timeGroupedThreads)&&(u=fIe(r.threads)),e({...r,timeGroupedThreads:u})})}]}),o_=zs({key:"SideView",default:void 0}),J7=zs({key:"CurrentThreadId",default:void 0}),q0=()=>{let e=ns(K7),t=ns(Z7),r=ns(Q7),a=ns(j7),u=ns(W7),A=ns(hR),c=ns(Qee),y=ns(pR),n=ns(X7),s=ns(Jee),b=(u==null?void 0:u.socket.connected)&&!(u!=null&&u.error),i=!b||e||(A==null?void 0:A.spec.type)==="file"||(A==null?void 0:A.spec.type)==="action";return{actions:a,askUser:A,callFn:c,chatSettingsDefaultValue:s,chatSettingsInputs:y,chatSettingsValue:n,connected:b,disabled:i,elements:t,error:u==null?void 0:u.error,loading:e,tasklists:r}},mIe=e=>{let t=[];for(let r of e)t=L2(t,r);return t},L2=(e,t)=>mR(e,t.id)?D2(e,t.id,t):"parentId"in t&&t.parentId?ete(e,t.parentId,t):"indent"in t&&t.indent&&t.indent>0?qee(e,t.indent,t):[...e,t],qee=(e,t,r,a=0)=>{let u=[...e];if(u.length===0)return[...u,r];{let A=u.length-1,c=u[A];return c.steps=c.steps||[],a+1===t?(c.steps=[...c.steps,r],u[A]={...c},u):(c.steps=qee(c.steps,t,r,a+1),u[A]={...c},u)}},ete=(e,t,r)=>{let a=[...e];for(let u=0;u<a.length;u++){let A=a[u];t_.isEqual(A.id,t)?(A.steps=A.steps?[...A.steps,r]:[r],a[u]={...A}):mR(a,t)&&A.steps&&(A.steps=ete(A.steps,t,r),a[u]={...A})}return a},tte=(e,t)=>{for(let r of e){if(t_.isEqual(r.id,t))return r;if(r.steps&&r.steps.length>0){let a=tte(r.steps,t);if(a)return a}}},mR=(e,t)=>tte(e,t)!==void 0,D2=(e,t,r)=>{let a=[...e];for(let u=0;u<a.length;u++){let A=a[u];t_.isEqual(A.id,t)?a[u]={steps:A.steps,...r}:mR(a,t)&&A.steps&&(A.steps=D2(A.steps,t,r),a[u]={...A})}return a},rte=(e,t)=>{let r=[...e];for(let a=0;a<r.length;a++){let u=r[a];u.id===t?r=[...r.slice(0,a),...r.slice(a+1)]:mR(r,t)&&u.steps&&(u.steps=rte(u.steps,t),r[a]={...u})}return r},nte=(e,t,r,a,u)=>{let A=[...e];for(let c=0;c<A.length;c++){let y=A[c];t_.isEqual(y.id,t)?("content"in y&&y.content!==void 0?a?y.content=r:y.content+=r:u?"input"in y&&y.input!==void 0&&(a?y.input=r:y.input+=r):"output"in y&&y.output!==void 0&&(a?y.output=r:y.output+=r),A[c]={...y}):y.steps&&(y.steps=nte(y.steps,t,r,a,u),A[c]={...y})}return A},q7="token";function ate(){try{return localStorage.getItem(q7)}catch{return}}function gIe(e){try{return localStorage.setItem(q7,e)}catch{return}}function ite(){try{return localStorage.removeItem(q7)}catch{return}}var yIe=async(e,t,r)=>{var a;return(a=await e.get(t,r))==null?void 0:a.json()};function $T(e,{token:t,...r}={}){let a=pt.useContext(Ac),u=ns(N2);u=t||u;let A=pt.useMemo(()=>([y,n])=>yIe(a,y,n),[a]),c=pt.useMemo(()=>e?[e,u]:null,[e,u]);return _Me(c,A,r)}var Vp=()=>{let e=pt.useContext(Ac),[t,r]=Cu(vIe),[a,u]=Cu(hIe),{data:A,isLoading:c}=$T(t?null:"/auth/config"),[y,n]=Cu(N2),s=Ho(HT);pt.useEffect(()=>{A&&r(A)},[A,r]);let b=!!(!c&&t),i=async()=>{await e.logout(),u(null),ite(),n(""),s(void 0)},w=p=>{if(!p){i();return}try{let{exp:_,...l}=F6e(p);gIe(p),n(`Bearer ${p}`),u(l)}catch(_){console.error("Invalid token, clearing token from local storage","error:",_),i()}};pt.useEffect(()=>{if(!a&&ate()){w(ate());return}},[]);let E=!!y;return t&&!t.requireLogin?{authConfig:t,user:null,isReady:b,isAuthenticated:!0,accessToken:"",logout:()=>{},setAccessToken:()=>{}}:{data:t,user:a,isAuthenticated:E,isReady:b,accessToken:y,logout:i,setAccessToken:w}},eP=class extends Error{constructor(e,t){super(e),this.detail=t}toString(){return this.detail?`${this.message}: ${this.detail}`:this.message}},bIe=class{constructor(e,t,r,a){this.httpEndpoint=e,this.type=t,this.on401=r,this.onError=a}buildEndpoint(e){return this.httpEndpoint.endsWith("/")?`${this.httpEndpoint.slice(0,-1)}${e}`:`${this.httpEndpoint}${e}`}checkToken(e){let t="Bearer ";return e.startsWith(t)?e:t+e}async fetch(e,t,r,a,u){try{let A={};r&&(A.Authorization=this.checkToken(r));let c;a instanceof FormData?c=a:(A["Content-Type"]="application/json",c=a?JSON.stringify(a):null);let y=await fetch(this.buildEndpoint(t),{method:e,headers:A,signal:u,body:c});if(!y.ok){let n=await y.json();throw y.status===401&&this.on401&&(ite(),this.on401()),new eP(y.statusText,n.detail)}return y}catch(A){throw A instanceof eP&&this.onError&&this.onError(A),console.error(A),A}}async get(e,t){return await this.fetch("GET",e,t)}async post(e,t,r,a){return await this.fetch("POST",e,r,t,a)}async put(e,t,r){return await this.fetch("PUT",e,r,t)}async patch(e,t,r){return await this.fetch("PATCH",e,r,t)}async delete(e,t,r){return await this.fetch("DELETE",e,r,t)}},ote=class extends bIe{async headerAuth(){return(await this.post("/auth/header",{})).json()}async passwordAuth(e){return(await this.post("/login",e)).json()}async logout(){return(await this.post("/logout",{})).json()}async setFeedback(e,t){return(await this.put("/feedback",{feedback:e},t)).json()}async deleteFeedback(e,t){return(await this.delete("/feedback",{feedbackId:e},t)).json()}async listThreads(e,t,r){return(await this.post("/project/threads",{pagination:e,filter:t},r)).json()}async deleteThread(e,t){return(await this.delete("/project/thread",{threadId:e},t)).json()}uploadFile(e,t,r,a){let u=new XMLHttpRequest,A=new Promise((c,y)=>{let n=new FormData;n.append("file",e),u.open("POST",this.buildEndpoint(`/project/file?session_id=${r}`),!0),a&&u.setRequestHeader("Authorization",this.checkToken(a)),u.upload.onprogress=function(s){if(s.lengthComputable){let b=s.loaded/s.total*100;t(b)}},u.onload=function(){if(u.status===200){let s=JSON.parse(u.responseText);c(s)}else y("Upload failed")},u.onerror=function(){y("Upload error")},u.send(n)});return{xhr:u,promise:A}}getElementUrl(e,t){let r=`?session_id=${t}`;return this.buildEndpoint(`/project/file/${e}${r}`)}getLogoEndpoint(e){return this.buildEndpoint(`/logo?theme=${e}`)}getOAuthEndpoint(e){return this.buildEndpoint(`/auth/oauth/${e}`)}},Ac=pt.createContext(new ote("http://localhost:8000","webapp")),Xu=()=>{let e=pt.useContext(Ac),t=ns(N2),r=ns(W7),a=ns(hR),u=ns(Y7),A=J5(pR),c=J5(Y7),y=J5(X7),n=Ho(vR),s=Ho(K7),b=Ho(i_),i=Ho(Z7),w=Ho(Q7),E=Ho(j7),p=Ho(Zee),_=Ho(Kee),l=Ho(o_),o=Ho(J7),d=pt.useCallback(()=>{r==null||r.socket.emit("clear_session"),r==null||r.socket.disconnect(),_(void 0),c(),n(void 0),b([]),i([]),w([]),E([]),p(0),A(),y(),l(void 0),o(void 0)},[r]),f=pt.useCallback((x,R=[])=>{x.id||(x.id=m7()),x.createdAt||(x.createdAt=new Date().toISOString()),b(P=>L2(P,x)),r==null||r.socket.emit("client_message",{message:x,fileReferences:R})},[r==null?void 0:r.socket]),h=pt.useCallback(x=>{r==null||r.socket.emit("edit_message",{message:x})},[r==null?void 0:r.socket]),g=pt.useCallback((x,R,P,L)=>{r==null||r.socket.emit("audio_chunk",{isStart:x,mimeType:R,elapsedTime:P,data:L})},[r==null?void 0:r.socket]),v=pt.useCallback(x=>{r==null||r.socket.emit("audio_end",{fileReferences:x})},[r==null?void 0:r.socket]),C=pt.useCallback(x=>{a&&(b(R=>L2(R,x)),a.callback(x))},[a]),S=pt.useCallback(x=>{r==null||r.socket.emit("chat_settings_change",x)},[r==null?void 0:r.socket]),I=pt.useCallback(()=>{b(x=>x.map(R=>(R.streaming=!1,R))),s(!1),r==null||r.socket.emit("stop")},[r==null?void 0:r.socket]),T=pt.useCallback(x=>{let R=r==null?void 0:r.socket;if(!R)return;let P=new Promise((L,F)=>{R.once("action_response",N=>{N.status?L(N):F(N)})});return R.emit("action_call",x),P},[r==null?void 0:r.socket]);return{uploadFile:pt.useCallback((x,R)=>e.uploadFile(x,R,u,t),[u,t]),callAction:T,clear:d,replyMessage:C,sendMessage:f,editMessage:h,sendAudioChunk:g,endAudioStream:v,stopTask:I,setIdToResume:_,updateChatSettings:S}},Kh=()=>{let e=ns(i_),t=ns(vR);return{threadId:ns(J7),messages:e,firstInteraction:t}},ig=()=>{let e=pt.useContext(Ac),t=ns(Y7),[r,a]=Cu(W7),u=J5(X7),A=Ho(vR),c=Ho(K7),y=Ho(i_),n=Ho(hR),s=Ho(Qee),b=Ho(Z7),i=Ho(Q7),w=Ho(j7),E=Ho(pR),p=Ho(Zee),[_,l]=Cu(dIe),o=ns(Kee),d=Ho(J7),f=pt.useCallback(({userEnv:v,accessToken:C})=>{let{protocol:S,host:I,pathname:T}=new URL(e.httpEndpoint),x=`${S}//${I}`,R=T&&T!=="/"?`${T}/ws/socket.io`:"/ws/socket.io",P=dR(x,{path:R,extraHeaders:{Authorization:C||"","X-Chainlit-Client-Type":e.type,"X-Chainlit-Session-Id":t,"X-Chainlit-Thread-Id":o||"","user-env":JSON.stringify(v),"X-Chainlit-Chat-Profile":_?encodeURIComponent(_):""}});a(L=>{var F,N;return(F=L==null?void 0:L.socket)==null||F.removeAllListeners(),(N=L==null?void 0:L.socket)==null||N.close(),{socket:P}}),P.on("connect",()=>{P.emit("connection_successful"),a(L=>({...L,error:!1}))}),P.on("connect_error",L=>{a(F=>({...F,error:!0}))}),P.on("task_start",()=>{c(!0)}),P.on("task_end",()=>{c(!1)}),P.on("reload",()=>{P.emit("clear_session"),window.location.reload()}),P.on("resume_thread",L=>{var k,O;let F=[];for(let m of L.steps)F=L2(F,m);(k=L.metadata)!=null&&k.chat_profile&&l((O=L.metadata)==null?void 0:O.chat_profile),y(F);let N=L.elements||[];i(N.filter(m=>m.type==="tasklist")),b(N.filter(m=>["avatar","tasklist"].indexOf(m.type)===-1))}),P.on("new_message",L=>{y(F=>L2(F,L))}),P.on("first_interaction",L=>{A(L.interaction),d(L.thread_id)}),P.on("update_message",L=>{y(F=>D2(F,L.id,L))}),P.on("delete_message",L=>{y(F=>rte(F,L.id))}),P.on("stream_start",L=>{y(F=>L2(F,L))}),P.on("stream_token",({id:L,token:F,isSequence:N,isInput:k})=>{y(O=>nte(O,L,F,N,k))}),P.on("ask",({msg:L,spec:F},N)=>{n({spec:F,callback:N}),y(k=>L2(k,L)),c(!1)}),P.on("ask_timeout",()=>{n(void 0),c(!1)}),P.on("clear_ask",()=>{n(void 0)}),P.on("call_fn",({name:L,args:F},N)=>{s({name:L,args:F,callback:N})}),P.on("clear_call_fn",()=>{s(void 0)}),P.on("call_fn_timeout",()=>{s(void 0)}),P.on("chat_settings",L=>{E(L),u()}),P.on("element",L=>{!L.url&&L.chainlitKey&&(L.url=e.getElementUrl(L.chainlitKey,t)),L.type==="tasklist"?i(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?[...F,L]:[...F.slice(0,N),L,...F.slice(N+1)]}):b(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?[...F,L]:[...F.slice(0,N),L,...F.slice(N+1)]})}),P.on("remove_element",L=>{b(F=>F.filter(N=>N.id!==L.id)),i(F=>F.filter(N=>N.id!==L.id))}),P.on("action",L=>{w(F=>[...F,L])}),P.on("remove_action",L=>{w(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?F:[...F.slice(0,N),...F.slice(N+1)]})}),P.on("token_usage",L=>{p(F=>F+L)})},[a,t,_]),h=pt.useCallback(t_.debounce(f,200),[f]),g=pt.useCallback(()=>{r!=null&&r.socket&&(r.socket.removeAllListeners(),r.socket.close())},[r]);return{connect:h,disconnect:g,session:r,sessionId:t,chatProfile:_,idToResume:o,setChatProfile:l}},xIe={enabled:!0,min_decibels:-45,initial_silence_timeout:3e3,silence_timeout:1500,max_duration:15e3,chunk_duration:1e3},_Ie=(e=xIe)=>{let t=pt.useRef(null),r=pt.useRef(!1),{sendAudioChunk:a,endAudioStream:u}=Xu(),[A,c]=pt.useState(!1),[y,n]=pt.useState(void 0),[s,b]=pt.useState(!1),[i,w]=pt.useState(void 0),[E,p]=pt.useState(!1),_=pt.useCallback(()=>{!A||!t.current||(r.current=!0,t.current.stop())},[A]),l=pt.useCallback(()=>{!A||!t.current||t.current.stop()},[A]);return{startRecording:pt.useCallback(o=>{if(A||!e)return;p(!1),w(void 0),clearTimeout(y),r.current=!1;let{min_decibels:d,silence_timeout:f,initial_silence_timeout:h,chunk_duration:g,max_duration:v}=e;navigator.mediaDevices.getUserMedia({audio:!0}).then(C=>{let S=!1,I=!1,T=!0,x=null,R=Date.now(),P=new MediaRecorder(C);t.current=P,P.addEventListener("start",()=>{c(!0),R=Date.now()}),P.addEventListener("dataavailable",async D=>{if(S||(x?x=new Blob([x,D.data],{type:D.data.type}):x=new Blob([D.data],{type:D.data.type})),P.state==="inactive")return;let M=Date.now()-R;if(M>=v){P.stop(),C.getTracks().forEach(Y=>Y.stop());return}b(I);let[H,B]=P.mimeType.split(";");x?(await a(T,H,M,new Blob([x,D.data])),x=null):await a(T,H,M,D.data),T&&(T=!1)}),P.addEventListener("stop",async()=>{c(!1),b(!1),S&&!r.current&&(p(!0),await u(o))});let L=new AudioContext,F=L.createMediaStreamSource(C),N=L.createAnalyser();N.minDecibels=d,F.connect(N);let k=N.frequencyBinCount,O=new Uint8Array(k);P.start(g);let m=()=>{if(P.state==="inactive")return;N.getByteFrequencyData(O);let D=O.some(M=>M>0);I||(I=D),!S&&D&&(b(I),S=!0),requestAnimationFrame(m)};m(),setTimeout(()=>{S?n(setInterval(()=>{I?I=!1:(P.stop(),C.getTracks().forEach(D=>D.stop()))},f)):(P.stop(),C.getTracks().forEach(D=>D.stop()))},h)}).catch(C=>{w(C.message)})},[y,A,e,a,u]),stopRecording:l,cancelRecording:_,isRecording:A,isSpeaking:s,isRecordingFinished:E,error:i}},Dl=e=>{let[t,r]=Cu(pIe),{isAuthenticated:a}=Vp(),u=navigator.language||"en-US",{data:A,error:c,isLoading:y}=$T(!t&&a?`/project/settings?language=${u}`:null,{token:e});return pt.useEffect(()=>{A&&r(A)},[A,r]),{config:t,error:c,isLoading:y,language:u}};function EIe(e){const t=e,r=()=>{Z0.error("Unauthorized")},a=u=>{Z0.error(u.toString())};return new ote(t,"copilot",r,a)}const SIe={accessToken:void 0},gR=pt.createContext(SIe);let yR;const TIe=new Uint8Array(16);function wIe(){if(!yR&&(yR=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yR))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yR(TIe)}const Qc=[];for(let e=0;e<256;++e)Qc.push((e+256).toString(16).slice(1));function AIe(e,t=0){return(Qc[e[t+0]]+Qc[e[t+1]]+Qc[e[t+2]]+Qc[e[t+3]]+"-"+Qc[e[t+4]]+Qc[e[t+5]]+"-"+Qc[e[t+6]]+Qc[e[t+7]]+"-"+Qc[e[t+8]]+Qc[e[t+9]]+"-"+Qc[e[t+10]]+Qc[e[t+11]]+Qc[e[t+12]]+Qc[e[t+13]]+Qc[e[t+14]]+Qc[e[t+15]]).toLowerCase()}const ste={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function tP(e,t,r){if(ste.randomUUID&&!t&&!e)return ste.randomUUID();e=e||{};const a=e.random||(e.rng||wIe)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,t){r=r||0;for(let u=0;u<16;++u)t[r+u]=a[u];return t}return AIe(a)}const GT={black:"#000",white:"#fff"},s_={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},l_={50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},u_={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},c_={50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},f_={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},VT={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},lte={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"};function P1(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function ute(e){if(!P1(e))return e;const t={};return Object.keys(e).forEach(r=>{t[r]=ute(e[r])}),t}function Zd(e,t,r={clone:!0}){const a=r.clone?ir({},e):e;return P1(e)&&P1(t)&&Object.keys(t).forEach(u=>{P1(t[u])&&Object.prototype.hasOwnProperty.call(e,u)&&P1(e[u])?a[u]=Zd(e[u],t[u],r):r.clone?a[u]=P1(t[u])?ute(t[u]):t[u]:a[u]=t[u]}),a}function k1(e){let t="https://mui.com/production-error/?code="+e;for(let r=1;r<arguments.length;r+=1)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified MUI error #"+e+"; visit "+t+" for the full message."}var js={};/**
|
|
88
|
+
*/var r_=pt;function B6e(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var z6e=typeof Object.is=="function"?Object.is:B6e,U6e=r_.useState,H6e=r_.useEffect,$6e=r_.useLayoutEffect,G6e=r_.useDebugValue;function V6e(e,t){var r=t(),a=U6e({inst:{value:r,getSnapshot:t}}),u=a[0].inst,A=a[1];return $6e(function(){u.value=r,u.getSnapshot=t,y7(u)&&A({inst:u})},[e,r,t]),H6e(function(){return y7(u)&&A({inst:u}),e(function(){y7(u)&&A({inst:u})})},[e]),G6e(r),r}function y7(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!z6e(e,r)}catch{return!0}}function Y6e(e,t){return t()}var W6e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Y6e:V6e;dee.useSyncExternalStore=r_.useSyncExternalStore!==void 0?r_.useSyncExternalStore:W6e,fee.exports=dee;var j6e=fee.exports;const L1=()=>{},Xd=L1(),b7=Object,Es=e=>e===Xd,ng=e=>typeof e=="function",D1=(e,t)=>({...e,...t}),K6e=e=>ng(e.then),rR=new WeakMap;let X6e=0;const kT=e=>{const t=typeof e,r=e&&e.constructor,a=r==Date;let u,A;if(b7(e)===e&&!a&&r!=RegExp){if(u=rR.get(e),u)return u;if(u=++X6e+"~",rR.set(e,u),r==Array){for(u="@",A=0;A<e.length;A++)u+=kT(e[A])+",";rR.set(e,u)}if(r==b7){u="#";const c=b7.keys(e).sort();for(;!Es(A=c.pop());)Es(e[A])||(u+=A+":"+kT(e[A])+",");rR.set(e,u)}}else u=a?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return u},ag=new WeakMap,x7={},nR={},_7="undefined",aR=typeof window!=_7,E7=typeof document!=_7,Z6e=()=>aR&&typeof window.requestAnimationFrame!=_7,hee=(e,t)=>{const r=ag.get(e);return[()=>!Es(t)&&e.get(t)||x7,a=>{if(!Es(t)){const u=e.get(t);t in nR||(nR[t]=u),r[5](t,D1(u,a),u||x7)}},r[6],()=>!Es(t)&&t in nR?nR[t]:!Es(t)&&e.get(t)||x7]};let S7=!0;const Q6e=()=>S7,[T7,w7]=aR&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[L1,L1],J6e=()=>{const e=E7&&document.visibilityState;return Es(e)||e!=="hidden"},q6e=e=>(E7&&document.addEventListener("visibilitychange",e),T7("focus",e),()=>{E7&&document.removeEventListener("visibilitychange",e),w7("focus",e)}),eMe=e=>{const t=()=>{S7=!0,e()},r=()=>{S7=!1};return T7("online",t),T7("offline",r),()=>{w7("online",t),w7("offline",r)}},tMe={isOnline:Q6e,isVisible:J6e},rMe={initFocus:q6e,initReconnect:eMe},pee=!Qn.useId,FT=!aR||"Deno"in window,nMe=e=>Z6e()?window.requestAnimationFrame(e):setTimeout(e,1),A7=FT?pt.useEffect:pt.useLayoutEffect,C7=typeof navigator<"u"&&navigator.connection,vee=!FT&&C7&&(["slow-2g","2g"].includes(C7.effectiveType)||C7.saveData),R7=e=>{if(ng(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?kT(e):"",[e,t]};let aMe=0;const M7=()=>++aMe,mee=0,gee=1,yee=2;var BT={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:mee,MUTATE_EVENT:yee,RECONNECT_EVENT:gee};async function bee(...e){const[t,r,a,u]=e,A=D1({populateCache:!0,throwOnError:!0},typeof u=="boolean"?{revalidate:u}:u||{});let c=A.populateCache;const y=A.rollbackOnError;let n=A.optimisticData;const s=A.revalidate!==!1,b=E=>typeof y=="function"?y(E):y!==!1,i=A.throwOnError;if(ng(r)){const E=r,p=[],_=t.keys();for(const l of _)!/^\$(inf|sub)\$/.test(l)&&E(t.get(l)._k)&&p.push(l);return Promise.all(p.map(w))}return w(r);async function w(E){const[p]=R7(E);if(!p)return;const[_,l]=hee(t,p),[o,d,f,h]=ag.get(t),g=()=>{const L=o[p];return s&&(delete f[p],delete h[p],L&&L[0])?L[0](yee).then(()=>_().data):_().data};if(e.length<3)return g();let v=a,C;const S=M7();d[p]=[S,0];const I=!Es(n),T=_(),x=T.data,R=T._c,P=Es(R)?x:R;if(I&&(n=ng(n)?n(P,x):n,l({data:n,_c:P})),ng(v))try{v=v(P)}catch(L){C=L}if(v&&K6e(v))if(v=await v.catch(L=>{C=L}),S!==d[p][0]){if(C)throw C;return v}else C&&I&&b(C)&&(c=!0,l({data:P,_c:Xd}));if(c&&!C)if(ng(c)){const L=c(v,P);l({data:L,error:Xd,_c:Xd})}else l({data:v,error:Xd,_c:Xd});if(d[p][1]=M7(),Promise.resolve(g()).then(()=>{l({_c:Xd})}),C){if(i)throw C;return}return v}}const xee=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},iMe=(e,t)=>{if(!ag.has(e)){const r=D1(rMe,t),a={},u=bee.bind(Xd,e);let A=L1;const c={},y=(b,i)=>{const w=c[b]||[];return c[b]=w,w.push(i),()=>w.splice(w.indexOf(i),1)},n=(b,i,w)=>{e.set(b,i);const E=c[b];if(E)for(const p of E)p(i,w)},s=()=>{if(!ag.has(e)&&(ag.set(e,[a,{},{},{},u,n,y]),!FT)){const b=r.initFocus(setTimeout.bind(Xd,xee.bind(Xd,a,mee))),i=r.initReconnect(setTimeout.bind(Xd,xee.bind(Xd,a,gee)));A=()=>{b&&b(),i&&i(),ag.delete(e)}}};return s(),[e,u,s,A]}return[e,ag.get(e)[4]]},oMe=(e,t,r,a,u)=>{const A=r.errorRetryCount,c=u.retryCount,y=~~((Math.random()+.5)*(1<<(c<8?c:8)))*r.errorRetryInterval;!Es(A)&&c>A||setTimeout(a,y,u)},sMe=(e,t)=>kT(e)==kT(t),[_ee,lMe]=iMe(new Map),uMe=D1({onLoadingSlow:L1,onSuccess:L1,onError:L1,onErrorRetry:oMe,onDiscarded:L1,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:vee?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:vee?5e3:3e3,compare:sMe,isPaused:()=>!1,cache:_ee,mutate:lMe,fallback:{}},tMe),cMe=(e,t)=>{const r=D1(e,t);if(t){const{use:a,fallback:u}=e,{use:A,fallback:c}=t;a&&A&&(r.use=a.concat(A)),u&&c&&(r.fallback=D1(u,c))}return r},fMe=pt.createContext({}),dMe="$inf$",Eee=aR&&window.__SWR_DEVTOOLS_USE__,hMe=Eee?window.__SWR_DEVTOOLS_USE__:[],pMe=()=>{Eee&&(window.__SWR_DEVTOOLS_REACT__=Qn)},vMe=e=>ng(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],mMe=()=>D1(uMe,pt.useContext(fMe)),gMe=e=>(t,r,a)=>e(t,r&&((...A)=>{const[c]=R7(t),[,,,y]=ag.get(_ee);if(c.startsWith(dMe))return r(...A);const n=y[c];return Es(n)?r(...A):(delete y[c],n)}),a),yMe=hMe.concat(gMe),bMe=e=>function(...r){const a=mMe(),[u,A,c]=vMe(r),y=cMe(a,c);let n=e;const{use:s}=y,b=(s||[]).concat(yMe);for(let i=b.length;i--;)n=b[i](n);return n(u,A||y.fetcher||null,y)},xMe=(e,t,r)=>{const a=t[e]||(t[e]=[]);return a.push(r),()=>{const u=a.indexOf(r);u>=0&&(a[u]=a[a.length-1],a.pop())}};pMe();const See=Qn.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),I7={dedupe:!0},_Me=bMe((e,t,r)=>{const{cache:a,compare:u,suspense:A,fallbackData:c,revalidateOnMount:y,revalidateIfStale:n,refreshInterval:s,refreshWhenHidden:b,refreshWhenOffline:i,keepPreviousData:w}=r,[E,p,_,l]=ag.get(a),[o,d]=R7(e),f=pt.useRef(!1),h=pt.useRef(!1),g=pt.useRef(o),v=pt.useRef(t),C=pt.useRef(r),S=()=>C.current,I=()=>S().isVisible()&&S().isOnline(),[T,x,R,P]=hee(a,o),L=pt.useRef({}).current,F=Es(c)?r.fallback[o]:c,N=(ie,se)=>{for(const he in L){const te=he;if(te==="data"){if(!u(ie[te],se[te])&&(!Es(ie[te])||!u($,se[te])))return!1}else if(se[te]!==ie[te])return!1}return!0},k=pt.useMemo(()=>{const ie=(()=>!o||!t?!1:Es(y)?S().isPaused()||A?!1:Es(n)?!0:n:y)(),se=ae=>{const ce=D1(ae);return delete ce._k,ie?{isValidating:!0,isLoading:!0,...ce}:ce},he=T(),te=P(),Z=se(he),J=he===te?Z:se(te);let re=Z;return[()=>{const ae=se(T());return N(ae,re)?(re.data=ae.data,re.isLoading=ae.isLoading,re.isValidating=ae.isValidating,re.error=ae.error,re):(re=ae,ae)},()=>J]},[a,o]),O=j6e.useSyncExternalStore(pt.useCallback(ie=>R(o,(se,he)=>{N(he,se)||ie()}),[a,o]),k[0],k[1]),m=!f.current,D=E[o]&&E[o].length>0,M=O.data,H=Es(M)?F:M,B=O.error,Y=pt.useRef(H),$=w?Es(M)?Y.current:M:H,V=(()=>D&&!Es(B)?!1:m&&!Es(y)?y:S().isPaused()?!1:A?Es(H)?!1:n:Es(H)||n)(),W=!!(o&&t&&m&&V),G=Es(O.isValidating)?W:O.isValidating,j=Es(O.isLoading)?W:O.isLoading,X=pt.useCallback(async ie=>{const se=v.current;if(!o||!se||h.current||S().isPaused())return!1;let he,te,Z=!0;const J=ie||{},re=!_[o]||!J.dedupe,ae=()=>pee?!h.current&&o===g.current&&f.current:o===g.current,ce={isValidating:!1,isLoading:!1},ne=()=>{x(ce)},Q=()=>{const oe=_[o];oe&&oe[1]===te&&delete _[o]},fe={isValidating:!0};Es(T().data)&&(fe.isLoading=!0);try{if(re&&(x(fe),r.loadingTimeout&&Es(T().data)&&setTimeout(()=>{Z&&ae()&&S().onLoadingSlow(o,r)},r.loadingTimeout),_[o]=[se(d),M7()]),[he,te]=_[o],he=await he,re&&setTimeout(Q,r.dedupingInterval),!_[o]||_[o][1]!==te)return re&&ae()&&S().onDiscarded(o),!1;ce.error=Xd;const oe=p[o];if(!Es(oe)&&(te<=oe[0]||te<=oe[1]||oe[1]===0))return ne(),re&&ae()&&S().onDiscarded(o),!1;const de=T().data;ce.data=u(de,he)?de:he,re&&ae()&&S().onSuccess(he,o,r)}catch(oe){Q();const de=S(),{shouldRetryOnError:me}=de;de.isPaused()||(ce.error=oe,re&&ae()&&(de.onError(oe,o,de),(me===!0||ng(me)&&me(oe))&&I()&&de.onErrorRetry(oe,o,de,xe=>{const Se=E[o];Se&&Se[0]&&Se[0](BT.ERROR_REVALIDATE_EVENT,xe)},{retryCount:(J.retryCount||0)+1,dedupe:!0})))}return Z=!1,ne(),!0},[o,a]),q=pt.useCallback((...ie)=>bee(a,g.current,...ie),[]);if(A7(()=>{v.current=t,C.current=r,Es(M)||(Y.current=M)}),A7(()=>{if(!o)return;const ie=X.bind(Xd,I7);let se=0;const te=xMe(o,E,(Z,J={})=>{if(Z==BT.FOCUS_EVENT){const re=Date.now();S().revalidateOnFocus&&re>se&&I()&&(se=re+S().focusThrottleInterval,ie())}else if(Z==BT.RECONNECT_EVENT)S().revalidateOnReconnect&&I()&&ie();else{if(Z==BT.MUTATE_EVENT)return X();if(Z==BT.ERROR_REVALIDATE_EVENT)return X(J)}});return h.current=!1,g.current=o,f.current=!0,x({_k:d}),V&&(Es(H)||FT?ie():nMe(ie)),()=>{h.current=!0,te()}},[o]),A7(()=>{let ie;function se(){const te=ng(s)?s(T().data):s;te&&ie!==-1&&(ie=setTimeout(he,te))}function he(){!T().error&&(b||S().isVisible())&&(i||S().isOnline())?X(I7).then(se):se()}return se(),()=>{ie&&(clearTimeout(ie),ie=-1)}},[s,b,i,o]),pt.useDebugValue($),A&&Es(H)&&o){if(!pee&&FT)throw new Error("Fallback data is required when using suspense in SSR.");v.current=t,C.current=r,h.current=!1;const ie=l[o];if(!Es(ie)){const se=q(ie);See(se)}if(Es(B)){const se=X(I7);Es($)||(se.status="fulfilled",se.value=!0),See(se)}else throw B}return{mutate:q,get data(){return L.data=!0,$},get error(){return L.error=!0,B},get isValidating(){return L.isValidating=!0,G},get isLoading(){return L.isLoading=!0,j}}}),qv=Object.create(null);qv.open="0",qv.close="1",qv.ping="2",qv.pong="3",qv.message="4",qv.upgrade="5",qv.noop="6";const iR=Object.create(null);Object.keys(qv).forEach(e=>{iR[qv[e]]=e});const O7={type:"error",data:"parser error"},Tee=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",wee=typeof ArrayBuffer=="function",Aee=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,N7=({type:e,data:t},r,a)=>Tee&&t instanceof Blob?r?a(t):Cee(t,a):wee&&(t instanceof ArrayBuffer||Aee(t))?r?a(t):Cee(new Blob([t]),a):a(qv[e]+(t||"")),Cee=(e,t)=>{const r=new FileReader;return r.onload=function(){const a=r.result.split(",")[1];t("b"+(a||""))},r.readAsDataURL(e)};function Ree(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let L7;function EMe(e,t){if(Tee&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ree).then(t);if(wee&&(e.data instanceof ArrayBuffer||Aee(e.data)))return t(Ree(e.data));N7(e,!1,r=>{L7||(L7=new TextEncoder),t(L7.encode(r))})}const Mee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zT=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Mee.length;e++)zT[Mee.charCodeAt(e)]=e;const SMe=e=>{let t=e.length*.75,r=e.length,a,u=0,A,c,y,n;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const s=new ArrayBuffer(t),b=new Uint8Array(s);for(a=0;a<r;a+=4)A=zT[e.charCodeAt(a)],c=zT[e.charCodeAt(a+1)],y=zT[e.charCodeAt(a+2)],n=zT[e.charCodeAt(a+3)],b[u++]=A<<2|c>>4,b[u++]=(c&15)<<4|y>>2,b[u++]=(y&3)<<6|n&63;return s},TMe=typeof ArrayBuffer=="function",D7=(e,t)=>{if(typeof e!="string")return{type:"message",data:Iee(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:wMe(e.substring(1),t)}:iR[r]?e.length>1?{type:iR[r],data:e.substring(1)}:{type:iR[r]}:O7},wMe=(e,t)=>{if(TMe){const r=SMe(e);return Iee(r,t)}else return{base64:!0,data:e}},Iee=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Oee=String.fromCharCode(30),AMe=(e,t)=>{const r=e.length,a=new Array(r);let u=0;e.forEach((A,c)=>{N7(A,!1,y=>{a[c]=y,++u===r&&t(a.join(Oee))})})},CMe=(e,t)=>{const r=e.split(Oee),a=[];for(let u=0;u<r.length;u++){const A=D7(r[u],t);if(a.push(A),A.type==="error")break}return a};function RMe(){return new TransformStream({transform(e,t){EMe(e,r=>{const a=r.length;let u;if(a<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,a);else if(a<65536){u=new Uint8Array(3);const A=new DataView(u.buffer);A.setUint8(0,126),A.setUint16(1,a)}else{u=new Uint8Array(9);const A=new DataView(u.buffer);A.setUint8(0,127),A.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(u[0]|=128),t.enqueue(u),t.enqueue(r)})}})}let P7;function oR(e){return e.reduce((t,r)=>t+r.length,0)}function sR(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let a=0;for(let u=0;u<t;u++)r[u]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),r}function MMe(e,t){P7||(P7=new TextDecoder);const r=[];let a=0,u=-1,A=!1;return new TransformStream({transform(c,y){for(r.push(c);;){if(a===0){if(oR(r)<1)break;const n=sR(r,1);A=(n[0]&128)===128,u=n[0]&127,u<126?a=3:u===126?a=1:a=2}else if(a===1){if(oR(r)<2)break;const n=sR(r,2);u=new DataView(n.buffer,n.byteOffset,n.length).getUint16(0),a=3}else if(a===2){if(oR(r)<8)break;const n=sR(r,8),s=new DataView(n.buffer,n.byteOffset,n.length),b=s.getUint32(0);if(b>Math.pow(2,53-32)-1){y.enqueue(O7);break}u=b*Math.pow(2,32)+s.getUint32(4),a=3}else{if(oR(r)<u)break;const n=sR(r,u);y.enqueue(D7(A?n:P7.decode(n),t)),a=0}if(u===0||u>e){y.enqueue(O7);break}}}})}const Nee=4;function Ku(e){if(e)return IMe(e)}function IMe(e){for(var t in Ku.prototype)e[t]=Ku.prototype[t];return e}Ku.prototype.on=Ku.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ku.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},Ku.prototype.off=Ku.prototype.removeListener=Ku.prototype.removeAllListeners=Ku.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,u=0;u<r.length;u++)if(a=r[u],a===t||a.fn===t){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+e],this},Ku.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(r){r=r.slice(0);for(var a=0,u=r.length;a<u;++a)r[a].apply(this,t)}return this},Ku.prototype.emitReserved=Ku.prototype.emit,Ku.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ku.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Gp=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Lee(e,...t){return t.reduce((r,a)=>(e.hasOwnProperty(a)&&(r[a]=e[a]),r),{})}const OMe=Gp.setTimeout,NMe=Gp.clearTimeout;function lR(e,t){t.useNativeTimers?(e.setTimeoutFn=OMe.bind(Gp),e.clearTimeoutFn=NMe.bind(Gp)):(e.setTimeoutFn=Gp.setTimeout.bind(Gp),e.clearTimeoutFn=Gp.clearTimeout.bind(Gp))}const LMe=1.33;function DMe(e){return typeof e=="string"?PMe(e):Math.ceil((e.byteLength||e.size)*LMe)}function PMe(e){let t=0,r=0;for(let a=0,u=e.length;a<u;a++)t=e.charCodeAt(a),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(a++,r+=4);return r}function kMe(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function FMe(e){let t={},r=e.split("&");for(let a=0,u=r.length;a<u;a++){let A=r[a].split("=");t[decodeURIComponent(A[0])]=decodeURIComponent(A[1])}return t}class BMe extends Error{constructor(t,r,a){super(t),this.description=r,this.context=a,this.type="TransportError"}}class k7 extends Ku{constructor(t){super(),this.writable=!1,lR(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,r,a){return super.emitReserved("error",new BMe(t,r,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const r=D7(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const r=kMe(t);return r.length?"?"+r:""}}const Dee="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),F7=64,zMe={};let Pee=0,uR=0,kee;function Fee(e){let t="";do t=Dee[e%F7]+t,e=Math.floor(e/F7);while(e>0);return t}function Bee(){const e=Fee(+new Date);return e!==kee?(Pee=0,kee=e):e+"."+Fee(Pee++)}for(;uR<F7;uR++)zMe[Dee[uR]]=uR;let zee=!1;try{zee=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const UMe=zee;function Uee(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||UMe))return new XMLHttpRequest}catch{}if(!t)try{return new Gp[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function GNt(){}function HMe(){}const $Me=function(){return new Uee({xdomain:!1}).responseType!=null}();class GMe extends k7{constructor(t){if(super(t),this.polling=!1,typeof location<"u"){const a=location.protocol==="https:";let u=location.port;u||(u=a?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||u!==t.port}const r=t&&t.forceBase64;this.supportsBinary=$Me&&!r,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let a=0;this.polling&&(a++,this.once("pollComplete",function(){--a||r()})),this.writable||(a++,this.once("drain",function(){--a||r()}))}else r()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};CMe(t,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,AMe(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=Bee()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new n_(this.uri(),t)}doWrite(t,r){const a=this.request({method:"POST",data:t});a.on("success",r),a.on("error",(u,A)=>{this.onError("xhr post error",u,A)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,a)=>{this.onError("xhr poll error",r,a)}),this.pollXhr=t}}let n_=class fN extends Ku{constructor(t,r){super(),lR(this,r),this.opts=r,this.method=r.method||"GET",this.uri=t,this.data=r.data!==void 0?r.data:null,this.create()}create(){var t;const r=Lee(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;const a=this.xhr=new Uee(r);try{a.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let u in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(u)&&a.setRequestHeader(u,this.opts.extraHeaders[u])}}catch{}if(this.method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(t=this.opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(a.timeout=this.opts.requestTimeout),a.onreadystatechange=()=>{var u;a.readyState===3&&((u=this.opts.cookieJar)===null||u===void 0||u.parseCookies(a)),a.readyState===4&&(a.status===200||a.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof a.status=="number"?a.status:0)},0))},a.send(this.data)}catch(u){this.setTimeoutFn(()=>{this.onError(u)},0);return}typeof document<"u"&&(this.index=fN.requestsCount++,fN.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=HMe,t)try{this.xhr.abort()}catch{}typeof document<"u"&&delete fN.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};if(n_.requestsCount=0,n_.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Hee);else if(typeof addEventListener=="function"){const e="onpagehide"in Gp?"pagehide":"unload";addEventListener(e,Hee,!1)}}function Hee(){for(let e in n_.requests)n_.requests.hasOwnProperty(e)&&n_.requests[e].abort()}const B7=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0))(),cR=Gp.WebSocket||Gp.MozWebSocket,$ee=!0,VMe="arraybuffer",Gee=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class YMe extends k7{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),r=this.opts.protocols,a=Gee?{}:Lee(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=$ee&&!Gee?r?new cR(t,r):new cR(t):new cR(t,r,a)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const a=t[r],u=r===t.length-1;N7(a,this.supportsBinary,A=>{const c={};try{$ee&&this.ws.send(A)}catch{}u&&B7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=Bee()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}check(){return!!cR}}class WMe extends k7{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(t=>{const r=MMe(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(r).getReader(),u=RMe();u.readable.pipeTo(t.writable),this.writer=u.writable.getWriter();const A=()=>{a.read().then(({done:y,value:n})=>{y||(this.onPacket(n),A())}).catch(y=>{})};A();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this.writer.write(c).then(()=>this.onOpen())})}))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const a=t[r],u=r===t.length-1;this.writer.write(a).then(()=>{u&&B7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this.transport)===null||t===void 0||t.close()}}const jMe={websocket:YMe,webtransport:WMe,polling:GMe},KMe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,XMe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function z7(e){if(e.length>2e3)throw"URI too long";const t=e,r=e.indexOf("["),a=e.indexOf("]");r!=-1&&a!=-1&&(e=e.substring(0,r)+e.substring(r,a).replace(/:/g,";")+e.substring(a,e.length));let u=KMe.exec(e||""),A={},c=14;for(;c--;)A[XMe[c]]=u[c]||"";return r!=-1&&a!=-1&&(A.source=t,A.host=A.host.substring(1,A.host.length-1).replace(/;/g,":"),A.authority=A.authority.replace("[","").replace("]","").replace(/;/g,":"),A.ipv6uri=!0),A.pathNames=ZMe(A,A.path),A.queryKey=QMe(A,A.query),A}function ZMe(e,t){const r=/\/{2,9}/g,a=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function QMe(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,u,A){u&&(r[u]=A)}),r}let Vee=class wS extends Ku{constructor(t,r={}){super(),this.binaryType=VMe,this.writeBuffer=[],t&&typeof t=="object"&&(r=t,t=null),t?(t=z7(t),r.hostname=t.host,r.secure=t.protocol==="https"||t.protocol==="wss",r.port=t.port,t.query&&(r.query=t.query)):r.host&&(r.hostname=z7(r.host).host),lR(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=r.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=FMe(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=Nee,r.transport=t,this.id&&(r.sid=this.id);const a=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new jMe[t](a)}open(){let t;if(this.opts.rememberUpgrade&&wS.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else t=this.transports[0];this.readyState="opening";try{t=this.createTransport(t)}catch{this.transports.shift(),this.open();return}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",r=>this.onClose("transport close",r))}probe(t){let r=this.createTransport(t),a=!1;wS.priorWebsocketSuccess=!1;const u=()=>{a||(r.send([{type:"ping",data:"probe"}]),r.once("packet",i=>{if(!a)if(i.type==="pong"&&i.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;wS.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(b(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const w=new Error("probe error");w.transport=r.name,this.emitReserved("upgradeError",w)}}))};function A(){a||(a=!0,b(),r.close(),r=null)}const c=i=>{const w=new Error("probe error: "+i);w.transport=r.name,A(),this.emitReserved("upgradeError",w)};function y(){c("transport closed")}function n(){c("socket closed")}function s(i){r&&i.name!==r.name&&A()}const b=()=>{r.removeListener("open",u),r.removeListener("error",c),r.removeListener("close",y),this.off("close",n),this.off("upgrading",s)};r.once("open",u),r.once("error",c),r.once("close",y),this.once("close",n),this.once("upgrading",s),this.upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||r.open()},200):r.open()}onOpen(){if(this.readyState="open",wS.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let t=0;const r=this.upgrades.length;for(;t<r;t++)this.probe(this.upgrades[t])}}onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const r=new Error("server error");r.code=t.data,this.onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let a=0;a<this.writeBuffer.length;a++){const u=this.writeBuffer[a].data;if(u&&(r+=DMe(u)),a>0&&r>this.maxPayload)return this.writeBuffer.slice(0,a);r+=2}return this.writeBuffer}write(t,r,a){return this.sendPacket("message",t,r,a),this}send(t,r,a){return this.sendPacket("message",t,r,a),this}sendPacket(t,r,a,u){if(typeof r=="function"&&(u=r,r=void 0),typeof a=="function"&&(u=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const A={type:t,data:r,options:a};this.emitReserved("packetCreate",A),this.writeBuffer.push(A),u&&this.once("flush",u),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},a=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():t()}):this.upgrading?a():t()),this}onError(t){wS.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,r){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const r=[];let a=0;const u=t.length;for(;a<u;a++)~this.transports.indexOf(t[a])&&r.push(t[a]);return r}};Vee.protocol=Nee;function JMe(e,t="",r){let a=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),a=z7(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const A=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+A+":"+a.port+t,a.href=a.protocol+"://"+A+(r&&r.port===a.port?"":":"+a.port),a}const qMe=typeof ArrayBuffer=="function",eIe=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Yee=Object.prototype.toString,tIe=typeof Blob=="function"||typeof Blob<"u"&&Yee.call(Blob)==="[object BlobConstructor]",rIe=typeof File=="function"||typeof File<"u"&&Yee.call(File)==="[object FileConstructor]";function U7(e){return qMe&&(e instanceof ArrayBuffer||eIe(e))||tIe&&e instanceof Blob||rIe&&e instanceof File}function fR(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,a=e.length;r<a;r++)if(fR(e[r]))return!0;return!1}if(U7(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return fR(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&fR(e[r]))return!0;return!1}function nIe(e){const t=[],r=e.data,a=e;return a.data=H7(r,t),a.attachments=t.length,{packet:a,buffers:t}}function H7(e,t){if(!e)return e;if(U7(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let a=0;a<e.length;a++)r[a]=H7(e[a],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=H7(e[a],t));return r}return e}function aIe(e,t){return e.data=$7(e.data,t),delete e.attachments,e}function $7(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=$7(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=$7(e[r],t));return e}const iIe=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],oIe=5;var as;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(as||(as={}));class sIe{constructor(t){this.replacer=t}encode(t){return(t.type===as.EVENT||t.type===as.ACK)&&fR(t)?this.encodeAsBinary({type:t.type===as.EVENT?as.BINARY_EVENT:as.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===as.BINARY_EVENT||t.type===as.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=nIe(t),a=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(a),u}}function Wee(e){return Object.prototype.toString.call(e)==="[object Object]"}class G7 extends Ku{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const a=r.type===as.BINARY_EVENT;a||r.type===as.BINARY_ACK?(r.type=a?as.EVENT:as.ACK,this.reconstructor=new lIe(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(U7(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const a={type:Number(t.charAt(0))};if(as[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===as.BINARY_EVENT||a.type===as.BINARY_ACK){const A=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const c=t.substring(A,r);if(c!=Number(c)||t.charAt(r)!=="-")throw new Error("Illegal attachments");a.attachments=Number(c)}if(t.charAt(r+1)==="/"){const A=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););a.nsp=t.substring(A,r)}else a.nsp="/";const u=t.charAt(r+1);if(u!==""&&Number(u)==u){const A=r+1;for(;++r;){const c=t.charAt(r);if(c==null||Number(c)!=c){--r;break}if(r===t.length)break}a.id=Number(t.substring(A,r+1))}if(t.charAt(++r)){const A=this.tryParse(t.substr(r));if(G7.isPayloadValid(a.type,A))a.data=A;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case as.CONNECT:return Wee(r);case as.DISCONNECT:return r===void 0;case as.CONNECT_ERROR:return typeof r=="string"||Wee(r);case as.EVENT:case as.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&iIe.indexOf(r[0])===-1);case as.ACK:case as.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lIe{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=aIe(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const uIe=Object.freeze(Object.defineProperty({__proto__:null,Decoder:G7,Encoder:sIe,get PacketType(){return as},protocol:oIe},Symbol.toStringTag,{value:"Module"}));function J0(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const cIe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class jee extends Ku{constructor(t,r,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=r,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[J0(t,"open",this.onopen.bind(this)),J0(t,"packet",this.onpacket.bind(this)),J0(t,"error",this.onerror.bind(this)),J0(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){if(cIe.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const a={type:as.EVENT,data:r};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const c=this.ids++,y=r.pop();this._registerAckCallback(c,y),a.id=c}const u=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!u||!this.connected)||(this.connected?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(t,r){var a;const u=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(u===void 0){this.acks[t]=r;return}const A=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let c=0;c<this.sendBuffer.length;c++)this.sendBuffer[c].id===t&&this.sendBuffer.splice(c,1);r.call(this,new Error("operation has timed out"))},u);this.acks[t]=(...c)=>{this.io.clearTimeoutFn(A),r.apply(this,[null,...c])}}emitWithAck(t,...r){const a=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((u,A)=>{r.push((c,y)=>a?c?A(c):u(y):u(c)),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((u,...A)=>a!==this._queue[0]?void 0:(u!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...A)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:as.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case as.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case as.EVENT:case as.BINARY_EVENT:this.onevent(t);break;case as.ACK:case as.BINARY_ACK:this.onack(t);break;case as.DISCONNECT:this.ondisconnect();break;case as.CONNECT_ERROR:this.destroy();const a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const a of r)a.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const r=this;let a=!1;return function(...u){a||(a=!0,r.packet({type:as.ACK,id:t,data:u}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(r.apply(this,t.data),delete this.acks[t.id])}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:as.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const r=this._anyListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const r=this._anyOutgoingListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const a of r)a.apply(this,t.data)}}}function a_(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}a_.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0},a_.prototype.reset=function(){this.attempts=0},a_.prototype.setMin=function(e){this.ms=e},a_.prototype.setMax=function(e){this.max=e},a_.prototype.setJitter=function(e){this.jitter=e};class V7 extends Ku{constructor(t,r){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,lR(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((a=r.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new a_({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const u=r.parser||uIe;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Vee(this.uri,this.opts);const r=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const u=J0(r,"open",function(){a.onopen(),t&&t()}),A=y=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},c=J0(r,"error",A);if(this._timeout!==!1){const y=this._timeout,n=this.setTimeoutFn(()=>{u(),A(new Error("timeout")),r.close()},y);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(u),this.subs.push(c),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(J0(t,"ping",this.onping.bind(this)),J0(t,"data",this.ondata.bind(this)),J0(t,"error",this.onerror.bind(this)),J0(t,"close",this.onclose.bind(this)),J0(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){B7(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new jee(this,t,r),this.nsps[t]=a),a}_destroy(t){const r=Object.keys(this.nsps);for(const a of r)if(this.nsps[a].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let a=0;a<r.length;a++)this.engine.write(r[a],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,r){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(u=>{u?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",u)):t.onreconnect()}))},r);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const UT={};function dR(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=JMe(e,t.path||"/socket.io"),a=r.source,u=r.id,A=r.path,c=UT[u]&&A in UT[u].nsps,y=t.forceNew||t["force new connection"]||t.multiplex===!1||c;let n;return y?n=new V7(a,t):(UT[u]||(UT[u]=new V7(a,t)),n=UT[u]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(dR,{Manager:V7,Socket:jee,io:dR,connect:dR});var fIe=e=>{let t={},r=new Date,a=new Date;a.setDate(r.getDate()-1);let u=new Date;u.setDate(r.getDate()-7);let A=new Date;return A.setDate(r.getDate()-30),e.forEach(c=>{let y=new Date(c.createdAt),n=y.toDateString()===r.toDateString(),s=y.toDateString()===a.toDateString(),b=y>=u,i=y>=A,w;n?w="Today":s?w="Yesterday":b?w="Previous 7 days":i?w="Previous 30 days":w=y.toLocaleString("default",{month:"long",year:"numeric"}).split(" ").slice(0,1).join(" "),t[w]||(t[w]=[]),t[w].push(c)}),t},Kee=zs({key:"ThreadIdToResume",default:void 0}),dIe=zs({key:"ChatProfile",default:void 0}),Xee=zs({key:"SessionId",default:m7()}),Y7=lee({key:"SessionIdSelector",get:({get:e})=>e(Xee),set:({set:e},t)=>e(Xee,t instanceof O6e?m7():t)}),W7=zs({key:"Session",dangerouslyAllowMutability:!0,default:void 0}),j7=zs({key:"Actions",default:[]}),i_=zs({key:"Messages",dangerouslyAllowMutability:!0,default:[]}),Zee=zs({key:"TokenCount",default:0}),K7=zs({key:"Loading",default:!1}),hR=zs({key:"AskUser",default:void 0}),Qee=zs({key:"CallFn",default:void 0}),pR=zs({key:"ChatSettings",default:[]}),Jee=lee({key:"ChatSettingsValue/Default",get:({get:e})=>e(pR).reduce((t,r)=>(t[r.id]=r.initial,t),{})}),X7=zs({key:"ChatSettingsValue",default:Jee}),Z7=zs({key:"DisplayElements",default:[]}),Q7=zs({key:"TasklistElements",default:[]}),vR=zs({key:"FirstUserInteraction",default:void 0}),N2=zs({key:"AccessToken",default:void 0}),hIe=zs({key:"User",default:null}),pIe=zs({key:"ChainlitConfig",default:void 0}),vIe=zs({key:"AuthConfig",default:void 0}),HT=zs({key:"ThreadHistory",default:{threads:void 0,currentThreadId:void 0,timeGroupedThreads:void 0,pageInfo:void 0},effects:[({setSelf:e,onSet:t})=>{t((r,a)=>{let u=r==null?void 0:r.timeGroupedThreads;r!=null&&r.threads&&!t_.isEqual(r.threads,a==null?void 0:a.timeGroupedThreads)&&(u=fIe(r.threads)),e({...r,timeGroupedThreads:u})})}]}),o_=zs({key:"SideView",default:void 0}),J7=zs({key:"CurrentThreadId",default:void 0}),q0=()=>{let e=ns(K7),t=ns(Z7),r=ns(Q7),a=ns(j7),u=ns(W7),A=ns(hR),c=ns(Qee),y=ns(pR),n=ns(X7),s=ns(Jee),b=(u==null?void 0:u.socket.connected)&&!(u!=null&&u.error),i=!b||e||(A==null?void 0:A.spec.type)==="file"||(A==null?void 0:A.spec.type)==="action";return{actions:a,askUser:A,callFn:c,chatSettingsDefaultValue:s,chatSettingsInputs:y,chatSettingsValue:n,connected:b,disabled:i,elements:t,error:u==null?void 0:u.error,loading:e,tasklists:r}},mIe=e=>{let t=[];for(let r of e)t=L2(t,r);return t},L2=(e,t)=>mR(e,t.id)?D2(e,t.id,t):"parentId"in t&&t.parentId?ete(e,t.parentId,t):"indent"in t&&t.indent&&t.indent>0?qee(e,t.indent,t):[...e,t],qee=(e,t,r,a=0)=>{let u=[...e];if(u.length===0)return[...u,r];{let A=u.length-1,c=u[A];return c.steps=c.steps||[],a+1===t?(c.steps=[...c.steps,r],u[A]={...c},u):(c.steps=qee(c.steps,t,r,a+1),u[A]={...c},u)}},ete=(e,t,r)=>{let a=[...e];for(let u=0;u<a.length;u++){let A=a[u];t_.isEqual(A.id,t)?(A.steps=A.steps?[...A.steps,r]:[r],a[u]={...A}):mR(a,t)&&A.steps&&(A.steps=ete(A.steps,t,r),a[u]={...A})}return a},tte=(e,t)=>{for(let r of e){if(t_.isEqual(r.id,t))return r;if(r.steps&&r.steps.length>0){let a=tte(r.steps,t);if(a)return a}}},mR=(e,t)=>tte(e,t)!==void 0,D2=(e,t,r)=>{let a=[...e];for(let u=0;u<a.length;u++){let A=a[u];t_.isEqual(A.id,t)?a[u]={steps:A.steps,...r}:mR(a,t)&&A.steps&&(A.steps=D2(A.steps,t,r),a[u]={...A})}return a},rte=(e,t)=>{let r=[...e];for(let a=0;a<r.length;a++){let u=r[a];u.id===t?r=[...r.slice(0,a),...r.slice(a+1)]:mR(r,t)&&u.steps&&(u.steps=rte(u.steps,t),r[a]={...u})}return r},nte=(e,t,r,a,u)=>{let A=[...e];for(let c=0;c<A.length;c++){let y=A[c];t_.isEqual(y.id,t)?("content"in y&&y.content!==void 0?a?y.content=r:y.content+=r:u?"input"in y&&y.input!==void 0&&(a?y.input=r:y.input+=r):"output"in y&&y.output!==void 0&&(a?y.output=r:y.output+=r),A[c]={...y}):y.steps&&(y.steps=nte(y.steps,t,r,a,u),A[c]={...y})}return A},q7="token";function ate(){try{return localStorage.getItem(q7)}catch{return}}function gIe(e){try{return localStorage.setItem(q7,e)}catch{return}}function ite(){try{return localStorage.removeItem(q7)}catch{return}}var yIe=async(e,t,r)=>{var a;return(a=await e.get(t,r))==null?void 0:a.json()};function $T(e,{token:t,...r}={}){let a=pt.useContext(Ac),u=ns(N2);u=t||u;let A=pt.useMemo(()=>([y,n])=>yIe(a,y,n),[a]),c=pt.useMemo(()=>e?[e,u]:null,[e,u]);return _Me(c,A,r)}var Vp=()=>{let e=pt.useContext(Ac),[t,r]=Cu(vIe),[a,u]=Cu(hIe),{data:A,isLoading:c}=$T(t?null:"/auth/config"),[y,n]=Cu(N2),s=Ho(HT);pt.useEffect(()=>{A&&r(A)},[A,r]);let b=!!(!c&&t),i=async(p=!1)=>{await e.logout(),u(null),ite(),n(""),s(void 0),p&&window.location.reload()},w=p=>{if(!p){i();return}try{let{exp:_,...l}=F6e(p);gIe(p),n(`Bearer ${p}`),u(l)}catch(_){console.error("Invalid token, clearing token from local storage","error:",_),i()}};pt.useEffect(()=>{if(!a&&ate()){w(ate());return}},[]);let E=!!y;return t&&!t.requireLogin?{authConfig:t,user:null,isReady:b,isAuthenticated:!0,accessToken:"",logout:()=>{},setAccessToken:()=>{}}:{data:t,user:a,isAuthenticated:E,isReady:b,accessToken:y,logout:i,setAccessToken:w}},eP=class extends Error{constructor(e,t){super(e),this.detail=t}toString(){return this.detail?`${this.message}: ${this.detail}`:this.message}},bIe=class{constructor(e,t,r,a){this.httpEndpoint=e,this.type=t,this.on401=r,this.onError=a}buildEndpoint(e){return this.httpEndpoint.endsWith("/")?`${this.httpEndpoint.slice(0,-1)}${e}`:`${this.httpEndpoint}${e}`}checkToken(e){let t="Bearer ";return e.startsWith(t)?e:t+e}async fetch(e,t,r,a,u){try{let A={};r&&(A.Authorization=this.checkToken(r));let c;a instanceof FormData?c=a:(A["Content-Type"]="application/json",c=a?JSON.stringify(a):null);let y=await fetch(this.buildEndpoint(t),{method:e,headers:A,signal:u,body:c});if(!y.ok){let n=await y.json();throw y.status===401&&this.on401&&(ite(),this.on401()),new eP(y.statusText,n.detail)}return y}catch(A){throw A instanceof eP&&this.onError&&this.onError(A),console.error(A),A}}async get(e,t){return await this.fetch("GET",e,t)}async post(e,t,r,a){return await this.fetch("POST",e,r,t,a)}async put(e,t,r){return await this.fetch("PUT",e,r,t)}async patch(e,t,r){return await this.fetch("PATCH",e,r,t)}async delete(e,t,r){return await this.fetch("DELETE",e,r,t)}},ote=class extends bIe{async headerAuth(){return(await this.post("/auth/header",{})).json()}async passwordAuth(e){return(await this.post("/login",e)).json()}async logout(){return(await this.post("/logout",{})).json()}async setFeedback(e,t){return(await this.put("/feedback",{feedback:e},t)).json()}async deleteFeedback(e,t){return(await this.delete("/feedback",{feedbackId:e},t)).json()}async listThreads(e,t,r){return(await this.post("/project/threads",{pagination:e,filter:t},r)).json()}async deleteThread(e,t){return(await this.delete("/project/thread",{threadId:e},t)).json()}uploadFile(e,t,r,a){let u=new XMLHttpRequest,A=new Promise((c,y)=>{let n=new FormData;n.append("file",e),u.open("POST",this.buildEndpoint(`/project/file?session_id=${r}`),!0),a&&u.setRequestHeader("Authorization",this.checkToken(a)),u.upload.onprogress=function(s){if(s.lengthComputable){let b=s.loaded/s.total*100;t(b)}},u.onload=function(){if(u.status===200){let s=JSON.parse(u.responseText);c(s)}else y("Upload failed")},u.onerror=function(){y("Upload error")},u.send(n)});return{xhr:u,promise:A}}getElementUrl(e,t){let r=`?session_id=${t}`;return this.buildEndpoint(`/project/file/${e}${r}`)}getLogoEndpoint(e){return this.buildEndpoint(`/logo?theme=${e}`)}getOAuthEndpoint(e){return this.buildEndpoint(`/auth/oauth/${e}`)}},Ac=pt.createContext(new ote("http://localhost:8000","webapp")),Xu=()=>{let e=pt.useContext(Ac),t=ns(N2),r=ns(W7),a=ns(hR),u=ns(Y7),A=J5(pR),c=J5(Y7),y=J5(X7),n=Ho(vR),s=Ho(K7),b=Ho(i_),i=Ho(Z7),w=Ho(Q7),E=Ho(j7),p=Ho(Zee),_=Ho(Kee),l=Ho(o_),o=Ho(J7),d=pt.useCallback(()=>{r==null||r.socket.emit("clear_session"),r==null||r.socket.disconnect(),_(void 0),c(),n(void 0),b([]),i([]),w([]),E([]),p(0),A(),y(),l(void 0),o(void 0)},[r]),f=pt.useCallback((x,R=[])=>{x.id||(x.id=m7()),x.createdAt||(x.createdAt=new Date().toISOString()),b(P=>L2(P,x)),r==null||r.socket.emit("client_message",{message:x,fileReferences:R})},[r==null?void 0:r.socket]),h=pt.useCallback(x=>{r==null||r.socket.emit("edit_message",{message:x})},[r==null?void 0:r.socket]),g=pt.useCallback((x,R,P,L)=>{r==null||r.socket.emit("audio_chunk",{isStart:x,mimeType:R,elapsedTime:P,data:L})},[r==null?void 0:r.socket]),v=pt.useCallback(x=>{r==null||r.socket.emit("audio_end",{fileReferences:x})},[r==null?void 0:r.socket]),C=pt.useCallback(x=>{a&&(b(R=>L2(R,x)),a.callback(x))},[a]),S=pt.useCallback(x=>{r==null||r.socket.emit("chat_settings_change",x)},[r==null?void 0:r.socket]),I=pt.useCallback(()=>{b(x=>x.map(R=>(R.streaming=!1,R))),s(!1),r==null||r.socket.emit("stop")},[r==null?void 0:r.socket]),T=pt.useCallback(x=>{let R=r==null?void 0:r.socket;if(!R)return;let P=new Promise((L,F)=>{R.once("action_response",N=>{N.status?L(N):F(N)})});return R.emit("action_call",x),P},[r==null?void 0:r.socket]);return{uploadFile:pt.useCallback((x,R)=>e.uploadFile(x,R,u,t),[u,t]),callAction:T,clear:d,replyMessage:C,sendMessage:f,editMessage:h,sendAudioChunk:g,endAudioStream:v,stopTask:I,setIdToResume:_,updateChatSettings:S}},Kh=()=>{let e=ns(i_),t=ns(vR);return{threadId:ns(J7),messages:e,firstInteraction:t}},ig=()=>{let e=pt.useContext(Ac),t=ns(Y7),[r,a]=Cu(W7),u=J5(X7),A=Ho(vR),c=Ho(K7),y=Ho(i_),n=Ho(hR),s=Ho(Qee),b=Ho(Z7),i=Ho(Q7),w=Ho(j7),E=Ho(pR),p=Ho(Zee),[_,l]=Cu(dIe),o=ns(Kee),d=Ho(J7),f=pt.useCallback(({userEnv:v,accessToken:C})=>{let{protocol:S,host:I,pathname:T}=new URL(e.httpEndpoint),x=`${S}//${I}`,R=T&&T!=="/"?`${T}/ws/socket.io`:"/ws/socket.io",P=dR(x,{path:R,extraHeaders:{Authorization:C||"","X-Chainlit-Client-Type":e.type,"X-Chainlit-Session-Id":t,"X-Chainlit-Thread-Id":o||"","user-env":JSON.stringify(v),"X-Chainlit-Chat-Profile":_?encodeURIComponent(_):""}});a(L=>{var F,N;return(F=L==null?void 0:L.socket)==null||F.removeAllListeners(),(N=L==null?void 0:L.socket)==null||N.close(),{socket:P}}),P.on("connect",()=>{P.emit("connection_successful"),a(L=>({...L,error:!1}))}),P.on("connect_error",L=>{a(F=>({...F,error:!0}))}),P.on("task_start",()=>{c(!0)}),P.on("task_end",()=>{c(!1)}),P.on("reload",()=>{P.emit("clear_session"),window.location.reload()}),P.on("resume_thread",L=>{var k,O;let F=[];for(let m of L.steps)F=L2(F,m);(k=L.metadata)!=null&&k.chat_profile&&l((O=L.metadata)==null?void 0:O.chat_profile),y(F);let N=L.elements||[];i(N.filter(m=>m.type==="tasklist")),b(N.filter(m=>["avatar","tasklist"].indexOf(m.type)===-1))}),P.on("new_message",L=>{y(F=>L2(F,L))}),P.on("first_interaction",L=>{A(L.interaction),d(L.thread_id)}),P.on("update_message",L=>{y(F=>D2(F,L.id,L))}),P.on("delete_message",L=>{y(F=>rte(F,L.id))}),P.on("stream_start",L=>{y(F=>L2(F,L))}),P.on("stream_token",({id:L,token:F,isSequence:N,isInput:k})=>{y(O=>nte(O,L,F,N,k))}),P.on("ask",({msg:L,spec:F},N)=>{n({spec:F,callback:N}),y(k=>L2(k,L)),c(!1)}),P.on("ask_timeout",()=>{n(void 0),c(!1)}),P.on("clear_ask",()=>{n(void 0)}),P.on("call_fn",({name:L,args:F},N)=>{s({name:L,args:F,callback:N})}),P.on("clear_call_fn",()=>{s(void 0)}),P.on("call_fn_timeout",()=>{s(void 0)}),P.on("chat_settings",L=>{E(L),u()}),P.on("element",L=>{!L.url&&L.chainlitKey&&(L.url=e.getElementUrl(L.chainlitKey,t)),L.type==="tasklist"?i(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?[...F,L]:[...F.slice(0,N),L,...F.slice(N+1)]}):b(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?[...F,L]:[...F.slice(0,N),L,...F.slice(N+1)]})}),P.on("remove_element",L=>{b(F=>F.filter(N=>N.id!==L.id)),i(F=>F.filter(N=>N.id!==L.id))}),P.on("action",L=>{w(F=>[...F,L])}),P.on("remove_action",L=>{w(F=>{let N=F.findIndex(k=>k.id===L.id);return N===-1?F:[...F.slice(0,N),...F.slice(N+1)]})}),P.on("token_usage",L=>{p(F=>F+L)})},[a,t,_]),h=pt.useCallback(t_.debounce(f,200),[f]),g=pt.useCallback(()=>{r!=null&&r.socket&&(r.socket.removeAllListeners(),r.socket.close())},[r]);return{connect:h,disconnect:g,session:r,sessionId:t,chatProfile:_,idToResume:o,setChatProfile:l}},xIe={enabled:!0,min_decibels:-45,initial_silence_timeout:3e3,silence_timeout:1500,max_duration:15e3,chunk_duration:1e3},_Ie=(e=xIe)=>{let t=pt.useRef(null),r=pt.useRef(!1),{sendAudioChunk:a,endAudioStream:u}=Xu(),[A,c]=pt.useState(!1),[y,n]=pt.useState(void 0),[s,b]=pt.useState(!1),[i,w]=pt.useState(void 0),[E,p]=pt.useState(!1),_=pt.useCallback(()=>{!A||!t.current||(r.current=!0,t.current.stop())},[A]),l=pt.useCallback(()=>{!A||!t.current||t.current.stop()},[A]);return{startRecording:pt.useCallback(o=>{if(A||!e)return;p(!1),w(void 0),clearTimeout(y),r.current=!1;let{min_decibels:d,silence_timeout:f,initial_silence_timeout:h,chunk_duration:g,max_duration:v}=e;navigator.mediaDevices.getUserMedia({audio:!0}).then(C=>{let S=!1,I=!1,T=!0,x=null,R=Date.now(),P=new MediaRecorder(C);t.current=P,P.addEventListener("start",()=>{c(!0),R=Date.now()}),P.addEventListener("dataavailable",async D=>{if(S||(x?x=new Blob([x,D.data],{type:D.data.type}):x=new Blob([D.data],{type:D.data.type})),P.state==="inactive")return;let M=Date.now()-R;if(M>=v){P.stop(),C.getTracks().forEach(Y=>Y.stop());return}b(I);let[H,B]=P.mimeType.split(";");x?(await a(T,H,M,new Blob([x,D.data])),x=null):await a(T,H,M,D.data),T&&(T=!1)}),P.addEventListener("stop",async()=>{c(!1),b(!1),S&&!r.current&&(p(!0),await u(o))});let L=new AudioContext,F=L.createMediaStreamSource(C),N=L.createAnalyser();N.minDecibels=d,F.connect(N);let k=N.frequencyBinCount,O=new Uint8Array(k);P.start(g);let m=()=>{if(P.state==="inactive")return;N.getByteFrequencyData(O);let D=O.some(M=>M>0);I||(I=D),!S&&D&&(b(I),S=!0),requestAnimationFrame(m)};m(),setTimeout(()=>{S?n(setInterval(()=>{I?I=!1:(P.stop(),C.getTracks().forEach(D=>D.stop()))},f)):(P.stop(),C.getTracks().forEach(D=>D.stop()))},h)}).catch(C=>{w(C.message)})},[y,A,e,a,u]),stopRecording:l,cancelRecording:_,isRecording:A,isSpeaking:s,isRecordingFinished:E,error:i}},Dl=e=>{let[t,r]=Cu(pIe),{isAuthenticated:a}=Vp(),u=navigator.language||"en-US",{data:A,error:c,isLoading:y}=$T(!t&&a?`/project/settings?language=${u}`:null,{token:e});return pt.useEffect(()=>{A&&r(A)},[A,r]),{config:t,error:c,isLoading:y,language:u}};function EIe(e){const t=e,r=()=>{Z0.error("Unauthorized")},a=u=>{Z0.error(u.toString())};return new ote(t,"copilot",r,a)}const SIe={accessToken:void 0},gR=pt.createContext(SIe);let yR;const TIe=new Uint8Array(16);function wIe(){if(!yR&&(yR=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yR))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yR(TIe)}const Qc=[];for(let e=0;e<256;++e)Qc.push((e+256).toString(16).slice(1));function AIe(e,t=0){return(Qc[e[t+0]]+Qc[e[t+1]]+Qc[e[t+2]]+Qc[e[t+3]]+"-"+Qc[e[t+4]]+Qc[e[t+5]]+"-"+Qc[e[t+6]]+Qc[e[t+7]]+"-"+Qc[e[t+8]]+Qc[e[t+9]]+"-"+Qc[e[t+10]]+Qc[e[t+11]]+Qc[e[t+12]]+Qc[e[t+13]]+Qc[e[t+14]]+Qc[e[t+15]]).toLowerCase()}const ste={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function tP(e,t,r){if(ste.randomUUID&&!t&&!e)return ste.randomUUID();e=e||{};const a=e.random||(e.rng||wIe)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,t){r=r||0;for(let u=0;u<16;++u)t[r+u]=a[u];return t}return AIe(a)}const GT={black:"#000",white:"#fff"},s_={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},l_={50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},u_={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},c_={50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},f_={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},VT={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},lte={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"};function P1(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function ute(e){if(!P1(e))return e;const t={};return Object.keys(e).forEach(r=>{t[r]=ute(e[r])}),t}function Zd(e,t,r={clone:!0}){const a=r.clone?ir({},e):e;return P1(e)&&P1(t)&&Object.keys(t).forEach(u=>{P1(t[u])&&Object.prototype.hasOwnProperty.call(e,u)&&P1(e[u])?a[u]=Zd(e[u],t[u],r):r.clone?a[u]=P1(t[u])?ute(t[u]):t[u]:a[u]=t[u]}),a}function k1(e){let t="https://mui.com/production-error/?code="+e;for(let r=1;r<arguments.length;r+=1)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified MUI error #"+e+"; visit "+t+" for the full message."}var js={};/**
|
|
89
89
|
* @license React
|
|
90
90
|
* react-is.production.min.js
|
|
91
91
|
*
|
|
@@ -754,7 +754,7 @@ ${d}`})}const p=He.jsxs(Wo,{sx:{minHeight:"20px",fontSize:"1rem",fontFamily:o=>o
|
|
|
754
754
|
* @license MIT
|
|
755
755
|
*/function MA(){return MA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},MA.apply(this,arguments)}function gSt(e,t){if(e==null)return{};var r={},a=Object.keys(e),u,A;for(A=0;A<a.length;A++)u=a[A],!(t.indexOf(u)>=0)&&(r[u]=e[u]);return r}function ySt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function bSt(e,t){return e.button===0&&(!t||t==="_self")&&!ySt(e)}const xSt=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"];function _St(e,t){return JEt({basename:t==null?void 0:t.basename,future:MA({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:xEt({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||ESt(),routes:e,mapRouteProperties:mSt}).initialize()}function ESt(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=MA({},t,{errors:SSt(t.errors)})),t}function SSt(e){if(!e)return null;let t=Object.entries(e),r={};for(let[a,u]of t)if(u&&u.__type==="RouteErrorResponse")r[a]=new ZV(u.status,u.statusText,u.data,u.internal===!0);else if(u&&u.__type==="Error"){if(u.__subType){let A=window[u.__subType];if(typeof A=="function")try{let c=new A(u.message);c.stack="",r[a]=c}catch{}}if(r[a]==null){let A=new Error(u.message);A.stack="",r[a]=A}}else r[a]=u;return r}const TSt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",wSt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,aY=pt.forwardRef(function(t,r){let{onClick:a,relative:u,reloadDocument:A,replace:c,state:y,target:n,to:s,preventScrollReset:b}=t,i=gSt(t,xSt),{basename:w}=pt.useContext(S8),E,p=!1;if(typeof s=="string"&&wSt.test(s)&&(E=s,TSt))try{let d=new URL(window.location.href),f=s.startsWith("//")?new URL(d.protocol+s):new URL(s),h=_A(f.pathname,w);f.origin===d.origin&&h!=null?s=h+f.search+f.hash:p=!0}catch{}let _=cSt(s,{relative:u}),l=ASt(s,{replace:c,state:y,target:n,preventScrollReset:b,relative:u});function o(d){a&&a(d),d.defaultPrevented||l(d)}return pt.createElement("a",MA({},i,{href:E||_,onClick:p||A?a:o,ref:r,target:n}))});var V2e;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher"})(V2e||(V2e={}));var Y2e;(function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Y2e||(Y2e={}));function ASt(e,t){let{target:r,replace:a,state:u,preventScrollReset:A,relative:c}=t===void 0?{}:t,y=up(),n=RA(),s=H2e(e,{relative:c});return pt.useCallback(b=>{if(bSt(b,r)){b.preventDefault();let i=a!==void 0?a:Db(n)===Db(s);y(e,{replace:i,state:u,preventScrollReset:A,relative:c})}},[n,y,s,a,u,r,e,A,c])}const CSt=()=>{const e=document.querySelector('meta[property="og:root_path"]');return e&&typeof e.getAttribute("content")=="string"?e.getAttribute("content"):""};function iY(){const{search:e}=RA();return pt.useMemo(()=>new URLSearchParams(e),[e])}function RSt(){const e=iY(),{user:t,setAccessToken:r}=Vp(),a=up();return pt.useEffect(()=>{const u=e.get("access_token");r(u)},[e]),pt.useEffect(()=>{t&&a("/")},[t]),null}var oY={exports:{}},IA={},w8={exports:{}},W2e={};function j2e(e){var t,r,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=j2e(e[t]))&&(a&&(a+=" "),a+=r);else for(t in e)e[t]&&(a&&(a+=" "),a+=t);return a}function K2e(){for(var e,t,r=0,a="";r<arguments.length;)(e=arguments[r++])&&(t=j2e(e))&&(a&&(a+=" "),a+=t);return a}const MSt=dN(Object.freeze(Object.defineProperty({__proto__:null,clsx:K2e,default:K2e},Symbol.toStringTag,{value:"Module"})));var du={},Em={};Object.defineProperty(Em,"__esModule",{value:!0}),Em.dontSetMe=DSt,Em.findInArray=ISt,Em.int=LSt,Em.isFunction=OSt,Em.isNum=NSt;function ISt(e,t){for(let r=0,a=e.length;r<a;r++)if(t.apply(t,[e[r],r,e]))return e[r]}function OSt(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function NSt(e){return typeof e=="number"&&!isNaN(e)}function LSt(e){return parseInt(e,10)}function DSt(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))}var Bb={};Object.defineProperty(Bb,"__esModule",{value:!0}),Bb.browserPrefixToKey=Z2e,Bb.browserPrefixToStyle=PSt,Bb.default=void 0,Bb.getPrefix=X2e;const sY=["Moz","Webkit","O","ms"];function X2e(){var e;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const r=(e=window.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.style;if(!r||t in r)return"";for(let a=0;a<sY.length;a++)if(Z2e(t,sY[a])in r)return sY[a];return""}function Z2e(e,t){return t?"".concat(t).concat(kSt(e)):e}function PSt(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e}function kSt(e){let t="",r=!0;for(let a=0;a<e.length;a++)r?(t+=e[a].toUpperCase(),r=!1):e[a]==="-"?r=!0:t+=e[a];return t}Bb.default=X2e(),Object.defineProperty(du,"__esModule",{value:!0}),du.addClassName=ebe,du.addEvent=zSt,du.addUserSelectStyles=ZSt,du.createCSSTransform=WSt,du.createSVGTransform=jSt,du.getTouch=KSt,du.getTouchIdentifier=XSt,du.getTranslation=lY,du.innerHeight=GSt,du.innerWidth=VSt,du.matchesSelector=q2e,du.matchesSelectorAndParentsTo=BSt,du.offsetXYFromParent=YSt,du.outerHeight=HSt,du.outerWidth=$St,du.removeClassName=tbe,du.removeEvent=USt,du.removeUserSelectStyles=QSt;var cp=Em,Q2e=FSt(Bb);function J2e(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(J2e=function(a){return a?r:t})(e)}function FSt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=J2e(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}let A8="";function q2e(e,t){return A8||(A8=(0,cp.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(r){return(0,cp.isFunction)(e[r])})),(0,cp.isFunction)(e[A8])?e[A8](t):!1}function BSt(e,t,r){let a=e;do{if(q2e(a,t))return!0;if(a===r)return!1;a=a.parentNode}while(a);return!1}function zSt(e,t,r,a){if(!e)return;const u={capture:!0,...a};e.addEventListener?e.addEventListener(t,r,u):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r}function USt(e,t,r,a){if(!e)return;const u={capture:!0,...a};e.removeEventListener?e.removeEventListener(t,r,u):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null}function HSt(e){let t=e.clientHeight;const r=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,cp.int)(r.borderTopWidth),t+=(0,cp.int)(r.borderBottomWidth),t}function $St(e){let t=e.clientWidth;const r=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,cp.int)(r.borderLeftWidth),t+=(0,cp.int)(r.borderRightWidth),t}function GSt(e){let t=e.clientHeight;const r=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,cp.int)(r.paddingTop),t-=(0,cp.int)(r.paddingBottom),t}function VSt(e){let t=e.clientWidth;const r=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,cp.int)(r.paddingLeft),t-=(0,cp.int)(r.paddingRight),t}function YSt(e,t,r){const u=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),A=(e.clientX+t.scrollLeft-u.left)/r,c=(e.clientY+t.scrollTop-u.top)/r;return{x:A,y:c}}function WSt(e,t){const r=lY(e,t,"px");return{[(0,Q2e.browserPrefixToKey)("transform",Q2e.default)]:r}}function jSt(e,t){return lY(e,t,"")}function lY(e,t,r){let{x:a,y:u}=e,A="translate(".concat(a).concat(r,",").concat(u).concat(r,")");if(t){const c="".concat(typeof t.x=="string"?t.x:t.x+r),y="".concat(typeof t.y=="string"?t.y:t.y+r);A="translate(".concat(c,", ").concat(y,")")+A}return A}function KSt(e,t){return e.targetTouches&&(0,cp.findInArray)(e.targetTouches,r=>t===r.identifier)||e.changedTouches&&(0,cp.findInArray)(e.changedTouches,r=>t===r.identifier)}function XSt(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function ZSt(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
756
756
|
`,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
757
|
-
`,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&ebe(e.body,"react-draggable-transparent-selection")}function QSt(e){if(e)try{if(e.body&&tbe(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function ebe(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function tbe(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}var Sm={};Object.defineProperty(Sm,"__esModule",{value:!0}),Sm.canDragX=eTt,Sm.canDragY=tTt,Sm.createCoreData=nTt,Sm.createDraggableData=aTt,Sm.getBoundPosition=JSt,Sm.getControlPosition=rTt,Sm.snapToGrid=qSt;var fp=Em,jE=du;function JSt(e,t,r){if(!e.props.bounds)return[t,r];let{bounds:a}=e.props;a=typeof a=="string"?a:iTt(a);const u=uY(e);if(typeof a=="string"){const{ownerDocument:A}=u,c=A.defaultView;let y;if(a==="parent"?y=u.parentNode:y=A.querySelector(a),!(y instanceof c.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const n=y,s=c.getComputedStyle(u),b=c.getComputedStyle(n);a={left:-u.offsetLeft+(0,fp.int)(b.paddingLeft)+(0,fp.int)(s.marginLeft),top:-u.offsetTop+(0,fp.int)(b.paddingTop)+(0,fp.int)(s.marginTop),right:(0,jE.innerWidth)(n)-(0,jE.outerWidth)(u)-u.offsetLeft+(0,fp.int)(b.paddingRight)-(0,fp.int)(s.marginRight),bottom:(0,jE.innerHeight)(n)-(0,jE.outerHeight)(u)-u.offsetTop+(0,fp.int)(b.paddingBottom)-(0,fp.int)(s.marginBottom)}}return(0,fp.isNum)(a.right)&&(t=Math.min(t,a.right)),(0,fp.isNum)(a.bottom)&&(r=Math.min(r,a.bottom)),(0,fp.isNum)(a.left)&&(t=Math.max(t,a.left)),(0,fp.isNum)(a.top)&&(r=Math.max(r,a.top)),[t,r]}function qSt(e,t,r){const a=Math.round(t/e[0])*e[0],u=Math.round(r/e[1])*e[1];return[a,u]}function eTt(e){return e.props.axis==="both"||e.props.axis==="x"}function tTt(e){return e.props.axis==="both"||e.props.axis==="y"}function rTt(e,t,r){const a=typeof t=="number"?(0,jE.getTouch)(e,t):null;if(typeof t=="number"&&!a)return null;const u=uY(r),A=r.props.offsetParent||u.offsetParent||u.ownerDocument.body;return(0,jE.offsetXYFromParent)(a||e,A,r.props.scale)}function nTt(e,t,r){const a=!(0,fp.isNum)(e.lastX),u=uY(e);return a?{node:u,deltaX:0,deltaY:0,lastX:t,lastY:r,x:t,y:r}:{node:u,deltaX:t-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:r}}function aTt(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}}function iTt(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function uY(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var C8={},R8={};Object.defineProperty(R8,"__esModule",{value:!0}),R8.default=oTt;function oTt(){}Object.defineProperty(C8,"__esModule",{value:!0}),C8.default=void 0;var cY=lTt(pt),vh=dY(ib),sTt=dY(zye),Vf=du,Py=Sm,fY=Em,OA=dY(R8);function dY(e){return e&&e.__esModule?e:{default:e}}function rbe(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(rbe=function(a){return a?r:t})(e)}function lTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=rbe(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function Sd(e,t,r){return t=uTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uTt(e){var t=cTt(e,"string");return typeof t=="symbol"?t:String(t)}function cTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const bv={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let ky=bv.mouse,M8=class extends cY.Component{constructor(){super(...arguments),Sd(this,"dragging",!1),Sd(this,"lastX",NaN),Sd(this,"lastY",NaN),Sd(this,"touchIdentifier",null),Sd(this,"mounted",!1),Sd(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const r=this.findDOMNode();if(!r||!r.ownerDocument||!r.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:a}=r;if(this.props.disabled||!(t.target instanceof a.defaultView.Node)||this.props.handle&&!(0,Vf.matchesSelectorAndParentsTo)(t.target,this.props.handle,r)||this.props.cancel&&(0,Vf.matchesSelectorAndParentsTo)(t.target,this.props.cancel,r))return;t.type==="touchstart"&&t.preventDefault();const u=(0,Vf.getTouchIdentifier)(t);this.touchIdentifier=u;const A=(0,Py.getControlPosition)(t,u,this);if(A==null)return;const{x:c,y}=A,n=(0,Py.createCoreData)(this,c,y);(0,OA.default)("DraggableCore: handleDragStart: %j",n),(0,OA.default)("calling",this.props.onStart),!(this.props.onStart(t,n)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,Vf.addUserSelectStyles)(a),this.dragging=!0,this.lastX=c,this.lastY=y,(0,Vf.addEvent)(a,ky.move,this.handleDrag),(0,Vf.addEvent)(a,ky.stop,this.handleDragStop))}),Sd(this,"handleDrag",t=>{const r=(0,Py.getControlPosition)(t,this.touchIdentifier,this);if(r==null)return;let{x:a,y:u}=r;if(Array.isArray(this.props.grid)){let y=a-this.lastX,n=u-this.lastY;if([y,n]=(0,Py.snapToGrid)(this.props.grid,y,n),!y&&!n)return;a=this.lastX+y,u=this.lastY+n}const A=(0,Py.createCoreData)(this,a,u);if((0,OA.default)("DraggableCore: handleDrag: %j",A),this.props.onDrag(t,A)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(n)}return}this.lastX=a,this.lastY=u}),Sd(this,"handleDragStop",t=>{if(!this.dragging)return;const r=(0,Py.getControlPosition)(t,this.touchIdentifier,this);if(r==null)return;let{x:a,y:u}=r;if(Array.isArray(this.props.grid)){let n=a-this.lastX||0,s=u-this.lastY||0;[n,s]=(0,Py.snapToGrid)(this.props.grid,n,s),a=this.lastX+n,u=this.lastY+s}const A=(0,Py.createCoreData)(this,a,u);if(this.props.onStop(t,A)===!1||this.mounted===!1)return!1;const y=this.findDOMNode();y&&this.props.enableUserSelectHack&&(0,Vf.removeUserSelectStyles)(y.ownerDocument),(0,OA.default)("DraggableCore: handleDragStop: %j",A),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,y&&((0,OA.default)("DraggableCore: Removing handlers"),(0,Vf.removeEvent)(y.ownerDocument,ky.move,this.handleDrag),(0,Vf.removeEvent)(y.ownerDocument,ky.stop,this.handleDragStop))}),Sd(this,"onMouseDown",t=>(ky=bv.mouse,this.handleDragStart(t))),Sd(this,"onMouseUp",t=>(ky=bv.mouse,this.handleDragStop(t))),Sd(this,"onTouchStart",t=>(ky=bv.touch,this.handleDragStart(t))),Sd(this,"onTouchEnd",t=>(ky=bv.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,Vf.addEvent)(t,bv.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:r}=t;(0,Vf.removeEvent)(r,bv.mouse.move,this.handleDrag),(0,Vf.removeEvent)(r,bv.touch.move,this.handleDrag),(0,Vf.removeEvent)(r,bv.mouse.stop,this.handleDragStop),(0,Vf.removeEvent)(r,bv.touch.stop,this.handleDragStop),(0,Vf.removeEvent)(t,bv.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Vf.removeUserSelectStyles)(r)}}findDOMNode(){var t,r;return(t=this.props)!==null&&t!==void 0&&t.nodeRef?(r=this.props)===null||r===void 0||(r=r.nodeRef)===null||r===void 0?void 0:r.current:sTt.default.findDOMNode(this)}render(){return cY.cloneElement(cY.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};C8.default=M8,Sd(M8,"displayName","DraggableCore"),Sd(M8,"propTypes",{allowAnyClick:vh.default.bool,children:vh.default.node.isRequired,disabled:vh.default.bool,enableUserSelectHack:vh.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:vh.default.arrayOf(vh.default.number),handle:vh.default.string,cancel:vh.default.string,nodeRef:vh.default.object,onStart:vh.default.func,onDrag:vh.default.func,onStop:vh.default.func,onMouseDown:vh.default.func,scale:vh.default.number,className:fY.dontSetMe,style:fY.dontSetMe,transform:fY.dontSetMe}),Sd(M8,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return n.default}}),e.default=void 0;var t=w(pt),r=b(ib),a=b(zye),u=b(MSt),A=du,c=Sm,y=Em,n=b(C8),s=b(R8);function b(d){return d&&d.__esModule?d:{default:d}}function i(d){if(typeof WeakMap!="function")return null;var f=new WeakMap,h=new WeakMap;return(i=function(g){return g?h:f})(d)}function w(d,f){if(!f&&d&&d.__esModule)return d;if(d===null||typeof d!="object"&&typeof d!="function")return{default:d};var h=i(f);if(h&&h.has(d))return h.get(d);var g={},v=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var C in d)if(C!=="default"&&Object.prototype.hasOwnProperty.call(d,C)){var S=v?Object.getOwnPropertyDescriptor(d,C):null;S&&(S.get||S.set)?Object.defineProperty(g,C,S):g[C]=d[C]}return g.default=d,h&&h.set(d,g),g}function E(){return E=Object.assign?Object.assign.bind():function(d){for(var f=1;f<arguments.length;f++){var h=arguments[f];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(d[g]=h[g])}return d},E.apply(this,arguments)}function p(d,f,h){return f=_(f),f in d?Object.defineProperty(d,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):d[f]=h,d}function _(d){var f=l(d,"string");return typeof f=="symbol"?f:String(f)}function l(d,f){if(typeof d!="object"||d===null)return d;var h=d[Symbol.toPrimitive];if(h!==void 0){var g=h.call(d,f||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(d)}class o extends t.Component{static getDerivedStateFromProps(f,h){let{position:g}=f,{prevPropsPosition:v}=h;return g&&(!v||g.x!==v.x||g.y!==v.y)?((0,s.default)("Draggable: getDerivedStateFromProps %j",{position:g,prevPropsPosition:v}),{x:g.x,y:g.y,prevPropsPosition:{...g}}):null}constructor(f){super(f),p(this,"onDragStart",(h,g)=>{if((0,s.default)("Draggable: onDragStart: %j",g),this.props.onStart(h,(0,c.createDraggableData)(this,g))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(h,g)=>{if(!this.state.dragging)return!1;(0,s.default)("Draggable: onDrag: %j",g);const v=(0,c.createDraggableData)(this,g),C={x:v.x,y:v.y,slackX:0,slackY:0};if(this.props.bounds){const{x:I,y:T}=C;C.x+=this.state.slackX,C.y+=this.state.slackY;const[x,R]=(0,c.getBoundPosition)(this,C.x,C.y);C.x=x,C.y=R,C.slackX=this.state.slackX+(I-C.x),C.slackY=this.state.slackY+(T-C.y),v.x=C.x,v.y=C.y,v.deltaX=C.x-this.state.x,v.deltaY=C.y-this.state.y}if(this.props.onDrag(h,v)===!1)return!1;this.setState(C)}),p(this,"onDragStop",(h,g)=>{if(!this.state.dragging||this.props.onStop(h,(0,c.createDraggableData)(this,g))===!1)return!1;(0,s.default)("Draggable: onDragStop: %j",g);const C={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:I,y:T}=this.props.position;C.x=I,C.y=T}this.setState(C)}),this.state={dragging:!1,dragged:!1,x:f.position?f.position.x:f.defaultPosition.x,y:f.position?f.position.y:f.defaultPosition.y,prevPropsPosition:{...f.position},slackX:0,slackY:0,isElementSVG:!1},f.position&&!(f.onDrag||f.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var f,h;return(f=(h=this.props)===null||h===void 0||(h=h.nodeRef)===null||h===void 0?void 0:h.current)!==null&&f!==void 0?f:a.default.findDOMNode(this)}render(){const{axis:f,bounds:h,children:g,defaultPosition:v,defaultClassName:C,defaultClassNameDragging:S,defaultClassNameDragged:I,position:T,positionOffset:x,scale:R,...P}=this.props;let L={},F=null;const k=!!!T||this.state.dragging,O=T||v,m={x:(0,c.canDragX)(this)&&k?this.state.x:O.x,y:(0,c.canDragY)(this)&&k?this.state.y:O.y};this.state.isElementSVG?F=(0,A.createSVGTransform)(m,x):L=(0,A.createCSSTransform)(m,x);const D=(0,u.default)(g.props.className||"",C,{[S]:this.state.dragging,[I]:this.state.dragged});return t.createElement(n.default,E({},P,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(g),{className:D,style:{...g.props.style,...L},transform:F}))}}e.default=o,p(o,"displayName","Draggable"),p(o,"propTypes",{...n.default.propTypes,axis:r.default.oneOf(["both","x","y","none"]),bounds:r.default.oneOfType([r.default.shape({left:r.default.number,right:r.default.number,top:r.default.number,bottom:r.default.number}),r.default.string,r.default.oneOf([!1])]),defaultClassName:r.default.string,defaultClassNameDragging:r.default.string,defaultClassNameDragged:r.default.string,defaultPosition:r.default.shape({x:r.default.number,y:r.default.number}),positionOffset:r.default.shape({x:r.default.oneOfType([r.default.number,r.default.string]),y:r.default.oneOfType([r.default.number,r.default.string])}),position:r.default.shape({x:r.default.number,y:r.default.number}),className:y.dontSetMe,style:y.dontSetMe,transform:y.dontSetMe}),p(o,"defaultProps",{...n.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(W2e);const{default:nbe,DraggableCore:fTt}=W2e;w8.exports=nbe,w8.exports.default=nbe,w8.exports.DraggableCore=fTt;var dTt=w8.exports,hY={};hY.__esModule=!0,hY.cloneElement=yTt;var hTt=pTt(pt);function pTt(e){return e&&e.__esModule?e:{default:e}}function abe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function ibe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?abe(Object(r),!0).forEach(function(a){vTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):abe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function vTt(e,t,r){return t=mTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mTt(e){var t=gTt(e,"string");return typeof t=="symbol"?t:String(t)}function gTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yTt(e,t){return t.style&&e.props.style&&(t.style=ibe(ibe({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),hTt.default.cloneElement(e,t)}var NA={};NA.__esModule=!0,NA.resizableProps=void 0;var Oo=bTt(ib);function bTt(e){return e&&e.__esModule?e:{default:e}}var xTt={axis:Oo.default.oneOf(["both","x","y","none"]),className:Oo.default.string,children:Oo.default.element.isRequired,draggableOpts:Oo.default.shape({allowAnyClick:Oo.default.bool,cancel:Oo.default.string,children:Oo.default.node,disabled:Oo.default.bool,enableUserSelectHack:Oo.default.bool,offsetParent:Oo.default.node,grid:Oo.default.arrayOf(Oo.default.number),handle:Oo.default.string,nodeRef:Oo.default.object,onStart:Oo.default.func,onDrag:Oo.default.func,onStop:Oo.default.func,onMouseDown:Oo.default.func,scale:Oo.default.number}),height:function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];var u=r[0];if(u.axis==="both"||u.axis==="y"){var A;return(A=Oo.default.number).isRequired.apply(A,r)}return Oo.default.number.apply(Oo.default,r)},handle:Oo.default.oneOfType([Oo.default.node,Oo.default.func]),handleSize:Oo.default.arrayOf(Oo.default.number),lockAspectRatio:Oo.default.bool,maxConstraints:Oo.default.arrayOf(Oo.default.number),minConstraints:Oo.default.arrayOf(Oo.default.number),onResizeStop:Oo.default.func,onResizeStart:Oo.default.func,onResize:Oo.default.func,resizeHandles:Oo.default.arrayOf(Oo.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:Oo.default.number,width:function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];var u=r[0];if(u.axis==="both"||u.axis==="x"){var A;return(A=Oo.default.number).isRequired.apply(A,r)}return Oo.default.number.apply(Oo.default,r)}};NA.resizableProps=xTt,IA.__esModule=!0,IA.default=void 0;var LA=wTt(pt),_Tt=dTt,ETt=hY,STt=NA,TTt=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function obe(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(obe=function(u){return u?r:t})(e)}function wTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=obe(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function pY(){return pY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},pY.apply(this,arguments)}function ATt(e,t){if(e==null)return{};var r={},a=Object.keys(e),u,A;for(A=0;A<a.length;A++)u=a[A],!(t.indexOf(u)>=0)&&(r[u]=e[u]);return r}function sbe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function vY(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sbe(Object(r),!0).forEach(function(a){CTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sbe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function CTt(e,t,r){return t=RTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function RTt(e){var t=MTt(e,"string");return typeof t=="symbol"?t:String(t)}function MTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ITt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,mY(e,t)}function mY(e,t){return mY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,u){return a.__proto__=u,a},mY(e,t)}var gY=function(e){ITt(t,e);function t(){for(var a,u=arguments.length,A=new Array(u),c=0;c<u;c++)A[c]=arguments[c];return a=e.call.apply(e,[this].concat(A))||this,a.handleRefs={},a.lastHandleRect=null,a.slack=null,a}var r=t.prototype;return r.componentWillUnmount=function(){this.resetData()},r.resetData=function(){this.lastHandleRect=this.slack=null},r.runConstraints=function(u,A){var c=this.props,y=c.minConstraints,n=c.maxConstraints,s=c.lockAspectRatio;if(!y&&!n&&!s)return[u,A];if(s){var b=this.props.width/this.props.height,i=u-this.props.width,w=A-this.props.height;Math.abs(i)>Math.abs(w*b)?A=u/b:u=A*b}var E=u,p=A,_=this.slack||[0,0],l=_[0],o=_[1];return u+=l,A+=o,y&&(u=Math.max(y[0],u),A=Math.max(y[1],A)),n&&(u=Math.min(n[0],u),A=Math.min(n[1],A)),this.slack=[l+(E-u),o+(p-A)],[u,A]},r.resizeHandler=function(u,A){var c=this;return function(y,n){var s=n.node,b=n.deltaX,i=n.deltaY;u==="onResizeStart"&&c.resetData();var w=(c.props.axis==="both"||c.props.axis==="x")&&A!=="n"&&A!=="s",E=(c.props.axis==="both"||c.props.axis==="y")&&A!=="e"&&A!=="w";if(!(!w&&!E)){var p=A[0],_=A[A.length-1],l=s.getBoundingClientRect();if(c.lastHandleRect!=null){if(_==="w"){var o=l.left-c.lastHandleRect.left;b+=o}if(p==="n"){var d=l.top-c.lastHandleRect.top;i+=d}}c.lastHandleRect=l,_==="w"&&(b=-b),p==="n"&&(i=-i);var f=c.props.width+(w?b/c.props.transformScale:0),h=c.props.height+(E?i/c.props.transformScale:0),g=c.runConstraints(f,h);f=g[0],h=g[1];var v=f!==c.props.width||h!==c.props.height,C=typeof c.props[u]=="function"?c.props[u]:null,S=u==="onResize"&&!v;C&&!S&&(y.persist==null||y.persist(),C(y,{node:s,size:{width:f,height:h},handle:A})),u==="onResizeStop"&&c.resetData()}}},r.renderResizeHandle=function(u,A){var c=this.props.handle;if(!c)return LA.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+u,ref:A});if(typeof c=="function")return c(u,A);var y=typeof c.type=="string",n=vY({ref:A},y?{}:{handleAxis:u});return LA.cloneElement(c,n)},r.render=function(){var u=this,A=this.props,c=A.children,y=A.className,n=A.draggableOpts;A.width,A.height,A.handle,A.handleSize,A.lockAspectRatio,A.axis,A.minConstraints,A.maxConstraints,A.onResize,A.onResizeStop,A.onResizeStart;var s=A.resizeHandles;A.transformScale;var b=ATt(A,TTt);return(0,ETt.cloneElement)(c,vY(vY({},b),{},{className:(y?y+" ":"")+"react-resizable",children:[].concat(c.props.children,s.map(function(i){var w,E=(w=u.handleRefs[i])!=null?w:u.handleRefs[i]=LA.createRef();return LA.createElement(_Tt.DraggableCore,pY({},n,{nodeRef:E,key:"resizableHandle-"+i,onStop:u.resizeHandler("onResizeStop",i),onStart:u.resizeHandler("onResizeStart",i),onDrag:u.resizeHandler("onResize",i)}),u.renderResizeHandle(i,E))}))}))},t}(LA.Component);IA.default=gY,gY.propTypes=STt.resizableProps,gY.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var I8={};I8.__esModule=!0,I8.default=void 0;var yY=PTt(pt),OTt=lbe(ib),NTt=lbe(IA),LTt=NA,DTt=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function lbe(e){return e&&e.__esModule?e:{default:e}}function ube(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(ube=function(u){return u?r:t})(e)}function PTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=ube(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function bY(){return bY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},bY.apply(this,arguments)}function cbe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function O8(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?cbe(Object(r),!0).forEach(function(a){kTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cbe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function kTt(e,t,r){return t=FTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function FTt(e){var t=BTt(e,"string");return typeof t=="symbol"?t:String(t)}function BTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zTt(e,t){if(e==null)return{};var r={},a=Object.keys(e),u,A;for(A=0;A<a.length;A++)u=a[A],!(t.indexOf(u)>=0)&&(r[u]=e[u]);return r}function UTt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,xY(e,t)}function xY(e,t){return xY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,u){return a.__proto__=u,a},xY(e,t)}var fbe=function(e){UTt(t,e);function t(){for(var a,u=arguments.length,A=new Array(u),c=0;c<u;c++)A[c]=arguments[c];return a=e.call.apply(e,[this].concat(A))||this,a.state={width:a.props.width,height:a.props.height,propsWidth:a.props.width,propsHeight:a.props.height},a.onResize=function(y,n){var s=n.size;a.props.onResize?(y.persist==null||y.persist(),a.setState(s,function(){return a.props.onResize&&a.props.onResize(y,n)})):a.setState(s)},a}t.getDerivedStateFromProps=function(u,A){return A.propsWidth!==u.width||A.propsHeight!==u.height?{width:u.width,height:u.height,propsWidth:u.width,propsHeight:u.height}:null};var r=t.prototype;return r.render=function(){var u=this.props,A=u.handle,c=u.handleSize;u.onResize;var y=u.onResizeStart,n=u.onResizeStop,s=u.draggableOpts,b=u.minConstraints,i=u.maxConstraints,w=u.lockAspectRatio,E=u.axis;u.width,u.height;var p=u.resizeHandles,_=u.style,l=u.transformScale,o=zTt(u,DTt);return yY.createElement(NTt.default,{axis:E,draggableOpts:s,handle:A,handleSize:c,height:this.state.height,lockAspectRatio:w,maxConstraints:i,minConstraints:b,onResizeStart:y,onResize:this.onResize,onResizeStop:n,resizeHandles:p,transformScale:l,width:this.state.width},yY.createElement("div",bY({},o,{style:O8(O8({},_),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(yY.Component);I8.default=fbe,fbe.propTypes=O8(O8({},LTt.resizableProps),{},{children:OTt.default.element}),oY.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};var HTt=oY.exports.Resizable=IA.default;oY.exports.ResizableBox=I8.default;const D7t="",_Y=400,$Tt=pt.forwardRef(function({...t},r){return delete t.handleAxis,He.jsx(Ka,{sx:{boxSizing:"content-box",width:"4px",height:"24px",position:"absolute",top:"50%",marginTop:"-12px",left:0,cursor:"ew-resize",padding:"10px 5px"},ref:r,...t,children:He.jsx(Ka,{sx:{boxSizing:"content-box",width:"100%",height:"100%",backgroundColor:"grey.300",borderRadius:"4px"}})})}),GTt=()=>{const[e,t]=pt.useState(!1),[r,a]=pt.useState(_Y),[u,A]=Cu(o_),c=(s,b)=>a(b.size.width),{width:y}=Tgt(),n=v3(s=>s.breakpoints.down("sm"));return r<_Y&&n&&a(_Y),He.jsx(HTt,{width:r,height:0,onResize:c,onResizeStart:()=>t(!0),onResizeStop:()=>t(!1),resizeHandles:["w"],handle:n?He.jsx(He.Fragment,{}):He.jsx($Tt,{}),axis:"x",minConstraints:[100,0],maxConstraints:[y/2,0],children:He.jsxs(VTt,{anchor:"right",isSmallScreen:n,open:!!u,variant:n?"temporary":"persistent",width:r,children:[He.jsxs(ki,{direction:"row",alignItems:"center",children:[He.jsx(Wo,{noWrap:!0,fontSize:"20px",fontWeight:500,id:"side-view-title",children:u==null?void 0:u.name}),He.jsx(Ss,{edge:"end",sx:{ml:"auto"},onClick:()=>A(void 0),children:He.jsx(X1,{})})]}),He.jsx(Ka,{mt:"1.5rem",id:"side-view-content",sx:{height:"100%",pointerEvents:e?"none":"auto"},children:He.jsx(S$,{element:u})})]})})},VTt=wa($re,{shouldForwardProp:e=>e!=="isSmallScreen"})(({theme:e,open:t,width:r,isSmallScreen:a})=>({width:r,flexShrink:0,display:t?"flex":"none","& .MuiDrawer-paper":{position:"inherit",width:r,maxWidth:a?"80%":"100%",backgroundColor:e.palette.background.paper,borderLeft:`1px solid ${e.palette.divider}`,flexDirection:"column",borderRadius:0,color:e.palette.text.primary,whiteSpace:"nowrap",boxSizing:"border-box",padding:"1.5rem",paddingTop:".5rem",overflowX:"hidden"}}));var EY={},YTt=ll;Object.defineProperty(EY,"__esModule",{value:!0});var dbe=EY.default=void 0,WTt=YTt(ul()),jTt=He,KTt=(0,WTt.default)((0,jTt.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");dbe=EY.default=KTt;const XTt=({element:e,onGoBack:t})=>{const r=Pg();return He.jsxs(Ka,{display:"flex",flexDirection:"column",flexGrow:1,p:3,gap:2,boxSizing:"border-box",mx:"auto",sx:{width:"100%",maxWidth:r,color:"text.primary"},id:"element-view",children:[He.jsxs(ki,{direction:"row",gap:1,children:[t?He.jsx(Ss,{edge:"start",onClick:t,children:He.jsx(dbe,{})}):null,He.jsx(Wo,{fontWeight:700,fontSize:"25px",children:e.name})]}),He.jsx(S$,{element:e})]})},ZTt=e=>He.jsx(uu,{children:He.jsxs("svg",{...e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[He.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),He.jsx("circle",{cx:"12",cy:"7",r:"4"})]})});function QTt(e){var r,a,u;const{user:t}=Vp();return He.jsx(Ss,{...e,children:He.jsx(UP,{sx:{width:32,height:32,bgcolor:"primary.main",color:"primary.contrastText"},src:((r=t==null?void 0:t.metadata)==null?void 0:r.image)||void 0,children:t?(u=(a=t.identifier)==null?void 0:a[0])==null?void 0:u.toUpperCase():He.jsx(ZTt,{sx:{height:20,width:20}})})})}var SY={},JTt=ll;Object.defineProperty(SY,"__esModule",{value:!0});var hbe=SY.default=void 0,qTt=JTt(ul()),e3t=He,t3t=(0,qTt.default)((0,e3t.jsx)("path",{d:"M9.37 5.51c-.18.64-.27 1.31-.27 1.99 0 4.08 3.32 7.4 7.4 7.4.68 0 1.35-.09 1.99-.27C17.45 17.19 14.93 19 12 19c-3.86 0-7-3.14-7-7 0-2.93 1.81-5.45 4.37-6.49zM12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z"}),"DarkModeOutlined");hbe=SY.default=t3t;var TY={},r3t=ll;Object.defineProperty(TY,"__esModule",{value:!0});var pbe=TY.default=void 0,n3t=r3t(ul()),a3t=He,i3t=(0,n3t.default)((0,a3t.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");pbe=TY.default=i3t;var wY={},o3t=ll;Object.defineProperty(wY,"__esModule",{value:!0});var vbe=wY.default=void 0,s3t=o3t(ul()),l3t=He,u3t=(0,s3t.default)((0,l3t.jsx)("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"}),"Logout");vbe=wY.default=u3t;function c3t({anchorEl:e,open:t,handleClose:r}){var _;const{user:a,logout:u}=Vp(),[A,c]=Cu(Lb),{config:y}=Dl(),n=!!((_=y==null?void 0:y.userEnv)!=null&&_.length),s=a&&He.jsxs(XP,{sx:{display:"flex",flexDirection:"column"},children:[He.jsx(Wo,{width:"100%",fontSize:"14px",fontWeight:700,children:a.id}),He.jsx(Wo,{width:"100%",fontSize:"13px",fontWeight:400,children:a.identifier})]},"user-name"),b=He.jsxs(XP,{sx:{display:"flex",gap:1},children:[He.jsx(ZP,{children:He.jsx(hbe,{})}),He.jsx(uFe,{id:"switch-theme",secondary:He.jsx(ji,{path:"components.molecules.settingsModal.darkMode"})}),He.jsx(Ka,{children:He.jsx(Goe,{id:"switch-theme",onChange:()=>{const l=A.theme==="light"?"dark":"light";localStorage.setItem("themeVariant",l),c(o=>({...o,theme:l}))},checked:A.theme==="dark",inputProps:{"aria-labelledby":"switch-theme"}})})]},"theme"),E=[s,b,n&&He.jsxs(x6,{component:aY,to:"/env",children:[He.jsx(ZP,{children:He.jsx(pbe,{fontSize:"small"})}),He.jsx(ji,{path:"components.atoms.buttons.userButton.menu.APIKeys"})]},"env"),a&&He.jsxs(x6,{onClick:()=>{u(),r()},children:[He.jsx(ZP,{children:He.jsx(vbe,{fontSize:"small"})}),He.jsx(ji,{path:"components.atoms.buttons.userButton.menu.logout"})]},"logout")].filter(l=>!!l),p=E.reduce((l,o,d)=>d===E.length-1?[...l,o]:[...l,o,He.jsx(Bre,{sx:{my:1}},`divider-${d}`)],[]);return He.jsx(g3,{anchorEl:e,id:"account-menu",open:t,onClose:r,PaperProps:{sx:{width:220,overflow:"visible",mt:1.5,backgroundImage:"none",border:l=>`1px solid ${l.palette.divider}`,boxShadow:l=>l.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D","& .MuiAvatar-root":{width:32,height:32,ml:-.5,mr:1},"&:before":{content:'""',display:"block",position:"absolute",top:0,right:14,width:10,height:10,bgcolor:"background.default",transform:"translateY(-50%) rotate(45deg)",zIndex:0}}},transformOrigin:{horizontal:"center",vertical:"top"},anchorOrigin:{horizontal:"center",vertical:"bottom"},children:p})}function f3t(){const[e,t]=pt.useState(null),r=!!e,a=A=>{t(A.currentTarget)},u=()=>{t(null)};return He.jsxs(He.Fragment,{children:[He.jsx(QTt,{onClick:a,"aria-controls":r?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0}),He.jsx(c3t,{open:r,anchorEl:e,handleClose:u})]})}function d3t(){var g,v;const e=pt.useContext(Ac),{config:t}=Dl(),{chatProfile:r,setChatProfile:a}=ig(),{firstInteraction:u}=Kh(),[A,c]=pt.useState(null),[y,n]=pt.useState(""),{clear:s}=Xu(),[b,i]=pt.useState(null),[w,E]=pt.useState(!1),p=up(),_=()=>{E(!1),i(null),p("/")},l=C=>{const S=C||b;if(!S)throw new Error("Retry clicking on a profile before starting a new chat");a(S),i(null),s(),_()};if(!r&&jV(t==null?void 0:t.chatProfiles)>0&&a(t==null?void 0:t.chatProfiles[0].name),typeof t>"u"||t.chatProfiles.length<=1)return null;const o=(g=t==null?void 0:t.features)==null?void 0:g.unsafe_allow_html,d=(v=t==null?void 0:t.features)==null?void 0:v.latex,f=!!A,h=t.chatProfiles.map(C=>{var I;const S=(I=C.icon)!=null&&I.includes("/public")?e.buildEndpoint(C.icon):C.icon;return{label:C.name,value:C.name,icon:S?He.jsx("img",{src:S,className:"chat-profile-icon",style:{width:"24px",height:"24px",borderRadius:"50%",objectFit:"cover"}}):void 0}});return He.jsxs(He.Fragment,{children:[He.jsx(Tne,{id:"chat-profile-description",anchorEl:A,open:f,PaperProps:{sx:{boxShadow:C=>C.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D",ml:2}},sx:{pointerEvents:"none",marginTop:1.5},anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},disableRestoreFocus:!0,children:He.jsx(Ka,{p:2,sx:{fontFamily:C=>C.typography.fontFamily},maxWidth:"20rem",children:He.jsx(Ew,{allowHtml:o,latex:d,children:y})})}),He.jsx(gk,{value:r||"",items:h,id:"chat-profile-selector",onItemMouseEnter:(C,S)=>{const I=t.chatProfiles.find(T=>T.name===S);I&&(n(I.markdown_description),c(C.currentTarget))},onItemMouseLeave:()=>c(null),onChange:C=>{const S=C.target.value;i(S),u?E(!0):l(S)},onClose:()=>c(null)}),He.jsx(x8,{open:w,handleClose:_,handleConfirm:()=>l()})]})}function h3t(e){const[t,r]=pt.useState(!1),a=up(),{clear:u}=Xu(),A=()=>{r(!0)},c=()=>{r(!1)},y=()=>{u(),a("/"),c()};return He.jsxs(Ka,{children:[He.jsx(cc,{title:He.jsx(ji,{path:"components.molecules.newChatButton.newChat"}),children:He.jsx(Ss,{id:"new-chat-button",onClick:A,...e,children:He.jsx(v2e,{sx:{height:20,width:20}})})}),He.jsx(x8,{open:t,handleClose:c,handleConfirm:y})]})}var AY={},p3t=ll;Object.defineProperty(AY,"__esModule",{value:!0});var mbe=AY.default=void 0,v3t=p3t(ul()),m3t=He,g3t=(0,v3t.default)((0,m3t.jsx)("path",{d:"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"}),"Sort");mbe=AY.default=g3t;const y3t=()=>{const e=Ho(Lb);return He.jsx(Ka,{children:He.jsx(Ss,{onClick:()=>e(t=>({...t,isChatHistoryOpen:!0})),children:He.jsx(mbe,{})})})},gbe=pt.memo(()=>{const e=v3("(max-width: 66rem)"),{isChatHistoryOpen:t}=ns(Lb);return He.jsxs(Ka,{px:1,py:1,display:"flex",height:"45px",alignItems:"center",flexDirection:"row",justifyContent:"space-between",color:"text.primary",gap:2,id:"header",position:"relative",children:[He.jsx(Ka,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:He.jsx(d3t,{})}),e?He.jsx(y3t,{}):t?null:He.jsx(b8,{style:{maxHeight:"25px",marginLeft:"8px"}}),He.jsx(Ka,{}),He.jsxs(ki,{direction:"row",alignItems:"center",children:[He.jsx(h3t,{}),He.jsx(f3t,{})]})]})}),b3t=e=>He.jsx(uu,{...e,viewBox:"0 0 98 96",children:He.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"})});function x3t({...e}){const{config:t}=Dl(),r=t==null?void 0:t.ui.github;return r?He.jsx(rh,{href:r,target:"_blank",color:"inherit",sx:{justifyContent:"start",textTransform:"none"},startIcon:He.jsx(b3t,{sx:{height:20,width:20}}),...e,children:"Repo"}):null}var CY={},_3t=ll;Object.defineProperty(CY,"__esModule",{value:!0});var ybe=CY.default=void 0,E3t=_3t(ul()),S3t=He,T3t=(0,E3t.default)((0,S3t.jsx)("path",{d:"M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"}),"HelpOutline");ybe=CY.default=T3t;const w3t=pt.memo(({markdown:e,allowHtml:t,latex:r})=>{const a=Pg();return e?He.jsx(Ka,{overflow:"auto",flexGrow:1,children:He.jsx(Ka,{id:"welcome-screen",sx:{boxSizing:"border-box",maxWidth:a,width:"100%",mx:"auto",color:"text.primary",fontFamily:"-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji",display:"flex",flexDirection:"column"},children:He.jsx(Ew,{allowHtml:t,latex:r,children:e})})}):He.jsx(Ka,{flexGrow:1})});function A3t(){var u,A;const{config:e}=Dl(),[t,r]=pt.useState(!1);if(!(e!=null&&e.markdown))return null;const a=()=>{r(!1)};return He.jsxs(He.Fragment,{children:[He.jsx(rh,{id:"readme-button",onClick:()=>r(!0),color:"inherit",sx:{textTransform:"none",justifyContent:"start"},startIcon:He.jsx(ybe,{}),children:He.jsx(ji,{path:"components.organisms.header.readme"})}),He.jsxs(u3,{open:t,maxWidth:"lg",onClose:a,scroll:"paper","aria-labelledby":"instructions","aria-describedby":"how-to-use-this-app",PaperProps:{sx:{backgroundImage:"none"}},children:[He.jsx(f3,{id:"instructions-dialog",children:He.jsx(ji,{path:"components.organisms.header.readme"})}),He.jsx(c3,{dividers:!0,children:He.jsx(w3t,{markdown:e==null?void 0:e.markdown,allowHtml:(u=e==null?void 0:e.features)==null?void 0:u.unsafe_allow_html,latex:(A=e==null?void 0:e.features)==null?void 0:A.latex})})]})]})}const bbe={height:"0.75rem",width:"0.25rem",backgroundColor:"text.primary",borderRadius:"20px",transition:"transform 0.3s ease"},C3t=({onClick:e,open:t})=>{const{t:r}=nv();return He.jsx(cc,{title:r(t?"components.organisms.threadHistory.sidebar.TriggerButton.closeSidebar":"components.organisms.threadHistory.sidebar.TriggerButton.openSidebar"),placement:"right",children:He.jsxs(Ka,{id:"open-sidebar-button",sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:2,"&:hover div:nth-child(1)":{transform:t?"rotate(15deg)":"rotate(-15deg)"},"&:hover div:nth-child(2)":{transform:t?"rotate(-15deg)":"rotate(15deg)"}},onClick:e,children:[He.jsx(Ka,{sx:{...bbe,marginTop:"0.25rem"}}),He.jsx(Ka,{sx:{...bbe,marginTop:"-0.25rem"}})]})})};var R3t=ek;function M3t(e,t){return R3t(e,t)}var I3t=M3t;const O3t=_s(I3t);function N3t(e,t,r,a){for(var u=e.length,A=r+(a?1:-1);a?A--:++A<u;)if(t(e[A],A,e))return A;return-1}var L3t=N3t;function D3t(e){return e!==e}var P3t=D3t;function k3t(e,t,r){for(var a=r-1,u=e.length;++a<u;)if(e[a]===t)return a;return-1}var F3t=k3t,B3t=L3t,z3t=P3t,U3t=F3t;function H3t(e,t,r){return t===t?U3t(e,t,r):B3t(e,z3t,r)}var $3t=H3t,G3t=$3t;function V3t(e,t){var r=e==null?0:e.length;return!!r&&G3t(e,t,0)>-1}var Y3t=V3t;function W3t(e,t,r){for(var a=-1,u=e==null?0:e.length;++a<u;)if(r(t,e[a]))return!0;return!1}var j3t=W3t;function K3t(){}var X3t=K3t,RY=Hie,Z3t=X3t,Q3t=Y9,J3t=1/0,q3t=RY&&1/Q3t(new RY([,-0]))[1]==J3t?function(e){return new RY(e)}:Z3t,ewt=q3t,twt=Rie,rwt=Y3t,nwt=j3t,awt=Mie,iwt=ewt,owt=Y9,swt=200;function lwt(e,t,r){var a=-1,u=rwt,A=e.length,c=!0,y=[],n=y;if(r)c=!1,u=nwt;else if(A>=swt){var s=t?null:iwt(e);if(s)return owt(s);c=!1,u=awt,n=new twt}else n=t?[]:y;e:for(;++a<A;){var b=e[a],i=t?t(b):b;if(b=r||b!==0?b:0,c&&i===i){for(var w=n.length;w--;)if(n[w]===i)continue e;t&&n.push(i),y.push(b)}else u(n,i,r)||(n!==y&&n.push(i),y.push(b))}return y}var uwt=lwt,cwt=ak,fwt=uwt;function dwt(e,t){return e&&e.length?fwt(e,cwt(t)):[]}var hwt=dwt;const pwt=_s(hwt),MY=zs({key:"ThreadsFilters",default:{}});function vwt(e,t,r){var a=-1,u=e.length;t<0&&(t=-t>u?0:u+t),r=r>u?u:r,r<0&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var A=Array(u);++a<u;)A[a]=e[a+t];return A}var mwt=vwt,gwt=mwt;function ywt(e,t,r){var a=e.length;return r=r===void 0?a:r,!t&&r>=a?e:gwt(e,t,r)}var bwt=ywt;function xwt(e){return e.split("")}var _wt=xwt,xbe="\\ud800-\\udfff",Ewt="\\u0300-\\u036f",Swt="\\ufe20-\\ufe2f",Twt="\\u20d0-\\u20ff",wwt=Ewt+Swt+Twt,Awt="\\ufe0e\\ufe0f",Cwt="["+xbe+"]",IY="["+wwt+"]",OY="\\ud83c[\\udffb-\\udfff]",Rwt="(?:"+IY+"|"+OY+")",_be="[^"+xbe+"]",Ebe="(?:\\ud83c[\\udde6-\\uddff]){2}",Sbe="[\\ud800-\\udbff][\\udc00-\\udfff]",Mwt="\\u200d",Tbe=Rwt+"?",wbe="["+Awt+"]?",Iwt="(?:"+Mwt+"(?:"+[_be,Ebe,Sbe].join("|")+")"+wbe+Tbe+")*",Owt=wbe+Tbe+Iwt,Nwt="(?:"+[_be+IY+"?",IY,Ebe,Sbe,Cwt].join("|")+")",Lwt=RegExp(OY+"(?="+OY+")|"+Nwt+Owt,"g");function Dwt(e){return e.match(Lwt)||[]}var Pwt=Dwt,kwt=_wt,Fwt=VV,Bwt=Pwt;function zwt(e){return Fwt(e)?Bwt(e):kwt(e)}var Uwt=zwt,Hwt=bwt,$wt=VV,Gwt=Uwt,Vwt=nk;function Ywt(e){return function(t){t=Vwt(t);var r=$wt(t)?Gwt(t):void 0,a=r?r[0]:t.charAt(0),u=r?Hwt(r,1).join(""):t.slice(1);return a[e]()+u}}var Wwt=Ywt,jwt=Wwt,Kwt=jwt("toUpperCase"),Xwt=Kwt,Zwt=nk,Qwt=Xwt;function Jwt(e){return Qwt(Zwt(e).toLowerCase())}var qwt=Jwt;const eAt=_s(qwt);var tAt=I3;function rAt(e,t){return function(r,a){if(r==null)return r;if(!tAt(r))return e(r,a);for(var u=r.length,A=t?u:-1,c=Object(r);(t?A--:++A<u)&&a(c[A],A,c)!==!1;);return r}}var nAt=rAt,aAt=wie,iAt=nAt,oAt=iAt(aAt),sAt=oAt,lAt=sAt,uAt=I3;function cAt(e,t){var r=-1,a=uAt(e)?Array(e.length):[];return lAt(e,function(u,A,c){a[++r]=t(u,A,c)}),a}var fAt=cAt,dAt=ioe,hAt=ak,pAt=fAt,vAt=ov;function mAt(e,t){var r=vAt(e)?dAt:pAt;return r(e,hAt(t))}var gAt=mAt;const Abe=_s(gAt);var NY={},yAt=ll;Object.defineProperty(NY,"__esModule",{value:!0});var Cbe=NY.default=void 0,bAt=yAt(ul()),xAt=He,_At=(0,bAt.default)((0,xAt.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"}),"ChatBubbleOutline");Cbe=NY.default=_At;var LY={},EAt=ll;Object.defineProperty(LY,"__esModule",{value:!0});var Rbe=LY.default=void 0,SAt=EAt(ul()),TAt=He,wAt=(0,SAt.default)((0,TAt.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM8 9h8v10H8V9zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutline");Rbe=LY.default=wAt;function AAt(e){return Bi("MuiLoadingButton",e)}const kg=Hi("MuiLoadingButton",["root","loading","loadingIndicator","loadingIndicatorCenter","loadingIndicatorStart","loadingIndicatorEnd","endIconLoadingEnd","startIconLoadingStart"]),CAt=["children","disabled","id","loading","loadingIndicator","loadingPosition","variant"],RAt=e=>{const{loading:t,loadingPosition:r,classes:a}=e,u={root:["root",t&&"loading"],startIcon:[t&&`startIconLoading${Ea(r)}`],endIcon:[t&&`endIconLoading${Ea(r)}`],loadingIndicator:["loadingIndicator",t&&`loadingIndicator${Ea(r)}`]},A=Ui(u,AAt,a);return ir({},a,A)},MAt=e=>e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"&&e!=="classes",IAt=wa(rh,{shouldForwardProp:e=>MAt(e)||e==="classes",name:"MuiLoadingButton",slot:"Root",overridesResolver:(e,t)=>[t.root,t.startIconLoadingStart&&{[`& .${kg.startIconLoadingStart}`]:t.startIconLoadingStart},t.endIconLoadingEnd&&{[`& .${kg.endIconLoadingEnd}`]:t.endIconLoadingEnd}]})(({ownerState:e,theme:t})=>ir({[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0}},e.loadingPosition==="center"&&{transition:t.transitions.create(["background-color","box-shadow","border-color"],{duration:t.transitions.duration.short}),[`&.${kg.loading}`]:{color:"transparent"}},e.loadingPosition==="start"&&e.fullWidth&&{[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginRight:-8}},e.loadingPosition==="end"&&e.fullWidth&&{[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginLeft:-8}})),OAt=wa("div",{name:"MuiLoadingButton",slot:"LoadingIndicator",overridesResolver:(e,t)=>{const{ownerState:r}=e;return[t.loadingIndicator,t[`loadingIndicator${Ea(r.loadingPosition)}`]]}})(({theme:e,ownerState:t})=>ir({position:"absolute",visibility:"visible",display:"flex"},t.loadingPosition==="start"&&(t.variant==="outlined"||t.variant==="contained")&&{left:t.size==="small"?10:14},t.loadingPosition==="start"&&t.variant==="text"&&{left:6},t.loadingPosition==="center"&&{left:"50%",transform:"translate(-50%)",color:(e.vars||e).palette.action.disabled},t.loadingPosition==="end"&&(t.variant==="outlined"||t.variant==="contained")&&{right:t.size==="small"?10:14},t.loadingPosition==="end"&&t.variant==="text"&&{right:6},t.loadingPosition==="start"&&t.fullWidth&&{position:"relative",left:-10},t.loadingPosition==="end"&&t.fullWidth&&{position:"relative",right:-10})),NAt=pt.forwardRef(function(t,r){const a=Vi({props:t,name:"MuiLoadingButton"}),{children:u,disabled:A=!1,id:c,loading:y=!1,loadingIndicator:n,loadingPosition:s="center",variant:b="text"}=a,i=ti(a,CAt),w=YT(c),E=n??He.jsx(l3,{"aria-labelledby":w,color:"inherit",size:16}),p=ir({},a,{disabled:A,loading:y,loadingIndicator:E,loadingPosition:s,variant:b}),_=RAt(p),l=y?He.jsx(OAt,{className:_.loadingIndicator,ownerState:p,children:E}):null;return He.jsxs(IAt,ir({disabled:A||y,id:w,ref:r},i,{variant:b,classes:_,ownerState:p,children:[p.loadingPosition==="end"?u:l,p.loadingPosition==="end"?l:u]}))}),LAt=({threadId:e,onDelete:t})=>{const[r,a]=pt.useState(!1),u=ns(N2),A=pt.useContext(Ac),c=()=>{a(!0)},y=()=>{a(!1)},n=async()=>{Gf.promise(A.deleteThread(e,u),{loading:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.deletingChat"}),success:()=>(t(),He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.chatDeleted"})),error:s=>s instanceof eP?He.jsx("span",{children:s.message}):He.jsx("span",{})}),y()};return He.jsxs("div",{children:[He.jsx(Ss,{size:"small",onClick:c,sx:{p:"2px"},children:He.jsx(Rbe,{sx:{width:16,height:16}})}),r&&He.jsxs(u3,{open:r,onClose:y,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",PaperProps:{sx:{backgroundImage:"none"}},children:[He.jsx(f3,{id:"alert-dialog-title",children:"Delete Thread?"}),He.jsx(c3,{children:He.jsx(Pre,{id:"alert-dialog-description",children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.confirmMessage"})})}),He.jsxs(m6,{sx:{color:"text.secondary",p:2},children:[He.jsx(rh,{variant:"outlined",color:"inherit",onClick:y,children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.cancel"})}),He.jsx(NAt,{variant:"outlined",color:"primary",onClick:n,autoFocus:!0,children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.confirm"})})]})]})]})},DAt=({threadHistory:e,error:t,fetchThreads:r,isFetching:a,isLoadingMore:u})=>{const{idToResume:A}=ig(),{clear:c}=Xu(),{threadId:y}=Kh(),n=up();if(a||!(e!=null&&e.timeGroupedThreads)&&u)return He.jsx(He.Fragment,{children:[1,2,3].map(b=>He.jsxs(Ka,{sx:{mt:2},children:[He.jsx(G1,{width:100}),[1,2].map(i=>He.jsxs(ki,{sx:{py:2,flexDirection:"row",alignItems:"center",gap:1.5},children:[He.jsx(G1,{width:30}),He.jsx(G1,{width:"100%"})]},`threads-skeleton-${b}-${i}`))]},`threads-skeleton-${b}`))});if(t)return He.jsx(ev,{severity:"error",children:t.message});if(!e)return null;if(jV(e==null?void 0:e.timeGroupedThreads)===0)return He.jsx(ev,{variant:"standard",severity:"info",children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.empty"})});const s=b=>{(b===A||b===y)&&c(),b===e.currentThreadId&&n("/"),r()};return He.jsxs(y6,{sx:{height:0,bgcolor:"background.paper","& ul":{padding:0}},subheader:He.jsx("li",{}),children:[Abe(e.timeGroupedThreads,(b,i)=>He.jsx("li",{children:He.jsxs("ul",{children:[He.jsx(v7e,{sx:{px:0},children:He.jsx(Wo,{sx:{py:1,color:"text.secondary",fontWeight:600,fontSize:"12px",backgroundColor:w=>w.palette.background.paper},children:(()=>i==="Today"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.today"}):i==="Yesterday"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.yesterday"}):i==="Previous 7 days"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.previous7days"}):i==="Previous 30 days"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.previous30days"}):He.jsx(He.Fragment,{children:i}))()})}),Abe(b,w=>{const E=A===w.id&&!e.currentThreadId,p=E||e.currentThreadId===w.id;return He.jsx(ki,{component:aY,id:`thread-${w.id}`,sx:_=>({textDecoration:"none",cursor:"pointer",p:1.5,mb:.5,gap:.5,flexDirection:"row",justifyContent:"space-between",borderRadius:1,backgroundColor:p?_.palette.mode==="dark"?Xi[800]:"grey.200":_.palette.background.paper,"&:hover":{backgroundColor:_.palette.mode==="dark"?Xi[800]:"grey.200"}}),to:E?"":`/thread/${w.id}`,children:He.jsxs(ki,{direction:"row",width:"100%",justifyContent:"space-between",children:[He.jsxs(ki,{sx:{alignItems:"center",flexDirection:"row",gap:1.5,overflow:"hidden",color:_=>_.palette.text.primary},children:[He.jsx(Cbe,{sx:{width:"14px",height:"14px"}}),He.jsx(Wo,{sx:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:eAt(w.name||"Unknown")})]}),p?He.jsx(LAt,{threadId:w.id,onDelete:()=>s(w.id)}):null]})},`thread-${w.id}`)})]})},`section-${i}`)),He.jsx(ki,{alignItems:"center",children:He.jsx(l3,{id:"chat-history-loader",size:30,sx:{my:1,opacity:u?1:0}})})]})};var DY={},PAt=ll;Object.defineProperty(DY,"__esModule",{value:!0});var Mbe=DY.default=void 0,kAt=PAt(ul()),FAt=He,BAt=(0,kAt.default)((0,FAt.jsx)("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}),"FilterList");Mbe=DY.default=BAt;var PY={},zAt=ll;Object.defineProperty(PY,"__esModule",{value:!0});var Ibe=PY.default=void 0,UAt=zAt(ul()),HAt=He,$At=(0,UAt.default)((0,HAt.jsx)("path",{d:"M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z"}),"ThumbDown");Ibe=PY.default=$At;var kY={},GAt=ll;Object.defineProperty(kY,"__esModule",{value:!0});var Obe=kY.default=void 0,VAt=GAt(ul()),YAt=He,WAt=(0,VAt.default)((0,YAt.jsx)("path",{d:"M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"}),"ThumbUp");Obe=kY.default=WAt;function jAt(){const[e,t]=Cu(MY),[r,a]=pt.useState(null),{t:u}=nv(),A=n=>{t(s=>({...s,feedback:n})),a(null)},c=(n,s)=>He.jsx(Ka,{onClick:()=>A(s),sx:{cursor:"pointer",px:1.5,py:1,borderRadius:1,"&:hover":{background:b=>b.palette.background.default}},children:n}),y=()=>{const n={width:20,height:20,color:"text.secondary"};switch(e.feedback){case 1:return He.jsx(Obe,{sx:n});case 0:return He.jsx(Ibe,{sx:n});default:return He.jsx(Mbe,{sx:n})}};return He.jsxs(He.Fragment,{children:[He.jsx(Ss,{disableRipple:!0,onClick:n=>a(n.currentTarget),edge:"end",children:y()}),He.jsx(g3,{id:"feedback-filter-select",autoFocus:!0,anchorEl:r,open:!!r,onClose:()=>a(null),sx:{mt:1},MenuListProps:{sx:{p:.5}},slotProps:{paper:{sx:{background:n=>n.palette.background.paper,border:n=>`1px solid ${n.palette.divider}`,boxShadow:n=>n.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D"}}},children:He.jsxs(ki,{children:[c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackAll"),void 0),c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackPositive"),1),c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackNegative"),0)]})})]})}var KAt=iv,XAt=function(){return KAt.Date.now()},ZAt=XAt,QAt=/\s/;function JAt(e){for(var t=e.length;t--&&QAt.test(e.charAt(t)););return t}var qAt=JAt,eCt=qAt,tCt=/^\s+/;function rCt(e){return e&&e.slice(0,eCt(e)+1).replace(tCt,"")}var nCt=rCt,aCt=nCt,Nbe=j1,iCt=V6,Lbe=0/0,oCt=/^[-+]0x[0-9a-f]+$/i,sCt=/^0b[01]+$/i,lCt=/^0o[0-7]+$/i,uCt=parseInt;function cCt(e){if(typeof e=="number")return e;if(iCt(e))return Lbe;if(Nbe(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Nbe(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=aCt(e);var r=sCt.test(e);return r||lCt.test(e)?uCt(e.slice(2),r?2:8):oCt.test(e)?Lbe:+e}var fCt=cCt,dCt=j1,FY=ZAt,Dbe=fCt,hCt="Expected a function",pCt=Math.max,vCt=Math.min;function mCt(e,t,r){var a,u,A,c,y,n,s=0,b=!1,i=!1,w=!0;if(typeof e!="function")throw new TypeError(hCt);t=Dbe(t)||0,dCt(r)&&(b=!!r.leading,i="maxWait"in r,A=i?pCt(Dbe(r.maxWait)||0,t):A,w="trailing"in r?!!r.trailing:w);function E(v){var C=a,S=u;return a=u=void 0,s=v,c=e.apply(S,C),c}function p(v){return s=v,y=setTimeout(o,t),b?E(v):c}function _(v){var C=v-n,S=v-s,I=t-C;return i?vCt(I,A-S):I}function l(v){var C=v-n,S=v-s;return n===void 0||C>=t||C<0||i&&S>=A}function o(){var v=FY();if(l(v))return d(v);y=setTimeout(o,_(v))}function d(v){return y=void 0,w&&a?E(v):(a=u=void 0,c)}function f(){y!==void 0&&clearTimeout(y),s=0,a=n=u=y=void 0}function h(){return y===void 0?c:d(FY())}function g(){var v=FY(),C=l(v);if(a=arguments,u=this,n=v,C){if(y===void 0)return p(n);if(i)return clearTimeout(y),y=setTimeout(o,t),E(n)}return y===void 0&&(y=setTimeout(o,t)),c}return g.cancel=f,g.flush=h,g}var gCt=mCt;const yCt=_s(gCt);var BY={},bCt=ll;Object.defineProperty(BY,"__esModule",{value:!0});var Pbe=BY.default=void 0,xCt=bCt(ul()),_Ct=He,ECt=(0,xCt.default)((0,_Ct.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),"Search");Pbe=BY.default=ECt;function SCt(){const[e,t]=Cu(MY),{t:r}=nv(),u=yCt(y=>{y=y.trim();const n=y===""?void 0:y;t(s=>({...s,search:n}))},300),A=pt.useRef(),c=()=>{u(""),A.current&&(A.current.value="")};return He.jsx(j2,{variant:"standard",sx:{width:"100%",border:"none",borderRadius:1,backgroundColor:y=>y.palette.mode==="dark"?Xi[850]:"grey.100"},InputProps:{sx:{px:1.5,py:1},disableUnderline:!0,startAdornment:He.jsx(WP,{position:"end",sx:{color:"text.secondary",mr:1,ml:0},children:He.jsx(Pbe,{sx:{height:20,width:20}})}),endAdornment:e.search?He.jsx(Ss,{onClick:c,sx:{p:"2px"},children:He.jsx(X1,{sx:{height:18,width:18}})}):null},placeholder:r("components.organisms.threadHistory.sidebar.filters.SearchBar.search"),inputProps:{"aria-label":"search",ref:A,sx:{p:0}},onChange:y=>u(y.target.value)})}function TCt(){return He.jsxs(ki,{sx:{flexDirection:"row",gap:1},children:[He.jsx(SCt,{}),He.jsx(jAt,{})]})}const wCt=20;let kbe=0;function ACt(){const e=ns(MY),t=pt.useRef(null),[r,a]=pt.useState(e),u=!O3t(r,e),[A,c]=Cu(HT),y=ns(N2),[n,s]=pt.useState(!1),[b,i]=pt.useState(void 0),[w,E]=pt.useState(!1),[p,_]=pt.useState(!1),l=pt.useContext(Ac),{firstInteraction:o,messages:d,threadId:f}=Kh(),h=up();pt.useEffect(()=>{t.current&&(t.current.scrollTop=kbe)},[]),pt.useEffect(()=>{var S;!o||o==="resume"&&((S=d.at(0))==null?void 0:S.output.toLowerCase())!=="resume"||v(void 0,!0).then(()=>{const I=new URL(window.location.href);f&&I.pathname==="/"&&h(`/thread/${f}`)})},[o]);const g=()=>{if(!t.current)return;const{scrollHeight:C,clientHeight:S,scrollTop:I}=t.current,T=I+S>=C-10;kbe=I,s(T)},v=async(C,S)=>{var I;try{C||S?E(!0):_(!0);const{pageInfo:T,data:x}=await l.listThreads({first:wCt,cursor:C},e,y);i(void 0);const R=pwt(C?(I=A==null?void 0:A.threads)==null?void 0:I.concat(x):x,"id");R&&c(P=>({...P,pageInfo:T,threads:R}))}catch(T){T instanceof Error&&i(T.message)}finally{s(!1),E(!1),_(!1)}};if(y&&!p&&!(A!=null&&A.threads)&&!b&&v(),A!=null&&A.pageInfo){const{hasNextPage:C,endCursor:S}=A.pageInfo;n&&!w&&C&&S&&v(S)}return u&&(a(e),v()),He.jsxs(He.Fragment,{children:[He.jsx(TCt,{}),A?He.jsx(Ka,{sx:{flexGrow:1,overflow:"auto"},onScroll:g,ref:t,children:He.jsx(DAt,{threadHistory:A,error:b,isFetching:p,isLoadingMore:w,fetchThreads:v})}):null]})}const CCt=260,RCt=()=>{const e=Vp(),t=v3("(max-width:66rem)"),[r,a]=Cu(Lb),{config:u}=Dl(),A=!!e.accessToken&&!!(u!=null&&u.dataPersistence);pt.useEffect(()=>{c(t?!1:A)},[A]);const c=y=>a(n=>({...n,isChatHistoryOpen:y}));return He.jsxs(Ka,{display:"flex",position:"relative",children:[He.jsxs($re,{className:"chat-history-drawer",anchor:"left",open:r.isChatHistoryOpen,variant:t?"temporary":"persistent",transitionDuration:0,hideBackdrop:!t,onClose:()=>c(!1),sx:{width:r.isChatHistoryOpen?"auto":0,"& .MuiDrawer-paper":{width:r.isChatHistoryOpen?CCt:0,position:"inherit",gap:1,display:"flex",flexDirection:"column",padding:"0px 4px",backgroundImage:"none",borderRight:"none",px:2,boxSizing:"border-box",boxShadow:y=>y.palette.mode==="dark"?"0px 4px 20px 0px rgba(0, 0, 0, 0.20)":"0px 4px 20px 0px rgba(0, 0, 0, 0.05)"}},children:[He.jsx(ki,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",height:"45px",mt:1},children:He.jsx(b8,{style:{maxHeight:"25px"}})}),A?He.jsx(ACt,{}):He.jsx(Ka,{sx:{flexGrow:1,overflow:"auto"},children:He.jsx(ev,{severity:"info",children:"Conversations are not persisted."})}),He.jsxs(ki,{mb:2,children:[He.jsx(A3t,{}),He.jsx(x3t,{})]})]}),t?null:He.jsx(Ka,{position:"absolute",sx:{top:"50%",transform:"translateY(-100%)",right:-30,zIndex:10},children:He.jsx(C3t,{onClick:()=>c(!r.isChatHistoryOpen),open:r.isChatHistoryOpen})})]})},Fbe=localStorage.getItem("userEnv"),Bbe=zs({key:"UserEnv",default:Fbe?JSON.parse(Fbe):{}}),zY=({children:e})=>{const{isAuthenticated:t}=Vp(),{config:r}=Dl(),a=ns(Bbe),u=ns(o_);if(r!=null&&r.userEnv){for(const A of r.userEnv||[])if(!a[A])return He.jsx(nY,{to:"/env"})}return t?He.jsx(Ka,{sx:{display:"flex",flexDirection:"column",width:"100%"},children:t?He.jsxs(ki,{direction:"row",height:"100%",width:"100%",children:[He.jsx(RCt,{}),He.jsxs(ki,{flexGrow:1,children:[He.jsx(gbe,{}),He.jsx(ki,{direction:"row",flexGrow:1,overflow:"auto",children:e})]}),u?null:He.jsx(f9,{isMobile:!1}),He.jsx(GTt,{})]}):He.jsx(ev,{severity:"error",children:He.jsx(ji,{path:"pages.Page.notPartOfProject"})})}):He.jsx(nY,{to:"/login"})};function MCt(){const{id:e}=U2e(),t=iY(),{elements:r}=q0(),{config:a}=Dl(),[u,A]=pt.useState(null),c=up(),y=t.get("thread"),n=a==null?void 0:a.dataPersistence,{data:s,error:b}=$T(e&&y&&n?`/project/thread/${y}/element/${e}`:null);return pt.useEffect(()=>{if(s)A(s);else if(e&&!n&&!u){const i=r.find(w=>w.id===e);i&&A(i)}},[s,u,r,e,y]),!u||b?null:He.jsx(zY,{children:He.jsx(XTt,{element:u,onGoBack:()=>c("/")})})}function zb(e){this._maxSize=e,this.clear()}zb.prototype.clear=function(){this._size=0,this._values=Object.create(null)},zb.prototype.get=function(e){return this._values[e]},zb.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var ICt=/[^.^\]^[]+|(?=\[\]|\.\.)/g,zbe=/^\d+$/,OCt=/^\d/,NCt=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,LCt=/^\s*(['"]?)(.*?)(\1)\s*$/,UY=512,Ube=new zb(UY),Hbe=new zb(UY),$be=new zb(UY),Ub={Cache:zb,split:$Y,normalizePath:HY,setter:function(e){var t=HY(e);return Hbe.get(e)||Hbe.set(e,function(a,u){for(var A=0,c=t.length,y=a;A<c-1;){var n=t[A];if(n==="__proto__"||n==="constructor"||n==="prototype")return a;y=y[t[A++]]}y[t[A]]=u})},getter:function(e,t){var r=HY(e);return $be.get(e)||$be.set(e,function(u){for(var A=0,c=r.length;A<c;)if(u!=null||!t)u=u[r[A++]];else return;return u})},join:function(e){return e.reduce(function(t,r){return t+(GY(r)||zbe.test(r)?"["+r+"]":(t?".":"")+r)},"")},forEach:function(e,t,r){DCt(Array.isArray(e)?e:$Y(e),t,r)}};function HY(e){return Ube.get(e)||Ube.set(e,$Y(e).map(function(t){return t.replace(LCt,"$2")}))}function $Y(e){return e.match(ICt)||[""]}function DCt(e,t,r){var a=e.length,u,A,c,y;for(A=0;A<a;A++)u=e[A],u&&(FCt(u)&&(u='"'+u+'"'),y=GY(u),c=!y&&/^\d+$/.test(u),t.call(r,u,y,c,A,e))}function GY(e){return typeof e=="string"&&e&&["'",'"'].indexOf(e.charAt(0))!==-1}function PCt(e){return e.match(OCt)&&!e.match(zbe)}function kCt(e){return NCt.test(e)}function FCt(e){return!GY(e)&&(PCt(e)||kCt(e))}const BCt=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,N8=e=>e.match(BCt)||[],L8=e=>e[0].toUpperCase()+e.slice(1),VY=(e,t)=>N8(e).join(t).toLowerCase(),Gbe=e=>N8(e).reduce((t,r)=>`${t}${t?r[0].toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()}`,"");var YY={words:N8,upperFirst:L8,camelCase:Gbe,pascalCase:e=>L8(Gbe(e)),snakeCase:e=>VY(e,"_"),kebabCase:e=>VY(e,"-"),sentenceCase:e=>L8(VY(e," ")),titleCase:e=>N8(e).map(L8).join(" ")},WY={exports:{}};WY.exports=function(e){return Vbe(zCt(e),e)},WY.exports.array=Vbe;function Vbe(e,t){var r=e.length,a=new Array(r),u={},A=r,c=UCt(t),y=HCt(e);for(t.forEach(function(s){if(!y.has(s[0])||!y.has(s[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});A--;)u[A]||n(e[A],A,new Set);return a;function n(s,b,i){if(i.has(s)){var w;try{w=", node was:"+JSON.stringify(s)}catch{w=""}throw new Error("Cyclic dependency"+w)}if(!y.has(s))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(s));if(!u[b]){u[b]=!0;var E=c.get(s)||new Set;if(E=Array.from(E),b=E.length){i.add(s);do{var p=E[--b];n(p,y.get(p),i)}while(b);i.delete(s)}a[--r]=s}}}function zCt(e){for(var t=new Set,r=0,a=e.length;r<a;r++){var u=e[r];t.add(u[0]),t.add(u[1])}return Array.from(t)}function UCt(e){for(var t=new Map,r=0,a=e.length;r<a;r++){var u=e[r];t.has(u[0])||t.set(u[0],new Set),t.has(u[1])||t.set(u[1],new Set),t.get(u[0]).add(u[1])}return t}function HCt(e){for(var t=new Map,r=0,a=e.length;r<a;r++)t.set(e[r],r);return t}var $Ct=WY.exports;const GCt=_s($Ct),VCt=Object.prototype.toString,YCt=Error.prototype.toString,WCt=RegExp.prototype.toString,jCt=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",KCt=/^Symbol\((.*)\)(.*)$/;function XCt(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Ybe(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return XCt(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return jCt.call(e).replace(KCt,"Symbol($1)");const a=VCt.call(e).slice(8,-1);return a==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):a==="Error"||e instanceof Error?"["+YCt.call(e)+"]":a==="RegExp"?WCt.call(e):null}function KE(e,t){let r=Ybe(e,t);return r!==null?r:JSON.stringify(e,function(a,u){let A=Ybe(this[a],t);return A!==null?A:u},2)}function Wbe(e){return e==null?[]:[].concat(e)}let ZCt=/\$\{\s*(\w+)\s*\}/g;class dp extends Error{static formatError(t,r){const a=r.label||r.path||"this";return a!==r.path&&(r=Object.assign({},r,{path:a})),typeof t=="string"?t.replace(ZCt,(u,A)=>KE(r[A])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,a,u){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=r,this.path=a,this.type=u,this.errors=[],this.inner=[],Wbe(t).forEach(A=>{dp.isError(A)?(this.errors.push(...A.errors),this.inner=this.inner.concat(A.inner.length?A.inner:A)):this.errors.push(A)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,dp)}}let Fg={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:a})=>{const u=a!=null&&a!==r?` (cast from the value \`${KE(a,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${KE(r,!0)}\``+u:`${e} must match the configured type. The validated value was: \`${KE(r,!0)}\``+u}},xv={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},QCt={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},jY={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},JCt={isValue:"${path} field must be ${value}"},KY={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:Fg,string:xv,number:QCt,date:jY,object:KY,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:JCt});const XY=e=>e&&e.__isYupSchema__;class D8{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:a,then:u,otherwise:A}=r,c=typeof a=="function"?a:(...y)=>y.every(n=>n===a);return new D8(t,(y,n)=>{var s;let b=c(...y)?u:A;return(s=b==null?void 0:b(n))!=null?s:n})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let a=this.refs.map(A=>A.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),u=this.fn(a,t,r);if(u===void 0||u===t)return t;if(!XY(u))throw new TypeError("conditions must return a schema object");return u.resolve(r)}}const P8={context:"$",value:"."};class Hb{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===P8.context,this.isValue=this.key[0]===P8.value,this.isSibling=!this.isContext&&!this.isValue;let a=this.isContext?P8.context:this.isValue?P8.value:"";this.path=this.key.slice(a.length),this.getter=this.path&&Ub.getter(this.path,!0),this.map=r.map}getValue(t,r,a){let u=this.isContext?a:this.isValue?t:r;return this.getter&&(u=this.getter(u||{})),this.map&&(u=this.map(u)),u}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}Hb.prototype.__isYupRef=!0;const $b=e=>e==null;function XE(e){function t({value:r,path:a="",options:u,originalValue:A,schema:c},y,n){const{name:s,test:b,params:i,message:w,skipAbsent:E}=e;let{parent:p,context:_,abortEarly:l=c.spec.abortEarly}=u;function o(T){return Hb.isRef(T)?T.getValue(r,p,_):T}function d(T={}){const x=Object.assign({value:r,originalValue:A,label:c.spec.label,path:T.path||a,spec:c.spec},i,T.params);for(const P of Object.keys(x))x[P]=o(x[P]);const R=new dp(dp.formatError(T.message||w,x),r,x.path,T.type||s);return R.params=x,R}const f=l?y:n;let h={path:a,parent:p,type:s,from:u.from,createError:d,resolve:o,options:u,originalValue:A,schema:c};const g=T=>{dp.isError(T)?f(T):T?n(null):f(d())},v=T=>{dp.isError(T)?f(T):y(T)},C=E&&$b(r);if(!u.sync){try{Promise.resolve(C?!0:b.call(h,r,h)).then(g,v)}catch(T){v(T)}return}let S;try{var I;if(S=C?!0:b.call(h,r,h),typeof((I=S)==null?void 0:I.then)=="function")throw new Error(`Validation test of type: "${h.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(T){v(T);return}g(S)}return t.OPTIONS=e,t}function qCt(e,t,r,a=r){let u,A,c;return t?(Ub.forEach(t,(y,n,s)=>{let b=n?y.slice(1,y.length-1):y;e=e.resolve({context:a,parent:u,value:r});let i=e.type==="tuple",w=s?parseInt(b,10):0;if(e.innerType||i){if(i&&!s)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${c}" must contain an index to the tuple element, e.g. "${c}[0]"`);if(r&&w>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${y}, in the path: ${t}. because there is no value at that index. `);u=r,r=r&&r[w],e=i?e.spec.types[w]:e.innerType}if(!s){if(!e.fields||!e.fields[b])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${c} which is a type: "${e.type}")`);u=r,r=r&&r[b],e=e.fields[b]}A=b,c=n?"["+y+"]":"."+y}),{schema:e,parent:u,parentPath:A}):{parent:u,parentPath:t,schema:e}}class k8 extends Set{describe(){const t=[];for(const r of this.values())t.push(Hb.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const a of this.values())r.push(t(a));return r}clone(){return new k8(this.values())}merge(t,r){const a=this.clone();return t.forEach(u=>a.add(u)),r.forEach(u=>a.delete(u)),a}}function ZE(e,t=new Map){if(XY(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let a=0;a<e.length;a++)r[a]=ZE(e[a],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[a,u]of e.entries())r.set(a,ZE(u,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const a of e)r.add(ZE(a,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[a,u]of Object.entries(e))r[a]=ZE(u,t)}else throw Error(`Unable to clone ${e}`);return r}class Tm{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new k8,this._blacklist=new k8,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Fg.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=ZE(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let a=t(this);return this._mutate=r,a}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,a=t.clone();const u=Object.assign({},r.spec,a.spec);return a.spec=u,a.internalTests=Object.assign({},r.internalTests,a.internalTests),a._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),a._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),a.tests=r.tests,a.exclusiveTests=r.exclusiveTests,a.withMutation(A=>{t.tests.forEach(c=>{A.test(c.OPTIONS)})}),a.transforms=[...r.transforms,...a.transforms],a}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let a=r.conditions;r=r.clone(),r.conditions=[],r=a.reduce((u,A)=>A.resolve(u,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,a,u;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(a=t.abortEarly)!=null?a:this.spec.abortEarly,recursive:(u=t.recursive)!=null?u:this.spec.recursive})}cast(t,r={}){let a=this.resolve(Object.assign({value:t},r)),u=r.assert==="ignore-optionality",A=a._cast(t,r);if(r.assert!==!1&&!a.isType(A)){if(u&&$b(A))return A;let c=KE(t),y=KE(A);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${a.type}".
|
|
757
|
+
`,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&ebe(e.body,"react-draggable-transparent-selection")}function QSt(e){if(e)try{if(e.body&&tbe(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function ebe(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function tbe(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}var Sm={};Object.defineProperty(Sm,"__esModule",{value:!0}),Sm.canDragX=eTt,Sm.canDragY=tTt,Sm.createCoreData=nTt,Sm.createDraggableData=aTt,Sm.getBoundPosition=JSt,Sm.getControlPosition=rTt,Sm.snapToGrid=qSt;var fp=Em,jE=du;function JSt(e,t,r){if(!e.props.bounds)return[t,r];let{bounds:a}=e.props;a=typeof a=="string"?a:iTt(a);const u=uY(e);if(typeof a=="string"){const{ownerDocument:A}=u,c=A.defaultView;let y;if(a==="parent"?y=u.parentNode:y=A.querySelector(a),!(y instanceof c.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const n=y,s=c.getComputedStyle(u),b=c.getComputedStyle(n);a={left:-u.offsetLeft+(0,fp.int)(b.paddingLeft)+(0,fp.int)(s.marginLeft),top:-u.offsetTop+(0,fp.int)(b.paddingTop)+(0,fp.int)(s.marginTop),right:(0,jE.innerWidth)(n)-(0,jE.outerWidth)(u)-u.offsetLeft+(0,fp.int)(b.paddingRight)-(0,fp.int)(s.marginRight),bottom:(0,jE.innerHeight)(n)-(0,jE.outerHeight)(u)-u.offsetTop+(0,fp.int)(b.paddingBottom)-(0,fp.int)(s.marginBottom)}}return(0,fp.isNum)(a.right)&&(t=Math.min(t,a.right)),(0,fp.isNum)(a.bottom)&&(r=Math.min(r,a.bottom)),(0,fp.isNum)(a.left)&&(t=Math.max(t,a.left)),(0,fp.isNum)(a.top)&&(r=Math.max(r,a.top)),[t,r]}function qSt(e,t,r){const a=Math.round(t/e[0])*e[0],u=Math.round(r/e[1])*e[1];return[a,u]}function eTt(e){return e.props.axis==="both"||e.props.axis==="x"}function tTt(e){return e.props.axis==="both"||e.props.axis==="y"}function rTt(e,t,r){const a=typeof t=="number"?(0,jE.getTouch)(e,t):null;if(typeof t=="number"&&!a)return null;const u=uY(r),A=r.props.offsetParent||u.offsetParent||u.ownerDocument.body;return(0,jE.offsetXYFromParent)(a||e,A,r.props.scale)}function nTt(e,t,r){const a=!(0,fp.isNum)(e.lastX),u=uY(e);return a?{node:u,deltaX:0,deltaY:0,lastX:t,lastY:r,x:t,y:r}:{node:u,deltaX:t-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:r}}function aTt(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}}function iTt(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function uY(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var C8={},R8={};Object.defineProperty(R8,"__esModule",{value:!0}),R8.default=oTt;function oTt(){}Object.defineProperty(C8,"__esModule",{value:!0}),C8.default=void 0;var cY=lTt(pt),vh=dY(ib),sTt=dY(zye),Vf=du,Py=Sm,fY=Em,OA=dY(R8);function dY(e){return e&&e.__esModule?e:{default:e}}function rbe(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(rbe=function(a){return a?r:t})(e)}function lTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=rbe(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function Sd(e,t,r){return t=uTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uTt(e){var t=cTt(e,"string");return typeof t=="symbol"?t:String(t)}function cTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const bv={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let ky=bv.mouse,M8=class extends cY.Component{constructor(){super(...arguments),Sd(this,"dragging",!1),Sd(this,"lastX",NaN),Sd(this,"lastY",NaN),Sd(this,"touchIdentifier",null),Sd(this,"mounted",!1),Sd(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const r=this.findDOMNode();if(!r||!r.ownerDocument||!r.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:a}=r;if(this.props.disabled||!(t.target instanceof a.defaultView.Node)||this.props.handle&&!(0,Vf.matchesSelectorAndParentsTo)(t.target,this.props.handle,r)||this.props.cancel&&(0,Vf.matchesSelectorAndParentsTo)(t.target,this.props.cancel,r))return;t.type==="touchstart"&&t.preventDefault();const u=(0,Vf.getTouchIdentifier)(t);this.touchIdentifier=u;const A=(0,Py.getControlPosition)(t,u,this);if(A==null)return;const{x:c,y}=A,n=(0,Py.createCoreData)(this,c,y);(0,OA.default)("DraggableCore: handleDragStart: %j",n),(0,OA.default)("calling",this.props.onStart),!(this.props.onStart(t,n)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,Vf.addUserSelectStyles)(a),this.dragging=!0,this.lastX=c,this.lastY=y,(0,Vf.addEvent)(a,ky.move,this.handleDrag),(0,Vf.addEvent)(a,ky.stop,this.handleDragStop))}),Sd(this,"handleDrag",t=>{const r=(0,Py.getControlPosition)(t,this.touchIdentifier,this);if(r==null)return;let{x:a,y:u}=r;if(Array.isArray(this.props.grid)){let y=a-this.lastX,n=u-this.lastY;if([y,n]=(0,Py.snapToGrid)(this.props.grid,y,n),!y&&!n)return;a=this.lastX+y,u=this.lastY+n}const A=(0,Py.createCoreData)(this,a,u);if((0,OA.default)("DraggableCore: handleDrag: %j",A),this.props.onDrag(t,A)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(n)}return}this.lastX=a,this.lastY=u}),Sd(this,"handleDragStop",t=>{if(!this.dragging)return;const r=(0,Py.getControlPosition)(t,this.touchIdentifier,this);if(r==null)return;let{x:a,y:u}=r;if(Array.isArray(this.props.grid)){let n=a-this.lastX||0,s=u-this.lastY||0;[n,s]=(0,Py.snapToGrid)(this.props.grid,n,s),a=this.lastX+n,u=this.lastY+s}const A=(0,Py.createCoreData)(this,a,u);if(this.props.onStop(t,A)===!1||this.mounted===!1)return!1;const y=this.findDOMNode();y&&this.props.enableUserSelectHack&&(0,Vf.removeUserSelectStyles)(y.ownerDocument),(0,OA.default)("DraggableCore: handleDragStop: %j",A),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,y&&((0,OA.default)("DraggableCore: Removing handlers"),(0,Vf.removeEvent)(y.ownerDocument,ky.move,this.handleDrag),(0,Vf.removeEvent)(y.ownerDocument,ky.stop,this.handleDragStop))}),Sd(this,"onMouseDown",t=>(ky=bv.mouse,this.handleDragStart(t))),Sd(this,"onMouseUp",t=>(ky=bv.mouse,this.handleDragStop(t))),Sd(this,"onTouchStart",t=>(ky=bv.touch,this.handleDragStart(t))),Sd(this,"onTouchEnd",t=>(ky=bv.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,Vf.addEvent)(t,bv.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:r}=t;(0,Vf.removeEvent)(r,bv.mouse.move,this.handleDrag),(0,Vf.removeEvent)(r,bv.touch.move,this.handleDrag),(0,Vf.removeEvent)(r,bv.mouse.stop,this.handleDragStop),(0,Vf.removeEvent)(r,bv.touch.stop,this.handleDragStop),(0,Vf.removeEvent)(t,bv.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Vf.removeUserSelectStyles)(r)}}findDOMNode(){var t,r;return(t=this.props)!==null&&t!==void 0&&t.nodeRef?(r=this.props)===null||r===void 0||(r=r.nodeRef)===null||r===void 0?void 0:r.current:sTt.default.findDOMNode(this)}render(){return cY.cloneElement(cY.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};C8.default=M8,Sd(M8,"displayName","DraggableCore"),Sd(M8,"propTypes",{allowAnyClick:vh.default.bool,children:vh.default.node.isRequired,disabled:vh.default.bool,enableUserSelectHack:vh.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:vh.default.arrayOf(vh.default.number),handle:vh.default.string,cancel:vh.default.string,nodeRef:vh.default.object,onStart:vh.default.func,onDrag:vh.default.func,onStop:vh.default.func,onMouseDown:vh.default.func,scale:vh.default.number,className:fY.dontSetMe,style:fY.dontSetMe,transform:fY.dontSetMe}),Sd(M8,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return n.default}}),e.default=void 0;var t=w(pt),r=b(ib),a=b(zye),u=b(MSt),A=du,c=Sm,y=Em,n=b(C8),s=b(R8);function b(d){return d&&d.__esModule?d:{default:d}}function i(d){if(typeof WeakMap!="function")return null;var f=new WeakMap,h=new WeakMap;return(i=function(g){return g?h:f})(d)}function w(d,f){if(!f&&d&&d.__esModule)return d;if(d===null||typeof d!="object"&&typeof d!="function")return{default:d};var h=i(f);if(h&&h.has(d))return h.get(d);var g={},v=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var C in d)if(C!=="default"&&Object.prototype.hasOwnProperty.call(d,C)){var S=v?Object.getOwnPropertyDescriptor(d,C):null;S&&(S.get||S.set)?Object.defineProperty(g,C,S):g[C]=d[C]}return g.default=d,h&&h.set(d,g),g}function E(){return E=Object.assign?Object.assign.bind():function(d){for(var f=1;f<arguments.length;f++){var h=arguments[f];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(d[g]=h[g])}return d},E.apply(this,arguments)}function p(d,f,h){return f=_(f),f in d?Object.defineProperty(d,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):d[f]=h,d}function _(d){var f=l(d,"string");return typeof f=="symbol"?f:String(f)}function l(d,f){if(typeof d!="object"||d===null)return d;var h=d[Symbol.toPrimitive];if(h!==void 0){var g=h.call(d,f||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(d)}class o extends t.Component{static getDerivedStateFromProps(f,h){let{position:g}=f,{prevPropsPosition:v}=h;return g&&(!v||g.x!==v.x||g.y!==v.y)?((0,s.default)("Draggable: getDerivedStateFromProps %j",{position:g,prevPropsPosition:v}),{x:g.x,y:g.y,prevPropsPosition:{...g}}):null}constructor(f){super(f),p(this,"onDragStart",(h,g)=>{if((0,s.default)("Draggable: onDragStart: %j",g),this.props.onStart(h,(0,c.createDraggableData)(this,g))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(h,g)=>{if(!this.state.dragging)return!1;(0,s.default)("Draggable: onDrag: %j",g);const v=(0,c.createDraggableData)(this,g),C={x:v.x,y:v.y,slackX:0,slackY:0};if(this.props.bounds){const{x:I,y:T}=C;C.x+=this.state.slackX,C.y+=this.state.slackY;const[x,R]=(0,c.getBoundPosition)(this,C.x,C.y);C.x=x,C.y=R,C.slackX=this.state.slackX+(I-C.x),C.slackY=this.state.slackY+(T-C.y),v.x=C.x,v.y=C.y,v.deltaX=C.x-this.state.x,v.deltaY=C.y-this.state.y}if(this.props.onDrag(h,v)===!1)return!1;this.setState(C)}),p(this,"onDragStop",(h,g)=>{if(!this.state.dragging||this.props.onStop(h,(0,c.createDraggableData)(this,g))===!1)return!1;(0,s.default)("Draggable: onDragStop: %j",g);const C={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:I,y:T}=this.props.position;C.x=I,C.y=T}this.setState(C)}),this.state={dragging:!1,dragged:!1,x:f.position?f.position.x:f.defaultPosition.x,y:f.position?f.position.y:f.defaultPosition.y,prevPropsPosition:{...f.position},slackX:0,slackY:0,isElementSVG:!1},f.position&&!(f.onDrag||f.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var f,h;return(f=(h=this.props)===null||h===void 0||(h=h.nodeRef)===null||h===void 0?void 0:h.current)!==null&&f!==void 0?f:a.default.findDOMNode(this)}render(){const{axis:f,bounds:h,children:g,defaultPosition:v,defaultClassName:C,defaultClassNameDragging:S,defaultClassNameDragged:I,position:T,positionOffset:x,scale:R,...P}=this.props;let L={},F=null;const k=!!!T||this.state.dragging,O=T||v,m={x:(0,c.canDragX)(this)&&k?this.state.x:O.x,y:(0,c.canDragY)(this)&&k?this.state.y:O.y};this.state.isElementSVG?F=(0,A.createSVGTransform)(m,x):L=(0,A.createCSSTransform)(m,x);const D=(0,u.default)(g.props.className||"",C,{[S]:this.state.dragging,[I]:this.state.dragged});return t.createElement(n.default,E({},P,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(g),{className:D,style:{...g.props.style,...L},transform:F}))}}e.default=o,p(o,"displayName","Draggable"),p(o,"propTypes",{...n.default.propTypes,axis:r.default.oneOf(["both","x","y","none"]),bounds:r.default.oneOfType([r.default.shape({left:r.default.number,right:r.default.number,top:r.default.number,bottom:r.default.number}),r.default.string,r.default.oneOf([!1])]),defaultClassName:r.default.string,defaultClassNameDragging:r.default.string,defaultClassNameDragged:r.default.string,defaultPosition:r.default.shape({x:r.default.number,y:r.default.number}),positionOffset:r.default.shape({x:r.default.oneOfType([r.default.number,r.default.string]),y:r.default.oneOfType([r.default.number,r.default.string])}),position:r.default.shape({x:r.default.number,y:r.default.number}),className:y.dontSetMe,style:y.dontSetMe,transform:y.dontSetMe}),p(o,"defaultProps",{...n.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(W2e);const{default:nbe,DraggableCore:fTt}=W2e;w8.exports=nbe,w8.exports.default=nbe,w8.exports.DraggableCore=fTt;var dTt=w8.exports,hY={};hY.__esModule=!0,hY.cloneElement=yTt;var hTt=pTt(pt);function pTt(e){return e&&e.__esModule?e:{default:e}}function abe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function ibe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?abe(Object(r),!0).forEach(function(a){vTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):abe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function vTt(e,t,r){return t=mTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mTt(e){var t=gTt(e,"string");return typeof t=="symbol"?t:String(t)}function gTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yTt(e,t){return t.style&&e.props.style&&(t.style=ibe(ibe({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),hTt.default.cloneElement(e,t)}var NA={};NA.__esModule=!0,NA.resizableProps=void 0;var Oo=bTt(ib);function bTt(e){return e&&e.__esModule?e:{default:e}}var xTt={axis:Oo.default.oneOf(["both","x","y","none"]),className:Oo.default.string,children:Oo.default.element.isRequired,draggableOpts:Oo.default.shape({allowAnyClick:Oo.default.bool,cancel:Oo.default.string,children:Oo.default.node,disabled:Oo.default.bool,enableUserSelectHack:Oo.default.bool,offsetParent:Oo.default.node,grid:Oo.default.arrayOf(Oo.default.number),handle:Oo.default.string,nodeRef:Oo.default.object,onStart:Oo.default.func,onDrag:Oo.default.func,onStop:Oo.default.func,onMouseDown:Oo.default.func,scale:Oo.default.number}),height:function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];var u=r[0];if(u.axis==="both"||u.axis==="y"){var A;return(A=Oo.default.number).isRequired.apply(A,r)}return Oo.default.number.apply(Oo.default,r)},handle:Oo.default.oneOfType([Oo.default.node,Oo.default.func]),handleSize:Oo.default.arrayOf(Oo.default.number),lockAspectRatio:Oo.default.bool,maxConstraints:Oo.default.arrayOf(Oo.default.number),minConstraints:Oo.default.arrayOf(Oo.default.number),onResizeStop:Oo.default.func,onResizeStart:Oo.default.func,onResize:Oo.default.func,resizeHandles:Oo.default.arrayOf(Oo.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:Oo.default.number,width:function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];var u=r[0];if(u.axis==="both"||u.axis==="x"){var A;return(A=Oo.default.number).isRequired.apply(A,r)}return Oo.default.number.apply(Oo.default,r)}};NA.resizableProps=xTt,IA.__esModule=!0,IA.default=void 0;var LA=wTt(pt),_Tt=dTt,ETt=hY,STt=NA,TTt=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function obe(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(obe=function(u){return u?r:t})(e)}function wTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=obe(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function pY(){return pY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},pY.apply(this,arguments)}function ATt(e,t){if(e==null)return{};var r={},a=Object.keys(e),u,A;for(A=0;A<a.length;A++)u=a[A],!(t.indexOf(u)>=0)&&(r[u]=e[u]);return r}function sbe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function vY(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sbe(Object(r),!0).forEach(function(a){CTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sbe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function CTt(e,t,r){return t=RTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function RTt(e){var t=MTt(e,"string");return typeof t=="symbol"?t:String(t)}function MTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ITt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,mY(e,t)}function mY(e,t){return mY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,u){return a.__proto__=u,a},mY(e,t)}var gY=function(e){ITt(t,e);function t(){for(var a,u=arguments.length,A=new Array(u),c=0;c<u;c++)A[c]=arguments[c];return a=e.call.apply(e,[this].concat(A))||this,a.handleRefs={},a.lastHandleRect=null,a.slack=null,a}var r=t.prototype;return r.componentWillUnmount=function(){this.resetData()},r.resetData=function(){this.lastHandleRect=this.slack=null},r.runConstraints=function(u,A){var c=this.props,y=c.minConstraints,n=c.maxConstraints,s=c.lockAspectRatio;if(!y&&!n&&!s)return[u,A];if(s){var b=this.props.width/this.props.height,i=u-this.props.width,w=A-this.props.height;Math.abs(i)>Math.abs(w*b)?A=u/b:u=A*b}var E=u,p=A,_=this.slack||[0,0],l=_[0],o=_[1];return u+=l,A+=o,y&&(u=Math.max(y[0],u),A=Math.max(y[1],A)),n&&(u=Math.min(n[0],u),A=Math.min(n[1],A)),this.slack=[l+(E-u),o+(p-A)],[u,A]},r.resizeHandler=function(u,A){var c=this;return function(y,n){var s=n.node,b=n.deltaX,i=n.deltaY;u==="onResizeStart"&&c.resetData();var w=(c.props.axis==="both"||c.props.axis==="x")&&A!=="n"&&A!=="s",E=(c.props.axis==="both"||c.props.axis==="y")&&A!=="e"&&A!=="w";if(!(!w&&!E)){var p=A[0],_=A[A.length-1],l=s.getBoundingClientRect();if(c.lastHandleRect!=null){if(_==="w"){var o=l.left-c.lastHandleRect.left;b+=o}if(p==="n"){var d=l.top-c.lastHandleRect.top;i+=d}}c.lastHandleRect=l,_==="w"&&(b=-b),p==="n"&&(i=-i);var f=c.props.width+(w?b/c.props.transformScale:0),h=c.props.height+(E?i/c.props.transformScale:0),g=c.runConstraints(f,h);f=g[0],h=g[1];var v=f!==c.props.width||h!==c.props.height,C=typeof c.props[u]=="function"?c.props[u]:null,S=u==="onResize"&&!v;C&&!S&&(y.persist==null||y.persist(),C(y,{node:s,size:{width:f,height:h},handle:A})),u==="onResizeStop"&&c.resetData()}}},r.renderResizeHandle=function(u,A){var c=this.props.handle;if(!c)return LA.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+u,ref:A});if(typeof c=="function")return c(u,A);var y=typeof c.type=="string",n=vY({ref:A},y?{}:{handleAxis:u});return LA.cloneElement(c,n)},r.render=function(){var u=this,A=this.props,c=A.children,y=A.className,n=A.draggableOpts;A.width,A.height,A.handle,A.handleSize,A.lockAspectRatio,A.axis,A.minConstraints,A.maxConstraints,A.onResize,A.onResizeStop,A.onResizeStart;var s=A.resizeHandles;A.transformScale;var b=ATt(A,TTt);return(0,ETt.cloneElement)(c,vY(vY({},b),{},{className:(y?y+" ":"")+"react-resizable",children:[].concat(c.props.children,s.map(function(i){var w,E=(w=u.handleRefs[i])!=null?w:u.handleRefs[i]=LA.createRef();return LA.createElement(_Tt.DraggableCore,pY({},n,{nodeRef:E,key:"resizableHandle-"+i,onStop:u.resizeHandler("onResizeStop",i),onStart:u.resizeHandler("onResizeStart",i),onDrag:u.resizeHandler("onResize",i)}),u.renderResizeHandle(i,E))}))}))},t}(LA.Component);IA.default=gY,gY.propTypes=STt.resizableProps,gY.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var I8={};I8.__esModule=!0,I8.default=void 0;var yY=PTt(pt),OTt=lbe(ib),NTt=lbe(IA),LTt=NA,DTt=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function lbe(e){return e&&e.__esModule?e:{default:e}}function ube(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,r=new WeakMap;return(ube=function(u){return u?r:t})(e)}function PTt(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var r=ube(t);if(r&&r.has(e))return r.get(e);var a={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in e)if(A!=="default"&&Object.prototype.hasOwnProperty.call(e,A)){var c=u?Object.getOwnPropertyDescriptor(e,A):null;c&&(c.get||c.set)?Object.defineProperty(a,A,c):a[A]=e[A]}return a.default=e,r&&r.set(e,a),a}function bY(){return bY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},bY.apply(this,arguments)}function cbe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,a)}return r}function O8(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?cbe(Object(r),!0).forEach(function(a){kTt(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cbe(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function kTt(e,t,r){return t=FTt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function FTt(e){var t=BTt(e,"string");return typeof t=="symbol"?t:String(t)}function BTt(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zTt(e,t){if(e==null)return{};var r={},a=Object.keys(e),u,A;for(A=0;A<a.length;A++)u=a[A],!(t.indexOf(u)>=0)&&(r[u]=e[u]);return r}function UTt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,xY(e,t)}function xY(e,t){return xY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,u){return a.__proto__=u,a},xY(e,t)}var fbe=function(e){UTt(t,e);function t(){for(var a,u=arguments.length,A=new Array(u),c=0;c<u;c++)A[c]=arguments[c];return a=e.call.apply(e,[this].concat(A))||this,a.state={width:a.props.width,height:a.props.height,propsWidth:a.props.width,propsHeight:a.props.height},a.onResize=function(y,n){var s=n.size;a.props.onResize?(y.persist==null||y.persist(),a.setState(s,function(){return a.props.onResize&&a.props.onResize(y,n)})):a.setState(s)},a}t.getDerivedStateFromProps=function(u,A){return A.propsWidth!==u.width||A.propsHeight!==u.height?{width:u.width,height:u.height,propsWidth:u.width,propsHeight:u.height}:null};var r=t.prototype;return r.render=function(){var u=this.props,A=u.handle,c=u.handleSize;u.onResize;var y=u.onResizeStart,n=u.onResizeStop,s=u.draggableOpts,b=u.minConstraints,i=u.maxConstraints,w=u.lockAspectRatio,E=u.axis;u.width,u.height;var p=u.resizeHandles,_=u.style,l=u.transformScale,o=zTt(u,DTt);return yY.createElement(NTt.default,{axis:E,draggableOpts:s,handle:A,handleSize:c,height:this.state.height,lockAspectRatio:w,maxConstraints:i,minConstraints:b,onResizeStart:y,onResize:this.onResize,onResizeStop:n,resizeHandles:p,transformScale:l,width:this.state.width},yY.createElement("div",bY({},o,{style:O8(O8({},_),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(yY.Component);I8.default=fbe,fbe.propTypes=O8(O8({},LTt.resizableProps),{},{children:OTt.default.element}),oY.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};var HTt=oY.exports.Resizable=IA.default;oY.exports.ResizableBox=I8.default;const D7t="",_Y=400,$Tt=pt.forwardRef(function({...t},r){return delete t.handleAxis,He.jsx(Ka,{sx:{boxSizing:"content-box",width:"4px",height:"24px",position:"absolute",top:"50%",marginTop:"-12px",left:0,cursor:"ew-resize",padding:"10px 5px"},ref:r,...t,children:He.jsx(Ka,{sx:{boxSizing:"content-box",width:"100%",height:"100%",backgroundColor:"grey.300",borderRadius:"4px"}})})}),GTt=()=>{const[e,t]=pt.useState(!1),[r,a]=pt.useState(_Y),[u,A]=Cu(o_),c=(s,b)=>a(b.size.width),{width:y}=Tgt(),n=v3(s=>s.breakpoints.down("sm"));return r<_Y&&n&&a(_Y),He.jsx(HTt,{width:r,height:0,onResize:c,onResizeStart:()=>t(!0),onResizeStop:()=>t(!1),resizeHandles:["w"],handle:n?He.jsx(He.Fragment,{}):He.jsx($Tt,{}),axis:"x",minConstraints:[100,0],maxConstraints:[y/2,0],children:He.jsxs(VTt,{anchor:"right",isSmallScreen:n,open:!!u,variant:n?"temporary":"persistent",width:r,children:[He.jsxs(ki,{direction:"row",alignItems:"center",children:[He.jsx(Wo,{noWrap:!0,fontSize:"20px",fontWeight:500,id:"side-view-title",children:u==null?void 0:u.name}),He.jsx(Ss,{edge:"end",sx:{ml:"auto"},onClick:()=>A(void 0),children:He.jsx(X1,{})})]}),He.jsx(Ka,{mt:"1.5rem",id:"side-view-content",sx:{height:"100%",pointerEvents:e?"none":"auto"},children:He.jsx(S$,{element:u})})]})})},VTt=wa($re,{shouldForwardProp:e=>e!=="isSmallScreen"})(({theme:e,open:t,width:r,isSmallScreen:a})=>({width:r,flexShrink:0,display:t?"flex":"none","& .MuiDrawer-paper":{position:"inherit",width:r,maxWidth:a?"80%":"100%",backgroundColor:e.palette.background.paper,borderLeft:`1px solid ${e.palette.divider}`,flexDirection:"column",borderRadius:0,color:e.palette.text.primary,whiteSpace:"nowrap",boxSizing:"border-box",padding:"1.5rem",paddingTop:".5rem",overflowX:"hidden"}}));var EY={},YTt=ll;Object.defineProperty(EY,"__esModule",{value:!0});var dbe=EY.default=void 0,WTt=YTt(ul()),jTt=He,KTt=(0,WTt.default)((0,jTt.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");dbe=EY.default=KTt;const XTt=({element:e,onGoBack:t})=>{const r=Pg();return He.jsxs(Ka,{display:"flex",flexDirection:"column",flexGrow:1,p:3,gap:2,boxSizing:"border-box",mx:"auto",sx:{width:"100%",maxWidth:r,color:"text.primary"},id:"element-view",children:[He.jsxs(ki,{direction:"row",gap:1,children:[t?He.jsx(Ss,{edge:"start",onClick:t,children:He.jsx(dbe,{})}):null,He.jsx(Wo,{fontWeight:700,fontSize:"25px",children:e.name})]}),He.jsx(S$,{element:e})]})},ZTt=e=>He.jsx(uu,{children:He.jsxs("svg",{...e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[He.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),He.jsx("circle",{cx:"12",cy:"7",r:"4"})]})});function QTt(e){var a,u;const{user:t}=Vp(),r=(t==null?void 0:t.display_name)||(t==null?void 0:t.identifier);return He.jsx(Ss,{...e,children:He.jsx(UP,{sx:{width:32,height:32,bgcolor:"primary.main",color:"primary.contrastText"},src:((a=t==null?void 0:t.metadata)==null?void 0:a.image)||void 0,children:t?(u=r==null?void 0:r[0])==null?void 0:u.toUpperCase():He.jsx(ZTt,{sx:{height:20,width:20}})})})}var SY={},JTt=ll;Object.defineProperty(SY,"__esModule",{value:!0});var hbe=SY.default=void 0,qTt=JTt(ul()),e3t=He,t3t=(0,qTt.default)((0,e3t.jsx)("path",{d:"M9.37 5.51c-.18.64-.27 1.31-.27 1.99 0 4.08 3.32 7.4 7.4 7.4.68 0 1.35-.09 1.99-.27C17.45 17.19 14.93 19 12 19c-3.86 0-7-3.14-7-7 0-2.93 1.81-5.45 4.37-6.49zM12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z"}),"DarkModeOutlined");hbe=SY.default=t3t;var TY={},r3t=ll;Object.defineProperty(TY,"__esModule",{value:!0});var pbe=TY.default=void 0,n3t=r3t(ul()),a3t=He,i3t=(0,n3t.default)((0,a3t.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");pbe=TY.default=i3t;var wY={},o3t=ll;Object.defineProperty(wY,"__esModule",{value:!0});var vbe=wY.default=void 0,s3t=o3t(ul()),l3t=He,u3t=(0,s3t.default)((0,l3t.jsx)("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"}),"Logout");vbe=wY.default=u3t;function c3t({anchorEl:e,open:t,handleClose:r}){var _;const{user:a,logout:u}=Vp(),[A,c]=Cu(Lb),{config:y}=Dl(),n=!!((_=y==null?void 0:y.userEnv)!=null&&_.length),s=a&&He.jsxs(XP,{sx:{display:"flex",flexDirection:"column"},children:[He.jsx(Wo,{width:"100%",fontSize:"14px",fontWeight:700,children:a.id}),He.jsx(Wo,{width:"100%",fontSize:"13px",fontWeight:400,children:a.display_name||a.identifier})]},"user-name"),b=He.jsxs(XP,{sx:{display:"flex",gap:1},children:[He.jsx(ZP,{children:He.jsx(hbe,{})}),He.jsx(uFe,{id:"switch-theme",secondary:He.jsx(ji,{path:"components.molecules.settingsModal.darkMode"})}),He.jsx(Ka,{children:He.jsx(Goe,{id:"switch-theme",onChange:()=>{const l=A.theme==="light"?"dark":"light";localStorage.setItem("themeVariant",l),c(o=>({...o,theme:l}))},checked:A.theme==="dark",inputProps:{"aria-labelledby":"switch-theme"}})})]},"theme"),E=[s,b,n&&He.jsxs(x6,{component:aY,to:"/env",children:[He.jsx(ZP,{children:He.jsx(pbe,{fontSize:"small"})}),He.jsx(ji,{path:"components.atoms.buttons.userButton.menu.APIKeys"})]},"env"),a&&He.jsxs(x6,{onClick:()=>{u(!0),r()},children:[He.jsx(ZP,{children:He.jsx(vbe,{fontSize:"small"})}),He.jsx(ji,{path:"components.atoms.buttons.userButton.menu.logout"})]},"logout")].filter(l=>!!l),p=E.reduce((l,o,d)=>d===E.length-1?[...l,o]:[...l,o,He.jsx(Bre,{sx:{my:1}},`divider-${d}`)],[]);return He.jsx(g3,{anchorEl:e,id:"account-menu",open:t,onClose:r,PaperProps:{sx:{width:220,overflow:"visible",mt:1.5,backgroundImage:"none",border:l=>`1px solid ${l.palette.divider}`,boxShadow:l=>l.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D","& .MuiAvatar-root":{width:32,height:32,ml:-.5,mr:1},"&:before":{content:'""',display:"block",position:"absolute",top:0,right:14,width:10,height:10,bgcolor:"background.default",transform:"translateY(-50%) rotate(45deg)",zIndex:0}}},transformOrigin:{horizontal:"center",vertical:"top"},anchorOrigin:{horizontal:"center",vertical:"bottom"},children:p})}function f3t(){const[e,t]=pt.useState(null),r=!!e,a=A=>{t(A.currentTarget)},u=()=>{t(null)};return He.jsxs(He.Fragment,{children:[He.jsx(QTt,{onClick:a,"aria-controls":r?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0}),He.jsx(c3t,{open:r,anchorEl:e,handleClose:u})]})}function d3t(){var g,v;const e=pt.useContext(Ac),{config:t}=Dl(),{chatProfile:r,setChatProfile:a}=ig(),{firstInteraction:u}=Kh(),[A,c]=pt.useState(null),[y,n]=pt.useState(""),{clear:s}=Xu(),[b,i]=pt.useState(null),[w,E]=pt.useState(!1),p=up(),_=()=>{E(!1),i(null),p("/")},l=C=>{const S=C||b;if(!S)throw new Error("Retry clicking on a profile before starting a new chat");a(S),i(null),s(),_()};if(!r&&jV(t==null?void 0:t.chatProfiles)>0&&a(t==null?void 0:t.chatProfiles[0].name),typeof t>"u"||t.chatProfiles.length<=1)return null;const o=(g=t==null?void 0:t.features)==null?void 0:g.unsafe_allow_html,d=(v=t==null?void 0:t.features)==null?void 0:v.latex,f=!!A,h=t.chatProfiles.map(C=>{var I;const S=(I=C.icon)!=null&&I.includes("/public")?e.buildEndpoint(C.icon):C.icon;return{label:C.name,value:C.name,icon:S?He.jsx("img",{src:S,className:"chat-profile-icon",style:{width:"24px",height:"24px",borderRadius:"50%",objectFit:"cover"}}):void 0}});return He.jsxs(He.Fragment,{children:[He.jsx(Tne,{id:"chat-profile-description",anchorEl:A,open:f,PaperProps:{sx:{boxShadow:C=>C.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D",ml:2}},sx:{pointerEvents:"none",marginTop:1.5},anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},disableRestoreFocus:!0,children:He.jsx(Ka,{p:2,sx:{fontFamily:C=>C.typography.fontFamily},maxWidth:"20rem",children:He.jsx(Ew,{allowHtml:o,latex:d,children:y})})}),He.jsx(gk,{value:r||"",items:h,id:"chat-profile-selector",onItemMouseEnter:(C,S)=>{const I=t.chatProfiles.find(T=>T.name===S);I&&(n(I.markdown_description),c(C.currentTarget))},onItemMouseLeave:()=>c(null),onChange:C=>{const S=C.target.value;i(S),u?E(!0):l(S)},onClose:()=>c(null)}),He.jsx(x8,{open:w,handleClose:_,handleConfirm:()=>l()})]})}function h3t(e){const[t,r]=pt.useState(!1),a=up(),{clear:u}=Xu(),A=()=>{r(!0)},c=()=>{r(!1)},y=()=>{u(),a("/"),c()};return He.jsxs(Ka,{children:[He.jsx(cc,{title:He.jsx(ji,{path:"components.molecules.newChatButton.newChat"}),children:He.jsx(Ss,{id:"new-chat-button",onClick:A,...e,children:He.jsx(v2e,{sx:{height:20,width:20}})})}),He.jsx(x8,{open:t,handleClose:c,handleConfirm:y})]})}var AY={},p3t=ll;Object.defineProperty(AY,"__esModule",{value:!0});var mbe=AY.default=void 0,v3t=p3t(ul()),m3t=He,g3t=(0,v3t.default)((0,m3t.jsx)("path",{d:"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"}),"Sort");mbe=AY.default=g3t;const y3t=()=>{const e=Ho(Lb);return He.jsx(Ka,{children:He.jsx(Ss,{onClick:()=>e(t=>({...t,isChatHistoryOpen:!0})),children:He.jsx(mbe,{})})})},gbe=pt.memo(()=>{const e=v3("(max-width: 66rem)"),{isChatHistoryOpen:t}=ns(Lb);return He.jsxs(Ka,{px:1,py:1,display:"flex",height:"45px",alignItems:"center",flexDirection:"row",justifyContent:"space-between",color:"text.primary",gap:2,id:"header",position:"relative",children:[He.jsx(Ka,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:He.jsx(d3t,{})}),e?He.jsx(y3t,{}):t?null:He.jsx(b8,{style:{maxHeight:"25px",marginLeft:"8px"}}),He.jsx(Ka,{}),He.jsxs(ki,{direction:"row",alignItems:"center",children:[He.jsx(h3t,{}),He.jsx(f3t,{})]})]})}),b3t=e=>He.jsx(uu,{...e,viewBox:"0 0 98 96",children:He.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"})});function x3t({...e}){const{config:t}=Dl(),r=t==null?void 0:t.ui.github;return r?He.jsx(rh,{href:r,target:"_blank",color:"inherit",sx:{justifyContent:"start",textTransform:"none"},startIcon:He.jsx(b3t,{sx:{height:20,width:20}}),...e,children:"Repo"}):null}var CY={},_3t=ll;Object.defineProperty(CY,"__esModule",{value:!0});var ybe=CY.default=void 0,E3t=_3t(ul()),S3t=He,T3t=(0,E3t.default)((0,S3t.jsx)("path",{d:"M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"}),"HelpOutline");ybe=CY.default=T3t;const w3t=pt.memo(({markdown:e,allowHtml:t,latex:r})=>{const a=Pg();return e?He.jsx(Ka,{overflow:"auto",flexGrow:1,children:He.jsx(Ka,{id:"welcome-screen",sx:{boxSizing:"border-box",maxWidth:a,width:"100%",mx:"auto",color:"text.primary",fontFamily:"-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji",display:"flex",flexDirection:"column"},children:He.jsx(Ew,{allowHtml:t,latex:r,children:e})})}):He.jsx(Ka,{flexGrow:1})});function A3t(){var u,A;const{config:e}=Dl(),[t,r]=pt.useState(!1);if(!(e!=null&&e.markdown))return null;const a=()=>{r(!1)};return He.jsxs(He.Fragment,{children:[He.jsx(rh,{id:"readme-button",onClick:()=>r(!0),color:"inherit",sx:{textTransform:"none",justifyContent:"start"},startIcon:He.jsx(ybe,{}),children:He.jsx(ji,{path:"components.organisms.header.readme"})}),He.jsxs(u3,{open:t,maxWidth:"lg",onClose:a,scroll:"paper","aria-labelledby":"instructions","aria-describedby":"how-to-use-this-app",PaperProps:{sx:{backgroundImage:"none"}},children:[He.jsx(f3,{id:"instructions-dialog",children:He.jsx(ji,{path:"components.organisms.header.readme"})}),He.jsx(c3,{dividers:!0,children:He.jsx(w3t,{markdown:e==null?void 0:e.markdown,allowHtml:(u=e==null?void 0:e.features)==null?void 0:u.unsafe_allow_html,latex:(A=e==null?void 0:e.features)==null?void 0:A.latex})})]})]})}const bbe={height:"0.75rem",width:"0.25rem",backgroundColor:"text.primary",borderRadius:"20px",transition:"transform 0.3s ease"},C3t=({onClick:e,open:t})=>{const{t:r}=nv();return He.jsx(cc,{title:r(t?"components.organisms.threadHistory.sidebar.TriggerButton.closeSidebar":"components.organisms.threadHistory.sidebar.TriggerButton.openSidebar"),placement:"right",children:He.jsxs(Ka,{id:"open-sidebar-button",sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:2,"&:hover div:nth-child(1)":{transform:t?"rotate(15deg)":"rotate(-15deg)"},"&:hover div:nth-child(2)":{transform:t?"rotate(-15deg)":"rotate(15deg)"}},onClick:e,children:[He.jsx(Ka,{sx:{...bbe,marginTop:"0.25rem"}}),He.jsx(Ka,{sx:{...bbe,marginTop:"-0.25rem"}})]})})};var R3t=ek;function M3t(e,t){return R3t(e,t)}var I3t=M3t;const O3t=_s(I3t);function N3t(e,t,r,a){for(var u=e.length,A=r+(a?1:-1);a?A--:++A<u;)if(t(e[A],A,e))return A;return-1}var L3t=N3t;function D3t(e){return e!==e}var P3t=D3t;function k3t(e,t,r){for(var a=r-1,u=e.length;++a<u;)if(e[a]===t)return a;return-1}var F3t=k3t,B3t=L3t,z3t=P3t,U3t=F3t;function H3t(e,t,r){return t===t?U3t(e,t,r):B3t(e,z3t,r)}var $3t=H3t,G3t=$3t;function V3t(e,t){var r=e==null?0:e.length;return!!r&&G3t(e,t,0)>-1}var Y3t=V3t;function W3t(e,t,r){for(var a=-1,u=e==null?0:e.length;++a<u;)if(r(t,e[a]))return!0;return!1}var j3t=W3t;function K3t(){}var X3t=K3t,RY=Hie,Z3t=X3t,Q3t=Y9,J3t=1/0,q3t=RY&&1/Q3t(new RY([,-0]))[1]==J3t?function(e){return new RY(e)}:Z3t,ewt=q3t,twt=Rie,rwt=Y3t,nwt=j3t,awt=Mie,iwt=ewt,owt=Y9,swt=200;function lwt(e,t,r){var a=-1,u=rwt,A=e.length,c=!0,y=[],n=y;if(r)c=!1,u=nwt;else if(A>=swt){var s=t?null:iwt(e);if(s)return owt(s);c=!1,u=awt,n=new twt}else n=t?[]:y;e:for(;++a<A;){var b=e[a],i=t?t(b):b;if(b=r||b!==0?b:0,c&&i===i){for(var w=n.length;w--;)if(n[w]===i)continue e;t&&n.push(i),y.push(b)}else u(n,i,r)||(n!==y&&n.push(i),y.push(b))}return y}var uwt=lwt,cwt=ak,fwt=uwt;function dwt(e,t){return e&&e.length?fwt(e,cwt(t)):[]}var hwt=dwt;const pwt=_s(hwt),MY=zs({key:"ThreadsFilters",default:{}});function vwt(e,t,r){var a=-1,u=e.length;t<0&&(t=-t>u?0:u+t),r=r>u?u:r,r<0&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var A=Array(u);++a<u;)A[a]=e[a+t];return A}var mwt=vwt,gwt=mwt;function ywt(e,t,r){var a=e.length;return r=r===void 0?a:r,!t&&r>=a?e:gwt(e,t,r)}var bwt=ywt;function xwt(e){return e.split("")}var _wt=xwt,xbe="\\ud800-\\udfff",Ewt="\\u0300-\\u036f",Swt="\\ufe20-\\ufe2f",Twt="\\u20d0-\\u20ff",wwt=Ewt+Swt+Twt,Awt="\\ufe0e\\ufe0f",Cwt="["+xbe+"]",IY="["+wwt+"]",OY="\\ud83c[\\udffb-\\udfff]",Rwt="(?:"+IY+"|"+OY+")",_be="[^"+xbe+"]",Ebe="(?:\\ud83c[\\udde6-\\uddff]){2}",Sbe="[\\ud800-\\udbff][\\udc00-\\udfff]",Mwt="\\u200d",Tbe=Rwt+"?",wbe="["+Awt+"]?",Iwt="(?:"+Mwt+"(?:"+[_be,Ebe,Sbe].join("|")+")"+wbe+Tbe+")*",Owt=wbe+Tbe+Iwt,Nwt="(?:"+[_be+IY+"?",IY,Ebe,Sbe,Cwt].join("|")+")",Lwt=RegExp(OY+"(?="+OY+")|"+Nwt+Owt,"g");function Dwt(e){return e.match(Lwt)||[]}var Pwt=Dwt,kwt=_wt,Fwt=VV,Bwt=Pwt;function zwt(e){return Fwt(e)?Bwt(e):kwt(e)}var Uwt=zwt,Hwt=bwt,$wt=VV,Gwt=Uwt,Vwt=nk;function Ywt(e){return function(t){t=Vwt(t);var r=$wt(t)?Gwt(t):void 0,a=r?r[0]:t.charAt(0),u=r?Hwt(r,1).join(""):t.slice(1);return a[e]()+u}}var Wwt=Ywt,jwt=Wwt,Kwt=jwt("toUpperCase"),Xwt=Kwt,Zwt=nk,Qwt=Xwt;function Jwt(e){return Qwt(Zwt(e).toLowerCase())}var qwt=Jwt;const eAt=_s(qwt);var tAt=I3;function rAt(e,t){return function(r,a){if(r==null)return r;if(!tAt(r))return e(r,a);for(var u=r.length,A=t?u:-1,c=Object(r);(t?A--:++A<u)&&a(c[A],A,c)!==!1;);return r}}var nAt=rAt,aAt=wie,iAt=nAt,oAt=iAt(aAt),sAt=oAt,lAt=sAt,uAt=I3;function cAt(e,t){var r=-1,a=uAt(e)?Array(e.length):[];return lAt(e,function(u,A,c){a[++r]=t(u,A,c)}),a}var fAt=cAt,dAt=ioe,hAt=ak,pAt=fAt,vAt=ov;function mAt(e,t){var r=vAt(e)?dAt:pAt;return r(e,hAt(t))}var gAt=mAt;const Abe=_s(gAt);var NY={},yAt=ll;Object.defineProperty(NY,"__esModule",{value:!0});var Cbe=NY.default=void 0,bAt=yAt(ul()),xAt=He,_At=(0,bAt.default)((0,xAt.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"}),"ChatBubbleOutline");Cbe=NY.default=_At;var LY={},EAt=ll;Object.defineProperty(LY,"__esModule",{value:!0});var Rbe=LY.default=void 0,SAt=EAt(ul()),TAt=He,wAt=(0,SAt.default)((0,TAt.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM8 9h8v10H8V9zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutline");Rbe=LY.default=wAt;function AAt(e){return Bi("MuiLoadingButton",e)}const kg=Hi("MuiLoadingButton",["root","loading","loadingIndicator","loadingIndicatorCenter","loadingIndicatorStart","loadingIndicatorEnd","endIconLoadingEnd","startIconLoadingStart"]),CAt=["children","disabled","id","loading","loadingIndicator","loadingPosition","variant"],RAt=e=>{const{loading:t,loadingPosition:r,classes:a}=e,u={root:["root",t&&"loading"],startIcon:[t&&`startIconLoading${Ea(r)}`],endIcon:[t&&`endIconLoading${Ea(r)}`],loadingIndicator:["loadingIndicator",t&&`loadingIndicator${Ea(r)}`]},A=Ui(u,AAt,a);return ir({},a,A)},MAt=e=>e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"&&e!=="classes",IAt=wa(rh,{shouldForwardProp:e=>MAt(e)||e==="classes",name:"MuiLoadingButton",slot:"Root",overridesResolver:(e,t)=>[t.root,t.startIconLoadingStart&&{[`& .${kg.startIconLoadingStart}`]:t.startIconLoadingStart},t.endIconLoadingEnd&&{[`& .${kg.endIconLoadingEnd}`]:t.endIconLoadingEnd}]})(({ownerState:e,theme:t})=>ir({[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0}},e.loadingPosition==="center"&&{transition:t.transitions.create(["background-color","box-shadow","border-color"],{duration:t.transitions.duration.short}),[`&.${kg.loading}`]:{color:"transparent"}},e.loadingPosition==="start"&&e.fullWidth&&{[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginRight:-8}},e.loadingPosition==="end"&&e.fullWidth&&{[`& .${kg.startIconLoadingStart}, & .${kg.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginLeft:-8}})),OAt=wa("div",{name:"MuiLoadingButton",slot:"LoadingIndicator",overridesResolver:(e,t)=>{const{ownerState:r}=e;return[t.loadingIndicator,t[`loadingIndicator${Ea(r.loadingPosition)}`]]}})(({theme:e,ownerState:t})=>ir({position:"absolute",visibility:"visible",display:"flex"},t.loadingPosition==="start"&&(t.variant==="outlined"||t.variant==="contained")&&{left:t.size==="small"?10:14},t.loadingPosition==="start"&&t.variant==="text"&&{left:6},t.loadingPosition==="center"&&{left:"50%",transform:"translate(-50%)",color:(e.vars||e).palette.action.disabled},t.loadingPosition==="end"&&(t.variant==="outlined"||t.variant==="contained")&&{right:t.size==="small"?10:14},t.loadingPosition==="end"&&t.variant==="text"&&{right:6},t.loadingPosition==="start"&&t.fullWidth&&{position:"relative",left:-10},t.loadingPosition==="end"&&t.fullWidth&&{position:"relative",right:-10})),NAt=pt.forwardRef(function(t,r){const a=Vi({props:t,name:"MuiLoadingButton"}),{children:u,disabled:A=!1,id:c,loading:y=!1,loadingIndicator:n,loadingPosition:s="center",variant:b="text"}=a,i=ti(a,CAt),w=YT(c),E=n??He.jsx(l3,{"aria-labelledby":w,color:"inherit",size:16}),p=ir({},a,{disabled:A,loading:y,loadingIndicator:E,loadingPosition:s,variant:b}),_=RAt(p),l=y?He.jsx(OAt,{className:_.loadingIndicator,ownerState:p,children:E}):null;return He.jsxs(IAt,ir({disabled:A||y,id:w,ref:r},i,{variant:b,classes:_,ownerState:p,children:[p.loadingPosition==="end"?u:l,p.loadingPosition==="end"?l:u]}))}),LAt=({threadId:e,onDelete:t})=>{const[r,a]=pt.useState(!1),u=ns(N2),A=pt.useContext(Ac),c=()=>{a(!0)},y=()=>{a(!1)},n=async()=>{Gf.promise(A.deleteThread(e,u),{loading:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.deletingChat"}),success:()=>(t(),He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.chatDeleted"})),error:s=>s instanceof eP?He.jsx("span",{children:s.message}):He.jsx("span",{})}),y()};return He.jsxs("div",{children:[He.jsx(Ss,{size:"small",onClick:c,sx:{p:"2px"},children:He.jsx(Rbe,{sx:{width:16,height:16}})}),r&&He.jsxs(u3,{open:r,onClose:y,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",PaperProps:{sx:{backgroundImage:"none"}},children:[He.jsx(f3,{id:"alert-dialog-title",children:"Delete Thread?"}),He.jsx(c3,{children:He.jsx(Pre,{id:"alert-dialog-description",children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.confirmMessage"})})}),He.jsxs(m6,{sx:{color:"text.secondary",p:2},children:[He.jsx(rh,{variant:"outlined",color:"inherit",onClick:y,children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.cancel"})}),He.jsx(NAt,{variant:"outlined",color:"primary",onClick:n,autoFocus:!0,children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.DeleteThreadButton.confirm"})})]})]})]})},DAt=({threadHistory:e,error:t,fetchThreads:r,isFetching:a,isLoadingMore:u})=>{const{idToResume:A}=ig(),{clear:c}=Xu(),{threadId:y}=Kh(),n=up();if(a||!(e!=null&&e.timeGroupedThreads)&&u)return He.jsx(He.Fragment,{children:[1,2,3].map(b=>He.jsxs(Ka,{sx:{mt:2},children:[He.jsx(G1,{width:100}),[1,2].map(i=>He.jsxs(ki,{sx:{py:2,flexDirection:"row",alignItems:"center",gap:1.5},children:[He.jsx(G1,{width:30}),He.jsx(G1,{width:"100%"})]},`threads-skeleton-${b}-${i}`))]},`threads-skeleton-${b}`))});if(t)return He.jsx(ev,{severity:"error",children:t.message});if(!e)return null;if(jV(e==null?void 0:e.timeGroupedThreads)===0)return He.jsx(ev,{variant:"standard",severity:"info",children:He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.empty"})});const s=b=>{(b===A||b===y)&&c(),b===e.currentThreadId&&n("/"),r()};return He.jsxs(y6,{sx:{height:0,bgcolor:"background.paper","& ul":{padding:0}},subheader:He.jsx("li",{}),children:[Abe(e.timeGroupedThreads,(b,i)=>He.jsx("li",{children:He.jsxs("ul",{children:[He.jsx(v7e,{sx:{px:0},children:He.jsx(Wo,{sx:{py:1,color:"text.secondary",fontWeight:600,fontSize:"12px",backgroundColor:w=>w.palette.background.paper},children:(()=>i==="Today"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.today"}):i==="Yesterday"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.yesterday"}):i==="Previous 7 days"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.previous7days"}):i==="Previous 30 days"?He.jsx(ji,{path:"components.organisms.threadHistory.sidebar.ThreadList.previous30days"}):He.jsx(He.Fragment,{children:i}))()})}),Abe(b,w=>{const E=A===w.id&&!e.currentThreadId,p=E||e.currentThreadId===w.id;return He.jsx(ki,{component:aY,id:`thread-${w.id}`,sx:_=>({textDecoration:"none",cursor:"pointer",p:1.5,mb:.5,gap:.5,flexDirection:"row",justifyContent:"space-between",borderRadius:1,backgroundColor:p?_.palette.mode==="dark"?Xi[800]:"grey.200":_.palette.background.paper,"&:hover":{backgroundColor:_.palette.mode==="dark"?Xi[800]:"grey.200"}}),to:E?"":`/thread/${w.id}`,children:He.jsxs(ki,{direction:"row",width:"100%",justifyContent:"space-between",children:[He.jsxs(ki,{sx:{alignItems:"center",flexDirection:"row",gap:1.5,overflow:"hidden",color:_=>_.palette.text.primary},children:[He.jsx(Cbe,{sx:{width:"14px",height:"14px"}}),He.jsx(Wo,{sx:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:eAt(w.name||"Unknown")})]}),p?He.jsx(LAt,{threadId:w.id,onDelete:()=>s(w.id)}):null]})},`thread-${w.id}`)})]})},`section-${i}`)),He.jsx(ki,{alignItems:"center",children:He.jsx(l3,{id:"chat-history-loader",size:30,sx:{my:1,opacity:u?1:0}})})]})};var DY={},PAt=ll;Object.defineProperty(DY,"__esModule",{value:!0});var Mbe=DY.default=void 0,kAt=PAt(ul()),FAt=He,BAt=(0,kAt.default)((0,FAt.jsx)("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}),"FilterList");Mbe=DY.default=BAt;var PY={},zAt=ll;Object.defineProperty(PY,"__esModule",{value:!0});var Ibe=PY.default=void 0,UAt=zAt(ul()),HAt=He,$At=(0,UAt.default)((0,HAt.jsx)("path",{d:"M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z"}),"ThumbDown");Ibe=PY.default=$At;var kY={},GAt=ll;Object.defineProperty(kY,"__esModule",{value:!0});var Obe=kY.default=void 0,VAt=GAt(ul()),YAt=He,WAt=(0,VAt.default)((0,YAt.jsx)("path",{d:"M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"}),"ThumbUp");Obe=kY.default=WAt;function jAt(){const[e,t]=Cu(MY),[r,a]=pt.useState(null),{t:u}=nv(),A=n=>{t(s=>({...s,feedback:n})),a(null)},c=(n,s)=>He.jsx(Ka,{onClick:()=>A(s),sx:{cursor:"pointer",px:1.5,py:1,borderRadius:1,"&:hover":{background:b=>b.palette.background.default}},children:n}),y=()=>{const n={width:20,height:20,color:"text.secondary"};switch(e.feedback){case 1:return He.jsx(Obe,{sx:n});case 0:return He.jsx(Ibe,{sx:n});default:return He.jsx(Mbe,{sx:n})}};return He.jsxs(He.Fragment,{children:[He.jsx(Ss,{disableRipple:!0,onClick:n=>a(n.currentTarget),edge:"end",children:y()}),He.jsx(g3,{id:"feedback-filter-select",autoFocus:!0,anchorEl:r,open:!!r,onClose:()=>a(null),sx:{mt:1},MenuListProps:{sx:{p:.5}},slotProps:{paper:{sx:{background:n=>n.palette.background.paper,border:n=>`1px solid ${n.palette.divider}`,boxShadow:n=>n.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D"}}},children:He.jsxs(ki,{children:[c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackAll"),void 0),c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackPositive"),1),c(u("components.organisms.threadHistory.sidebar.filters.FeedbackSelect.feedbackNegative"),0)]})})]})}var KAt=iv,XAt=function(){return KAt.Date.now()},ZAt=XAt,QAt=/\s/;function JAt(e){for(var t=e.length;t--&&QAt.test(e.charAt(t)););return t}var qAt=JAt,eCt=qAt,tCt=/^\s+/;function rCt(e){return e&&e.slice(0,eCt(e)+1).replace(tCt,"")}var nCt=rCt,aCt=nCt,Nbe=j1,iCt=V6,Lbe=0/0,oCt=/^[-+]0x[0-9a-f]+$/i,sCt=/^0b[01]+$/i,lCt=/^0o[0-7]+$/i,uCt=parseInt;function cCt(e){if(typeof e=="number")return e;if(iCt(e))return Lbe;if(Nbe(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Nbe(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=aCt(e);var r=sCt.test(e);return r||lCt.test(e)?uCt(e.slice(2),r?2:8):oCt.test(e)?Lbe:+e}var fCt=cCt,dCt=j1,FY=ZAt,Dbe=fCt,hCt="Expected a function",pCt=Math.max,vCt=Math.min;function mCt(e,t,r){var a,u,A,c,y,n,s=0,b=!1,i=!1,w=!0;if(typeof e!="function")throw new TypeError(hCt);t=Dbe(t)||0,dCt(r)&&(b=!!r.leading,i="maxWait"in r,A=i?pCt(Dbe(r.maxWait)||0,t):A,w="trailing"in r?!!r.trailing:w);function E(v){var C=a,S=u;return a=u=void 0,s=v,c=e.apply(S,C),c}function p(v){return s=v,y=setTimeout(o,t),b?E(v):c}function _(v){var C=v-n,S=v-s,I=t-C;return i?vCt(I,A-S):I}function l(v){var C=v-n,S=v-s;return n===void 0||C>=t||C<0||i&&S>=A}function o(){var v=FY();if(l(v))return d(v);y=setTimeout(o,_(v))}function d(v){return y=void 0,w&&a?E(v):(a=u=void 0,c)}function f(){y!==void 0&&clearTimeout(y),s=0,a=n=u=y=void 0}function h(){return y===void 0?c:d(FY())}function g(){var v=FY(),C=l(v);if(a=arguments,u=this,n=v,C){if(y===void 0)return p(n);if(i)return clearTimeout(y),y=setTimeout(o,t),E(n)}return y===void 0&&(y=setTimeout(o,t)),c}return g.cancel=f,g.flush=h,g}var gCt=mCt;const yCt=_s(gCt);var BY={},bCt=ll;Object.defineProperty(BY,"__esModule",{value:!0});var Pbe=BY.default=void 0,xCt=bCt(ul()),_Ct=He,ECt=(0,xCt.default)((0,_Ct.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),"Search");Pbe=BY.default=ECt;function SCt(){const[e,t]=Cu(MY),{t:r}=nv(),u=yCt(y=>{y=y.trim();const n=y===""?void 0:y;t(s=>({...s,search:n}))},300),A=pt.useRef(),c=()=>{u(""),A.current&&(A.current.value="")};return He.jsx(j2,{variant:"standard",sx:{width:"100%",border:"none",borderRadius:1,backgroundColor:y=>y.palette.mode==="dark"?Xi[850]:"grey.100"},InputProps:{sx:{px:1.5,py:1},disableUnderline:!0,startAdornment:He.jsx(WP,{position:"end",sx:{color:"text.secondary",mr:1,ml:0},children:He.jsx(Pbe,{sx:{height:20,width:20}})}),endAdornment:e.search?He.jsx(Ss,{onClick:c,sx:{p:"2px"},children:He.jsx(X1,{sx:{height:18,width:18}})}):null},placeholder:r("components.organisms.threadHistory.sidebar.filters.SearchBar.search"),inputProps:{"aria-label":"search",ref:A,sx:{p:0}},onChange:y=>u(y.target.value)})}function TCt(){return He.jsxs(ki,{sx:{flexDirection:"row",gap:1},children:[He.jsx(SCt,{}),He.jsx(jAt,{})]})}const wCt=20;let kbe=0;function ACt(){const e=ns(MY),t=pt.useRef(null),[r,a]=pt.useState(e),u=!O3t(r,e),[A,c]=Cu(HT),y=ns(N2),[n,s]=pt.useState(!1),[b,i]=pt.useState(void 0),[w,E]=pt.useState(!1),[p,_]=pt.useState(!1),l=pt.useContext(Ac),{firstInteraction:o,messages:d,threadId:f}=Kh(),h=up();pt.useEffect(()=>{t.current&&(t.current.scrollTop=kbe)},[]),pt.useEffect(()=>{var S;!o||o==="resume"&&((S=d.at(0))==null?void 0:S.output.toLowerCase())!=="resume"||v(void 0,!0).then(()=>{const I=new URL(window.location.href);f&&I.pathname==="/"&&h(`/thread/${f}`)})},[o]);const g=()=>{if(!t.current)return;const{scrollHeight:C,clientHeight:S,scrollTop:I}=t.current,T=I+S>=C-10;kbe=I,s(T)},v=async(C,S)=>{var I;try{C||S?E(!0):_(!0);const{pageInfo:T,data:x}=await l.listThreads({first:wCt,cursor:C},e,y);i(void 0);const R=pwt(C?(I=A==null?void 0:A.threads)==null?void 0:I.concat(x):x,"id");R&&c(P=>({...P,pageInfo:T,threads:R}))}catch(T){T instanceof Error&&i(T.message)}finally{s(!1),E(!1),_(!1)}};if(y&&!p&&!(A!=null&&A.threads)&&!b&&v(),A!=null&&A.pageInfo){const{hasNextPage:C,endCursor:S}=A.pageInfo;n&&!w&&C&&S&&v(S)}return u&&(a(e),v()),He.jsxs(He.Fragment,{children:[He.jsx(TCt,{}),A?He.jsx(Ka,{sx:{flexGrow:1,overflow:"auto"},onScroll:g,ref:t,children:He.jsx(DAt,{threadHistory:A,error:b,isFetching:p,isLoadingMore:w,fetchThreads:v})}):null]})}const CCt=260,RCt=()=>{const e=Vp(),t=v3("(max-width:66rem)"),[r,a]=Cu(Lb),{config:u}=Dl(),A=!!e.accessToken&&!!(u!=null&&u.dataPersistence);pt.useEffect(()=>{c(t?!1:A)},[A]);const c=y=>a(n=>({...n,isChatHistoryOpen:y}));return He.jsxs(Ka,{display:"flex",position:"relative",children:[He.jsxs($re,{className:"chat-history-drawer",anchor:"left",open:r.isChatHistoryOpen,variant:t?"temporary":"persistent",transitionDuration:0,hideBackdrop:!t,onClose:()=>c(!1),sx:{width:r.isChatHistoryOpen?"auto":0,"& .MuiDrawer-paper":{width:r.isChatHistoryOpen?CCt:0,position:"inherit",gap:1,display:"flex",flexDirection:"column",padding:"0px 4px",backgroundImage:"none",borderRight:"none",px:2,boxSizing:"border-box",boxShadow:y=>y.palette.mode==="dark"?"0px 4px 20px 0px rgba(0, 0, 0, 0.20)":"0px 4px 20px 0px rgba(0, 0, 0, 0.05)"}},children:[He.jsx(ki,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",height:"45px",mt:1},children:He.jsx(b8,{style:{maxHeight:"25px"}})}),A?He.jsx(ACt,{}):He.jsx(Ka,{sx:{flexGrow:1,overflow:"auto"},children:He.jsx(ev,{severity:"info",children:"Conversations are not persisted."})}),He.jsxs(ki,{mb:2,children:[He.jsx(A3t,{}),He.jsx(x3t,{})]})]}),t?null:He.jsx(Ka,{position:"absolute",sx:{top:"50%",transform:"translateY(-100%)",right:-30,zIndex:10},children:He.jsx(C3t,{onClick:()=>c(!r.isChatHistoryOpen),open:r.isChatHistoryOpen})})]})},Fbe=localStorage.getItem("userEnv"),Bbe=zs({key:"UserEnv",default:Fbe?JSON.parse(Fbe):{}}),zY=({children:e})=>{const{isAuthenticated:t}=Vp(),{config:r}=Dl(),a=ns(Bbe),u=ns(o_);if(r!=null&&r.userEnv){for(const A of r.userEnv||[])if(!a[A])return He.jsx(nY,{to:"/env"})}return t?He.jsx(Ka,{sx:{display:"flex",flexDirection:"column",width:"100%"},children:t?He.jsxs(ki,{direction:"row",height:"100%",width:"100%",children:[He.jsx(RCt,{}),He.jsxs(ki,{flexGrow:1,children:[He.jsx(gbe,{}),He.jsx(ki,{direction:"row",flexGrow:1,overflow:"auto",children:e})]}),u?null:He.jsx(f9,{isMobile:!1}),He.jsx(GTt,{})]}):He.jsx(ev,{severity:"error",children:He.jsx(ji,{path:"pages.Page.notPartOfProject"})})}):He.jsx(nY,{to:"/login"})};function MCt(){const{id:e}=U2e(),t=iY(),{elements:r}=q0(),{config:a}=Dl(),[u,A]=pt.useState(null),c=up(),y=t.get("thread"),n=a==null?void 0:a.dataPersistence,{data:s,error:b}=$T(e&&y&&n?`/project/thread/${y}/element/${e}`:null);return pt.useEffect(()=>{if(s)A(s);else if(e&&!n&&!u){const i=r.find(w=>w.id===e);i&&A(i)}},[s,u,r,e,y]),!u||b?null:He.jsx(zY,{children:He.jsx(XTt,{element:u,onGoBack:()=>c("/")})})}function zb(e){this._maxSize=e,this.clear()}zb.prototype.clear=function(){this._size=0,this._values=Object.create(null)},zb.prototype.get=function(e){return this._values[e]},zb.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var ICt=/[^.^\]^[]+|(?=\[\]|\.\.)/g,zbe=/^\d+$/,OCt=/^\d/,NCt=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,LCt=/^\s*(['"]?)(.*?)(\1)\s*$/,UY=512,Ube=new zb(UY),Hbe=new zb(UY),$be=new zb(UY),Ub={Cache:zb,split:$Y,normalizePath:HY,setter:function(e){var t=HY(e);return Hbe.get(e)||Hbe.set(e,function(a,u){for(var A=0,c=t.length,y=a;A<c-1;){var n=t[A];if(n==="__proto__"||n==="constructor"||n==="prototype")return a;y=y[t[A++]]}y[t[A]]=u})},getter:function(e,t){var r=HY(e);return $be.get(e)||$be.set(e,function(u){for(var A=0,c=r.length;A<c;)if(u!=null||!t)u=u[r[A++]];else return;return u})},join:function(e){return e.reduce(function(t,r){return t+(GY(r)||zbe.test(r)?"["+r+"]":(t?".":"")+r)},"")},forEach:function(e,t,r){DCt(Array.isArray(e)?e:$Y(e),t,r)}};function HY(e){return Ube.get(e)||Ube.set(e,$Y(e).map(function(t){return t.replace(LCt,"$2")}))}function $Y(e){return e.match(ICt)||[""]}function DCt(e,t,r){var a=e.length,u,A,c,y;for(A=0;A<a;A++)u=e[A],u&&(FCt(u)&&(u='"'+u+'"'),y=GY(u),c=!y&&/^\d+$/.test(u),t.call(r,u,y,c,A,e))}function GY(e){return typeof e=="string"&&e&&["'",'"'].indexOf(e.charAt(0))!==-1}function PCt(e){return e.match(OCt)&&!e.match(zbe)}function kCt(e){return NCt.test(e)}function FCt(e){return!GY(e)&&(PCt(e)||kCt(e))}const BCt=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,N8=e=>e.match(BCt)||[],L8=e=>e[0].toUpperCase()+e.slice(1),VY=(e,t)=>N8(e).join(t).toLowerCase(),Gbe=e=>N8(e).reduce((t,r)=>`${t}${t?r[0].toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()}`,"");var YY={words:N8,upperFirst:L8,camelCase:Gbe,pascalCase:e=>L8(Gbe(e)),snakeCase:e=>VY(e,"_"),kebabCase:e=>VY(e,"-"),sentenceCase:e=>L8(VY(e," ")),titleCase:e=>N8(e).map(L8).join(" ")},WY={exports:{}};WY.exports=function(e){return Vbe(zCt(e),e)},WY.exports.array=Vbe;function Vbe(e,t){var r=e.length,a=new Array(r),u={},A=r,c=UCt(t),y=HCt(e);for(t.forEach(function(s){if(!y.has(s[0])||!y.has(s[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});A--;)u[A]||n(e[A],A,new Set);return a;function n(s,b,i){if(i.has(s)){var w;try{w=", node was:"+JSON.stringify(s)}catch{w=""}throw new Error("Cyclic dependency"+w)}if(!y.has(s))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(s));if(!u[b]){u[b]=!0;var E=c.get(s)||new Set;if(E=Array.from(E),b=E.length){i.add(s);do{var p=E[--b];n(p,y.get(p),i)}while(b);i.delete(s)}a[--r]=s}}}function zCt(e){for(var t=new Set,r=0,a=e.length;r<a;r++){var u=e[r];t.add(u[0]),t.add(u[1])}return Array.from(t)}function UCt(e){for(var t=new Map,r=0,a=e.length;r<a;r++){var u=e[r];t.has(u[0])||t.set(u[0],new Set),t.has(u[1])||t.set(u[1],new Set),t.get(u[0]).add(u[1])}return t}function HCt(e){for(var t=new Map,r=0,a=e.length;r<a;r++)t.set(e[r],r);return t}var $Ct=WY.exports;const GCt=_s($Ct),VCt=Object.prototype.toString,YCt=Error.prototype.toString,WCt=RegExp.prototype.toString,jCt=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",KCt=/^Symbol\((.*)\)(.*)$/;function XCt(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Ybe(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return XCt(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return jCt.call(e).replace(KCt,"Symbol($1)");const a=VCt.call(e).slice(8,-1);return a==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):a==="Error"||e instanceof Error?"["+YCt.call(e)+"]":a==="RegExp"?WCt.call(e):null}function KE(e,t){let r=Ybe(e,t);return r!==null?r:JSON.stringify(e,function(a,u){let A=Ybe(this[a],t);return A!==null?A:u},2)}function Wbe(e){return e==null?[]:[].concat(e)}let ZCt=/\$\{\s*(\w+)\s*\}/g;class dp extends Error{static formatError(t,r){const a=r.label||r.path||"this";return a!==r.path&&(r=Object.assign({},r,{path:a})),typeof t=="string"?t.replace(ZCt,(u,A)=>KE(r[A])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,a,u){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=r,this.path=a,this.type=u,this.errors=[],this.inner=[],Wbe(t).forEach(A=>{dp.isError(A)?(this.errors.push(...A.errors),this.inner=this.inner.concat(A.inner.length?A.inner:A)):this.errors.push(A)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,dp)}}let Fg={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:a})=>{const u=a!=null&&a!==r?` (cast from the value \`${KE(a,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${KE(r,!0)}\``+u:`${e} must match the configured type. The validated value was: \`${KE(r,!0)}\``+u}},xv={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},QCt={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},jY={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},JCt={isValue:"${path} field must be ${value}"},KY={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:Fg,string:xv,number:QCt,date:jY,object:KY,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:JCt});const XY=e=>e&&e.__isYupSchema__;class D8{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:a,then:u,otherwise:A}=r,c=typeof a=="function"?a:(...y)=>y.every(n=>n===a);return new D8(t,(y,n)=>{var s;let b=c(...y)?u:A;return(s=b==null?void 0:b(n))!=null?s:n})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let a=this.refs.map(A=>A.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),u=this.fn(a,t,r);if(u===void 0||u===t)return t;if(!XY(u))throw new TypeError("conditions must return a schema object");return u.resolve(r)}}const P8={context:"$",value:"."};class Hb{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===P8.context,this.isValue=this.key[0]===P8.value,this.isSibling=!this.isContext&&!this.isValue;let a=this.isContext?P8.context:this.isValue?P8.value:"";this.path=this.key.slice(a.length),this.getter=this.path&&Ub.getter(this.path,!0),this.map=r.map}getValue(t,r,a){let u=this.isContext?a:this.isValue?t:r;return this.getter&&(u=this.getter(u||{})),this.map&&(u=this.map(u)),u}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}Hb.prototype.__isYupRef=!0;const $b=e=>e==null;function XE(e){function t({value:r,path:a="",options:u,originalValue:A,schema:c},y,n){const{name:s,test:b,params:i,message:w,skipAbsent:E}=e;let{parent:p,context:_,abortEarly:l=c.spec.abortEarly}=u;function o(T){return Hb.isRef(T)?T.getValue(r,p,_):T}function d(T={}){const x=Object.assign({value:r,originalValue:A,label:c.spec.label,path:T.path||a,spec:c.spec},i,T.params);for(const P of Object.keys(x))x[P]=o(x[P]);const R=new dp(dp.formatError(T.message||w,x),r,x.path,T.type||s);return R.params=x,R}const f=l?y:n;let h={path:a,parent:p,type:s,from:u.from,createError:d,resolve:o,options:u,originalValue:A,schema:c};const g=T=>{dp.isError(T)?f(T):T?n(null):f(d())},v=T=>{dp.isError(T)?f(T):y(T)},C=E&&$b(r);if(!u.sync){try{Promise.resolve(C?!0:b.call(h,r,h)).then(g,v)}catch(T){v(T)}return}let S;try{var I;if(S=C?!0:b.call(h,r,h),typeof((I=S)==null?void 0:I.then)=="function")throw new Error(`Validation test of type: "${h.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(T){v(T);return}g(S)}return t.OPTIONS=e,t}function qCt(e,t,r,a=r){let u,A,c;return t?(Ub.forEach(t,(y,n,s)=>{let b=n?y.slice(1,y.length-1):y;e=e.resolve({context:a,parent:u,value:r});let i=e.type==="tuple",w=s?parseInt(b,10):0;if(e.innerType||i){if(i&&!s)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${c}" must contain an index to the tuple element, e.g. "${c}[0]"`);if(r&&w>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${y}, in the path: ${t}. because there is no value at that index. `);u=r,r=r&&r[w],e=i?e.spec.types[w]:e.innerType}if(!s){if(!e.fields||!e.fields[b])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${c} which is a type: "${e.type}")`);u=r,r=r&&r[b],e=e.fields[b]}A=b,c=n?"["+y+"]":"."+y}),{schema:e,parent:u,parentPath:A}):{parent:u,parentPath:t,schema:e}}class k8 extends Set{describe(){const t=[];for(const r of this.values())t.push(Hb.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const a of this.values())r.push(t(a));return r}clone(){return new k8(this.values())}merge(t,r){const a=this.clone();return t.forEach(u=>a.add(u)),r.forEach(u=>a.delete(u)),a}}function ZE(e,t=new Map){if(XY(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let a=0;a<e.length;a++)r[a]=ZE(e[a],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[a,u]of e.entries())r.set(a,ZE(u,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const a of e)r.add(ZE(a,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[a,u]of Object.entries(e))r[a]=ZE(u,t)}else throw Error(`Unable to clone ${e}`);return r}class Tm{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new k8,this._blacklist=new k8,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Fg.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=ZE(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let a=t(this);return this._mutate=r,a}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,a=t.clone();const u=Object.assign({},r.spec,a.spec);return a.spec=u,a.internalTests=Object.assign({},r.internalTests,a.internalTests),a._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),a._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),a.tests=r.tests,a.exclusiveTests=r.exclusiveTests,a.withMutation(A=>{t.tests.forEach(c=>{A.test(c.OPTIONS)})}),a.transforms=[...r.transforms,...a.transforms],a}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let a=r.conditions;r=r.clone(),r.conditions=[],r=a.reduce((u,A)=>A.resolve(u,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,a,u;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(a=t.abortEarly)!=null?a:this.spec.abortEarly,recursive:(u=t.recursive)!=null?u:this.spec.recursive})}cast(t,r={}){let a=this.resolve(Object.assign({value:t},r)),u=r.assert==="ignore-optionality",A=a._cast(t,r);if(r.assert!==!1&&!a.isType(A)){if(u&&$b(A))return A;let c=KE(t),y=KE(A);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${a.type}".
|
|
758
758
|
|
|
759
759
|
attempted value: ${c}
|
|
760
760
|
`+(y!==c?`result of cast: ${y}`:""))}return A}_cast(t,r){let a=t===void 0?t:this.transforms.reduce((u,A)=>A.call(this,u,t,this),t);return a===void 0&&(a=this.getDefault(r)),a}_validate(t,r={},a,u){let{path:A,originalValue:c=t,strict:y=this.spec.strict}=r,n=t;y||(n=this._cast(n,Object.assign({assert:!1},r)));let s=[];for(let b of Object.values(this.internalTests))b&&s.push(b);this.runTests({path:A,value:n,originalValue:c,options:r,tests:s},a,b=>{if(b.length)return u(b,n);this.runTests({path:A,value:n,originalValue:c,options:r,tests:this.tests},a,u)})}runTests(t,r,a){let u=!1,{tests:A,value:c,originalValue:y,path:n,options:s}=t,b=_=>{u||(u=!0,r(_,c))},i=_=>{u||(u=!0,a(_,c))},w=A.length,E=[];if(!w)return i([]);let p={value:c,originalValue:y,path:n,options:s,schema:this};for(let _=0;_<A.length;_++){const l=A[_];l(p,b,function(d){d&&(E=E.concat(d)),--w<=0&&i(E)})}}asNestedTest({key:t,index:r,parent:a,parentPath:u,originalParent:A,options:c}){const y=t??r;if(y==null)throw TypeError("Must include `key` or `index` for nested validations");const n=typeof y=="number";let s=a[y];const b=Object.assign({},c,{strict:!0,parent:a,value:s,originalValue:A[y],key:void 0,[n?"index":"key"]:y,path:n||y.includes(".")?`${u||""}[${s?y:`"${y}"`}]`:(u?`${u}.`:"")+t});return(i,w,E)=>this.resolve(b)._validate(s,b,w,E)}validate(t,r){let a=this.resolve(Object.assign({},r,{value:t}));return new Promise((u,A)=>a._validate(t,r,(c,y)=>{dp.isError(c)&&(c.value=y),A(c)},(c,y)=>{c.length?A(new dp(c,y)):u(y)}))}validateSync(t,r){let a=this.resolve(Object.assign({},r,{value:t})),u;return a._validate(t,Object.assign({},r,{sync:!0}),(A,c)=>{throw dp.isError(A)&&(A.value=c),A},(A,c)=>{if(A.length)throw new dp(A,t);u=c}),u}isValid(t,r){return this.validate(t,r).then(()=>!0,a=>{if(dp.isError(a))return!1;throw a})}isValidSync(t,r){try{return this.validateSync(t,r),!0}catch(a){if(dp.isError(a))return!1;throw a}}_getDefault(t){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,t):ZE(r)}getDefault(t){return this.resolve(t||{})._getDefault(t)}default(t){return arguments.length===0?this._getDefault():this.clone({default:t})}strict(t=!0){return this.clone({strict:t})}nullability(t,r){const a=this.clone({nullable:t});return a.internalTests.nullable=XE({message:r,name:"nullable",test(u){return u===null?this.schema.spec.nullable:!0}}),a}optionality(t,r){const a=this.clone({optional:t});return a.internalTests.optionality=XE({message:r,name:"optionality",test(u){return u===void 0?this.schema.spec.optional:!0}}),a}optional(){return this.optionality(!0)}defined(t=Fg.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=Fg.notNull){return this.nullability(!1,t)}required(t=Fg.required){return this.clone().withMutation(r=>r.nonNullable(t).defined(t))}notRequired(){return this.clone().withMutation(t=>t.nullable().optional())}transform(t){let r=this.clone();return r.transforms.push(t),r}test(...t){let r;if(t.length===1?typeof t[0]=="function"?r={test:t[0]}:r=t[0]:t.length===2?r={name:t[0],test:t[1]}:r={name:t[0],message:t[1],test:t[2]},r.message===void 0&&(r.message=Fg.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let a=this.clone(),u=XE(r),A=r.exclusive||r.name&&a.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(a.exclusiveTests[r.name]=!!r.exclusive),a.tests=a.tests.filter(c=>!(c.OPTIONS.name===r.name&&(A||c.OPTIONS.test===u.OPTIONS.test))),a.tests.push(u),a}when(t,r){!Array.isArray(t)&&typeof t!="string"&&(r=t,t=".");let a=this.clone(),u=Wbe(t).map(A=>new Hb(A));return u.forEach(A=>{A.isSibling&&a.deps.push(A.key)}),a.conditions.push(typeof r=="function"?new D8(u,r):D8.fromOptions(u,r)),a}typeError(t){let r=this.clone();return r.internalTests.typeError=XE({message:t,name:"typeError",skipAbsent:!0,test(a){return this.schema._typeCheck(a)?!0:this.createError({params:{type:this.schema.type}})}}),r}oneOf(t,r=Fg.oneOf){let a=this.clone();return t.forEach(u=>{a._whitelist.add(u),a._blacklist.delete(u)}),a.internalTests.whiteList=XE({message:r,name:"oneOf",skipAbsent:!0,test(u){let A=this.schema._whitelist,c=A.resolveAll(this.resolve);return c.includes(u)?!0:this.createError({params:{values:Array.from(A).join(", "),resolved:c}})}}),a}notOneOf(t,r=Fg.notOneOf){let a=this.clone();return t.forEach(u=>{a._blacklist.add(u),a._whitelist.delete(u)}),a.internalTests.blacklist=XE({message:r,name:"notOneOf",test(u){let A=this.schema._blacklist,c=A.resolveAll(this.resolve);return c.includes(u)?this.createError({params:{values:Array.from(A).join(", "),resolved:c}}):!0}}),a}strip(t=!0){let r=this.clone();return r.spec.strip=t,r}describe(t){const r=(t?this.resolve(t):this).clone(),{label:a,meta:u,optional:A,nullable:c}=r.spec;return{meta:u,label:a,optional:A,nullable:c,default:r.getDefault(t),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.map(n=>({name:n.OPTIONS.name,params:n.OPTIONS.params})).filter((n,s,b)=>b.findIndex(i=>i.name===n.name)===s)}}}Tm.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])Tm.prototype[`${e}At`]=function(t,r,a={}){const{parent:u,parentPath:A,schema:c}=qCt(this,t,r,a.context);return c[e](u&&u[A],Object.assign({},a,{parent:u,path:t}))};for(const e of["equals","is"])Tm.prototype[e]=Tm.prototype.oneOf;for(const e of["not","nope"])Tm.prototype[e]=Tm.prototype.notOneOf;let e4t=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,t4t=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,r4t=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,n4t=e=>$b(e)||e===e.trim(),a4t={}.toString();function F8(){return new jbe}class jbe extends Tm{constructor(){super({type:"string",check(t){return t instanceof String&&(t=t.valueOf()),typeof t=="string"}}),this.withMutation(()=>{this.transform((t,r,a)=>{if(!a.spec.coerce||a.isType(t)||Array.isArray(t))return t;const u=t!=null&&t.toString?t.toString():t;return u===a4t?t:u})})}required(t){return super.required(t).withMutation(r=>r.test({message:t||Fg.required,name:"required",skipAbsent:!0,test:a=>!!a.length}))}notRequired(){return super.notRequired().withMutation(t=>(t.tests=t.tests.filter(r=>r.OPTIONS.name!=="required"),t))}length(t,r=xv.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(a){return a.length===this.resolve(t)}})}min(t,r=xv.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(a){return a.length>=this.resolve(t)}})}max(t,r=xv.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:t},skipAbsent:!0,test(a){return a.length<=this.resolve(t)}})}matches(t,r){let a=!1,u,A;return r&&(typeof r=="object"?{excludeEmptyString:a=!1,message:u,name:A}=r:u=r),this.test({name:A||"matches",message:u||xv.matches,params:{regex:t},skipAbsent:!0,test:c=>c===""&&a||c.search(t)!==-1})}email(t=xv.email){return this.matches(e4t,{name:"email",message:t,excludeEmptyString:!0})}url(t=xv.url){return this.matches(t4t,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=xv.uuid){return this.matches(r4t,{name:"uuid",message:t,excludeEmptyString:!1})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=xv.trim){return this.transform(r=>r!=null?r.trim():r).test({message:t,name:"trim",test:n4t})}lowercase(t=xv.lowercase){return this.transform(r=>$b(r)?r:r.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>$b(r)||r===r.toLowerCase()})}uppercase(t=xv.uppercase){return this.transform(r=>$b(r)?r:r.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>$b(r)||r===r.toUpperCase()})}}F8.prototype=jbe.prototype;var i4t=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function o4t(e){var t=[1,4,5,6,7,10,11],r=0,a,u;if(u=i4t.exec(e)){for(var A=0,c;c=t[A];++A)u[c]=+u[c]||0;u[2]=(+u[2]||1)-1,u[3]=+u[3]||1,u[7]=u[7]?String(u[7]).substr(0,3):0,(u[8]===void 0||u[8]==="")&&(u[9]===void 0||u[9]==="")?a=+new Date(u[1],u[2],u[3],u[4],u[5],u[6],u[7]):(u[8]!=="Z"&&u[9]!==void 0&&(r=u[10]*60+u[11],u[9]==="+"&&(r=0-r)),a=Date.UTC(u[1],u[2],u[3],u[4],u[5]+r,u[6],u[7]))}else a=Date.parse?Date.parse(e):NaN;return a}let s4t=new Date(""),l4t=e=>Object.prototype.toString.call(e)==="[object Date]";class B8 extends Tm{constructor(){super({type:"date",check(t){return l4t(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,r,a)=>!a.spec.coerce||a.isType(t)||t===null?t:(t=o4t(t),isNaN(t)?B8.INVALID_DATE:new Date(t)))})}prepareParam(t,r){let a;if(Hb.isRef(t))a=t;else{let u=this.cast(t);if(!this._typeCheck(u))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);a=u}return a}min(t,r=jY.min){let a=this.prepareParam(t,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(u){return u>=this.resolve(a)}})}max(t,r=jY.max){let a=this.prepareParam(t,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(u){return u<=this.resolve(a)}})}}B8.INVALID_DATE=s4t,B8.prototype;function u4t(e,t=[]){let r=[],a=new Set,u=new Set(t.map(([c,y])=>`${c}-${y}`));function A(c,y){let n=Ub.split(c)[0];a.add(n),u.has(`${y}-${n}`)||r.push([y,n])}for(const c of Object.keys(e)){let y=e[c];a.add(c),Hb.isRef(y)&&y.isSibling?A(y.path,c):XY(y)&&"deps"in y&&y.deps.forEach(n=>A(n,c))}return GCt.array(Array.from(a),r).reverse()}function Kbe(e,t){let r=1/0;return e.some((a,u)=>{var A;if((A=t.path)!=null&&A.includes(a))return r=u,!0}),r}function Xbe(e){return(t,r)=>Kbe(e,t)-Kbe(e,r)}const c4t=(e,t,r)=>{if(typeof e!="string")return e;let a=e;try{a=JSON.parse(e)}catch{}return r.isType(a)?a:e};function z8(e){if("fields"in e){const t={};for(const[r,a]of Object.entries(e.fields))t[r]=z8(a);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=z8(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(z8)}):"optional"in e?e.optional():e}const f4t=(e,t)=>{const r=[...Ub.normalizePath(t)];if(r.length===1)return r[0]in e;let a=r.pop(),u=Ub.getter(Ub.join(r),!0)(e);return!!(u&&a in u)};let Zbe=e=>Object.prototype.toString.call(e)==="[object Object]";function d4t(e,t){let r=Object.keys(e.fields);return Object.keys(t).filter(a=>r.indexOf(a)===-1)}const h4t=Xbe([]);function ZY(e){return new Qbe(e)}class Qbe extends Tm{constructor(t){super({type:"object",check(r){return Zbe(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=h4t,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,r={}){var a;let u=super._cast(t,r);if(u===void 0)return this.getDefault(r);if(!this._typeCheck(u))return u;let A=this.fields,c=(a=r.stripUnknown)!=null?a:this.spec.noUnknown,y=[].concat(this._nodes,Object.keys(u).filter(i=>!this._nodes.includes(i))),n={},s=Object.assign({},r,{parent:n,__validating:r.__validating||!1}),b=!1;for(const i of y){let w=A[i],E=i in u;if(w){let p,_=u[i];s.path=(r.path?`${r.path}.`:"")+i,w=w.resolve({value:_,context:r.context,parent:n});let l=w instanceof Tm?w.spec:void 0,o=l==null?void 0:l.strict;if(l!=null&&l.strip){b=b||i in u;continue}p=!r.__validating||!o?w.cast(u[i],s):u[i],p!==void 0&&(n[i]=p)}else E&&!c&&(n[i]=u[i]);(E!==i in n||n[i]!==u[i])&&(b=!0)}return b?n:u}_validate(t,r={},a,u){let{from:A=[],originalValue:c=t,recursive:y=this.spec.recursive}=r;r.from=[{schema:this,value:c},...A],r.__validating=!0,r.originalValue=c,super._validate(t,r,a,(n,s)=>{if(!y||!Zbe(s)){u(n,s);return}c=c||s;let b=[];for(let i of this._nodes){let w=this.fields[i];!w||Hb.isRef(w)||b.push(w.asNestedTest({options:r,key:i,parent:s,parentPath:r.path,originalParent:c}))}this.runTests({tests:b,value:s,originalValue:c,options:r},a,i=>{u(i.sort(this._sortErrors).concat(n),s)})})}clone(t){const r=super.clone(t);return r.fields=Object.assign({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(t){let r=super.concat(t),a=r.fields;for(let[u,A]of Object.entries(this.fields)){const c=a[u];a[u]=c===void 0?A:c}return r.withMutation(u=>u.setFields(a,[...this._excludedEdges,...t._excludedEdges]))}_getDefault(t){if("default"in this.spec)return super._getDefault(t);if(!this._nodes.length)return;let r={};return this._nodes.forEach(a=>{var u;const A=this.fields[a];let c=t;(u=c)!=null&&u.value&&(c=Object.assign({},c,{parent:c.value,value:c.value[a]})),r[a]=A&&"getDefault"in A?A.getDefault(c):void 0}),r}setFields(t,r){let a=this.clone();return a.fields=t,a._nodes=u4t(t,r),a._sortErrors=Xbe(Object.keys(t)),r&&(a._excludedEdges=r),a}shape(t,r=[]){return this.clone().withMutation(a=>{let u=a._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),u=[...a._excludedEdges,...r]),a.setFields(Object.assign(a.fields,t),u)})}partial(){const t={};for(const[r,a]of Object.entries(this.fields))t[r]="optional"in a&&a.optional instanceof Function?a.optional():a;return this.setFields(t)}deepPartial(){return z8(this)}pick(t){const r={};for(const a of t)this.fields[a]&&(r[a]=this.fields[a]);return this.setFields(r)}omit(t){const r=Object.assign({},this.fields);for(const a of t)delete r[a];return this.setFields(r)}from(t,r,a){let u=Ub.getter(t,!0);return this.transform(A=>{if(!A)return A;let c=A;return f4t(A,t)&&(c=Object.assign({},A),a||delete c[t],c[r]=u(A)),c})}json(){return this.transform(c4t)}noUnknown(t=!0,r=KY.noUnknown){typeof t!="boolean"&&(r=t,t=!0);let a=this.test({name:"noUnknown",exclusive:!0,message:r,test(u){if(u==null)return!0;const A=d4t(this.schema,u);return!t||A.length===0||this.createError({params:{unknown:A.join(", ")}})}});return a.spec.noUnknown=t,a}unknown(t=!0,r=KY.noUnknown){return this.noUnknown(!t,r)}transformKeys(t){return this.transform(r=>{if(!r)return r;const a={};for(const u of Object.keys(r))a[t(u)]=r[u];return a})}camelCase(){return this.transformKeys(YY.camelCase)}snakeCase(){return this.transformKeys(YY.snakeCase)}constantCase(){return this.transformKeys(t=>YY.snakeCase(t).toUpperCase())}describe(t){let r=super.describe(t);r.fields={};for(const[u,A]of Object.entries(this.fields)){var a;let c=t;(a=c)!=null&&a.value&&(c=Object.assign({},c,{parent:c.value,value:c.value[u]})),r.fields[u]=A.describe(c)}return r}}ZY.prototype=Qbe.prototype;function p4t(){const[e,t]=Cu(Bbe),{config:r}=Dl(),a=Pg(),u=up(),{t:A}=nv(),c=(r==null?void 0:r.userEnv)||[],y={},n={};c.forEach(w=>{y[w]=e[w]||"",n[w]=F8().required()});const s=ZY(n),b=N9({initialValues:y,validationSchema:s,onSubmit:async w=>(localStorage.setItem("userEnv",JSON.stringify(w)),t(w),Gf.success(A("pages.Env.savedSuccessfully")),u("/"))});c.length===0&&u("/");const i=w=>{const E=!!b.errors[w];return He.jsx(H_,{id:w,className:w,label:w,value:b.values[w],size:"medium",hasError:E,description:E?b.errors[w]:"",onChange:p=>b.setFieldValue(w,p.target.value)})};return He.jsxs(Ka,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[He.jsx(gbe,{}),He.jsxs(Ka,{id:"env",display:"flex",flexDirection:"column",flexGrow:1,gap:2,sx:{maxWidth:a,width:"100%",mx:"auto"},children:[He.jsx(Wo,{mt:5,fontSize:"18px",fontWeight:700,color:"text.primary",children:He.jsx(ji,{path:"pages.Env.requiredApiKeys"})}),He.jsx(ev,{severity:"info",children:He.jsx(ji,{path:"pages.Env.requiredApiKeysInfo"})}),He.jsxs("form",{onSubmit:b.handleSubmit,children:[c.map(w=>i(w)),He.jsx(rh,{id:"submit-env",fullWidth:!0,type:"submit",variant:"contained",sx:{mt:1},children:"Save"})]})]})]})}const Jbe=pt.memo(({askUser:e,loading:t,actions:r,elements:a,messages:u,onFeedbackUpdated:A,onFeedbackDeleted:c,callAction:y})=>{var f,h;const{config:n}=Dl(),s=Ho(o_),b=ns(u9),{uploadFile:i}=Xu(),w=pt.useCallback((g,v)=>i(g,v),[i]),E=!!(n!=null&&n.dataPersistence),p=up(),_=pt.useCallback(g=>{let v=`/element/${g.id}`;if(g.display==="side"){s(g);return}return g.threadId&&(v+=`?thread=${g.threadId}`),p(g.display==="page"?v:"#")},[s,p]),l=pt.useMemo(()=>r.map(g=>({...g,onClick:async()=>{try{y==null||y(g)}catch(v){v instanceof Error&&Gf.error(v.message)}}})),[r]),o=pt.useCallback(g=>Gf.error(g),[Gf]),d=pt.useMemo(()=>{var g,v,C;return{uploadFile:w,askUser:e,allowHtml:(g=n==null?void 0:n.features)==null?void 0:g.unsafe_allow_html,latex:(v=n==null?void 0:n.features)==null?void 0:v.latex,defaultCollapseContent:!!(n!=null&&n.ui.default_collapse_content),highlightedMessage:b,loading:t,showFeedbackButtons:E,uiName:((C=n==null?void 0:n.ui)==null?void 0:C.name)||"",onElementRefClick:_,onError:o,onFeedbackUpdated:A,onFeedbackDeleted:c}},[e,E,b,t,(f=n==null?void 0:n.ui)==null?void 0:f.name,(h=n==null?void 0:n.features)==null?void 0:h.unsafe_allow_html,_,o,A]);return He.jsx(s2e,{actions:l,elements:a,messages:u,context:d})}),v4t=()=>{const e=pt.useContext(Ac),{elements:t,askUser:r,loading:a,actions:u}=q0(),{messages:A}=Kh(),{callAction:c}=Xu(),y=ns(N2),n=Ho(i_),{t:s}=nv(),b=pt.useCallback(async(w,E,p)=>{try{Gf.promise(e.setFeedback(p,y),{loading:s("components.organisms.chat.Messages.index.updating"),success:_=>(n(l=>D2(l,w.id,{...w,feedback:{...p,id:_.feedbackId}})),E(),s("components.organisms.chat.Messages.index.feedbackUpdated")),error:_=>He.jsx("span",{children:_.message})})}catch(_){console.log(_)}},[]),i=pt.useCallback(async(w,E,p)=>{try{Gf.promise(e.deleteFeedback(p,y),{loading:s("components.organisms.chat.Messages.index.updating"),success:()=>(n(_=>D2(_,w.id,{...w,feedback:void 0})),E(),s("components.organisms.chat.Messages.index.feedbackUpdated")),error:_=>He.jsx("span",{children:_.message})})}catch(_){console.log(_)}},[]);return He.jsx(Jbe,{loading:a,askUser:r,actions:u,elements:t,messages:A,onFeedbackUpdated:b,onFeedbackDeleted:i,callAction:c})};var m4t={exports:{}};(function(e){var t=function(r){var a=Object.prototype,u=a.hasOwnProperty,A=Object.defineProperty||function(m,D,M){m[D]=M.value},c,y=typeof Symbol=="function"?Symbol:{},n=y.iterator||"@@iterator",s=y.asyncIterator||"@@asyncIterator",b=y.toStringTag||"@@toStringTag";function i(m,D,M){return Object.defineProperty(m,D,{value:M,enumerable:!0,configurable:!0,writable:!0}),m[D]}try{i({},"")}catch{i=function(D,M,H){return D[M]=H}}function w(m,D,M,H){var B=D&&D.prototype instanceof f?D:f,Y=Object.create(B.prototype),$=new N(H||[]);return A(Y,"_invoke",{value:R(m,M,$)}),Y}r.wrap=w;function E(m,D,M){try{return{type:"normal",arg:m.call(D,M)}}catch(H){return{type:"throw",arg:H}}}var p="suspendedStart",_="suspendedYield",l="executing",o="completed",d={};function f(){}function h(){}function g(){}var v={};i(v,n,function(){return this});var C=Object.getPrototypeOf,S=C&&C(C(k([])));S&&S!==a&&u.call(S,n)&&(v=S);var I=g.prototype=f.prototype=Object.create(v);h.prototype=g,A(I,"constructor",{value:g,configurable:!0}),A(g,"constructor",{value:h,configurable:!0}),h.displayName=i(g,b,"GeneratorFunction");function T(m){["next","throw","return"].forEach(function(D){i(m,D,function(M){return this._invoke(D,M)})})}r.isGeneratorFunction=function(m){var D=typeof m=="function"&&m.constructor;return D?D===h||(D.displayName||D.name)==="GeneratorFunction":!1},r.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,g):(m.__proto__=g,i(m,b,"GeneratorFunction")),m.prototype=Object.create(I),m},r.awrap=function(m){return{__await:m}};function x(m,D){function M(Y,$,V,W){var G=E(m[Y],m,$);if(G.type==="throw")W(G.arg);else{var j=G.arg,X=j.value;return X&&typeof X=="object"&&u.call(X,"__await")?D.resolve(X.__await).then(function(q){M("next",q,V,W)},function(q){M("throw",q,V,W)}):D.resolve(X).then(function(q){j.value=q,V(j)},function(q){return M("throw",q,V,W)})}}var H;function B(Y,$){function V(){return new D(function(W,G){M(Y,$,W,G)})}return H=H?H.then(V,V):V()}A(this,"_invoke",{value:B})}T(x.prototype),i(x.prototype,s,function(){return this}),r.AsyncIterator=x,r.async=function(m,D,M,H,B){B===void 0&&(B=Promise);var Y=new x(w(m,D,M,H),B);return r.isGeneratorFunction(D)?Y:Y.next().then(function($){return $.done?$.value:Y.next()})};function R(m,D,M){var H=p;return function(Y,$){if(H===l)throw new Error("Generator is already running");if(H===o){if(Y==="throw")throw $;return O()}for(M.method=Y,M.arg=$;;){var V=M.delegate;if(V){var W=P(V,M);if(W){if(W===d)continue;return W}}if(M.method==="next")M.sent=M._sent=M.arg;else if(M.method==="throw"){if(H===p)throw H=o,M.arg;M.dispatchException(M.arg)}else M.method==="return"&&M.abrupt("return",M.arg);H=l;var G=E(m,D,M);if(G.type==="normal"){if(H=M.done?o:_,G.arg===d)continue;return{value:G.arg,done:M.done}}else G.type==="throw"&&(H=o,M.method="throw",M.arg=G.arg)}}}function P(m,D){var M=D.method,H=m.iterator[M];if(H===c)return D.delegate=null,M==="throw"&&m.iterator.return&&(D.method="return",D.arg=c,P(m,D),D.method==="throw")||M!=="return"&&(D.method="throw",D.arg=new TypeError("The iterator does not provide a '"+M+"' method")),d;var B=E(H,m.iterator,D.arg);if(B.type==="throw")return D.method="throw",D.arg=B.arg,D.delegate=null,d;var Y=B.arg;if(!Y)return D.method="throw",D.arg=new TypeError("iterator result is not an object"),D.delegate=null,d;if(Y.done)D[m.resultName]=Y.value,D.next=m.nextLoc,D.method!=="return"&&(D.method="next",D.arg=c);else return Y;return D.delegate=null,d}T(I),i(I,b,"Generator"),i(I,n,function(){return this}),i(I,"toString",function(){return"[object Generator]"});function L(m){var D={tryLoc:m[0]};1 in m&&(D.catchLoc=m[1]),2 in m&&(D.finallyLoc=m[2],D.afterLoc=m[3]),this.tryEntries.push(D)}function F(m){var D=m.completion||{};D.type="normal",delete D.arg,m.completion=D}function N(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(L,this),this.reset(!0)}r.keys=function(m){var D=Object(m),M=[];for(var H in D)M.push(H);return M.reverse(),function B(){for(;M.length;){var Y=M.pop();if(Y in D)return B.value=Y,B.done=!1,B}return B.done=!0,B}};function k(m){if(m||m===""){var D=m[n];if(D)return D.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var M=-1,H=function B(){for(;++M<m.length;)if(u.call(m,M))return B.value=m[M],B.done=!1,B;return B.value=c,B.done=!0,B};return H.next=H}}throw new TypeError(typeof m+" is not iterable")}r.values=k;function O(){return{value:c,done:!0}}return N.prototype={constructor:N,reset:function(m){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(F),!m)for(var D in this)D.charAt(0)==="t"&&u.call(this,D)&&!isNaN(+D.slice(1))&&(this[D]=c)},stop:function(){this.done=!0;var m=this.tryEntries[0],D=m.completion;if(D.type==="throw")throw D.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var D=this;function M(W,G){return Y.type="throw",Y.arg=m,D.next=W,G&&(D.method="next",D.arg=c),!!G}for(var H=this.tryEntries.length-1;H>=0;--H){var B=this.tryEntries[H],Y=B.completion;if(B.tryLoc==="root")return M("end");if(B.tryLoc<=this.prev){var $=u.call(B,"catchLoc"),V=u.call(B,"finallyLoc");if($&&V){if(this.prev<B.catchLoc)return M(B.catchLoc,!0);if(this.prev<B.finallyLoc)return M(B.finallyLoc)}else if($){if(this.prev<B.catchLoc)return M(B.catchLoc,!0)}else if(V){if(this.prev<B.finallyLoc)return M(B.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(m,D){for(var M=this.tryEntries.length-1;M>=0;--M){var H=this.tryEntries[M];if(H.tryLoc<=this.prev&&u.call(H,"finallyLoc")&&this.prev<H.finallyLoc){var B=H;break}}B&&(m==="break"||m==="continue")&&B.tryLoc<=D&&D<=B.finallyLoc&&(B=null);var Y=B?B.completion:{};return Y.type=m,Y.arg=D,B?(this.method="next",this.next=B.finallyLoc,d):this.complete(Y)},complete:function(m,D){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&D&&(this.next=D),d},finish:function(m){for(var D=this.tryEntries.length-1;D>=0;--D){var M=this.tryEntries[D];if(M.finallyLoc===m)return this.complete(M.completion,M.afterLoc),F(M),d}},catch:function(m){for(var D=this.tryEntries.length-1;D>=0;--D){var M=this.tryEntries[D];if(M.tryLoc===m){var H=M.completion;if(H.type==="throw"){var B=H.arg;F(M)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(m,D,M){return this.delegate={iterator:k(m),resultName:D,nextLoc:M},this.method==="next"&&(this.arg=c),d}},r}(e.exports);try{regeneratorRuntime=t}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})(m4t);function g4t(e,t){for(var r=-1,a=e==null?0:e.length;++r<a&&t(e[r],r,e)!==!1;);return e}var y4t=g4t,b4t=P9,x4t=H9,_4t=Object.prototype,E4t=_4t.hasOwnProperty;function S4t(e,t,r){var a=e[t];(!(E4t.call(e,t)&&x4t(a,r))||r===void 0&&!(t in e))&&b4t(e,t,r)}var qbe=S4t,T4t=qbe,w4t=P9;function A4t(e,t,r,a){var u=!r;r||(r={});for(var A=-1,c=t.length;++A<c;){var y=t[A],n=a?a(r[y],e[y],y,r,e):void 0;n===void 0&&(n=e[y]),u?w4t(r,y,n):T4t(r,y,n)}return r}var U8=A4t,C4t=U8,R4t=O3;function M4t(e,t){return e&&C4t(t,R4t(t),e)}var I4t=M4t;function O4t(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var N4t=O4t,L4t=j1,D4t=U9,P4t=N4t,k4t=Object.prototype,F4t=k4t.hasOwnProperty;function B4t(e){if(!L4t(e))return P4t(e);var t=D4t(e),r=[];for(var a in e)a=="constructor"&&(t||!F4t.call(e,a))||r.push(a);return r}var z4t=B4t,U4t=Eie,H4t=z4t,$4t=I3;function G4t(e){return $4t(e)?U4t(e,!0):H4t(e)}var QY=G4t,V4t=U8,Y4t=QY;function W4t(e,t){return e&&V4t(t,Y4t(t),e)}var j4t=W4t,H8={exports:{}};H8.exports,function(e,t){var r=iv,a=t&&!t.nodeType&&t,u=a&&!0&&e&&!e.nodeType&&e,A=u&&u.exports===a,c=A?r.Buffer:void 0,y=c?c.allocUnsafe:void 0;function n(s,b){if(b)return s.slice();var i=s.length,w=y?y(i):new s.constructor(i);return s.copy(w),w}e.exports=n}(H8,H8.exports);var K4t=H8.exports;function X4t(e,t){var r=-1,a=e.length;for(t||(t=Array(a));++r<a;)t[r]=e[r];return t}var Z4t=X4t,Q4t=U8,J4t=j9;function q4t(e,t){return Q4t(e,J4t(e),t)}var e5t=q4t,t5t=Sie,r5t=t5t(Object.getPrototypeOf,Object),exe=r5t,n5t=Pie,a5t=exe,i5t=j9,o5t=Fie,s5t=Object.getOwnPropertySymbols,l5t=s5t?function(e){for(var t=[];e;)n5t(t,i5t(e)),e=a5t(e);return t}:o5t,txe=l5t,u5t=U8,c5t=txe;function f5t(e,t){return u5t(e,c5t(e),t)}var d5t=f5t,h5t=kie,p5t=txe,v5t=QY;function m5t(e){return h5t(e,v5t,p5t)}var g5t=m5t,y5t=Object.prototype,b5t=y5t.hasOwnProperty;function x5t(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&b5t.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var _5t=x5t,rxe=Oie;function E5t(e){var t=new e.constructor(e.byteLength);return new rxe(t).set(new rxe(e)),t}var JY=E5t,S5t=JY;function T5t(e,t){var r=t?S5t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var w5t=T5t,A5t=/\w*$/;function C5t(e){var t=new e.constructor(e.source,A5t.exec(e));return t.lastIndex=e.lastIndex,t}var R5t=C5t,nxe=R3,axe=nxe?nxe.prototype:void 0,ixe=axe?axe.valueOf:void 0;function M5t(e){return ixe?Object(ixe.call(e)):{}}var I5t=M5t,O5t=JY;function N5t(e,t){var r=t?O5t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var L5t=N5t,D5t=JY,P5t=w5t,k5t=R5t,F5t=I5t,B5t=L5t,z5t="[object Boolean]",U5t="[object Date]",H5t="[object Map]",$5t="[object Number]",G5t="[object RegExp]",V5t="[object Set]",Y5t="[object String]",W5t="[object Symbol]",j5t="[object ArrayBuffer]",K5t="[object DataView]",X5t="[object Float32Array]",Z5t="[object Float64Array]",Q5t="[object Int8Array]",J5t="[object Int16Array]",q5t="[object Int32Array]",eRt="[object Uint8Array]",tRt="[object Uint8ClampedArray]",rRt="[object Uint16Array]",nRt="[object Uint32Array]";function aRt(e,t,r){var a=e.constructor;switch(t){case j5t:return D5t(e);case z5t:case U5t:return new a(+e);case K5t:return P5t(e,r);case X5t:case Z5t:case Q5t:case J5t:case q5t:case eRt:case tRt:case rRt:case nRt:return B5t(e,r);case H5t:return new a;case $5t:case Y5t:return new a(e);case G5t:return k5t(e);case V5t:return new a;case W5t:return F5t(e)}}var iRt=aRt,oRt=j1,oxe=Object.create,sRt=function(){function e(){}return function(t){if(!oRt(t))return{};if(oxe)return oxe(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),lRt=sRt,uRt=lRt,cRt=exe,fRt=U9;function dRt(e){return typeof e.constructor=="function"&&!fRt(e)?uRt(cRt(e)):{}}var hRt=dRt,pRt=N3,vRt=K1,mRt="[object Map]";function gRt(e){return vRt(e)&&pRt(e)==mRt}var yRt=gRt,bRt=yRt,xRt=B9,sxe=z9,lxe=sxe&&sxe.isMap,_Rt=lxe?xRt(lxe):bRt,ERt=_Rt,SRt=N3,TRt=K1,wRt="[object Set]";function ARt(e){return TRt(e)&&SRt(e)==wRt}var CRt=ARt,RRt=CRt,MRt=B9,uxe=z9,cxe=uxe&&uxe.isSet,IRt=cxe?MRt(cxe):RRt,ORt=IRt,NRt=V9,LRt=y4t,DRt=qbe,PRt=I4t,kRt=j4t,FRt=K4t,BRt=Z4t,zRt=e5t,URt=d5t,HRt=zie,$Rt=g5t,GRt=N3,VRt=_5t,YRt=iRt,WRt=hRt,jRt=ov,KRt=k9,XRt=ERt,ZRt=j1,QRt=ORt,JRt=O3,qRt=QY,e6t=1,t6t=2,r6t=4,fxe="[object Arguments]",n6t="[object Array]",a6t="[object Boolean]",i6t="[object Date]",o6t="[object Error]",dxe="[object Function]",s6t="[object GeneratorFunction]",l6t="[object Map]",u6t="[object Number]",hxe="[object Object]",c6t="[object RegExp]",f6t="[object Set]",d6t="[object String]",h6t="[object Symbol]",p6t="[object WeakMap]",v6t="[object ArrayBuffer]",m6t="[object DataView]",g6t="[object Float32Array]",y6t="[object Float64Array]",b6t="[object Int8Array]",x6t="[object Int16Array]",_6t="[object Int32Array]",E6t="[object Uint8Array]",S6t="[object Uint8ClampedArray]",T6t="[object Uint16Array]",w6t="[object Uint32Array]",hl={};hl[fxe]=hl[n6t]=hl[v6t]=hl[m6t]=hl[a6t]=hl[i6t]=hl[g6t]=hl[y6t]=hl[b6t]=hl[x6t]=hl[_6t]=hl[l6t]=hl[u6t]=hl[hxe]=hl[c6t]=hl[f6t]=hl[d6t]=hl[h6t]=hl[E6t]=hl[S6t]=hl[T6t]=hl[w6t]=!0,hl[o6t]=hl[dxe]=hl[p6t]=!1;function $8(e,t,r,a,u,A){var c,y=t&e6t,n=t&t6t,s=t&r6t;if(r&&(c=u?r(e,a,u,A):r(e)),c!==void 0)return c;if(!ZRt(e))return e;var b=jRt(e);if(b){if(c=VRt(e),!y)return BRt(e,c)}else{var i=GRt(e),w=i==dxe||i==s6t;if(KRt(e))return FRt(e,y);if(i==hxe||i==fxe||w&&!u){if(c=n||w?{}:WRt(e),!y)return n?URt(e,kRt(c,e)):zRt(e,PRt(c,e))}else{if(!hl[i])return u?e:{};c=YRt(e,i,y)}}A||(A=new NRt);var E=A.get(e);if(E)return E;A.set(e,c),QRt(e)?e.forEach(function(l){c.add($8(l,t,r,l,e,A))}):XRt(e)&&e.forEach(function(l,o){c.set(o,$8(l,t,r,o,e,A))});var p=s?n?$Rt:HRt:n?qRt:JRt,_=b?void 0:p(e);return LRt(_||e,function(l,o){_&&(o=l,l=e[o]),DRt(c,o,$8(l,t,r,o,e,A))}),c}var A6t=$8,C6t=A6t,R6t=1,M6t=4;function I6t(e){return C6t(e,R6t|M6t)}var O6t=I6t;const N6t=_s(O6t);var qY={},L6t=ll;Object.defineProperty(qY,"__esModule",{value:!0});var pxe=qY.default=void 0,D6t=L6t(ul()),vxe=He,P6t=(0,D6t.default)([(0,vxe.jsx)("path",{d:"M15 2h-3.5l-1-1h-5l-1 1H1v2h14zm1 7c-.7 0-1.37.1-2 .29V5H2v12c0 1.1.9 2 2 2h5.68c1.12 2.36 3.53 4 6.32 4 3.87 0 7-3.13 7-7s-3.13-7-7-7zm0 12c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"},"0"),(0,vxe.jsx)("path",{d:"M16.5 12H15v5l3.6 2.1.8-1.2-2.9-1.7z"},"1")],"AutoDelete");pxe=qY.default=P6t;function k6t(e){const t={},r=N6t(e).reverse();return r==null||r.forEach(a=>{const{createdAt:u,content:A}=a,c={day:"numeric",month:"numeric",year:"numeric"},y=new Date(u).toLocaleDateString(void 0,c);t[y]||(t[y]=[]);const n={hour:"numeric",minute:"numeric"};t[y].push({key:u,hour:new Date(u).toLocaleTimeString(void 0,n),content:A})}),t}function F6t({onClick:e}){const[t,r]=Cu(Iw),a=pt.useRef(),[u,A]=pt.useState(null);t.open&&!u&&a.current&&A(a.current);const c=w=>r(E=>({...E,open:w})),y=He.jsxs(ki,{disabled:!0,direction:"row",p:1,justifyContent:"space-between",alignItems:"center",children:[He.jsx(Wo,{color:"text.primary",sx:{fontSize:"14px",fontWeight:700},children:He.jsx(ji,{path:"components.organisms.chat.history.index.lastInputs"})}),He.jsx(Ss,{onClick:()=>r(w=>({...w,inputs:[]})),children:He.jsx(pxe,{})})]},"title"),n=(t==null?void 0:t.inputs.length)===0?He.jsx("div",{id:"history-empty",disabled:!0,children:He.jsx(Wo,{color:"text.secondary",sx:{fontSize:"12px",fontWeight:700,padding:"16px 12px",textTransform:"uppercase"},children:He.jsx(ji,{path:"components.organisms.chat.history.index.noInputs"})})},"empty"):null,s=t.inputs?null:He.jsx("div",{id:"history-loading",disabled:!0,children:He.jsx(Wo,{color:"text.secondary",sx:{fontSize:"12px",fontWeight:700,padding:"16px 12px",textTransform:"uppercase"},children:He.jsx(ji,{path:"components.organisms.chat.history.index.loading"})})},"loading"),b=[y,n,s];if(t.inputs){const w=k6t(t.inputs);Object.keys(w).forEach(E=>{b.push(He.jsx("div",{disabled:!0,children:He.jsx(Wo,{color:"text.primary",sx:{p:1,fontSize:"10px",fontWeight:700,color:Xi[500]},children:E})},E));let p="";w[E].forEach(_=>{p!==_.content&&(p=_.content,b.push(He.jsx(x6,{className:"history-item",onClick:l=>{l.stopPropagation(),l.preventDefault(),c(!1),e(_.content)},disableRipple:!0,sx:{p:1,alignItems:"baseline",borderRadius:"4px"},children:He.jsx(Wo,{color:"text.primary",sx:{whiteSpace:"pre-wrap",fontSize:"14px",maxHeight:"50px",display:"-webkit-box",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",flexGrow:0,overflow:"hidden",textOverflow:"ellipsis",lineHeight:"24px"},children:_.content})},_.key)))})})}const i=u?He.jsx(g3,{autoFocus:!0,anchorEl:u,open:t.open,onClose:()=>c(!1),PaperProps:{sx:{p:1,backgroundImage:"none",mt:-4,ml:-1,overflow:"visible",maxHeight:"314px",width:"334px",overflowY:"auto",border:w=>`1px solid ${w.palette.divider}`,boxShadow:w=>w.palette.mode==="light"?"0px 2px 4px 0px #0000000D":"0px 10px 10px 0px #0000000D"}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:b}):null;return He.jsx("div",{ref:a,children:i})}function B6t(e){const t=e.querySelector("textarea");return t?t.value.split(`
|