@opencx/widget 3.0.87 → 3.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/designs.cjs +337 -32
- package/dist/designs.cjs.map +1 -1
- package/dist/designs.js +26076 -10040
- package/dist/designs.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +2 -2
- package/dist/src/designs/react/index.d.ts +3 -2
- package/dist/src/designs/react/screens/chat/ChatCanvas.d.ts +1 -1
- package/dist/src/headless/core/__tests__/test-utils.d.ts +39 -0
- package/dist/src/headless/core/api/api-caller.d.ts +39 -0
- package/dist/src/headless/core/api/schema.d.ts +3 -0
- package/dist/src/headless/core/context/message.ctx.d.ts +1 -0
- package/dist/src/headless/core/context/session.ctx.d.ts +16 -0
- package/dist/src/headless/core/index.d.ts +1 -1
- package/dist/src/headless/react/WidgetProvider.d.ts +4 -1
- package/dist/src/headless/react/hooks/useMessages.d.ts +1 -0
- package/dist/src/headless/react/hooks/useModes.d.ts +3 -0
- package/dist/src/headless/react/hooks/useSessions.d.ts +15 -0
- package/dist/src/headless/react/index.d.ts +1 -0
- package/dist/src/headless/react/types/modes.components.d.ts +11 -0
- package/dist/useModes-BAr0RJcP.js +3183 -0
- package/dist/useModes-BAr0RJcP.js.map +1 -0
- package/dist/useModes-C4Sdixy0.cjs +85 -0
- package/dist/useModes-C4Sdixy0.cjs.map +1 -0
- package/dist/widget.ctx-Db3DyLM5.js +1564 -0
- package/dist/widget.ctx-Db3DyLM5.js.map +1 -0
- package/dist/widget.ctx-RfaE5VPy.cjs +5 -0
- package/dist/widget.ctx-RfaE5VPy.cjs.map +1 -0
- package/dist-embed/script.js +18 -18
- package/dist-embed/script.js.map +1 -1
- package/package.json +113 -55
- package/dist/is-exhaustive-9o43S91P.cjs +0 -2
- package/dist/is-exhaustive-9o43S91P.cjs.map +0 -1
- package/dist/is-exhaustive-DGJzQK69.js +0 -7
- package/dist/is-exhaustive-DGJzQK69.js.map +0 -1
- package/dist/useModes-C5Jd3NZU.cjs +0 -18
- package/dist/useModes-C5Jd3NZU.cjs.map +0 -1
- package/dist/useModes-CCwRYrkY.js +0 -1373
- package/dist/useModes-CCwRYrkY.js.map +0 -1
- package/dist/widget.ctx-BIrCsbNY.cjs +0 -5
- package/dist/widget.ctx-BIrCsbNY.cjs.map +0 -1
- package/dist/widget.ctx-D-BdBFz5.js +0 -676
- package/dist/widget.ctx-D-BdBFz5.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencx/widget",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.89",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -17,50 +17,6 @@
|
|
|
17
17
|
"name": "openchatai",
|
|
18
18
|
"url": "https://github.com/openchatai"
|
|
19
19
|
},
|
|
20
|
-
"peerDependencies": {
|
|
21
|
-
"@types/react": ">=18 <20",
|
|
22
|
-
"@types/react-dom": ">=18 <20",
|
|
23
|
-
"lucide-react": "^0.412.0",
|
|
24
|
-
"react": ">=18 <20",
|
|
25
|
-
"react-dom": ">=18 <20",
|
|
26
|
-
"rehype-raw": "^7.0.0"
|
|
27
|
-
},
|
|
28
|
-
"peerDependenciesMeta": {
|
|
29
|
-
"react": {
|
|
30
|
-
"optional": true
|
|
31
|
-
},
|
|
32
|
-
"react-dom": {
|
|
33
|
-
"optional": true
|
|
34
|
-
},
|
|
35
|
-
"@types/react": {
|
|
36
|
-
"optional": true
|
|
37
|
-
},
|
|
38
|
-
"@types/react-dom": {
|
|
39
|
-
"optional": true
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"optionalDependencies": {
|
|
43
|
-
"zod": "^3.23.8"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@radix-ui/react-avatar": "^1.1.0",
|
|
47
|
-
"@radix-ui/react-dialog": "^1.1.5",
|
|
48
|
-
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
|
49
|
-
"@radix-ui/react-popover": "^1.1.2",
|
|
50
|
-
"@radix-ui/react-slot": "^1.1.0",
|
|
51
|
-
"@radix-ui/react-switch": "^1.1.0",
|
|
52
|
-
"@radix-ui/react-tooltip": "^1.1.2",
|
|
53
|
-
"clsx": "^2.1.1",
|
|
54
|
-
"framer-motion": "^11.3.30",
|
|
55
|
-
"lodash.isequal": "^4.5.0",
|
|
56
|
-
"lucide-react": "^0.436.0",
|
|
57
|
-
"openapi-fetch": "^0.13.4",
|
|
58
|
-
"openapi-typescript": "^7.5.2",
|
|
59
|
-
"react-dropzone": "^14.3.5",
|
|
60
|
-
"tinycolor2": "^1.6.0",
|
|
61
|
-
"uuid": "^11.0.4",
|
|
62
|
-
"zod": "^3.23.8"
|
|
63
|
-
},
|
|
64
20
|
"files": [
|
|
65
21
|
"dist",
|
|
66
22
|
"dist-embed"
|
|
@@ -83,6 +39,115 @@
|
|
|
83
39
|
"require": "./dist/designs.cjs"
|
|
84
40
|
}
|
|
85
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"lodash.isequal": "^4.5.0",
|
|
44
|
+
"openapi-fetch": "^0.13.4",
|
|
45
|
+
"uuid": "^11.0.4"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@types/react": ">=18 <20",
|
|
49
|
+
"@types/react-dom": ">=18 <20",
|
|
50
|
+
"react": ">=18 <20",
|
|
51
|
+
"react-dom": ">=18 <20",
|
|
52
|
+
"@radix-ui/react-avatar": "^1.1.0",
|
|
53
|
+
"@radix-ui/react-dialog": "^1.1.5",
|
|
54
|
+
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
|
55
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
56
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
57
|
+
"@radix-ui/react-switch": "^1.1.0",
|
|
58
|
+
"@radix-ui/react-tooltip": "^1.1.2",
|
|
59
|
+
"clsx": "^2.1.1",
|
|
60
|
+
"framer-motion": "^11.3.30",
|
|
61
|
+
"lucide-react": "^0.436.0",
|
|
62
|
+
"react-dropzone": "^14.3.5",
|
|
63
|
+
"tinycolor2": "^1.6.0",
|
|
64
|
+
"zod": "^3.23.8",
|
|
65
|
+
"react-markdown": "^9.0.1",
|
|
66
|
+
"react-use": "^17.5.1",
|
|
67
|
+
"rehype-raw": "^7.0.0",
|
|
68
|
+
"remark-gfm": "^4.0.0",
|
|
69
|
+
"swr": "^2.2.5",
|
|
70
|
+
"tailwind-merge": "^2.4.0",
|
|
71
|
+
"class-variance-authority": "^0.7.0",
|
|
72
|
+
"@uiw/react-iframe": "^1.0.3"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@types/react": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@types/react-dom": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"react": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"react-dom": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@radix-ui/react-avatar": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@radix-ui/react-dialog": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@radix-ui/react-dropdown-menu": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@radix-ui/react-popover": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@radix-ui/react-slot": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@radix-ui/react-switch": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@radix-ui/react-tooltip": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"clsx": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"framer-motion": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"lucide-react": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"react-dropzone": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"tinycolor2": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
123
|
+
"zod": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"react-markdown": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
129
|
+
"react-use": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"rehype-raw": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"remark-gfm": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"swr": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"tailwind-merge": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"class-variance-authority": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"@uiw/react-iframe": {
|
|
148
|
+
"optional": true
|
|
149
|
+
}
|
|
150
|
+
},
|
|
86
151
|
"devDependencies": {
|
|
87
152
|
"@changesets/cli": "^2.27.9",
|
|
88
153
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -93,9 +158,9 @@
|
|
|
93
158
|
"@types/tinycolor2": "^1.4.6",
|
|
94
159
|
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
|
95
160
|
"@typescript-eslint/parser": "^8.29.0",
|
|
96
|
-
"@uiw/react-iframe": "^1.0.3",
|
|
97
161
|
"@vitejs/plugin-react": "^4.3.4",
|
|
98
|
-
"
|
|
162
|
+
"tailwindcss": "^3.4.6",
|
|
163
|
+
"tailwindcss-animate": "^1.0.7",
|
|
99
164
|
"eslint": "^9.23.0",
|
|
100
165
|
"eslint-config-prettier": "^10.1.1",
|
|
101
166
|
"eslint-plugin-prettier": "^5.2.6",
|
|
@@ -108,14 +173,7 @@
|
|
|
108
173
|
"lucide": "^0.525.0",
|
|
109
174
|
"postcss": "^8.4.41",
|
|
110
175
|
"prettier": "^3.5.3",
|
|
111
|
-
"
|
|
112
|
-
"react-use": "^17.5.1",
|
|
113
|
-
"rehype-raw": "^7.0.0",
|
|
114
|
-
"remark-gfm": "^4.0.0",
|
|
115
|
-
"swr": "^2.2.5",
|
|
116
|
-
"tailwind-merge": "^2.4.0",
|
|
117
|
-
"tailwindcss": "^3.4.6",
|
|
118
|
-
"tailwindcss-animate": "^1.0.7",
|
|
176
|
+
"openapi-typescript": "^7.5.2",
|
|
119
177
|
"typescript": "^5.5.4",
|
|
120
178
|
"vite": "^5.4.2",
|
|
121
179
|
"vite-plugin-dts": "4.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-exhaustive-9o43S91P.cjs","sources":["../src/headless/core/utils/is-exhaustive.ts"],"sourcesContent":["export function isExhaustive(value: never, funcName: string) {\n console.error(`Missing case for ${value} in ${funcName}`);\n}\n"],"names":["isExhaustive","value","funcName"],"mappings":"aAAgB,SAAAA,EAAaC,EAAcC,EAAkB,CAC3D,QAAQ,MAAM,oBAAoBD,CAAK,OAAOC,CAAQ,EAAE,CAC1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-exhaustive-DGJzQK69.js","sources":["../src/headless/core/utils/is-exhaustive.ts"],"sourcesContent":["export function isExhaustive(value: never, funcName: string) {\n console.error(`Missing case for ${value} in ${funcName}`);\n}\n"],"names":["isExhaustive","value","funcName"],"mappings":"AAAgB,SAAAA,EAAaC,GAAcC,GAAkB;AAC3D,UAAQ,MAAM,oBAAoBD,CAAK,OAAOC,CAAQ,EAAE;AAC1D;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("react"),Ht=require("uuid"),tt=require("react/jsx-runtime"),Kt=require("./widget.ctx-BIrCsbNY.cjs"),zt="3.0.87";class kt{constructor(t){this.components=[];const{components:n}=t;if(n&&n.forEach(r=>this.register(r)),this.components.length===0)throw new Error("No components registered");if(!this.get("fallback"))throw new Error("No fallback component registered")}register(t){const n=this.components.findIndex(r=>r.key===t.key);return n!==-1?this.components[n]=t:this.components.push(t),this}get(t){const n=this.components.find(r=>r.key.toUpperCase()===t.toUpperCase());return n||null}getComponent(t){var n;return(n=this.get(t))==null?void 0:n.component}}const nt=h.createContext(null);function Yt({options:e,children:t,components:n,storage:r,loadingComponent:o}){const s=h.useRef(null),i=h.useRef(!1),[f,g]=h.useState(null),c=h.useMemo(()=>new kt({components:n}),[n]);return h.useEffect(()=>{i.current||(i.current=!0,Kt.WidgetCtx.initialize({config:e,storage:r}).then(g))},[]),f?tt.jsx(nt.Provider,{value:{widgetCtx:f,config:e,components:n,componentStore:c,version:zt,contentIframeRef:s},children:t}):o||null}function B(){const e=h.useContext(nt);if(!e)throw new Error("useWidget must be used within a WidgetProvider");return e}function Ie(){const{config:e}=B();return e}function ee(e){return h.useSyncExternalStore(e.subscribe,e.get,e.get)}function Jt(){const{widgetCtx:e}=B();return{contactState:ee(e.contactCtx.state),createUnverifiedContact:e.contactCtx.createUnverifiedContact}}function rt(){const{widgetCtx:e}=B();return{messagesState:ee(e.messageCtx.state),sendMessage:e.messageCtx.sendMessage}}function Le(){const{widgetCtx:e}=B(),{oneOpenSessionAllowed:t}=Ie(),n=ee(e.sessionCtx.sessionState),r=ee(e.sessionCtx.sessionsState),{openSessions:o,closedSessions:s}=h.useMemo(()=>({openSessions:r.data.filter(f=>f.isOpened===!0),closedSessions:r.data.filter(f=>f.isOpened===!1)}),[r.data]),i=h.useMemo(()=>t?o.length===0:!0,[t,o.length]);return{sessionState:n,sessionsState:r,loadMoreSessions:e.sessionCtx.loadMoreSessions,resolveSession:e.sessionCtx.resolveSession,openSessions:o,closedSessions:s,canCreateNewSession:i}}function Xt(){var i;const{sessionState:e}=Le(),{messagesState:t}=rt(),n=((i=e.session)==null?void 0:i.assignee.kind)==="ai",r=t.messages.length>0?t.messages[t.messages.length-1]:null,o=(r==null?void 0:r.type)==="FROM_USER";return{isAwaitingBotReply:(n||e.isCreatingSession)&&(t.isSendingMessage||o)}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function en(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Re={exports:{}},_e={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* use-sync-external-store-shim.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ke;function tn(){if(ke)return _e;ke=1;var e=h;function t(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function f(u,d){var l=d(),_=r({inst:{value:l,getSnapshot:d}}),y=_[0].inst,C=_[1];return s(function(){y.value=l,y.getSnapshot=d,g(y)&&C({inst:y})},[u,l,d]),o(function(){return g(y)&&C({inst:y}),u(function(){g(y)&&C({inst:y})})},[u]),i(l),l}function g(u){var d=u.getSnapshot;u=u.value;try{var l=d();return!n(u,l)}catch{return!0}}function c(u,d){return d()}var a=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:f;return _e.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:a,_e}var ve={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* use-sync-external-store-shim.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Ye;function nn(){return Ye||(Ye=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=h,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(R){{for(var E=arguments.length,w=new Array(E>1?E-1:0),S=1;S<E;S++)w[S-1]=arguments[S];r("error",R,w)}}function r(R,E,w){{var S=t.ReactDebugCurrentFrame,L=S.getStackAddendum();L!==""&&(E+="%s",w=w.concat([L]));var m=w.map(function(D){return String(D)});m.unshift("Warning: "+E),Function.prototype.apply.call(console[R],console,m)}}function o(R,E){return R===E&&(R!==0||1/R===1/E)||R!==R&&E!==E}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,f=e.useEffect,g=e.useLayoutEffect,c=e.useDebugValue,a=!1,u=!1;function d(R,E,w){a||e.startTransition!==void 0&&(a=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=E();if(!u){var L=E();s(S,L)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var m=i({inst:{value:S,getSnapshot:E}}),D=m[0].inst,j=m[1];return g(function(){D.value=S,D.getSnapshot=E,l(D)&&j({inst:D})},[R,S,E]),f(function(){l(D)&&j({inst:D});var $=function(){l(D)&&j({inst:D})};return R($)},[R]),c(S),S}function l(R){var E=R.getSnapshot,w=R.value;try{var S=E();return!s(w,S)}catch{return!0}}function _(R,E,w){return E()}var y=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",C=!y,p=C?_:d,k=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p;ve.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ve}process.env.NODE_ENV==="production"?Re.exports=tn():Re.exports=nn();var rn=Re.exports;const H=()=>{},I=H(),Ee=Object,v=e=>e===I,F=e=>typeof e=="function",K=(e,t)=>({...e,...t}),on=e=>F(e.then),ue=new WeakMap;let sn=0;const oe=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let o,s;if(Ee(e)===e&&!r&&n!=RegExp){if(o=ue.get(e),o)return o;if(o=++sn+"~",ue.set(e,o),n==Array){for(o="@",s=0;s<e.length;s++)o+=oe(e[s])+",";ue.set(e,o)}if(n==Ee){o="#";const i=Ee.keys(e).sort();for(;!v(s=i.pop());)v(e[s])||(o+=s+":"+oe(e[s])+",");ue.set(e,o)}}else o=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},q=new WeakMap,Se={},ce={},Me="undefined",pe=typeof window!=Me,Te=typeof document!=Me,an=()=>pe&&typeof window.requestAnimationFrame!=Me,ot=(e,t)=>{const n=q.get(e);return[()=>!v(t)&&e.get(t)||Se,r=>{if(!v(t)){const o=e.get(t);t in ce||(ce[t]=o),n[5](t,K(o,r),o||Se)}},n[6],()=>!v(t)&&t in ce?ce[t]:!v(t)&&e.get(t)||Se]};let Ce=!0;const un=()=>Ce,[De,Ae]=pe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[H,H],cn=()=>{const e=Te&&document.visibilityState;return v(e)||e!=="hidden"},fn=e=>(Te&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Te&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),ln=e=>{const t=()=>{Ce=!0,e()},n=()=>{Ce=!1};return De("online",t),De("offline",n),()=>{Ae("online",t),Ae("offline",n)}},dn={isOnline:un,isVisible:cn},pn={initFocus:fn,initReconnect:ln},Je=!h.useId,se=!pe||"Deno"in window,gn=e=>an()?window.requestAnimationFrame(e):setTimeout(e,1),we=se?h.useEffect:h.useLayoutEffect,me=typeof navigator<"u"&&navigator.connection,Xe=!se&&me&&(["slow-2g","2g"].includes(me.effectiveType)||me.saveData),Ve=e=>{if(F(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?oe(e):"",[e,t]};let hn=0;const xe=()=>++hn,st=0,it=1,at=2,yn=3;var re={__proto__:null,ERROR_REVALIDATE_EVENT:yn,FOCUS_EVENT:st,MUTATE_EVENT:at,RECONNECT_EVENT:it};async function ut(...e){const[t,n,r,o]=e,s=K({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=s.populateCache;const f=s.rollbackOnError;let g=s.optimisticData;const c=d=>typeof f=="function"?f(d):f!==!1,a=s.throwOnError;if(F(n)){const d=n,l=[],_=t.keys();for(const y of _)!/^\$(inf|sub)\$/.test(y)&&d(t.get(y)._k)&&l.push(y);return Promise.all(l.map(u))}return u(n);async function u(d){const[l]=Ve(d);if(!l)return;const[_,y]=ot(t,l),[C,p,k,R]=q.get(t),E=()=>{const V=C[l];return(F(s.revalidate)?s.revalidate(_().data,d):s.revalidate!==!1)&&(delete k[l],delete R[l],V&&V[0])?V[0](at).then(()=>_().data):_().data};if(e.length<3)return E();let w=r,S;const L=xe();p[l]=[L,0];const m=!v(g),D=_(),j=D.data,$=D._c,z=v($)?j:$;if(m&&(g=F(g)?g(z,j):g,y({data:g,_c:z})),F(w))try{w=w(z)}catch(V){S=V}if(w&&on(w))if(w=await w.catch(V=>{S=V}),L!==p[l][0]){if(S)throw S;return w}else S&&m&&c(S)&&(i=!0,y({data:z,_c:I}));if(i&&!S)if(F(i)){const V=i(w,z);y({data:V,error:I,_c:I})}else y({data:w,error:I,_c:I});if(p[l][1]=xe(),Promise.resolve(E()).then(()=>{y({_c:I})}),S){if(a)throw S;return}return w}}const Qe=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},_n=(e,t)=>{if(!q.has(e)){const n=K(pn,t),r={},o=ut.bind(I,e);let s=H;const i={},f=(a,u)=>{const d=i[a]||[];return i[a]=d,d.push(u),()=>d.splice(d.indexOf(u),1)},g=(a,u,d)=>{e.set(a,u);const l=i[a];if(l)for(const _ of l)_(u,d)},c=()=>{if(!q.has(e)&&(q.set(e,[r,{},{},{},o,g,f]),!se)){const a=n.initFocus(setTimeout.bind(I,Qe.bind(I,r,st))),u=n.initReconnect(setTimeout.bind(I,Qe.bind(I,r,it)));s=()=>{a&&a(),u&&u(),q.delete(e)}}};return c(),[e,o,c,s]}return[e,q.get(e)[4]]},vn=(e,t,n,r,o)=>{const s=n.errorRetryCount,i=o.retryCount,f=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!v(s)&&i>s||setTimeout(r,f,o)},En=(e,t)=>oe(e)==oe(t),[ct,Sn]=_n(new Map),wn=K({onLoadingSlow:H,onSuccess:H,onError:H,onErrorRetry:vn,onDiscarded:H,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Xe?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Xe?5e3:3e3,compare:En,isPaused:()=>!1,cache:ct,mutate:Sn,fallback:{}},dn),mn=(e,t)=>{const n=K(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:i}=t;r&&s&&(n.use=r.concat(s)),o&&i&&(n.fallback=K(o,i))}return n},bn=h.createContext({}),On="$inf$",ft=pe&&window.__SWR_DEVTOOLS_USE__,Rn=ft?window.__SWR_DEVTOOLS_USE__:[],Tn=()=>{ft&&(window.__SWR_DEVTOOLS_REACT__=h)},Cn=e=>F(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Dn=()=>K(wn,h.useContext(bn)),An=e=>(t,n,r)=>e(t,n&&((...s)=>{const[i]=Ve(t),[,,,f]=q.get(ct);if(i.startsWith(On))return n(...s);const g=f[i];return v(g)?n(...s):(delete f[i],g)}),r),xn=Rn.concat(An),Pn=e=>function(...n){const r=Dn(),[o,s,i]=Cn(n),f=mn(r,i);let g=e;const{use:c}=f,a=(c||[]).concat(xn);for(let u=a.length;u--;)g=a[u](g);return g(o,s||f.fetcher||null,f)},jn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Tn();const Ze=h.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)}),be={dedupe:!0},In=(e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:f,revalidateIfStale:g,refreshInterval:c,refreshWhenHidden:a,refreshWhenOffline:u,keepPreviousData:d}=n,[l,_,y,C]=q.get(r),[p,k]=Ve(e),R=h.useRef(!1),E=h.useRef(!1),w=h.useRef(p),S=h.useRef(t),L=h.useRef(n),m=()=>L.current,D=()=>m().isVisible()&&m().isOnline(),[j,$,z,V]=ot(r,p),Y=h.useRef({}).current,Wt=v(i)?n.fallback[p]:i,Fe=(b,O)=>{for(const x in Y){const T=x;if(T==="data"){if(!o(b[T],O[T])&&(!v(b[T])||!o(ae,O[T])))return!1}else if(O[T]!==b[T])return!1}return!0},Ue=h.useMemo(()=>{const b=!p||!t?!1:v(f)?m().isPaused()||s?!1:v(g)?!0:g:f,O=P=>{const U=K(P);return delete U._k,b?{isValidating:!0,isLoading:!0,...U}:U},x=j(),T=V(),N=O(x),Z=x===T?N:O(T);let A=N;return[()=>{const P=O(j());return Fe(P,A)?(A.data=P.data,A.isLoading=P.isLoading,A.isValidating=P.isValidating,A.error=P.error,A):(A=P,P)},()=>Z]},[r,p]),J=rn.useSyncExternalStore(h.useCallback(b=>z(p,(O,x)=>{Fe(x,O)||b()}),[r,p]),Ue[0],Ue[1]),We=!R.current,qt=l[p]&&l[p].length>0,X=J.data,Q=v(X)?Wt:X,ie=J.error,qe=h.useRef(Q),ae=d?v(X)?qe.current:X:Q,Be=qt&&!v(ie)?!1:We&&!v(f)?f:m().isPaused()?!1:s?v(Q)?!1:g:v(Q)||g,$e=!!(p&&t&&We&&Be),Bt=v(J.isValidating)?$e:J.isValidating,$t=v(J.isLoading)?$e:J.isLoading,ne=h.useCallback(async b=>{const O=S.current;if(!p||!O||E.current||m().isPaused())return!1;let x,T,N=!0;const Z=b||{},A=!y[p]||!Z.dedupe,P=()=>Je?!E.current&&p===w.current&&R.current:p===w.current,U={isValidating:!1,isLoading:!1},He=()=>{$(U)},Ke=()=>{const M=y[p];M&&M[1]===T&&delete y[p]},ze={isValidating:!0};v(j().data)&&(ze.isLoading=!0);try{if(A&&($(ze),n.loadingTimeout&&v(j().data)&&setTimeout(()=>{N&&P()&&m().onLoadingSlow(p,n)},n.loadingTimeout),y[p]=[O(k),xe()]),[x,T]=y[p],x=await x,A&&setTimeout(Ke,n.dedupingInterval),!y[p]||y[p][1]!==T)return A&&P()&&m().onDiscarded(p),!1;U.error=I;const M=_[p];if(!v(M)&&(T<=M[0]||T<=M[1]||M[1]===0))return He(),A&&P()&&m().onDiscarded(p),!1;const W=j().data;U.data=o(W,x)?W:x,A&&P()&&m().onSuccess(x,p,n)}catch(M){Ke();const W=m(),{shouldRetryOnError:he}=W;W.isPaused()||(U.error=M,A&&P()&&(W.onError(M,p,W),(he===!0||F(he)&&he(M))&&(!m().revalidateOnFocus||!m().revalidateOnReconnect||D())&&W.onErrorRetry(M,p,W,Gt=>{const ye=l[p];ye&&ye[0]&&ye[0](re.ERROR_REVALIDATE_EVENT,Gt)},{retryCount:(Z.retryCount||0)+1,dedupe:!0})))}return N=!1,He(),!0},[p,r]),Ge=h.useCallback((...b)=>ut(r,w.current,...b),[]);if(we(()=>{S.current=t,L.current=n,v(X)||(qe.current=X)}),we(()=>{if(!p)return;const b=ne.bind(I,be);let O=0;const T=jn(p,l,(N,Z={})=>{if(N==re.FOCUS_EVENT){const A=Date.now();m().revalidateOnFocus&&A>O&&D()&&(O=A+m().focusThrottleInterval,b())}else if(N==re.RECONNECT_EVENT)m().revalidateOnReconnect&&D()&&b();else{if(N==re.MUTATE_EVENT)return ne();if(N==re.ERROR_REVALIDATE_EVENT)return ne(Z)}});return E.current=!1,w.current=p,R.current=!0,$({_k:k}),Be&&(v(Q)||se?b():gn(b)),()=>{E.current=!0,T()}},[p]),we(()=>{let b;function O(){const T=F(c)?c(j().data):c;T&&b!==-1&&(b=setTimeout(x,T))}function x(){!j().error&&(a||m().isVisible())&&(u||m().isOnline())?ne(be).then(O):O()}return O(),()=>{b&&(clearTimeout(b),b=-1)}},[c,a,u,p]),h.useDebugValue(ae),s&&v(Q)&&p){if(!Je&&se)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,L.current=n,E.current=!1;const b=C[p];if(!v(b)){const O=Ge(b);Ze(O)}if(v(ie)){const O=ne(be);v(ae)||(O.status="fulfilled",O.value=!0),Ze(O)}else throw ie}return{mutate:Ge,get data(){return Y.data=!0,ae},get error(){return Y.error=!0,ie},get isValidating(){return Y.isValidating=!0,Bt},get isLoading(){return Y.isLoading=!0,$t}}},Ln=Pn(In);function Mn(){const{widgetCtx:e}=B();return Ln([e.config.token],e.api.widgetPrelude,{revalidateOnFocus:!1})}function Vn(){const{widgetCtx:e}=B();return{routerState:ee(e.routerCtx.state),toSessionsScreen:e.routerCtx.toSessionsScreen,toChatScreen:e.routerCtx.toChatScreen}}var lt={},Pe=function(e,t){return Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},Pe(e,t)};function dt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},le.apply(this,arguments)};function pt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function gt(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var f=e.length-1;f>=0;f--)(i=e[f])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function ht(e,t){return function(n,r){t(n,r,e)}}function yt(e,t,n,r,o,s){function i(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var f=r.kind,g=f==="getter"?"get":f==="setter"?"set":"value",c=!t&&e?r.static?e:e.prototype:null,a=t||(c?Object.getOwnPropertyDescriptor(c,r.name):{}),u,d=!1,l=n.length-1;l>=0;l--){var _={};for(var y in r)_[y]=y==="access"?{}:r[y];for(var y in r.access)_.access[y]=r.access[y];_.addInitializer=function(p){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(p||null))};var C=(0,n[l])(f==="accessor"?{get:a.get,set:a.set}:a[g],_);if(f==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(u=i(C.get))&&(a.get=u),(u=i(C.set))&&(a.set=u),(u=i(C.init))&&o.unshift(u)}else(u=i(C))&&(f==="field"?o.unshift(u):a[g]=u)}c&&Object.defineProperty(c,r.name,a),d=!0}function _t(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function vt(e){return typeof e=="symbol"?e:"".concat(e)}function Et(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function St(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function wt(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function f(a){try{c(r.next(a))}catch(u){i(u)}}function g(a){try{c(r.throw(a))}catch(u){i(u)}}function c(a){a.done?s(a.value):o(a.value).then(f,g)}c((r=r.apply(e,t||[])).next())})}function mt(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=f(0),i.throw=f(1),i.return=f(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function f(c){return function(a){return g([c,a])}}function g(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(s=c[0]&2?o.return:c[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,c[1])).done)return s;switch(o=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(a){c=[6,a],o=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var ge=Object.create?function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]};function bt(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&ge(t,e,n)}function de(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ne(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(f){i={error:f}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Ot(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ne(arguments[t]));return e}function Rt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,f=s.length;i<f;i++,o++)r[o]=s[i];return r}function Tt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function te(e){return this instanceof te?(this.v=e,this):new te(e)}function Ct(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(l){return function(_){return Promise.resolve(_).then(l,u)}}function f(l,_){r[l]&&(o[l]=function(y){return new Promise(function(C,p){s.push([l,y,C,p])>1||g(l,y)})},_&&(o[l]=_(o[l])))}function g(l,_){try{c(r[l](_))}catch(y){d(s[0][3],y)}}function c(l){l.value instanceof te?Promise.resolve(l.value.v).then(a,u):d(s[0][2],l)}function a(l){g("next",l)}function u(l){g("throw",l)}function d(l,_){l(_),s.shift(),s.length&&g(s[0][0],s[0][1])}}function Dt(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,s){t[o]=e[o]?function(i){return(n=!n)?{value:te(e[o](i)),done:!1}:s?s(i):i}:s}}function At(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof de=="function"?de(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(f,g){i=e[s](i),o(f,g,i.done,i.value)})}}function o(s,i,f,g){Promise.resolve(g).then(function(c){s({value:c,done:f})},i)}}function xt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Nn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Pt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&ge(t,e,n);return Nn(t,e),t}function jt(e){return e&&e.__esModule?e:{default:e}}function It(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function Lt(e,t,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:t.set(e,n),n}function Mt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function Vt(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(s){return Promise.reject(s)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var Fn=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function Nt(e){function t(s){e.error=e.hasError?new Fn(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,r=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(o,function(i){return t(i),o()})}else r|=1}catch(i){t(i)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function Ft(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e}const Un={__extends:dt,__assign:le,__rest:pt,__decorate:gt,__param:ht,__esDecorate:yt,__runInitializers:_t,__propKey:vt,__setFunctionName:Et,__metadata:St,__awaiter:wt,__generator:mt,__createBinding:ge,__exportStar:bt,__values:de,__read:Ne,__spread:Ot,__spreadArrays:Rt,__spreadArray:Tt,__await:te,__asyncGenerator:Ct,__asyncDelegator:Dt,__asyncValues:At,__makeTemplateObject:xt,__importStar:Pt,__importDefault:jt,__classPrivateFieldGet:It,__classPrivateFieldSet:Lt,__classPrivateFieldIn:Mt,__addDisposableResource:Vt,__disposeResources:Nt,__rewriteRelativeImportExtension:Ft},Wn=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Vt,get __assign(){return le},__asyncDelegator:Dt,__asyncGenerator:Ct,__asyncValues:At,__await:te,__awaiter:wt,__classPrivateFieldGet:It,__classPrivateFieldIn:Mt,__classPrivateFieldSet:Lt,__createBinding:ge,__decorate:gt,__disposeResources:Nt,__esDecorate:yt,__exportStar:bt,__extends:dt,__generator:mt,__importDefault:jt,__importStar:Pt,__makeTemplateObject:xt,__metadata:St,__param:ht,__propKey:vt,__read:Ne,__rest:pt,__rewriteRelativeImportExtension:Ft,__runInitializers:_t,__setFunctionName:Et,__spread:Ot,__spreadArray:Tt,__spreadArrays:Rt,__values:de,default:Un},Symbol.toStringTag,{value:"Module"})),qn=en(Wn);var fe={},et;function Bn(){if(et)return fe;et=1,Object.defineProperty(fe,"__esModule",{value:!0});var e=h;function t(){var n=e.useRef(!1),r=e.useCallback(function(){return n.current},[]);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}return fe.default=t,fe}Object.defineProperty(lt,"__esModule",{value:!0});var je=qn,Oe=h,$n=je.__importDefault(Bn());function Gn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n={loading:!1});var r=Oe.useRef(0),o=$n.default(),s=Oe.useState(n),i=s[0],f=s[1],g=Oe.useCallback(function(){for(var c=[],a=0;a<arguments.length;a++)c[a]=arguments[a];var u=++r.current;return i.loading||f(function(d){return je.__assign(je.__assign({},d),{loading:!0})}),e.apply(void 0,c).then(function(d){return o()&&u===r.current&&f({value:d,loading:!1}),d},function(d){return o()&&u===r.current&&f({error:d,loading:!1}),d})},t);return[i,g]}var Hn=lt.default=Gn;const G=new Map;function Kn(){const[e,t]=h.useState([]),{widgetCtx:{api:n}}=B();function r(a){const u=a.map(d=>({file:d,id:Ht.v4(),status:"pending",progress:0}));t(d=>[...d,...u]),u.forEach(i)}function o(a,u){t(d=>d.map(l=>l.id===a?{...l,...u}:l))}function s(a){t(u=>u.filter(d=>d.id!==a))}const i=async a=>{const u=new AbortController;G.set(a.id,u);try{t(l=>l.map(_=>_.id===a.id?{..._,status:"uploading",progress:0}:_));const d=await n.uploadFile({file:a.file,abortSignal:u.signal,onProgress:l=>{o(a.id,{progress:l})}});o(a.id,{status:"success",fileUrl:d.fileUrl,progress:100})}catch(d){u.signal.aborted||o(a.id,{status:"error",error:d instanceof Error?d.message:"Upload failed",progress:0})}finally{G.delete(a.id)}},f=a=>{const u=G.get(a);u&&(u.abort(),G.delete(a)),s(a)},g=h.useMemo(()=>e.filter(a=>a.status==="success"&&a.fileUrl),[e]);function c(){G.forEach(a=>a.abort()),G.clear(),t([])}return h.useEffect(()=>()=>{G.forEach(a=>a.abort()),G.clear()},[]),{allFiles:e,appendFiles:r,handleCancelUpload:f,successFiles:g,emptyTheFiles:c,getFileById:a=>e.find(u=>u.id===a),getUploadProgress:a=>{var u;return((u=e.find(d=>d.id===a))==null?void 0:u.progress)??0},getUploadStatus:a=>{var u;return(u=e.find(d=>d.id===a))==null?void 0:u.status},hasErrors:e.some(a=>a.status==="error"),isUploading:e.some(a=>a.status==="uploading")}}const Ut=h.createContext(null);function zn({children:e}){const t=Ie(),[n,r]=h.useState(t.isOpen??!1);return h.useEffect(()=>{r(o=>t.isOpen??o)},[t.isOpen]),h.useEffect(()=>{const o=t.openAfterNSeconds;if(typeof o!="number"||isNaN(o))return;const s=setTimeout(()=>r(!0),o*1e3);return()=>clearTimeout(s)},[t.openAfterNSeconds]),tt.jsx(Ut.Provider,{value:{isOpen:n,setIsOpen:r},children:e})}function kn(){const e=h.useContext(Ut);if(!e)throw new Error("useWidgetTrigger must be used within a WidgetTriggerProvider");return e}function Yn(){var s;const{widgetCtx:e}=B(),{sessionState:t}=Le(),n=e.modes,r=(s=t.session)==null?void 0:s.modeId,o=n.find(i=>i.id===r);return{modes:n,activeMode:o}}exports.WidgetProvider=Yt;exports.WidgetTriggerProvider=zn;exports._default=Hn;exports.commonjsGlobal=Qt;exports.getDefaultExportFromCjs=Zt;exports.useConfig=Ie;exports.useContact=Jt;exports.useIsAwaitingBotReply=Xt;exports.useMessages=rt;exports.useModes=Yn;exports.usePreludeData=Mn;exports.usePrimitiveState=ee;exports.useSessions=Le;exports.useUploadFiles=Kn;exports.useWidget=B;exports.useWidgetRouter=Vn;exports.useWidgetTrigger=kn;
|
|
18
|
-
//# sourceMappingURL=useModes-C5Jd3NZU.cjs.map
|