@moderta/mint-ai-assistant 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/index.d.ts +76 -0
- package/dist/mint-ai-assistant.cjs +43 -0
- package/dist/mint-ai-assistant.js +7144 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @moderta/mint-ai-assistant
|
|
2
|
+
|
|
3
|
+
Embeddable **Mint AI** assistant — a floating chat widget shared across Moderta apps.
|
|
4
|
+
React component, Tailwind-styled, distributed as an npm package.
|
|
5
|
+
|
|
6
|
+
## Why this exists
|
|
7
|
+
|
|
8
|
+
The same architecture as the main `frontend` (RTK Query `api-details` → `base-slice`
|
|
9
|
+
registry, scoped store), but packaged as a **library** you can drop into any React app
|
|
10
|
+
without it touching the host's styles.
|
|
11
|
+
|
|
12
|
+
- **Isolation:** Tailwind preflight is disabled and every utility is `mint-` prefixed, so
|
|
13
|
+
embedding never resets or restyles the host app. The compiled CSS is auto-injected.
|
|
14
|
+
- **Config via props**, not env vars (the package runs inside someone else's bundle).
|
|
15
|
+
- **React + ReactDOM are peer dependencies** — the host provides them.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @moderta/mint-ai-assistant
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { MintAIAssistant } from '@moderta/mint-ai-assistant';
|
|
27
|
+
|
|
28
|
+
export function App() {
|
|
29
|
+
return (
|
|
30
|
+
<MintAIAssistant
|
|
31
|
+
baseUrl="https://api.moderta.io/ai"
|
|
32
|
+
getToken={() => localStorage.getItem('token') ?? undefined}
|
|
33
|
+
title="Mint AI"
|
|
34
|
+
placement="bottom-right"
|
|
35
|
+
enableExpandMode={false}
|
|
36
|
+
context={{ orgId: 'org_123' }}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Props (`MintAIConfig`)
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Notes |
|
|
45
|
+
| ---------------- | ----------------------------- | ---------------- | --------------------------------------- |
|
|
46
|
+
| `baseUrl` | `string` | — | Required. Base URL of the assistant API |
|
|
47
|
+
| `getToken` | `() => string \| Promise<…>` | — | Bearer token for requests |
|
|
48
|
+
| `placement` | `bottom-right \| …` | `bottom-right` | Launcher corner |
|
|
49
|
+
| `title` | `string` | `Mint AI` | Panel header title |
|
|
50
|
+
| `welcomeMessage` | `string` | greeting | Shown when there's no history |
|
|
51
|
+
| `defaultOpen` | `boolean` | `false` | Open the panel on mount |
|
|
52
|
+
| `context` | `Record<string, unknown>` | — | Forwarded with every chat request |
|
|
53
|
+
|
|
54
|
+
## API contract
|
|
55
|
+
|
|
56
|
+
The widget talks to a small API (`src/api/api-details`):
|
|
57
|
+
|
|
58
|
+
- `POST {baseUrl}/chat/messages` → `{ conversationId, reply }`
|
|
59
|
+
- `GET {baseUrl}/chat/conversations/:id` → `{ conversationId, messages }`
|
|
60
|
+
- `POST {baseUrl}/chat/feedback` → `{ success }`
|
|
61
|
+
|
|
62
|
+
## Develop
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install
|
|
66
|
+
npm run dev # playground host app at / (see dev/main.tsx)
|
|
67
|
+
npm run build # emits dist/ (ESM + CJS + types)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Project structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/
|
|
74
|
+
index.ts public API
|
|
75
|
+
mint-ai-assistant.tsx root component (provider + widget)
|
|
76
|
+
config/ props-based config (replaces global-config)
|
|
77
|
+
providers/ scoped provider stack
|
|
78
|
+
store/ widget-scoped Redux + chat UI slice
|
|
79
|
+
api/ RTK Query: api-details registry → base-slice
|
|
80
|
+
sections/assistant/ the chat UI (launcher, panel, list, composer)
|
|
81
|
+
components/iconify/ shared UI primitives
|
|
82
|
+
hooks/ useChat
|
|
83
|
+
types/ shared types
|
|
84
|
+
utils/ cn(), uid()
|
|
85
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ChatMessageData } from '@moderta/api-contracts';
|
|
2
|
+
import { ChatRole } from '@moderta/api-contracts';
|
|
3
|
+
import { JSX as JSX_2 } from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export declare type AssistantPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
7
|
+
|
|
8
|
+
export declare interface ChatMessage extends Omit<ChatMessageData, 'timestamp'> {
|
|
9
|
+
role: ChatRole | 'system';
|
|
10
|
+
createdAt: string;
|
|
11
|
+
status?: ChatMessageStatus;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare type ChatMessageStatus = 'sending' | 'sent' | 'error';
|
|
15
|
+
|
|
16
|
+
export { ChatRole }
|
|
17
|
+
|
|
18
|
+
export declare function MintAIAssistant({ children, ...config }: MintAIAssistantProps): JSX_2.Element;
|
|
19
|
+
|
|
20
|
+
export declare interface MintAIAssistantProps extends MintAIConfig {
|
|
21
|
+
/** Optional extra UI rendered inside the provider tree. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare interface MintAIConfig {
|
|
26
|
+
/** Base URL of the assistant API, e.g. `https://api.moderta.io`. */
|
|
27
|
+
baseUrl: string;
|
|
28
|
+
/** Returns the bearer token for the current user (sync or async). */
|
|
29
|
+
getToken?: TokenGetter;
|
|
30
|
+
/** Where the floating launcher sits. Default: `bottom-right`. */
|
|
31
|
+
placement?: AssistantPlacement;
|
|
32
|
+
/** Greeting shown when the chat opens with no history. */
|
|
33
|
+
welcomeMessage?: string;
|
|
34
|
+
/** Title shown in the chat panel header. Default: `ESM Sustainability AI`. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** Start the panel open. Default: `false`. */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
/** Show expand-mode entry point. Default: `false`. */
|
|
39
|
+
enableExpandMode?: boolean;
|
|
40
|
+
/** Arbitrary metadata forwarded with every chat request (e.g. orgId). */
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare type ResolvedConfig = MintAIConfig & Required<Pick<MintAIConfig, 'placement' | 'title' | 'welcomeMessage' | 'defaultOpen' | 'enableExpandMode'>>;
|
|
45
|
+
|
|
46
|
+
export declare function SampleConversationPanel({ onClose }: {
|
|
47
|
+
onClose?: () => void;
|
|
48
|
+
}): JSX_2.Element;
|
|
49
|
+
|
|
50
|
+
export declare function SampleEmptyPanel({ onClose }: {
|
|
51
|
+
onClose?: () => void;
|
|
52
|
+
}): JSX_2.Element;
|
|
53
|
+
|
|
54
|
+
export declare function SampleExpandedMode({ onCollapse, onClose, }: {
|
|
55
|
+
onCollapse?: () => void;
|
|
56
|
+
onClose?: () => void;
|
|
57
|
+
}): JSX_2.Element;
|
|
58
|
+
|
|
59
|
+
export declare function SampleShowcase({ initial }: {
|
|
60
|
+
initial?: Screen_2;
|
|
61
|
+
}): JSX_2.Element;
|
|
62
|
+
|
|
63
|
+
declare type Screen_2 = 'empty' | 'conversation' | 'expanded';
|
|
64
|
+
|
|
65
|
+
export declare type TokenGetter = () => string | undefined | Promise<string | undefined>;
|
|
66
|
+
|
|
67
|
+
export declare function useChat(): {
|
|
68
|
+
messages: ChatMessage[];
|
|
69
|
+
draft: string;
|
|
70
|
+
isLoading: any;
|
|
71
|
+
send: (raw?: string) => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export declare function useConfig(): ResolvedConfig;
|
|
75
|
+
|
|
76
|
+
export { }
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(`.mint-pointer-events-none{pointer-events:none}.mint-fixed{position:fixed}.mint-absolute{position:absolute}.mint-relative{position:relative}.mint-inset-0{top:0;right:0;bottom:0;left:0}.mint-bottom-4{bottom:1rem}.mint-bottom-6{bottom:1.5rem}.mint-bottom-8{bottom:2rem}.mint-left-4{left:1rem}.mint-left-\\[66px\\]{left:66px}.mint-right-2{right:.5rem}.mint-right-4{right:1rem}.mint-right-6{right:1.5rem}.mint-right-\\[66px\\]{right:66px}.mint-top-1\\/2{top:50%}.mint-top-4{top:1rem}.mint-z-widget{z-index:2147483000}.mint-col-span-1{grid-column:span 1 / span 1}.mint-m-0{margin:0}.mint-mx-2{margin-left:.5rem;margin-right:.5rem}.mint-mx-6{margin-left:1.5rem;margin-right:1.5rem}.mint-mt-0{margin-top:0}.mint-mt-1{margin-top:.25rem}.mint-mt-2{margin-top:.5rem}.mint-mt-3{margin-top:.75rem}.mint-mt-4{margin-top:1rem}.mint-mt-6{margin-top:1.5rem}.mint-inline-block{display:inline-block}.mint-flex{display:flex}.mint-inline-flex{display:inline-flex}.mint-grid{display:grid}.mint-h-10{height:2.5rem}.mint-h-11{height:2.75rem}.mint-h-12{height:3rem}.mint-h-14{height:3.5rem}.mint-h-2{height:.5rem}.mint-h-5{height:1.25rem}.mint-h-6{height:1.5rem}.mint-h-7{height:1.75rem}.mint-h-8{height:2rem}.mint-h-\\[640px\\]{height:640px}.mint-h-\\[82px\\]{height:82px}.mint-h-\\[min\\(92vh\\,614px\\)\\]{height:min(92vh,614px)}.mint-h-px{height:1px}.mint-max-h-20{max-height:5rem}.mint-max-h-\\[85vh\\]{max-height:85vh}.mint-min-h-screen{min-height:100vh}.mint-w-10{width:2.5rem}.mint-w-11{width:2.75rem}.mint-w-12{width:3rem}.mint-w-14{width:3.5rem}.mint-w-2{width:.5rem}.mint-w-7{width:1.75rem}.mint-w-8{width:2rem}.mint-w-\\[226px\\]{width:226px}.mint-w-\\[420px\\]{width:420px}.mint-w-\\[min\\(1080px\\,calc\\(100vw-32px\\)\\)\\]{width:min(1080px,calc(100vw - 32px))}.mint-w-fit{width:-moz-fit-content;width:fit-content}.mint-w-full{width:100%}.mint-min-w-0{min-width:0px}.mint-max-w-\\[78\\%\\]{max-width:78%}.mint-max-w-\\[calc\\(100vw-32px\\)\\]{max-width:calc(100vw - 32px)}.mint-max-w-full{max-width:100%}.mint-flex-1{flex:1 1 0%}.mint-shrink-0{flex-shrink:0}.mint--translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes mint-bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.mint-animate-bounce{animation:mint-bounce 1s infinite}.mint-resize-none{resize:none}.mint-appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.mint-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.mint-flex-row-reverse{flex-direction:row-reverse}.mint-flex-col{flex-direction:column}.mint-flex-wrap{flex-wrap:wrap}.mint-items-start{align-items:flex-start}.mint-items-end{align-items:flex-end}.mint-items-center{align-items:center}.mint-justify-start{justify-content:flex-start}.mint-justify-end{justify-content:flex-end}.mint-justify-center{justify-content:center}.mint-justify-between{justify-content:space-between}.mint-gap-1{gap:.25rem}.mint-gap-1\\.5{gap:.375rem}.mint-gap-2{gap:.5rem}.mint-gap-3{gap:.75rem}.mint-gap-5{gap:1.25rem}.mint-gap-6{gap:1.5rem}.mint-gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.mint-gap-y-3{row-gap:.75rem}.mint-self-end{align-self:flex-end}.mint-overflow-hidden{overflow:hidden}.mint-overflow-y-auto{overflow-y:auto}.mint-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mint-whitespace-nowrap{white-space:nowrap}.mint-whitespace-pre-wrap{white-space:pre-wrap}.mint-break-words{overflow-wrap:break-word}.mint-rounded{border-radius:.25rem}.mint-rounded-2xl{border-radius:1rem}.mint-rounded-full{border-radius:9999px}.mint-rounded-lg{border-radius:.5rem}.mint-rounded-md{border-radius:.375rem}.mint-rounded-xl{border-radius:.75rem}.mint-rounded-tl-sm{border-top-left-radius:.125rem}.mint-rounded-tr-sm{border-top-right-radius:.125rem}.mint-border{border-width:1px}.mint-border-0{border-width:0px}.mint-border-b{border-bottom-width:1px}.mint-border-\\[\\#56E3AB\\]{--tw-border-opacity: 1;border-color:rgb(86 227 171 / var(--tw-border-opacity, 1))}.mint-border-grey-100{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.mint-border-grey-200{--tw-border-opacity: 1;border-color:rgb(244 246 248 / var(--tw-border-opacity, 1))}.mint-border-grey-300{--tw-border-opacity: 1;border-color:rgb(223 227 232 / var(--tw-border-opacity, 1))}.mint-border-primary-light{--tw-border-opacity: 1;border-color:rgb(91 228 155 / var(--tw-border-opacity, 1))}.mint-bg-\\[\\#56E3AB\\]\\/\\[0\\.05\\]{background-color:#56e3ab0d}.mint-bg-\\[\\#5EECB0\\]{--tw-bg-opacity: 1;background-color:rgb(94 236 176 / var(--tw-bg-opacity, 1))}.mint-bg-\\[\\#D9D9D9\\]{--tw-bg-opacity: 1;background-color:rgb(217 217 217 / var(--tw-bg-opacity, 1))}.mint-bg-\\[\\#E5E7EB\\]{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.mint-bg-black\\/20{background-color:#0003}.mint-bg-error\\/10{background-color:#ff56301a}.mint-bg-grey-100{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.mint-bg-grey-200{--tw-bg-opacity: 1;background-color:rgb(244 246 248 / var(--tw-bg-opacity, 1))}.mint-bg-grey-300{--tw-bg-opacity: 1;background-color:rgb(223 227 232 / var(--tw-bg-opacity, 1))}.mint-bg-grey-500{--tw-bg-opacity: 1;background-color:rgb(145 158 171 / var(--tw-bg-opacity, 1))}.mint-bg-primary{--tw-bg-opacity: 1;background-color:rgb(0 167 111 / var(--tw-bg-opacity, 1))}.mint-bg-primary-dark{--tw-bg-opacity: 1;background-color:rgb(0 120 103 / var(--tw-bg-opacity, 1))}.mint-bg-primary-light{--tw-bg-opacity: 1;background-color:rgb(91 228 155 / var(--tw-bg-opacity, 1))}.mint-bg-primary-lighter\\/40{background-color:#c8fad666}.mint-bg-transparent{background-color:transparent}.mint-bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.mint-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.mint-from-primary-light{--tw-gradient-from: #5BE49B var(--tw-gradient-from-position);--tw-gradient-to: rgb(91 228 155 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.mint-to-primary{--tw-gradient-to: #00A76F var(--tw-gradient-to-position)}.mint-p-0{padding:0}.mint-p-1{padding:.25rem}.mint-p-2{padding:.5rem}.mint-p-3{padding:.75rem}.mint-p-4{padding:1rem}.mint-p-6{padding:1.5rem}.mint-px-1{padding-left:.25rem;padding-right:.25rem}.mint-px-2{padding-left:.5rem;padding-right:.5rem}.mint-px-3{padding-left:.75rem;padding-right:.75rem}.mint-px-4{padding-left:1rem;padding-right:1rem}.mint-px-5{padding-left:1.25rem;padding-right:1.25rem}.mint-px-6{padding-left:1.5rem;padding-right:1.5rem}.mint-px-\\[66px\\]{padding-left:66px;padding-right:66px}.mint-py-1{padding-top:.25rem;padding-bottom:.25rem}.mint-py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.mint-py-2{padding-top:.5rem;padding-bottom:.5rem}.mint-py-3{padding-top:.75rem;padding-bottom:.75rem}.mint-py-4{padding-top:1rem;padding-bottom:1rem}.mint-py-5{padding-top:1.25rem;padding-bottom:1.25rem}.mint-pb-28{padding-bottom:7rem}.mint-pb-5{padding-bottom:1.25rem}.mint-pb-\\[60px\\]{padding-bottom:60px}.mint-pr-5{padding-right:1.25rem}.mint-pt-3{padding-top:.75rem}.mint-text-center{text-align:center}.mint-text-2xl{font-size:1.5rem;line-height:2rem}.mint-text-3xl{font-size:1.875rem;line-height:2.25rem}.mint-text-\\[10px\\]{font-size:10px}.mint-text-\\[11px\\]{font-size:11px}.mint-text-\\[21px\\]{font-size:21px}.mint-text-\\[22px\\]{font-size:22px}.mint-text-\\[24px\\]{font-size:24px}.mint-text-\\[28px\\]{font-size:28px}.mint-text-\\[6px\\]{font-size:6px}.mint-text-\\[7px\\]{font-size:7px}.mint-text-lg{font-size:1.125rem;line-height:1.75rem}.mint-text-sm{font-size:.875rem;line-height:1.25rem}.mint-text-xs{font-size:.75rem;line-height:1rem}.mint-font-bold{font-weight:700}.mint-font-extrabold{font-weight:800}.mint-font-medium{font-weight:500}.mint-font-normal{font-weight:400}.mint-font-semibold{font-weight:600}.mint-leading-3{line-height:.75rem}.mint-leading-4{line-height:1rem}.mint-leading-5{line-height:1.25rem}.mint-leading-6{line-height:1.5rem}.mint-leading-7{line-height:1.75rem}.mint-leading-8{line-height:2rem}.mint-leading-9{line-height:2.25rem}.mint-leading-none{line-height:1}.mint-leading-relaxed{line-height:1.625}.mint-text-\\[\\#56E3AB\\]{--tw-text-opacity: 1;color:rgb(86 227 171 / var(--tw-text-opacity, 1))}.mint-text-error{--tw-text-opacity: 1;color:rgb(255 86 48 / var(--tw-text-opacity, 1))}.mint-text-grey-500{--tw-text-opacity: 1;color:rgb(145 158 171 / var(--tw-text-opacity, 1))}.mint-text-grey-600{--tw-text-opacity: 1;color:rgb(99 115 129 / var(--tw-text-opacity, 1))}.mint-text-grey-700{--tw-text-opacity: 1;color:rgb(69 79 91 / var(--tw-text-opacity, 1))}.mint-text-grey-800{--tw-text-opacity: 1;color:rgb(28 37 46 / var(--tw-text-opacity, 1))}.mint-text-grey-900{--tw-text-opacity: 1;color:rgb(20 26 33 / var(--tw-text-opacity, 1))}.mint-text-primary{--tw-text-opacity: 1;color:rgb(0 167 111 / var(--tw-text-opacity, 1))}.mint-text-primary-contrast{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.mint-text-primary-light{--tw-text-opacity: 1;color:rgb(91 228 155 / var(--tw-text-opacity, 1))}.mint-opacity-60{opacity:.6}.mint-shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.mint-shadow-widget{--tw-shadow: 0 0 2px 0 rgba(145,158,171,.2), 0 12px 24px -4px rgba(145,158,171,.12);--tw-shadow-colored: 0 0 2px 0 var(--tw-shadow-color), 0 12px 24px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.mint-outline-none{outline:2px solid transparent;outline-offset:2px}.mint-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.mint-transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.\\[animation-delay\\:-0\\.15s\\]{animation-delay:-.15s}.\\[animation-delay\\:-0\\.3s\\]{animation-delay:-.3s}.mint-ai-root,.mint-ai-root *{box-sizing:border-box}.mint-ai-root{font-family:'"Public Sans Variable"',system-ui,sans-serif;line-height:1.5;color:#1c252e}.mint-ai-root button,.mint-ai-root textarea{font-family:inherit}.mint-ai-root button{-webkit-appearance:none;-moz-appearance:none;appearance:none}.mint-ai-shell{width:min(440px,calc(100vw - 32px));height:min(560px,calc(100vh - 112px));padding:8px;border-radius:16px;background:#d0d0d0}.mint-ai-panel{width:100%;height:100%;font-family:Roboto,'"Public Sans Variable"',system-ui,sans-serif}.mint-ai-root .mint-scroll{scrollbar-width:thin;scrollbar-color:#c4cdd5 transparent}.mint-ai-root .mint-scroll::-webkit-scrollbar{width:6px;height:6px}.mint-ai-root .mint-scroll::-webkit-scrollbar-thumb{background-color:#c4cdd5;border-radius:9999px}.placeholder\\:mint-text-grey-600::-moz-placeholder{--tw-text-opacity: 1;color:rgb(99 115 129 / var(--tw-text-opacity, 1))}.placeholder\\:mint-text-grey-600::placeholder{--tw-text-opacity: 1;color:rgb(99 115 129 / var(--tw-text-opacity, 1))}.hover\\:mint-scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:mint-border-primary:hover{--tw-border-opacity: 1;border-color:rgb(0 167 111 / var(--tw-border-opacity, 1))}.hover\\:mint-bg-grey-100:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\\:mint-bg-primary-darker:hover{--tw-bg-opacity: 1;background-color:rgb(0 75 80 / var(--tw-bg-opacity, 1))}.hover\\:mint-bg-primary-lighter:hover{--tw-bg-opacity: 1;background-color:rgb(200 250 214 / var(--tw-bg-opacity, 1))}.hover\\:mint-text-primary:hover{--tw-text-opacity: 1;color:rgb(0 167 111 / var(--tw-text-opacity, 1))}.focus\\:mint-border-primary:focus{--tw-border-opacity: 1;border-color:rgb(0 167 111 / var(--tw-border-opacity, 1))}.disabled\\:mint-opacity-40:disabled{opacity:.4}.disabled\\:hover\\:mint-scale-100:hover:disabled{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}`)),document.head.appendChild(t)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
|
|
2
|
+
"use strict";var xo=Object.defineProperty;var Eo=(e,t,n)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var re=(e,t,n)=>Eo(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),T=require("react");function So(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ie=So(T);var vt={exports:{}},nn={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* use-sync-external-store-with-selector.production.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var nr;function No(){if(nr)return nn;nr=1;var e=T;function t(a,u){return a===u&&(a!==0||1/a===1/u)||a!==a&&u!==u}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,o=e.useEffect,s=e.useMemo,c=e.useDebugValue;return nn.useSyncExternalStoreWithSelector=function(a,u,l,y,O){var g=i(null);if(g.current===null){var p={hasValue:!1,value:null};g.current=p}else p=g.current;g=s(function(){function m(d){if(!E){if(E=!0,k=d,d=y(d),O!==void 0&&p.hasValue){var f=p.value;if(O(f,d))return b=f}return b=d}if(f=b,n(k,d))return f;var S=y(d);return O!==void 0&&O(f,S)?(k=d,f):(k=d,b=S)}var E=!1,k,b,v=l===void 0?null:l;return[function(){return m(u())},v===null?void 0:function(){return m(v())}]},[u,l,y,O]);var _=r(a,g[0],g[1]);return o(function(){p.hasValue=!0,p.value=_},[_]),c(_),_},nn}var rn={};/**
|
|
11
|
+
* @license React
|
|
12
|
+
* use-sync-external-store-with-selector.development.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var rr;function _o(){return rr||(rr=1,process.env.NODE_ENV!=="production"&&(function(){function e(a,u){return a===u&&(a!==0||1/a===1/u)||a!==a&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=T,n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,o=t.useEffect,s=t.useMemo,c=t.useDebugValue;rn.useSyncExternalStoreWithSelector=function(a,u,l,y,O){var g=i(null);if(g.current===null){var p={hasValue:!1,value:null};g.current=p}else p=g.current;g=s(function(){function m(d){if(!E){if(E=!0,k=d,d=y(d),O!==void 0&&p.hasValue){var f=p.value;if(O(f,d))return b=f}return b=d}if(f=b,n(k,d))return f;var S=y(d);return O!==void 0&&O(f,S)?(k=d,f):(k=d,b=S)}var E=!1,k,b,v=l===void 0?null:l;return[function(){return m(u())},v===null?void 0:function(){return m(v())}]},[u,l,y,O]);var _=r(a,g[0],g[1]);return o(function(){p.hasValue=!0,p.value=_},[_]),c(_),_},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),rn}var ir;function Oo(){return ir||(ir=1,process.env.NODE_ENV==="production"?vt.exports=No():vt.exports=_o()),vt.exports}var Io=Oo();function ni(e){e()}function Co(){let e=null,t=null;return{clear(){e=null,t=null},notify(){ni(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var or={notify(){},get:()=>[]};function jo(e,t){let n,r=or,i=0,o=!1;function s(_){l();const m=r.subscribe(_);let E=!1;return()=>{E||(E=!0,m(),y())}}function c(){r.notify()}function a(){p.onStateChange&&p.onStateChange()}function u(){return o}function l(){i++,n||(n=e.subscribe(a),r=Co())}function y(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=or)}function O(){o||(o=!0,l())}function g(){o&&(o=!1,y())}const p={addNestedSub:s,notifyNestedSubs:c,handleChangeWrapper:a,isSubscribed:u,trySubscribe:O,tryUnsubscribe:g,getListeners:()=>r};return p}var ko=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Po=ko(),Ao=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Do=Ao(),Ro=()=>Po||Do?ie.useLayoutEffect:ie.useEffect,Mo=Ro();function sr(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Ye(e,t){if(sr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(!Object.prototype.hasOwnProperty.call(t,n[i])||!sr(e[n[i]],t[n[i]]))return!1;return!0}var on=Symbol.for("react-redux-context"),sn=typeof globalThis<"u"?globalThis:{};function To(){if(!ie.createContext)return{};const e=sn[on]??(sn[on]=new Map);let t=e.get(ie.createContext);return t||(t=ie.createContext(null),process.env.NODE_ENV!=="production"&&(t.displayName="ReactRedux"),e.set(ie.createContext,t)),t}var _e=To();function Vo(e){const{children:t,context:n,serverState:r,store:i}=e,o=ie.useMemo(()=>{const a=jo(i),u={store:i,subscription:a,getServerState:r?()=>r:void 0};if(process.env.NODE_ENV==="production")return u;{const{identityFunctionCheck:l="once",stabilityCheck:y="once"}=e;return Object.assign(u,{stabilityCheck:y,identityFunctionCheck:l})}},[i,r]),s=ie.useMemo(()=>i.getState(),[i]);Mo(()=>{const{subscription:a}=o;return a.onStateChange=a.notifyNestedSubs,a.trySubscribe(),s!==i.getState()&&a.notifyNestedSubs(),()=>{a.tryUnsubscribe(),a.onStateChange=void 0}},[o,s]);const c=n||_e;return ie.createElement(c.Provider,{value:o},t)}var Fo=Vo;function Vn(e=_e){return function(){const n=ie.useContext(e);if(process.env.NODE_ENV!=="production"&&!n)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return n}}var ri=Vn();function ii(e=_e){const t=e===_e?ri:Vn(e),n=()=>{const{store:r}=t();return r};return Object.assign(n,{withTypes:()=>n}),n}var oi=ii();function Qo(e=_e){const t=e===_e?oi:ii(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var si=Qo(),$o=(e,t)=>e===t;function Lo(e=_e){const t=e===_e?ri:Vn(e),n=(r,i={})=>{const{equalityFn:o=$o}=typeof i=="function"?{equalityFn:i}:i;if(process.env.NODE_ENV!=="production"){if(!r)throw new Error("You must pass a selector to useSelector");if(typeof r!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof o!="function")throw new Error("You must pass a function as an equality function to useSelector")}const s=t(),{store:c,subscription:a,getServerState:u}=s,l=ie.useRef(!0),y=ie.useCallback({[r.name](g){const p=r(g);if(process.env.NODE_ENV!=="production"){const{devModeChecks:_={}}=typeof i=="function"?{}:i,{identityFunctionCheck:m,stabilityCheck:E}=s,{identityFunctionCheck:k,stabilityCheck:b}={stabilityCheck:E,identityFunctionCheck:m,..._};if(b==="always"||b==="once"&&l.current){const v=r(g);if(!o(p,v)){let d;try{throw new Error}catch(f){({stack:d}=f)}console.warn("Selector "+(r.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
|
|
19
|
+
Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:g,selected:p,selected2:v,stack:d})}}if((k==="always"||k==="once"&&l.current)&&p===g){let v;try{throw new Error}catch(d){({stack:v}=d)}console.warn("Selector "+(r.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
|
|
20
|
+
Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:v})}l.current&&(l.current=!1)}return p}}[r.name],[r]),O=Io.useSyncExternalStoreWithSelector(a.addNestedSub,c.getState,u||c.getState,y,o);return ie.useDebugValue(O),O};return Object.assign(n,{withTypes:()=>n}),n}var ci=Lo(),qo=ni;let bn=null;function Uo(e){bn=e}function zo(){if(!bn)throw new Error("[mint-ai-assistant] Config not initialised. Render <MintAIAssistant /> before calling the API.");return bn}const Wo={placement:"bottom-right",title:"ESM Sustainability AI",welcomeMessage:"What can I help with?",defaultOpen:!1,enableExpandMode:!1},ai=T.createContext(null);function Bo({config:e,children:t}){const n=T.useMemo(()=>({...Wo,...e}),[e]);return Uo(n),P.jsx(ai.Provider,{value:n,children:t})}function ut(){const e=T.useContext(ai);if(!e)throw new Error("useConfig must be used within <MintAIAssistant />");return e}function ee(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Ho=typeof Symbol=="function"&&Symbol.observable||"@@observable",cr=Ho,cn=()=>Math.random().toString(36).substring(7).split("").join("."),Ko={INIT:`@@redux/INIT${cn()}`,REPLACE:`@@redux/REPLACE${cn()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${cn()}`},ke=Ko;function me(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Go(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(Xo(e))return"date";if(Jo(e))return"error";const n=Yo(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Yo(e){return typeof e.constructor=="function"?e.constructor.name:null}function Jo(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function Xo(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Se(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=Go(e)),t}function ui(e,t,n){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?ee(2):`Expected the root reducer to be a function. Instead, received: '${Se(e)}'`);if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?ee(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(process.env.NODE_ENV==="production"?ee(1):`Expected the enhancer to be a function. Instead, received: '${Se(n)}'`);return n(ui)(e,t)}let r=e,i=t,o=new Map,s=o,c=0,a=!1;function u(){s===o&&(s=new Map,o.forEach((m,E)=>{s.set(E,m)}))}function l(){if(a)throw new Error(process.env.NODE_ENV==="production"?ee(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function y(m){if(typeof m!="function")throw new Error(process.env.NODE_ENV==="production"?ee(4):`Expected the listener to be a function. Instead, received: '${Se(m)}'`);if(a)throw new Error(process.env.NODE_ENV==="production"?ee(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let E=!0;u();const k=c++;return s.set(k,m),function(){if(E){if(a)throw new Error(process.env.NODE_ENV==="production"?ee(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");E=!1,u(),s.delete(k),o=null}}}function O(m){if(!me(m))throw new Error(process.env.NODE_ENV==="production"?ee(7):`Actions must be plain objects. Instead, the actual type was: '${Se(m)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof m.type>"u")throw new Error(process.env.NODE_ENV==="production"?ee(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof m.type!="string")throw new Error(process.env.NODE_ENV==="production"?ee(17):`Action "type" property must be a string. Instead, the actual type was: '${Se(m.type)}'. Value was: '${m.type}' (stringified)`);if(a)throw new Error(process.env.NODE_ENV==="production"?ee(9):"Reducers may not dispatch actions.");try{a=!0,i=r(i,m)}finally{a=!1}return(o=s).forEach(k=>{k()}),m}function g(m){if(typeof m!="function")throw new Error(process.env.NODE_ENV==="production"?ee(10):`Expected the nextReducer to be a function. Instead, received: '${Se(m)}`);r=m,O({type:ke.REPLACE})}function p(){const m=y;return{subscribe(E){if(typeof E!="object"||E===null)throw new Error(process.env.NODE_ENV==="production"?ee(11):`Expected the observer to be an object. Instead, received: '${Se(E)}'`);function k(){const v=E;v.next&&v.next(l())}return k(),{unsubscribe:m(k)}},[cr](){return this}}}return O({type:ke.INIT}),{dispatch:O,subscribe:y,getState:l,replaceReducer:g,[cr]:p}}function ar(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function Zo(e,t,n,r){const i=Object.keys(t),o=n&&n.type===ke.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(i.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!me(e))return`The ${o} has unexpected type of "${Se(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter(c=>!t.hasOwnProperty(c)&&!r[c]);if(s.forEach(c=>{r[c]=!0}),!(n&&n.type===ke.REPLACE)&&s.length>0)return`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${o}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`}function es(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:ke.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?ee(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof n(void 0,{type:ke.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?ee(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${ke.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function li(e){const t=Object.keys(e),n={};for(let s=0;s<t.length;s++){const c=t[s];process.env.NODE_ENV!=="production"&&typeof e[c]>"u"&&ar(`No reducer provided for key "${c}"`),typeof e[c]=="function"&&(n[c]=e[c])}const r=Object.keys(n);let i;process.env.NODE_ENV!=="production"&&(i={});let o;try{es(n)}catch(s){o=s}return function(c={},a){if(o)throw o;if(process.env.NODE_ENV!=="production"){const y=Zo(c,n,a,i);y&&ar(y)}let u=!1;const l={};for(let y=0;y<r.length;y++){const O=r[y],g=n[O],p=c[O],_=g(p,a);if(typeof _>"u"){const m=a&&a.type;throw new Error(process.env.NODE_ENV==="production"?ee(14):`When called with an action of type ${m?`"${String(m)}"`:"(unknown type)"}, the slice reducer for key "${O}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}l[O]=_,u=u||_!==p}return u=u||r.length!==Object.keys(c).length,u?l:c}}function Dt(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function ts(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(process.env.NODE_ENV==="production"?ee(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:i.getState,dispatch:(a,...u)=>o(a,...u)},c=e.map(a=>a(s));return o=Dt(...c)(i.dispatch),{...i,dispatch:o}}}function Fn(e){return me(e)&&"type"in e&&typeof e.type=="string"}var Qn=Symbol.for("immer-nothing"),Je=Symbol.for("immer-draftable"),Z=Symbol.for("immer-state"),fi=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function J(e,...t){if(process.env.NODE_ENV!=="production"){const n=fi[e],r=Ne(n)?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var oe=Object,Pe=oe.getPrototypeOf,tt="constructor",lt="prototype",vn="configurable",Rt="enumerable",Ct="writable",nt="value",se=e=>!!e&&!!e[Z];function ce(e){var t;return e?di(e)||dt(e)||!!e[Je]||!!((t=e[tt])!=null&&t[Je])||mt(e)||pt(e):!1}var ns=oe[lt][tt].toString(),ur=new WeakMap;function di(e){if(!e||!Fe(e))return!1;const t=Pe(e);if(t===null||t===oe[lt])return!0;const n=oe.hasOwnProperty.call(t,tt)&&t[tt];if(n===Object)return!0;if(!Ne(n))return!1;let r=ur.get(n);return r===void 0&&(r=Function.toString.call(n),ur.set(n,r)),r===ns}function rs(e){return se(e)||J(15,e),e[Z].base_}function ft(e,t,n=!0){Ae(e)===0?(n?Reflect.ownKeys(e):oe.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Ae(e){const t=e[Z];return t?t.type_:dt(e)?1:mt(e)?2:pt(e)?3:0}var Xe=(e,t,n=Ae(e))=>n===2?e.has(t):oe[lt].hasOwnProperty.call(e,t),he=(e,t,n=Ae(e))=>n===2?e.get(t):e[t],Mt=(e,t,n,r=Ae(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function is(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var dt=Array.isArray,mt=e=>e instanceof Map,pt=e=>e instanceof Set,Fe=e=>typeof e=="object",Ne=e=>typeof e=="function",an=e=>typeof e=="boolean";function os(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ss=e=>Fe(e)?e==null?void 0:e[Z]:null,ye=e=>e.copy_||e.base_,$n=e=>e.modified_?e.copy_:e.base_;function wn(e,t){if(mt(e))return new Map(e);if(pt(e))return new Set(e);if(dt(e))return Array[lt].slice.call(e);const n=di(e);if(t===!0||t==="class_only"&&!n){const r=oe.getOwnPropertyDescriptors(e);delete r[Z];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const s=i[o],c=r[s];c[Ct]===!1&&(c[Ct]=!0,c[vn]=!0),(c.get||c.set)&&(r[s]={[vn]:!0,[Ct]:!0,[Rt]:c[Rt],[nt]:e[s]})}return oe.create(Pe(e),r)}else{const r=Pe(e);if(r!==null&&n)return{...e};const i=oe.create(r);return oe.assign(i,e)}}function Ln(e,t=!1){return Ht(e)||se(e)||!ce(e)||(Ae(e)>1&&oe.defineProperties(e,{set:wt,add:wt,clear:wt,delete:wt}),oe.freeze(e),t&&ft(e,(n,r)=>{Ln(r,!0)},!1)),e}function cs(){J(2)}var wt={[nt]:cs};function Ht(e){return e===null||!Fe(e)?!0:oe.isFrozen(e)}var Tt="MapSet",Vt="Patches",lr="ArrayMethods",Ft={};function De(e){const t=Ft[e];return t||J(0,e),t}var fr=e=>!!Ft[e];function as(e,t){Ft[e]||(Ft[e]=t)}var rt,mi=()=>rt,us=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:fr(Tt)?De(Tt):void 0,arrayMethodsPlugin_:fr(lr)?De(lr):void 0});function dr(e,t){t&&(e.patchPlugin_=De(Vt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function xn(e){En(e),e.drafts_.forEach(ls),e.drafts_=null}function En(e){e===rt&&(rt=e.parent_)}var mr=e=>rt=us(rt,e);function ls(e){const t=e[Z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Z].modified_&&(xn(t),J(4)),ce(e)&&(e=hr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[Z].base_,e,t)}else e=hr(t,n);return fs(t,e,!0),xn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Qn?e:void 0}function hr(e,t){if(Ht(t))return t;const n=t[Z];if(!n)return Qt(t,e.handledSet_,e);if(!Kt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);yi(n,e)}return n.copy_}function fs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ln(t,n)}function pi(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Kt=(e,t)=>e.scope_===t,ds=[];function hi(e,t,n,r){const i=ye(e),o=e.type_;if(r!==void 0&&he(i,r,o)===t){Mt(i,r,n,o);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;ft(i,(a,u)=>{if(se(u)){const l=c.get(u)||[];l.push(a),c.set(u,l)}})}const s=e.draftLocations_.get(t)??ds;for(const c of s)Mt(i,c,n,o)}function ms(e,t,n){e.callbacks_.push(function(i){var c;const o=t;if(!o||!Kt(o,i))return;(c=i.mapSetPlugin_)==null||c.fixSetContents(o);const s=$n(o);hi(e,o.draft_??o,s,n),yi(o,i)})}function yi(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const o=i.getPath(e);o&&i.generatePatches_(e,o,t)}pi(e)}}function ps(e,t,n){const{scope_:r}=e;if(se(n)){const i=n[Z];Kt(i,r)&&i.callbacks_.push(function(){jt(e);const s=$n(i);hi(e,n,s,t)})}else ce(n)&&e.callbacks_.push(function(){const o=ye(e);e.type_===3?o.has(n)&&Qt(n,r.handledSet_,r):he(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Qt(he(e.copy_,t,e.type_),r.handledSet_,r)})}function Qt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||se(e)||t.has(e)||!ce(e)||Ht(e)||(t.add(e),ft(e,(r,i)=>{if(se(i)){const o=i[Z];if(Kt(o,n)){const s=$n(o);Mt(e,r,s,e.type_),pi(o)}}else ce(i)&&Qt(i,t,n)})),e}function hs(e,t){const n=dt(e),r={type_:n?1:0,scope_:t?t.scope_:mi(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=$t;n&&(i=[r],o=it);const{revoke:s,proxy:c}=Proxy.revocable(i,o);return r.draft_=c,r.revoke_=s,[c,r]}var $t={get(e,t){if(t===Z)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=ye(e);if(!Xe(i,t,e.type_))return ys(e,i,t);const o=i[t];if(e.finalized_||!ce(o)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&os(t))return o;if(o===un(e.base_,t)){jt(e);const s=e.type_===1?+t:t,c=Nn(e.scope_,o,e,s);return e.copy_[s]=c}return o},has(e,t){return t in ye(e)},ownKeys(e){return Reflect.ownKeys(ye(e))},set(e,t,n){const r=gi(ye(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=un(ye(e),t),o=i==null?void 0:i[Z];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(is(n,i)&&(n!==void 0||Xe(e.base_,t,e.type_)))return!0;jt(e),Sn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),ps(e,t,n)),!0},deleteProperty(e,t){return jt(e),un(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Sn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ye(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Ct]:!0,[vn]:e.type_!==1||t!=="length",[Rt]:r[Rt],[nt]:n[t]}},defineProperty(){J(11)},getPrototypeOf(e){return Pe(e.base_)},setPrototypeOf(){J(12)}},it={};for(let e in $t){let t=$t[e];it[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}it.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&J(13),it.set.call(this,e,t,void 0)};it.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&J(14),$t.set.call(this,e[0],t,n,e[0])};function un(e,t){const n=e[Z];return(n?ye(n):e)[t]}function ys(e,t,n){var i;const r=gi(t,n);return r?nt in r?r[nt]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function gi(e,t){if(!(t in e))return;let n=Pe(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Pe(n)}}function Sn(e){e.modified_||(e.modified_=!0,e.parent_&&Sn(e.parent_))}function jt(e){e.copy_||(e.assigned_=new Map,e.copy_=wn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ne(t)&&!Ne(n)){const o=n;n=t;const s=this;return function(a=o,...u){return s.produce(a,l=>n.call(this,l,...u))}}Ne(n)||J(6),r!==void 0&&!Ne(r)&&J(7);let i;if(ce(t)){const o=mr(this),s=Nn(o,t,void 0);let c=!0;try{i=n(s),c=!1}finally{c?xn(o):En(o)}return dr(o,r),pr(i,o)}else if(!t||!Fe(t)){if(i=n(t),i===void 0&&(i=t),i===Qn&&(i=void 0),this.autoFreeze_&&Ln(i,!0),r){const o=[],s=[];De(Vt).generateReplacementPatches_(t,i,{patches_:o,inversePatches_:s}),r(o,s)}return i}else J(1,t)},this.produceWithPatches=(t,n)=>{if(Ne(t))return(s,...c)=>this.produceWithPatches(s,a=>t(a,...c));let r,i;return[this.produce(t,n,(s,c)=>{r=s,i=c}),r,i]},an(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),an(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),an(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ce(e)||J(8),se(e)&&(e=bi(e));const t=mr(this),n=Nn(t,e,void 0);return n[Z].isManual_=!0,En(t),n}finishDraft(e,t){const n=e&&e[Z];(!n||!n.isManual_)&&J(9);const{scope_:r}=n;return dr(r,t),pr(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=De(Vt).applyPatches_;return se(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Nn(e,t,n,r){const[i,o]=mt(t)?De(Tt).proxyMap_(t,n):pt(t)?De(Tt).proxySet_(t,n):hs(t,n);return((n==null?void 0:n.scope_)??mi()).drafts_.push(i),o.callbacks_=(n==null?void 0:n.callbacks_)??[],o.key_=r,n&&r!==void 0?ms(n,o,r):o.callbacks_.push(function(a){var l;(l=a.mapSetPlugin_)==null||l.fixSetContents(o);const{patchPlugin_:u}=a;o.modified_&&u&&u.generatePatches_(o,[],a)}),i}function bi(e){return se(e)||J(10,e),vi(e)}function vi(e){if(!ce(e)||Ht(e))return e;const t=e[Z];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=wn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=wn(e,!0);return ft(n,(i,o)=>{Mt(n,i,vi(o))},r),t&&(t.finalized_=!1),n}function bs(){process.env.NODE_ENV!=="production"&&fi.push('Sets cannot have "replace" patches.',function(p){return"Unsupported patch operation: "+p},function(p){return"Cannot apply patch, path doesn't resolve: "+p},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");function t(p,_=[]){if(p.key_!==void 0){const m=p.parent_.copy_??p.parent_.base_,E=ss(he(m,p.key_)),k=he(m,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||E!=null&&E.base_!==p.base_)return null;const b=p.parent_.type_===3;let v;if(b){const d=p.parent_;v=Array.from(d.drafts_.keys()).indexOf(p.key_)}else v=p.key_;if(!(b&&m.size>v||Xe(m,v)))return null;_.push(v)}if(p.parent_)return t(p.parent_,_);_.reverse();try{n(p.copy_,_)}catch{return null}return _}function n(p,_){let m=p;for(let E=0;E<_.length-1;E++){const k=_[E];if(m=he(m,k),!Fe(m)||m===null)throw new Error(`Cannot resolve path at '${_.join("/")}'`)}return m}const r="replace",i="add",o="remove";function s(p,_,m){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:E,inversePatches_:k}=m;switch(p.type_){case 0:case 2:return a(p,_,E,k);case 1:return c(p,_,E,k);case 3:return u(p,_,E,k)}}function c(p,_,m,E){let{base_:k,assigned_:b}=p,v=p.copy_;v.length<k.length&&([k,v]=[v,k],[m,E]=[E,m]);const d=p.allIndicesReassigned_===!0;for(let f=0;f<k.length;f++){const S=v[f],I=k[f];if((d||(b==null?void 0:b.get(f.toString())))&&S!==I){const x=S==null?void 0:S[Z];if(x&&x.modified_)continue;const h=_.concat([f]);m.push({op:r,path:h,value:g(S)}),E.push({op:r,path:h,value:g(I)})}}for(let f=k.length;f<v.length;f++){const S=_.concat([f]);m.push({op:i,path:S,value:g(v[f])})}for(let f=v.length-1;k.length<=f;--f){const S=_.concat([f]);E.push({op:o,path:S})}}function a(p,_,m,E){const{base_:k,copy_:b,type_:v}=p;ft(p.assigned_,(d,f)=>{const S=he(k,d,v),I=he(b,d,v),N=f?Xe(k,d)?r:i:o;if(S===I&&N===r)return;const x=_.concat(d);m.push(N===o?{op:N,path:x}:{op:N,path:x,value:g(I)}),E.push(N===i?{op:o,path:x}:N===o?{op:i,path:x,value:g(S)}:{op:r,path:x,value:g(S)})})}function u(p,_,m,E){let{base_:k,copy_:b}=p,v=0;k.forEach(d=>{if(!b.has(d)){const f=_.concat([v]);m.push({op:o,path:f,value:d}),E.unshift({op:i,path:f,value:d})}v++}),v=0,b.forEach(d=>{if(!k.has(d)){const f=_.concat([v]);m.push({op:i,path:f,value:d}),E.unshift({op:o,path:f,value:d})}v++})}function l(p,_,m){const{patches_:E,inversePatches_:k}=m;E.push({op:r,path:[],value:_===Qn?void 0:_}),k.push({op:r,path:[],value:p})}function y(p,_){return _.forEach(m=>{const{path:E,op:k}=m;let b=p;for(let S=0;S<E.length-1;S++){const I=Ae(b);let N=E[S];typeof N!="string"&&typeof N!="number"&&(N=""+N),(I===0||I===1)&&(N==="__proto__"||N===tt)&&J(19),Ne(b)&&N===lt&&J(19),b=he(b,N),Fe(b)||J(18,E.join("/"))}const v=Ae(b),d=O(m.value),f=E[E.length-1];switch(k){case r:switch(v){case 2:return b.set(f,d);case 3:J(16);default:return b[f]=d}case i:switch(v){case 1:return f==="-"?b.push(d):b.splice(f,0,d);case 2:return b.set(f,d);case 3:return b.add(d);default:return b[f]=d}case o:switch(v){case 1:return b.splice(f,1);case 2:return b.delete(f);case 3:return b.delete(m.value);default:return delete b[f]}default:J(17,k)}}),p}function O(p){if(!ce(p))return p;if(dt(p))return p.map(O);if(mt(p))return new Map(Array.from(p.entries()).map(([m,E])=>[m,O(E)]));if(pt(p))return new Set(Array.from(p).map(O));const _=Object.create(Pe(p));for(const m in p)_[m]=O(p[m]);return Xe(p,Je)&&(_[Je]=p[Je]),_}function g(p){return se(p)?O(p):p}as(Vt,{applyPatches_:y,generatePatches_:s,generateReplacementPatches_:l,getPath:t})}var ot=new gs,ht=ot.produce,wi=ot.produceWithPatches.bind(ot),yr=ot.applyPatches.bind(ot),vs=(e,t,n)=>{if(t.length===1&&t[0]===n){let r=!1;try{const i={};e(i)===i&&(r=!0)}catch{}if(r){let i;try{throw new Error}catch(o){({stack:i}=o)}console.warn(`The result function returned its own inputs without modification. e.g
|
|
21
|
+
\`createSelector([state => state.todos], todos => todos)\`
|
|
22
|
+
This could lead to inefficient memoization and unnecessary re-renders.
|
|
23
|
+
Ensure transformation logic is in the result function, and extraction logic is in the input selectors.`,{stack:i})}}},ws=(e,t,n)=>{const{memoize:r,memoizeOptions:i}=t,{inputSelectorResults:o,inputSelectorResultsCopy:s}=e,c=r(()=>({}),...i);if(!(c.apply(null,o)===c.apply(null,s))){let u;try{throw new Error}catch(l){({stack:u}=l)}console.warn(`An input selector returned a different result when passed same arguments.
|
|
24
|
+
This means your output selector will likely run more frequently than intended.
|
|
25
|
+
Avoid returning a new reference inside your input selector, e.g.
|
|
26
|
+
\`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)\``,{arguments:n,firstInputs:o,secondInputs:s,stack:u})}},xs={inputStabilityCheck:"once",identityFunctionCheck:"once"};function Es(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Ss(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var gr=e=>Array.isArray(e)?e:[e];function Ns(e){const t=Array.isArray(e[0])?e[0]:e;return Ss(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function br(e,t){const n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}var _s=(e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...xs,...t};return{identityFunctionCheck:{shouldRun:n==="always"||n==="once"&&e,run:vs},inputStabilityCheck:{shouldRun:r==="always"||r==="once"&&e,run:ws}}},Os=class{constructor(e){this.value=e}deref(){return this.value}},Is=()=>typeof WeakRef>"u"?Os:WeakRef,xi=Is(),Cs=0,vr=1;function xt(){return{s:Cs,v:void 0,o:null,p:null}}function js(e){return e instanceof xi?e.deref():e}function Lt(e,t={}){let n=xt();const{resultEqualityCheck:r}=t;let i,o=0;function s(){let c=n;const{length:a}=arguments;for(let y=0,O=a;y<O;y++){const g=arguments[y];if(typeof g=="function"||typeof g=="object"&&g!==null){let p=c.o;p===null&&(c.o=p=new WeakMap);const _=p.get(g);_===void 0?(c=xt(),p.set(g,c)):c=_}else{let p=c.p;p===null&&(c.p=p=new Map);const _=p.get(g);_===void 0?(c=xt(),p.set(g,c)):c=_}}const u=c;let l;if(c.s===vr)l=c.v;else if(l=e.apply(null,arguments),o++,r){const y=js(i);y!=null&&r(y,l)&&(l=y,o!==0&&o--),i=typeof l=="object"&&l!==null||typeof l=="function"?new xi(l):l}return u.s=vr,u.v=l,l}return s.clearCache=()=>{n=xt(),s.resetResultsCount()},s.resultsCount=()=>o,s.resetResultsCount=()=>{o=0},s}function ks(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,s=0,c,a={},u=i.pop();typeof u=="object"&&(a=u,u=i.pop()),Es(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const l={...n,...a},{memoize:y,memoizeOptions:O=[],argsMemoize:g=Lt,argsMemoizeOptions:p=[]}=l,_=gr(O),m=gr(p),E=Ns(i),k=y(function(){return o++,u.apply(null,arguments)},..._);let b=!0;const v=g(function(){s++;const f=br(E,arguments);if(c=k.apply(null,f),process.env.NODE_ENV!=="production"){const{devModeChecks:S={}}=l,{identityFunctionCheck:I,inputStabilityCheck:N}=_s(b,S);if(I.shouldRun&&I.run(u,f,c),N.shouldRun){const x=br(E,arguments);N.run({inputSelectorResults:f,inputSelectorResultsCopy:x},{memoize:y,memoizeOptions:_},arguments)}b&&(b=!1)}return c},...m);return Object.assign(v,{resultFunc:u,memoizedResultFunc:k,dependencies:E,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>c,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:y,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var Ei=ks(Lt);function Si(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var Ps=Si(),As=Si,Ds=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Dt:Dt.apply(null,arguments)},Ni=e=>e&&typeof e.match=="function";function de(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(process.env.NODE_ENV==="production"?U(0):"prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Fn(r)&&r.type===e,n}function Rs(e){return typeof e=="function"&&"type"in e&&Ni(e)}function Ms(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
|
|
27
|
+
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}function Ts(e={}){if(process.env.NODE_ENV==="production")return()=>n=>r=>n(r);const{isActionCreator:t=Rs}=e;return()=>n=>r=>(t(r)&&console.warn(Ms(r.type)),n(r))}function _i(e,t){let n=0;return{measureTime(r){const i=Date.now();try{return r()}finally{const o=Date.now();n+=o-i}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms.
|
|
28
|
+
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
|
|
29
|
+
It is disabled in production builds, so you don't need to worry about that.`)}}}var Oi=class He extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,He.prototype)}static get[Symbol.species](){return He}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new He(...t[0].concat(this)):new He(...t.concat(this))}};function wr(e){return ce(e)?ht(e,()=>{}):e}function Et(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function Vs(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function Fs(e,t,n){const r=Ii(e,t,n);return{detectMutations(){return Ci(e,t,r,n)}}}function Ii(e,t=[],n,r="",i=new Set){const o={value:n};if(!e(n)&&!i.has(n)){i.add(n),o.children={};const s=t.length>0;for(const c in n){const a=r?r+"."+c:c;s&&t.some(l=>l instanceof RegExp?l.test(a):a===l)||(o.children[c]=Ii(e,t,n[c],a))}}return o}function Ci(e,t=[],n,r,i=!1,o=""){const s=n?n.value:void 0,c=s===r;if(i&&!c&&!Number.isNaN(r))return{wasMutated:!0,path:o};if(e(s)||e(r))return{wasMutated:!1};const a={};for(let l in n.children)a[l]=!0;for(let l in r)a[l]=!0;const u=t.length>0;for(let l in a){const y=o?o+"."+l:l;if(u&&t.some(p=>p instanceof RegExp?p.test(y):y===p))continue;const O=Ci(e,t,n.children[l],r[l],c,y);if(O.wasMutated)return O}return{wasMutated:!1}}function Qs(e={}){if(process.env.NODE_ENV==="production")return()=>t=>n=>t(n);{let t=function(c,a,u,l){return JSON.stringify(c,n(a,l),u)},n=function(c,a){let u=[],l=[];return a||(a=function(y,O){return u[0]===O?"[Circular ~]":"[Circular ~."+l.slice(0,u.indexOf(O)).join(".")+"]"}),function(y,O){if(u.length>0){var g=u.indexOf(this);~g?u.splice(g+1):u.push(this),~g?l.splice(g,1/0,y):l.push(y),~u.indexOf(O)&&(O=a.call(this,y,O))}else u.push(O);return c==null?O:c.call(this,y,O)}},{isImmutable:r=Vs,ignoredPaths:i,warnAfter:o=32}=e;const s=Fs.bind(null,r,i);return({getState:c})=>{let a=c(),u=s(a),l;return y=>O=>{const g=_i(o,"ImmutableStateInvariantMiddleware");g.measureTime(()=>{if(a=c(),l=u.detectMutations(),u=s(a),l.wasMutated)throw new Error(process.env.NODE_ENV==="production"?U(19):`A state mutation was detected between dispatches, in the path '${l.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const p=y(O);return g.measureTime(()=>{if(a=c(),l=u.detectMutations(),u=s(a),l.wasMutated)throw new Error(process.env.NODE_ENV==="production"?U(20):`A state mutation was detected inside a dispatch, in the path: ${l.path||""}. Take a look at the reducer(s) handling the action ${t(O)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),g.warnIfExceeded(),p}}}}function ji(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||me(e)}function _n(e,t="",n=ji,r,i=[],o){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||o!=null&&o.has(e))return!1;const c=r!=null?r(e):Object.entries(e),a=i.length>0;for(const[u,l]of c){const y=t?t+"."+u:u;if(!(a&&i.some(g=>g instanceof RegExp?g.test(y):y===g))){if(!n(l))return{keyPath:y,value:l};if(typeof l=="object"&&(s=_n(l,y,n,r,i,o),s))return s}}return o&&ki(e)&&o.add(e),!1}function ki(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if(!(typeof t!="object"||t===null)&&!ki(t))return!1;return!0}function $s(e={}){if(process.env.NODE_ENV==="production")return()=>t=>n=>t(n);{const{isSerializable:t=ji,getEntries:n,ignoredActions:r=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:o=[],warnAfter:s=32,ignoreState:c=!1,ignoreActions:a=!1,disableCache:u=!1}=e,l=!u&&WeakSet?new WeakSet:void 0;return y=>O=>g=>{if(!Fn(g))return O(g);const p=O(g),_=_i(s,"SerializableStateInvariantMiddleware");return!a&&!(r.length&&r.indexOf(g.type)!==-1)&&_.measureTime(()=>{const m=_n(g,"",t,n,i,l);if(m){const{keyPath:E,value:k}=m;console.error(`A non-serializable value was detected in an action, in the path: \`${E}\`. Value:`,k,`
|
|
30
|
+
Take a look at the logic that dispatched this action: `,g,`
|
|
31
|
+
(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
|
|
32
|
+
(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),c||(_.measureTime(()=>{const m=y.getState(),E=_n(m,"",t,n,o,l);if(E){const{keyPath:k,value:b}=E;console.error(`A non-serializable value was detected in the state, in the path: \`${k}\`. Value:`,b,`
|
|
33
|
+
Take a look at the reducer(s) handling this action type: ${g.type}.
|
|
34
|
+
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),_.warnIfExceeded()),p}}}function St(e){return typeof e=="boolean"}var Ls=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let s=new Oi;if(n&&(St(n)?s.push(Ps):s.push(As(n.extraArgument))),process.env.NODE_ENV!=="production"){if(r){let c={};St(r)||(c=r),s.unshift(Qs(c))}if(i){let c={};St(i)||(c=i),s.push($s(c))}if(o){let c={};St(o)||(c=o),s.unshift(Ts(c))}}return s},Gt="RTK_autoBatch",qe=()=>e=>({payload:e,meta:{[Gt]:!0}}),xr=e=>t=>{setTimeout(t,e)},qs=(e,t)=>n=>{let r=!1;const i=()=>{r||(r=!0,cancelAnimationFrame(o),clearTimeout(s),n())},o=e(i),s=setTimeout(i,t)},Us=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,s=!1;const c=new Set,a=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?qs(window.requestAnimationFrame,100):xr(10):e.type==="callback"?e.queueNotification:xr(e.timeout),u=()=>{s=!1,o&&(o=!1,c.forEach(l=>l()))};return Object.assign({},r,{subscribe(l){const y=()=>i&&l(),O=r.subscribe(y);return c.add(l),()=>{O(),c.delete(l)}},dispatch(l){var y;try{return i=!((y=l==null?void 0:l.meta)!=null&&y[Gt]),o=!i,o&&(s||(s=!0,a(u))),r.dispatch(l)}finally{i=!0}}})},zs=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new Oi(e);return r&&i.push(Us(typeof r=="object"?r:void 0)),i};function Ws(e){const t=Ls(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:o=!0,preloadedState:s=void 0,enhancers:c=void 0}=e||{};let a;if(typeof n=="function")a=n;else if(me(n))a=li(n);else throw new Error(process.env.NODE_ENV==="production"?U(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(process.env.NODE_ENV!=="production"&&r&&typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?U(2):"`middleware` field must be a callback");let u;if(typeof r=="function"){if(u=r(t),process.env.NODE_ENV!=="production"&&!Array.isArray(u))throw new Error(process.env.NODE_ENV==="production"?U(3):"when using a middleware builder function, an array of middleware must be returned")}else u=t();if(process.env.NODE_ENV!=="production"&&u.some(_=>typeof _!="function"))throw new Error(process.env.NODE_ENV==="production"?U(4):"each middleware provided to configureStore must be a function");if(process.env.NODE_ENV!=="production"&&o){let _=new Set;u.forEach(m=>{if(_.has(m))throw new Error(process.env.NODE_ENV==="production"?U(42):"Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");_.add(m)})}let l=Dt;i&&(l=Ds({trace:process.env.NODE_ENV!=="production",...typeof i=="object"&&i}));const y=ts(...u),O=zs(y);if(process.env.NODE_ENV!=="production"&&c&&typeof c!="function")throw new Error(process.env.NODE_ENV==="production"?U(5):"`enhancers` field must be a callback");let g=typeof c=="function"?c(O):O();if(process.env.NODE_ENV!=="production"&&!Array.isArray(g))throw new Error(process.env.NODE_ENV==="production"?U(6):"`enhancers` callback must return an array");if(process.env.NODE_ENV!=="production"&&g.some(_=>typeof _!="function"))throw new Error(process.env.NODE_ENV==="production"?U(7):"each enhancer provided to configureStore must be a function");process.env.NODE_ENV!=="production"&&u.length&&!g.includes(y)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const p=l(...g);return ui(a,s,p)}function Pi(e){const t={},n=[];let r;const i={addCase(o,s){if(process.env.NODE_ENV!=="production"){if(n.length>0)throw new Error(process.env.NODE_ENV==="production"?U(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error(process.env.NODE_ENV==="production"?U(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const c=typeof o=="string"?o:o.type;if(!c)throw new Error(process.env.NODE_ENV==="production"?U(28):"`builder.addCase` cannot be called with an empty action type");if(c in t)throw new Error(process.env.NODE_ENV==="production"?U(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${c}'`);return t[c]=s,i},addAsyncThunk(o,s){if(process.env.NODE_ENV!=="production"&&r)throw new Error(process.env.NODE_ENV==="production"?U(43):"`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");return s.pending&&(t[o.pending.type]=s.pending),s.rejected&&(t[o.rejected.type]=s.rejected),s.fulfilled&&(t[o.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:o.settled,reducer:s.settled}),i},addMatcher(o,s){if(process.env.NODE_ENV!=="production"&&r)throw new Error(process.env.NODE_ENV==="production"?U(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:o,reducer:s}),i},addDefaultCase(o){if(process.env.NODE_ENV!=="production"&&r)throw new Error(process.env.NODE_ENV==="production"?U(31):"`builder.addDefaultCase` can only be called once");return r=o,i}};return e(i),[t,n,r]}function Bs(e){return typeof e=="function"}function Hs(e,t){if(process.env.NODE_ENV!=="production"&&typeof t=="object")throw new Error(process.env.NODE_ENV==="production"?U(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[n,r,i]=Pi(t),o;if(Bs(e))o=()=>wr(e());else{const c=wr(e);o=()=>c}function s(c=o(),a){let u=[n[a.type],...r.filter(({matcher:l})=>l(a)).map(({reducer:l})=>l)];return u.filter(l=>!!l).length===0&&(u=[i]),u.reduce((l,y)=>{if(y)if(se(l)){const g=y(l,a);return g===void 0?l:g}else{if(ce(l))return ht(l,O=>y(O,a));{const O=y(l,a);if(O===void 0){if(l===null)return l;throw Error("A case reducer on a non-draftable value must not return undefined")}return O}}return l},c)}return s.getInitialState=o,s}var Ai=(e,t)=>Ni(e)?e.match(t):e(t);function ge(...e){return t=>e.some(n=>Ai(n,t))}function Ze(...e){return t=>e.every(n=>Ai(n,t))}function Yt(e,t){if(!e||!e.meta)return!1;const n=typeof e.meta.requestId=="string",r=t.indexOf(e.meta.requestStatus)>-1;return n&&r}function yt(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function qn(...e){return e.length===0?t=>Yt(t,["pending"]):yt(e)?ge(...e.map(t=>t.pending)):qn()(e[0])}function Qe(...e){return e.length===0?t=>Yt(t,["rejected"]):yt(e)?ge(...e.map(t=>t.rejected)):Qe()(e[0])}function Jt(...e){const t=n=>n&&n.meta&&n.meta.rejectedWithValue;return e.length===0?Ze(Qe(...e),t):yt(e)?Ze(Qe(...e),t):Jt()(e[0])}function Oe(...e){return e.length===0?t=>Yt(t,["fulfilled"]):yt(e)?ge(...e.map(t=>t.fulfilled)):Oe()(e[0])}function On(...e){return e.length===0?t=>Yt(t,["pending","fulfilled","rejected"]):yt(e)?ge(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):On()(e[0])}var Ks="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Un=(e=21)=>{let t="",n=e;for(;n--;)t+=Ks[Math.random()*64|0];return t},Gs=["name","message","stack","code"],ln=class{constructor(e,t){re(this,"payload");re(this,"meta");re(this,"_type");this.payload=e,this.meta=t}},Er=class{constructor(e,t){re(this,"payload");re(this,"meta");re(this,"_type");this.payload=e,this.meta=t}},Ys=e=>{if(typeof e=="object"&&e!==null){const t={};for(const n of Gs)typeof e[n]=="string"&&(t[n]=e[n]);return t}return{message:String(e)}},Sr="External signal was aborted",Nr=(()=>{function e(t,n,r){const i=de(t+"/fulfilled",(a,u,l,y)=>({payload:a,meta:{...y||{},arg:l,requestId:u,requestStatus:"fulfilled"}})),o=de(t+"/pending",(a,u,l)=>({payload:void 0,meta:{...l||{},arg:u,requestId:a,requestStatus:"pending"}})),s=de(t+"/rejected",(a,u,l,y,O)=>({payload:y,error:(r&&r.serializeError||Ys)(a||"Rejected"),meta:{...O||{},arg:l,requestId:u,rejectedWithValue:!!y,requestStatus:"rejected",aborted:(a==null?void 0:a.name)==="AbortError",condition:(a==null?void 0:a.name)==="ConditionError"}}));function c(a,{signal:u}={}){return(l,y,O)=>{const g=r!=null&&r.idGenerator?r.idGenerator(a):Un(),p=new AbortController;let _,m;function E(b){m=b,p.abort()}u&&(u.aborted?E(Sr):u.addEventListener("abort",()=>E(Sr),{once:!0}));const k=(async function(){var d,f;let b;try{let S=(d=r==null?void 0:r.condition)==null?void 0:d.call(r,a,{getState:y,extra:O});if(Xs(S)&&(S=await S),S===!1||p.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const I=new Promise((N,x)=>{_=()=>{x({name:"AbortError",message:m||"Aborted"})},p.signal.addEventListener("abort",_,{once:!0})});l(o(g,a,(f=r==null?void 0:r.getPendingMeta)==null?void 0:f.call(r,{requestId:g,arg:a},{getState:y,extra:O}))),b=await Promise.race([I,Promise.resolve(n(a,{dispatch:l,getState:y,extra:O,requestId:g,signal:p.signal,abort:E,rejectWithValue:((N,x)=>new ln(N,x)),fulfillWithValue:((N,x)=>new Er(N,x))})).then(N=>{if(N instanceof ln)throw N;return N instanceof Er?i(N.payload,g,a,N.meta):i(N,g,a)})])}catch(S){b=S instanceof ln?s(null,g,a,S.payload,S.meta):s(S,g,a)}finally{_&&p.signal.removeEventListener("abort",_)}return r&&!r.dispatchConditionRejection&&s.match(b)&&b.meta.condition||l(b),b})();return Object.assign(k,{abort:E,requestId:g,arg:a,unwrap(){return k.then(Js)}})}}return Object.assign(c,{pending:o,rejected:s,fulfilled:i,settled:ge(s,i),typePrefix:t})}return e.withTypes=()=>e,e})();function Js(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function Xs(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var Zs=Symbol.for("rtk-slice-createasyncthunk");function ec(e,t){return`${e}/${t}`}function tc({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[Zs];return function(i){const{name:o,reducerPath:s=o}=i;if(!o)throw new Error(process.env.NODE_ENV==="production"?U(11):"`name` is a required option for createSlice");typeof process<"u"&&process.env.NODE_ENV==="development"&&i.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const c=(typeof i.reducers=="function"?i.reducers(rc()):i.reducers)||{},a=Object.keys(c),u={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(v,d){const f=typeof v=="string"?v:v.type;if(!f)throw new Error(process.env.NODE_ENV==="production"?U(12):"`context.addCase` cannot be called with an empty action type");if(f in u.sliceCaseReducersByType)throw new Error(process.env.NODE_ENV==="production"?U(13):"`context.addCase` cannot be called with two reducers for the same action type: "+f);return u.sliceCaseReducersByType[f]=d,l},addMatcher(v,d){return u.sliceMatchers.push({matcher:v,reducer:d}),l},exposeAction(v,d){return u.actionCreators[v]=d,l},exposeCaseReducer(v,d){return u.sliceCaseReducersByName[v]=d,l}};a.forEach(v=>{const d=c[v],f={reducerName:v,type:ec(o,v),createNotation:typeof i.reducers=="function"};oc(d)?cc(f,d,l,t):ic(f,d,l)});function y(){if(process.env.NODE_ENV!=="production"&&typeof i.extraReducers=="object")throw new Error(process.env.NODE_ENV==="production"?U(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[v={},d=[],f=void 0]=typeof i.extraReducers=="function"?Pi(i.extraReducers):[i.extraReducers],S={...v,...u.sliceCaseReducersByType};return Hs(i.initialState,I=>{for(let N in S)I.addCase(N,S[N]);for(let N of u.sliceMatchers)I.addMatcher(N.matcher,N.reducer);for(let N of d)I.addMatcher(N.matcher,N.reducer);f&&I.addDefaultCase(f)})}const O=v=>v,g=new Map,p=new WeakMap;let _;function m(v,d){return _||(_=y()),_(v,d)}function E(){return _||(_=y()),_.getInitialState()}function k(v,d=!1){function f(I){let N=I[v];if(typeof N>"u"){if(d)N=Et(p,f,E);else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?U(15):"selectSlice returned undefined for an uninjected slice reducer")}return N}function S(I=O){const N=Et(g,d,()=>new WeakMap);return Et(N,I,()=>{const x={};for(const[h,w]of Object.entries(i.selectors??{}))x[h]=nc(w,I,()=>Et(p,I,E),d);return x})}return{reducerPath:v,getSelectors:S,get selectors(){return S(f)},selectSlice:f}}const b={name:o,reducer:m,actions:u.actionCreators,caseReducers:u.sliceCaseReducersByName,getInitialState:E,...k(s),injectInto(v,{reducerPath:d,...f}={}){const S=d??s;return v.inject({reducerPath:S,reducer:m},f),{...b,...k(S,!0)}}};return b}}function nc(e,t,n,r){function i(o,...s){let c=t(o);if(typeof c>"u"){if(r)c=n();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?U(16):"selectState returned undefined for an uninjected slice reducer")}return e(c,...s)}return i.unwrapped=e,i}var je=tc();function rc(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function ic({type:e,reducerName:t,createNotation:n},r,i){let o,s;if("reducer"in r){if(n&&!sc(r))throw new Error(process.env.NODE_ENV==="production"?U(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");o=r.reducer,s=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,s?de(e,s):de(e))}function oc(e){return e._reducerDefinitionType==="asyncThunk"}function sc(e){return e._reducerDefinitionType==="reducerWithPrepare"}function cc({type:e,reducerName:t},n,r,i){if(!i)throw new Error(process.env.NODE_ENV==="production"?U(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:o,fulfilled:s,pending:c,rejected:a,settled:u,options:l}=n,y=i(e,o,l);r.exposeAction(t,y),s&&r.addCase(y.fulfilled,s),c&&r.addCase(y.pending,c),a&&r.addCase(y.rejected,a),u&&r.addMatcher(y.settled,u),r.exposeCaseReducer(t,{fulfilled:s||Nt,pending:c||Nt,rejected:a||Nt,settled:u||Nt})}function Nt(){}function U(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ac=class extends Error{constructor(t){super(t[0].message);re(this,"issues");this.name="SchemaError",this.issues=t}},Di=(e=>(e.uninitialized="uninitialized",e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected",e))(Di||{}),be="uninitialized",In="pending",Ke="fulfilled",Ge="rejected";function _r(e){return{status:e,isUninitialized:e===be,isLoading:e===In,isSuccess:e===Ke,isError:e===Ge}}var Or=me;function zn(e,t){if(e===t||!(Or(e)&&Or(t)||Array.isArray(e)&&Array.isArray(t)))return t;const n=Object.keys(t),r=Object.keys(e);let i=n.length===r.length;const o=Array.isArray(t)?[]:{};for(const s of n)o[s]=zn(e[s],t[s]),i&&(i=e[s]===o[s]);return i?e:o}function Cn(e,t,n){return e.reduce((r,i,o)=>(t(i,o)&&r.push(n(i,o)),r),[]).flat()}function uc(e){return new RegExp("(^|:)//").test(e)}function lc(){return typeof document>"u"?!0:document.visibilityState!=="hidden"}function Wn(e){return e!=null}function Ir(e){return[...(e==null?void 0:e.values())??[]].filter(Wn)}function fc(){return typeof navigator>"u"||navigator.onLine===void 0?!0:navigator.onLine}var dc=e=>e.replace(/\/$/,""),mc=e=>e.replace(/^\//,"");function pc(e,t){if(!e)return t;if(!t)return e;if(uc(t))return t;const n=e.endsWith("/")||!t.startsWith("?")?"/":"";return e=dc(e),t=mc(t),`${e}${n}${t}`}function qt(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var jn=()=>new Map,hc=e=>{const t=new AbortController;return setTimeout(()=>{const n="signal timed out",r="TimeoutError";t.abort(typeof DOMException<"u"?new DOMException(n,r):Object.assign(new Error(n),{name:r}))},e),t.signal},yc=(...e)=>{for(const n of e)if(n.aborted)return AbortSignal.abort(n.reason);const t=new AbortController;for(const n of e)n.addEventListener("abort",()=>t.abort(n.reason),{signal:t.signal,once:!0});return t.signal},Cr=(...e)=>fetch(...e),gc=e=>e.status>=200&&e.status<=299,bc=e=>/ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"");function jr(e){if(!me(e))return e;const t={...e};for(const[n,r]of Object.entries(t))r===void 0&&delete t[n];return t}var vc=e=>typeof e=="object"&&(me(e)||Array.isArray(e)||typeof e.toJSON=="function");function wc({baseUrl:e,prepareHeaders:t=y=>y,fetchFn:n=Cr,paramsSerializer:r,isJsonContentType:i=bc,jsonContentType:o="application/json",jsonReplacer:s,timeout:c,responseHandler:a,validateStatus:u,...l}={}){return typeof fetch>"u"&&n===Cr&&console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments."),async(O,g,p)=>{const{getState:_,extra:m,endpoint:E,forced:k,type:b}=g;let v,{url:d,headers:f=new Headers(l.headers),params:S=void 0,responseHandler:I=a??"json",validateStatus:N=u??gc,timeout:x=c,...h}=typeof O=="string"?{url:O}:O,w={...l,signal:x?yc(g.signal,hc(x)):g.signal,...h};f=new Headers(jr(f)),w.headers=await t(f,{getState:_,arg:O,extra:m,endpoint:E,forced:k,type:b,extraOptions:p})||f;const C=vc(w.body);if(w.body!=null&&!C&&typeof w.body!="string"&&w.headers.delete("content-type"),!w.headers.has("content-type")&&C&&w.headers.set("content-type",o),C&&i(w.headers)&&(w.body=JSON.stringify(w.body,s)),w.headers.has("accept")||(I==="json"?w.headers.set("accept","application/json"):I==="text"&&w.headers.set("accept","text/plain, text/html, */*")),S){const V=~d.indexOf("?")?"&":"?",F=r?r(S):new URLSearchParams(jr(S));d+=V+F}d=pc(e,d);const j=new Request(d,w);v={request:new Request(d,w)};let R;try{R=await n(j)}catch(V){return{error:{status:(V instanceof Error||typeof DOMException<"u"&&V instanceof DOMException)&&V.name==="TimeoutError"?"TIMEOUT_ERROR":"FETCH_ERROR",error:String(V)},meta:v}}const Q=R.clone();v.response=Q;let M,A="";try{let V;if(await Promise.all([y(R,I).then(F=>M=F,F=>V=F),Q.text().then(F=>A=F,()=>{})]),V)throw V}catch(V){return{error:{status:"PARSING_ERROR",originalStatus:R.status,data:A,error:String(V)},meta:v}}return N(R,M)?{data:M,meta:v}:{error:{status:R.status,data:M},meta:v}};async function y(O,g){if(typeof g=="function")return g(O);if(g==="content-type"&&(g=i(O.headers)?"json":"text"),g==="json"){const p=await O.text();return p.length?JSON.parse(p):null}return O.text()}}var kr=class{constructor(e,t=void 0){re(this,"value");re(this,"meta");this.value=e,this.meta=t}},Xt="__rtkq/",xc="online",Ec="offline",Ri="focused",Bn=de(`${Xt}${Ri}`),Mi=de(`${Xt}un${Ri}`),Hn=de(`${Xt}${xc}`),Ti=de(`${Xt}${Ec}`),gt="query",Vi="mutation",Fi="infinitequery";function Zt(e){return e.type===gt}function Sc(e){return e.type===Vi}function bt(e){return e.type===Fi}function Ut(e){return Zt(e)||bt(e)}function Kn(e,t,n,r,i,o){const s=Nc(e)?e(t,n,r,i):e;return s?Cn(s,Wn,c=>o(Qi(c))):[]}function Nc(e){return typeof e=="function"}function Qi(e){return typeof e=="string"?{type:e}:e}function _c(e,t){return e.catch(t)}var $e=(e,t)=>e.endpointDefinitions[t],st=Symbol("forceQueryFn"),kn=e=>typeof e[st]=="function";function Oc({serializeQueryArgs:e,queryThunk:t,infiniteQueryThunk:n,mutationThunk:r,api:i,context:o,getInternalState:s}){const c=d=>{var f;return(f=s(d))==null?void 0:f.runningQueries},a=d=>{var f;return(f=s(d))==null?void 0:f.runningMutations},{unsubscribeQueryResult:u,removeMutationResult:l,updateSubscriptionOptions:y}=i.internalActions;return{buildInitiateQuery:k,buildInitiateInfiniteQuery:b,buildInitiateMutation:v,getRunningQueryThunk:O,getRunningMutationThunk:g,getRunningQueriesThunk:p,getRunningMutationsThunk:_};function O(d,f){return S=>{var x;const I=$e(o,d),N=e({queryArgs:f,endpointDefinition:I,endpointName:d});return(x=c(S))==null?void 0:x.get(N)}}function g(d,f){return S=>{var I;return(I=a(S))==null?void 0:I.get(f)}}function p(){return d=>Ir(c(d))}function _(){return d=>Ir(a(d))}function m(d){if(process.env.NODE_ENV!=="production"){if(m.triggered)return;const f=d(i.internalActions.internal_getRTKQSubscriptions());if(m.triggered=!0,typeof f!="object"||typeof(f==null?void 0:f.type)=="string")throw new Error(process.env.NODE_ENV==="production"?U(34):`Warning: Middleware for RTK-Query API at reducerPath "${i.reducerPath}" has not been added to the store.
|
|
35
|
+
You must add the middleware for RTK-Query to function correctly!`)}}function E(d,f){const S=(I,{subscribe:N=!0,forceRefetch:x,subscriptionOptions:h,[st]:w,...C}={})=>(j,D)=>{var W;const R=e({queryArgs:I,endpointDefinition:f,endpointName:d});let Q;const M={...C,type:gt,subscribe:N,forceRefetch:x,subscriptionOptions:h,endpointName:d,originalArgs:I,queryCacheKey:R,[st]:w};if(Zt(f))Q=t(M);else{const{direction:L,initialPageParam:te,refetchCachedPages:z}=C;Q=n({...M,direction:L,initialPageParam:te,refetchCachedPages:z})}const A=i.endpoints[d].select(I),V=j(Q),F=A(D());m(j);const{requestId:B,abort:K}=V,H=F.requestId!==B,Y=(W=c(j))==null?void 0:W.get(R),G=()=>A(D()),$=Object.assign(w?V.then(G):H&&!Y?Promise.resolve(F):Promise.all([Y,V]).then(G),{arg:I,requestId:B,subscriptionOptions:h,queryCacheKey:R,abort:K,async unwrap(){const L=await $;if(L.isError)throw L.error;return L.data},refetch:L=>j(S(I,{subscribe:!1,forceRefetch:!0,...L})),unsubscribe(){N&&j(u({queryCacheKey:R,requestId:B}))},updateSubscriptionOptions(L){$.subscriptionOptions=L,j(y({endpointName:d,requestId:B,queryCacheKey:R,options:L}))}});if(!Y&&!H&&!w){const L=c(j);L.set(R,$),$.then(()=>{L.delete(R)})}return $};return S}function k(d,f){return E(d,f)}function b(d,f){return E(d,f)}function v(d){return(f,{track:S=!0,fixedCacheKey:I}={})=>(N,x)=>{const h=r({type:"mutation",endpointName:d,originalArgs:f,track:S,fixedCacheKey:I}),w=N(h);m(N);const{requestId:C,abort:j,unwrap:D}=w,R=_c(w.unwrap().then(V=>({data:V})),V=>({error:V})),Q=()=>{N(l({requestId:C,fixedCacheKey:I}))},M=Object.assign(R,{arg:w.arg,requestId:C,abort:j,unwrap:D,reset:Q}),A=a(N);return A.set(C,M),M.then(()=>{A.delete(C)}),I&&(A.set(I,M),M.then(()=>{A.get(I)===M&&A.delete(I)})),M}}}var $i=class extends ac{constructor(t,n,r,i){super(t);re(this,"value");re(this,"schemaName");re(this,"_bqMeta");this.value=n,this.schemaName=r,this._bqMeta=i}},Ie=(e,t)=>Array.isArray(e)?e.includes(t):!!e;async function Ce(e,t,n,r){const i=await e["~standard"].validate(t);if(i.issues)throw new $i(i.issues,t,n,r);return i.value}function Pr(e){return e}var Ue=(e={})=>({...e,[Gt]:!0});function Ic({reducerPath:e,baseQuery:t,context:{endpointDefinitions:n},serializeQueryArgs:r,api:i,assertTagType:o,selectors:s,onSchemaFailure:c,catchSchemaFailure:a,skipSchemaValidation:u}){const l=(h,w,C,j)=>(D,R)=>{const Q=n[h],M=r({queryArgs:w,endpointDefinition:Q,endpointName:h});if(D(i.internalActions.queryResultPatched({queryCacheKey:M,patches:C})),!j)return;const A=i.endpoints[h].select(w)(R()),V=Kn(Q.providesTags,A.data,void 0,w,{},o);D(i.internalActions.updateProvidedBy([{queryCacheKey:M,providedTags:V}]))};function y(h,w,C=0){const j=[w,...h];return C&&j.length>C?j.slice(0,-1):j}function O(h,w,C=0){const j=[...h,w];return C&&j.length>C?j.slice(1):j}const g=(h,w,C,j=!0)=>(D,R)=>{const M=i.endpoints[h].select(w)(R()),A={patches:[],inversePatches:[],undo:()=>D(i.util.patchQueryData(h,w,A.inversePatches,j))};if(M.status===be)return A;let V;if("data"in M)if(ce(M.data)){const[F,B,K]=wi(M.data,C);A.patches.push(...B),A.inversePatches.push(...K),V=F}else V=C(M.data),A.patches.push({op:"replace",path:[],value:V}),A.inversePatches.push({op:"replace",path:[],value:M.data});return A.patches.length===0||D(i.util.patchQueryData(h,w,A.patches,j)),A},p=(h,w,C)=>j=>j(i.endpoints[h].initiate(w,{subscribe:!1,forceRefetch:!0,[st]:()=>({data:C})})),_=(h,w)=>h.query&&h[w]?h[w]:Pr,m=async(h,{signal:w,abort:C,rejectWithValue:j,fulfillWithValue:D,dispatch:R,getState:Q,extra:M})=>{var K,H;const A=n[h.endpointName],{metaSchema:V,skipSchemaValidation:F=u}=A,B=h.type===gt;try{let Y=Pr;const G={signal:w,abort:C,dispatch:R,getState:Q,extra:M,endpoint:h.endpointName,type:h.type,forced:B?E(h,Q()):void 0,queryCacheKey:B?h.queryCacheKey:void 0},$=B?h[st]:void 0;let W;const L=async(z,q,we,ne)=>{if(q==null&&z.pages.length)return Promise.resolve({data:z});const Re={queryArg:h.originalArgs,pageParam:q},ue=await te(Re),Me=ne?y:O;return{data:{pages:Me(z.pages,ue.data,we),pageParams:Me(z.pageParams,q,we)},meta:ue.meta}};async function te(z){let q;const{extraOptions:we,argSchema:ne,rawResponseSchema:Re,responseSchema:ue}=A;if(ne&&!Ie(F,"arg")&&(z=await Ce(ne,z,"argSchema",{})),$?q=$():A.query?(Y=_(A,"transformResponse"),q=await t(A.query(z),G,we)):q=await A.queryFn(z,G,we,ae=>t(ae,G,we)),typeof process<"u"&&process.env.NODE_ENV==="development"){const ae=A.query?"`baseQuery`":"`queryFn`";let le;if(!q)le=`${ae} did not return anything.`;else if(typeof q!="object")le=`${ae} did not return an object.`;else if(q.error&&q.data)le=`${ae} returned an object containing both \`error\` and \`result\`.`;else if(q.error===void 0&&q.data===void 0)le=`${ae} returned an object containing neither a valid \`error\` and \`result\`. At least one of them should not be \`undefined\``;else for(const Ee of Object.keys(q))if(Ee!=="error"&&Ee!=="data"&&Ee!=="meta"){le=`The object returned by ${ae} has the unknown property ${Ee}.`;break}le&&console.error(`Error encountered handling the endpoint ${h.endpointName}.
|
|
36
|
+
${le}
|
|
37
|
+
It needs to return an object with either the shape \`{ data: <value> }\` or \`{ error: <value> }\` that may contain an optional \`meta\` property.
|
|
38
|
+
Object returned was:`,q)}if(q.error)throw new kr(q.error,q.meta);let{data:Me}=q;Re&&!Ie(F,"rawResponse")&&(Me=await Ce(Re,q.data,"rawResponseSchema",q.meta));let xe=await Y(Me,q.meta,z);return ue&&!Ie(F,"response")&&(xe=await Ce(ue,xe,"responseSchema",q.meta)),{...q,data:xe}}if(B&&"infiniteQueryOptions"in A){const{infiniteQueryOptions:z}=A,{maxPages:q=1/0}=z,we=h.refetchCachedPages??z.refetchCachedPages??!0;let ne;const Re={pages:[],pageParams:[]},ue=(K=s.selectQueryEntry(Q(),h.queryCacheKey))==null?void 0:K.data,xe=E(h,Q())&&!h.direction||!ue?Re:ue;if("direction"in h&&h.direction&&xe.pages.length){const ae=h.direction==="backward",Ee=(ae?Li:Pn)(z,xe,h.originalArgs);ne=await L(xe,Ee,q,ae)}else{const{initialPageParam:ae=z.initialPageParam}=h,le=(ue==null?void 0:ue.pageParams)??[],Ee=le[0]??ae,vo=le.length;if(ne=await L(xe,Ee,q),$&&(ne={data:ne.data.pages[0]}),we)for(let tr=1;tr<vo;tr++){const wo=Pn(z,ne.data,h.originalArgs);ne=await L(ne.data,wo,q)}}W=ne}else W=await te(h.originalArgs);return V&&!Ie(F,"meta")&&W.meta&&(W.meta=await Ce(V,W.meta,"metaSchema",W.meta)),D(W.data,Ue({fulfilledTimeStamp:Date.now(),baseQueryMeta:W.meta}))}catch(Y){let G=Y;if(G instanceof kr){let $=_(A,"transformErrorResponse");const{rawErrorResponseSchema:W,errorResponseSchema:L}=A;let{value:te,meta:z}=G;try{W&&!Ie(F,"rawErrorResponse")&&(te=await Ce(W,te,"rawErrorResponseSchema",z)),V&&!Ie(F,"meta")&&(z=await Ce(V,z,"metaSchema",z));let q=await $(te,z,h.originalArgs);return L&&!Ie(F,"errorResponse")&&(q=await Ce(L,q,"errorResponseSchema",z)),j(q,Ue({baseQueryMeta:z}))}catch(q){G=q}}try{if(G instanceof $i){const $={endpoint:h.endpointName,arg:h.originalArgs,type:h.type,queryCacheKey:B?h.queryCacheKey:void 0};(H=A.onSchemaFailure)==null||H.call(A,G,$),c==null||c(G,$);const{catchSchemaFailure:W=a}=A;if(W)return j(W(G,$),Ue({baseQueryMeta:G._bqMeta}))}}catch($){G=$}throw typeof process<"u"&&process.env.NODE_ENV!=="production"?console.error(`An unhandled error occurred processing a request for the endpoint "${h.endpointName}".
|
|
39
|
+
In the case of an unhandled error, no tags will be "provided" or "invalidated".`,G):console.error(G),G}};function E(h,w){const C=s.selectQueryEntry(w,h.queryCacheKey),j=s.selectConfig(w).refetchOnMountOrArgChange,D=C==null?void 0:C.fulfilledTimeStamp,R=h.forceRefetch??(h.subscribe&&j);return R?R===!0||(Number(new Date)-Number(D))/1e3>=R:!1}const k=()=>Nr(`${e}/executeQuery`,m,{getPendingMeta({arg:w}){const C=n[w.endpointName];return Ue({startedTimeStamp:Date.now(),...bt(C)?{direction:w.direction}:{}})},condition(w,{getState:C}){var F;const j=C(),D=s.selectQueryEntry(j,w.queryCacheKey),R=D==null?void 0:D.fulfilledTimeStamp,Q=w.originalArgs,M=D==null?void 0:D.originalArgs,A=n[w.endpointName],V=w.direction;return kn(w)?!0:(D==null?void 0:D.status)==="pending"?!1:E(w,j)||Zt(A)&&((F=A==null?void 0:A.forceRefetch)!=null&&F.call(A,{currentArg:Q,previousArg:M,endpointState:D,state:j}))?!0:!(R&&!V)},dispatchConditionRejection:!0}),b=k(),v=k(),d=Nr(`${e}/executeMutation`,m,{getPendingMeta(){return Ue({startedTimeStamp:Date.now()})}}),f=h=>"force"in h,S=h=>"ifOlderThan"in h,I=(h,w,C={})=>(j,D)=>{const R=f(C)&&C.force,Q=S(C)&&C.ifOlderThan,M=(V=!0)=>{const F={forceRefetch:V,subscribe:!1};return i.endpoints[h].initiate(w,F)},A=i.endpoints[h].select(w)(D());if(R)j(M());else if(Q){const V=A==null?void 0:A.fulfilledTimeStamp;if(!V){j(M());return}(Number(new Date)-Number(new Date(V)))/1e3>=Q&&j(M())}else j(M(!1))};function N(h){return w=>{var C,j;return((j=(C=w==null?void 0:w.meta)==null?void 0:C.arg)==null?void 0:j.endpointName)===h}}function x(h,w){return{matchPending:Ze(qn(h),N(w)),matchFulfilled:Ze(Oe(h),N(w)),matchRejected:Ze(Qe(h),N(w))}}return{queryThunk:b,mutationThunk:d,infiniteQueryThunk:v,prefetch:I,updateQueryData:g,upsertQueryData:p,patchQueryData:l,buildMatchThunkActions:x}}function Pn(e,{pages:t,pageParams:n},r){const i=t.length-1;return e.getNextPageParam(t[i],t,n[i],n,r)}function Li(e,{pages:t,pageParams:n},r){var i;return(i=e.getPreviousPageParam)==null?void 0:i.call(e,t[0],t,n[0],n,r)}function qi(e,t,n,r){return Kn(n[e.meta.arg.endpointName][t],Oe(e)?e.payload:void 0,Jt(e)?e.payload:void 0,e.meta.arg.originalArgs,"baseQueryMeta"in e.meta?e.meta.baseQueryMeta:void 0,r)}function Ar(e){return se(e)?bi(e):e}function _t(e,t,n){const r=e[t];r&&n(r)}function ct(e){return("arg"in e?e.arg.fixedCacheKey:e.fixedCacheKey)??e.requestId}function Dr(e,t,n){const r=e[ct(t)];r&&n(r)}var Ot={};function Cc({reducerPath:e,queryThunk:t,mutationThunk:n,serializeQueryArgs:r,context:{endpointDefinitions:i,apiUid:o,extractRehydrationInfo:s,hasRehydrationInfo:c},assertTagType:a,config:u}){const l=de(`${e}/resetApiState`);function y(N,x,h,w){var C;N[C=x.queryCacheKey]??(N[C]={status:be,endpointName:x.endpointName}),_t(N,x.queryCacheKey,j=>{j.status=In,j.requestId=h&&j.requestId?j.requestId:w.requestId,x.originalArgs!==void 0&&(j.originalArgs=x.originalArgs),j.startedTimeStamp=w.startedTimeStamp;const D=i[w.arg.endpointName];bt(D)&&"direction"in x&&(j.direction=x.direction)})}function O(N,x,h,w){_t(N,x.arg.queryCacheKey,C=>{if(C.requestId!==x.requestId&&!w)return;const{merge:j}=i[x.arg.endpointName];if(C.status=Ke,j)if(C.data!==void 0){const{fulfilledTimeStamp:D,arg:R,baseQueryMeta:Q,requestId:M}=x;let A=ht(C.data,V=>j(V,h,{arg:R.originalArgs,baseQueryMeta:Q,fulfilledTimeStamp:D,requestId:M}));C.data=A}else C.data=h;else C.data=i[x.arg.endpointName].structuralSharing??!0?zn(se(C.data)?rs(C.data):C.data,h):h;delete C.error,C.fulfilledTimeStamp=x.fulfilledTimeStamp})}const g=je({name:`${e}/queries`,initialState:Ot,reducers:{removeQueryResult:{reducer(N,{payload:{queryCacheKey:x}}){delete N[x]},prepare:qe()},cacheEntriesUpserted:{reducer(N,x){for(const h of x.payload){const{queryDescription:w,value:C}=h;y(N,w,!0,{arg:w,requestId:x.meta.requestId,startedTimeStamp:x.meta.timestamp}),O(N,{arg:w,requestId:x.meta.requestId,fulfilledTimeStamp:x.meta.timestamp,baseQueryMeta:{}},C,!0)}},prepare:N=>({payload:N.map(w=>{const{endpointName:C,arg:j,value:D}=w,R=i[C];return{queryDescription:{type:gt,endpointName:C,originalArgs:w.arg,queryCacheKey:r({queryArgs:j,endpointDefinition:R,endpointName:C})},value:D}}),meta:{[Gt]:!0,requestId:Un(),timestamp:Date.now()}})},queryResultPatched:{reducer(N,{payload:{queryCacheKey:x,patches:h}}){_t(N,x,w=>{w.data=yr(w.data,h.concat())})},prepare:qe()}},extraReducers(N){N.addCase(t.pending,(x,{meta:h,meta:{arg:w}})=>{const C=kn(w);y(x,w,C,h)}).addCase(t.fulfilled,(x,{meta:h,payload:w})=>{const C=kn(h.arg);O(x,h,w,C)}).addCase(t.rejected,(x,{meta:{condition:h,arg:w,requestId:C},error:j,payload:D})=>{_t(x,w.queryCacheKey,R=>{if(!h){if(R.requestId!==C)return;R.status=Ge,R.error=D??j}})}).addMatcher(c,(x,h)=>{const{queries:w}=s(h);for(const[C,j]of Object.entries(w))((j==null?void 0:j.status)===Ke||(j==null?void 0:j.status)===Ge)&&(x[C]=j)})}}),p=je({name:`${e}/mutations`,initialState:Ot,reducers:{removeMutationResult:{reducer(N,{payload:x}){const h=ct(x);h in N&&delete N[h]},prepare:qe()}},extraReducers(N){N.addCase(n.pending,(x,{meta:h,meta:{requestId:w,arg:C,startedTimeStamp:j}})=>{C.track&&(x[ct(h)]={requestId:w,status:In,endpointName:C.endpointName,startedTimeStamp:j})}).addCase(n.fulfilled,(x,{payload:h,meta:w})=>{w.arg.track&&Dr(x,w,C=>{C.requestId===w.requestId&&(C.status=Ke,C.data=h,C.fulfilledTimeStamp=w.fulfilledTimeStamp)})}).addCase(n.rejected,(x,{payload:h,error:w,meta:C})=>{C.arg.track&&Dr(x,C,j=>{j.requestId===C.requestId&&(j.status=Ge,j.error=h??w)})}).addMatcher(c,(x,h)=>{const{mutations:w}=s(h);for(const[C,j]of Object.entries(w))((j==null?void 0:j.status)===Ke||(j==null?void 0:j.status)===Ge)&&C!==(j==null?void 0:j.requestId)&&(x[C]=j)})}}),_={tags:{},keys:{}},m=je({name:`${e}/invalidation`,initialState:_,reducers:{updateProvidedBy:{reducer(N,x){var h,w,C;for(const{queryCacheKey:j,providedTags:D}of x.payload){E(N,j);for(const{type:R,id:Q}of D){const M=(w=(h=N.tags)[R]??(h[R]={}))[C=Q||"__internal_without_id"]??(w[C]=[]);M.includes(j)||M.push(j)}N.keys[j]=D}},prepare:qe()}},extraReducers(N){N.addCase(g.actions.removeQueryResult,(x,{payload:{queryCacheKey:h}})=>{E(x,h)}).addMatcher(c,(x,h)=>{var C,j,D;const{provided:w}=s(h);for(const[R,Q]of Object.entries(w.tags??{}))for(const[M,A]of Object.entries(Q)){const V=(j=(C=x.tags)[R]??(C[R]={}))[D=M||"__internal_without_id"]??(j[D]=[]);for(const F of A)V.includes(F)||V.push(F),x.keys[F]=w.keys[F]}}).addMatcher(ge(Oe(t),Jt(t)),(x,h)=>{k(x,[h])}).addMatcher(g.actions.cacheEntriesUpserted.match,(x,h)=>{const w=h.payload.map(({queryDescription:C,value:j})=>({type:"UNKNOWN",payload:j,meta:{requestStatus:"fulfilled",requestId:"UNKNOWN",arg:C}}));k(x,w)})}});function E(N,x){var w;const h=Ar(N.keys[x]??[]);for(const C of h){const j=C.type,D=C.id??"__internal_without_id",R=(w=N.tags[j])==null?void 0:w[D];R&&(N.tags[j][D]=Ar(R).filter(Q=>Q!==x))}delete N.keys[x]}function k(N,x){const h=x.map(w=>{const C=qi(w,"providesTags",i,a),{queryCacheKey:j}=w.meta.arg;return{queryCacheKey:j,providedTags:C}});m.caseReducers.updateProvidedBy(N,m.actions.updateProvidedBy(h))}const b=je({name:`${e}/subscriptions`,initialState:Ot,reducers:{updateSubscriptionOptions(N,x){},unsubscribeQueryResult(N,x){},internal_getRTKQSubscriptions(){}}}),v=je({name:`${e}/internalSubscriptions`,initialState:Ot,reducers:{subscriptionsUpdated:{reducer(N,x){return yr(N,x.payload)},prepare:qe()}}}),d=je({name:`${e}/config`,initialState:{online:fc(),focused:lc(),middlewareRegistered:!1,...u},reducers:{middlewareRegistered(N,{payload:x}){N.middlewareRegistered=N.middlewareRegistered==="conflict"||o!==x?"conflict":!0}},extraReducers:N=>{N.addCase(Hn,x=>{x.online=!0}).addCase(Ti,x=>{x.online=!1}).addCase(Bn,x=>{x.focused=!0}).addCase(Mi,x=>{x.focused=!1}).addMatcher(c,x=>({...x}))}}),f=li({queries:g.reducer,mutations:p.reducer,provided:m.reducer,subscriptions:v.reducer,config:d.reducer}),S=(N,x)=>f(l.match(x)?void 0:N,x),I={...d.actions,...g.actions,...b.actions,...v.actions,...p.actions,...m.actions,resetApiState:l};return{reducer:S,actions:I}}var fe=Symbol.for("RTKQ/skipToken"),Ui={status:be},Rr=ht(Ui,()=>{}),Mr=ht(Ui,()=>{});function jc({serializeQueryArgs:e,reducerPath:t,createSelector:n}){const r=b=>Rr,i=b=>Mr;return{buildQuerySelector:O,buildInfiniteQuerySelector:g,buildMutationSelector:p,selectInvalidatedBy:_,selectCachedArgsForQuery:m,selectApiState:s,selectQueries:c,selectMutations:u,selectQueryEntry:a,selectConfig:l};function o(b){return{...b,..._r(b.status)}}function s(b){const v=b[t];if(process.env.NODE_ENV!=="production"&&!v){if(s.triggered)return v;s.triggered=!0,console.error(`Error: No data found at \`state.${t}\`. Did you forget to add the reducer to the store?`)}return v}function c(b){var v;return(v=s(b))==null?void 0:v.queries}function a(b,v){var d;return(d=c(b))==null?void 0:d[v]}function u(b){var v;return(v=s(b))==null?void 0:v.mutations}function l(b){var v;return(v=s(b))==null?void 0:v.config}function y(b,v,d){return f=>{if(f===fe)return n(r,d);const S=e({queryArgs:f,endpointDefinition:v,endpointName:b});return n(N=>a(N,S)??Rr,d)}}function O(b,v){return y(b,v,o)}function g(b,v){const{infiniteQueryOptions:d}=v;function f(S){const I={...S,..._r(S.status)},{isLoading:N,isError:x,direction:h}=I,w=h==="forward",C=h==="backward";return{...I,hasNextPage:E(d,I.data,I.originalArgs),hasPreviousPage:k(d,I.data,I.originalArgs),isFetchingNextPage:N&&w,isFetchingPreviousPage:N&&C,isFetchNextPageError:x&&w,isFetchPreviousPageError:x&&C}}return y(b,v,f)}function p(){return(b=>{let v;return typeof b=="object"?v=ct(b)??fe:v=b,n(v===fe?i:S=>{var I,N;return((N=(I=s(S))==null?void 0:I.mutations)==null?void 0:N[v])??Mr},o)})}function _(b,v){const d=b[t],f=new Set,S=Cn(v,Wn,Qi);for(const I of S){const N=d.provided.tags[I.type];if(!N)continue;let x=(I.id!==void 0?N[I.id]:Object.values(N).flat())??[];for(const h of x)f.add(h)}return Array.from(f.values()).flatMap(I=>{const N=d.queries[I];return N?{queryCacheKey:I,endpointName:N.endpointName,originalArgs:N.originalArgs}:[]})}function m(b,v){return Cn(Object.values(c(b)),d=>(d==null?void 0:d.endpointName)===v&&d.status!==be,d=>d.originalArgs)}function E(b,v,d){return v?Pn(b,v,d)!=null:!1}function k(b,v,d){return!v||!b.getPreviousPageParam?!1:Li(b,v,d)!=null}}var Te=WeakMap?new WeakMap:void 0,Tr=({endpointName:e,queryArgs:t})=>{let n="";const r=Te==null?void 0:Te.get(t);if(typeof r=="string")n=r;else{const i=JSON.stringify(t,(o,s)=>(s=typeof s=="bigint"?{$bigint:s.toString()}:s,s=me(s)?Object.keys(s).sort().reduce((c,a)=>(c[a]=s[a],c),{}):s,s));me(t)&&(Te==null||Te.set(t,i)),n=i}return`${e}(${n})`};function zi(...e){return function(n){const r=Lt(u=>{var l;return(l=n.extractRehydrationInfo)==null?void 0:l.call(n,u,{reducerPath:n.reducerPath??"api"})}),i={reducerPath:"api",keepUnusedDataFor:60,refetchOnMountOrArgChange:!1,refetchOnFocus:!1,refetchOnReconnect:!1,invalidationBehavior:"delayed",...n,extractRehydrationInfo:r,serializeQueryArgs(u){let l=Tr;if("serializeQueryArgs"in u.endpointDefinition){const y=u.endpointDefinition.serializeQueryArgs;l=O=>{const g=y(O);return typeof g=="string"?g:Tr({...O,queryArgs:g})}}else n.serializeQueryArgs&&(l=n.serializeQueryArgs);return l(u)},tagTypes:[...n.tagTypes||[]]},o={endpointDefinitions:{},batch(u){u()},apiUid:Un(),extractRehydrationInfo:r,hasRehydrationInfo:Lt(u=>r(u)!=null)},s={injectEndpoints:a,enhanceEndpoints({addTagTypes:u,endpoints:l}){if(u)for(const y of u)i.tagTypes.includes(y)||i.tagTypes.push(y);if(l)for(const[y,O]of Object.entries(l))typeof O=="function"?O($e(o,y)):Object.assign($e(o,y)||{},O);return s}},c=e.map(u=>u.init(s,i,o));function a(u){const l=u.endpoints({query:y=>({...y,type:gt}),mutation:y=>({...y,type:Vi}),infiniteQuery:y=>({...y,type:Fi})});for(const[y,O]of Object.entries(l)){if(u.overrideExisting!==!0&&y in o.endpointDefinitions){if(u.overrideExisting==="throw")throw new Error(process.env.NODE_ENV==="production"?U(39):`called \`injectEndpoints\` to override already-existing endpointName ${y} without specifying \`overrideExisting: true\``);typeof process<"u"&&process.env.NODE_ENV==="development"&&console.error(`called \`injectEndpoints\` to override already-existing endpointName ${y} without specifying \`overrideExisting: true\``);continue}if(typeof process<"u"&&process.env.NODE_ENV==="development"&&bt(O)){const{infiniteQueryOptions:g}=O,{maxPages:p,getPreviousPageParam:_}=g;if(typeof p=="number"){if(p<1)throw new Error(process.env.NODE_ENV==="production"?U(40):`maxPages for endpoint '${y}' must be a number greater than 0`);if(typeof _!="function")throw new Error(process.env.NODE_ENV==="production"?U(41):`getPreviousPageParam for endpoint '${y}' must be a function if maxPages is used`)}}o.endpointDefinitions[y]=O;for(const g of c)g.injectEndpoint(y,O)}return s}return s.injectEndpoints({endpoints:n.endpoints})}}function pe(e,...t){return Object.assign(e,...t)}var kc=({api:e,queryThunk:t,internalState:n,mwApi:r})=>{const i=`${e.reducerPath}/subscriptions`;let o=null,s=null;const{updateSubscriptionOptions:c,unsubscribeQueryResult:a}=e.internalActions,u=(_,m)=>{if(c.match(m)){const{queryCacheKey:k,requestId:b,options:v}=m.payload,d=_.get(k);return d!=null&&d.has(b)&&d.set(b,v),!0}if(a.match(m)){const{queryCacheKey:k,requestId:b}=m.payload,v=_.get(k);return v&&v.delete(b),!0}if(e.internalActions.removeQueryResult.match(m))return _.delete(m.payload.queryCacheKey),!0;if(t.pending.match(m)){const{meta:{arg:k,requestId:b}}=m,v=qt(_,k.queryCacheKey,jn);return k.subscribe&&v.set(b,k.subscriptionOptions??v.get(b)??{}),!0}let E=!1;if(t.rejected.match(m)){const{meta:{condition:k,arg:b,requestId:v}}=m;if(k&&b.subscribe){const d=qt(_,b.queryCacheKey,jn);d.set(v,b.subscriptionOptions??d.get(v)??{}),E=!0}}return E},l=()=>n.currentSubscriptions,g={getSubscriptions:l,getSubscriptionCount:_=>{const E=l().get(_);return(E==null?void 0:E.size)??0},isRequestSubscribed:(_,m)=>{var k;const E=l();return!!((k=E==null?void 0:E.get(_))!=null&&k.get(m))}};function p(_){return JSON.parse(JSON.stringify(Object.fromEntries([..._].map(([m,E])=>[m,Object.fromEntries(E)]))))}return(_,m)=>{if(o||(o=p(n.currentSubscriptions)),e.util.resetApiState.match(_))return o={},n.currentSubscriptions.clear(),s=null,[!0,!1];if(e.internalActions.internal_getRTKQSubscriptions.match(_))return[!1,g];const E=u(n.currentSubscriptions,_);let k=!0;if(process.env.NODE_ENV==="test"&&typeof _.type=="string"&&_.type===`${e.reducerPath}/getPolling`)return[!1,n.currentPolls];if(E){s||(s=setTimeout(()=>{const d=p(n.currentSubscriptions),[,f]=wi(o,()=>d);m.next(e.internalActions.subscriptionsUpdated(f)),o=d,s=null},500));const b=typeof _.type=="string"&&!!_.type.startsWith(i),v=t.rejected.match(_)&&_.meta.condition&&!!_.meta.arg.subscribe;k=!b&&!v}return[k,!1]}},Pc=2147483647/1e3-1,Ac=({reducerPath:e,api:t,queryThunk:n,context:r,internalState:i,selectors:{selectQueryEntry:o,selectConfig:s},getRunningQueryThunk:c,mwApi:a})=>{const{removeQueryResult:u,unsubscribeQueryResult:l,cacheEntriesUpserted:y}=t.internalActions,O=ge(l.match,n.fulfilled,n.rejected,y.match);function g(b){const v=i.currentSubscriptions.get(b);return v?v.size>0:!1}const p={};function _(b){var v;for(const d of b.values())(v=d==null?void 0:d.abort)==null||v.call(d)}const m=(b,v)=>{const d=v.getState(),f=s(d);if(O(b)){let S;if(y.match(b))S=b.payload.map(I=>I.queryDescription.queryCacheKey);else{const{queryCacheKey:I}=l.match(b)?b.payload:b.meta.arg;S=[I]}E(S,v,f)}if(t.util.resetApiState.match(b)){for(const[S,I]of Object.entries(p))I&&clearTimeout(I),delete p[S];_(i.runningQueries),_(i.runningMutations)}if(r.hasRehydrationInfo(b)){const{queries:S}=r.extractRehydrationInfo(b);E(Object.keys(S),v,f)}};function E(b,v,d){const f=v.getState();for(const S of b){const I=o(f,S);I!=null&&I.endpointName&&k(S,I.endpointName,v,d)}}function k(b,v,d,f){const S=$e(r,v),I=(S==null?void 0:S.keepUnusedDataFor)??f.keepUnusedDataFor;if(I===1/0)return;const N=Math.max(0,Math.min(I,Pc));if(!g(b)){const x=p[b];x&&clearTimeout(x),p[b]=setTimeout(()=>{if(!g(b)){const h=o(d.getState(),b);if(h!=null&&h.endpointName){const w=d.dispatch(c(h.endpointName,h.originalArgs));w==null||w.abort()}d.dispatch(u({queryCacheKey:b}))}delete p[b]},N*1e3)}}return m},Vr=new Error("Promise never resolved before cacheEntryRemoved."),Dc=({api:e,reducerPath:t,context:n,queryThunk:r,mutationThunk:i,internalState:o,selectors:{selectQueryEntry:s,selectApiState:c}})=>{const a=On(r),u=On(i),l=Oe(r,i),y={},{removeQueryResult:O,removeMutationResult:g,cacheEntriesUpserted:p}=e.internalActions;function _(d,f,S){const I=y[d];I!=null&&I.valueResolved&&(I.valueResolved({data:f,meta:S}),delete I.valueResolved)}function m(d){const f=y[d];f&&(delete y[d],f.cacheEntryRemoved())}function E(d){const{arg:f,requestId:S}=d.meta,{endpointName:I,originalArgs:N}=f;return[I,N,S]}const k=(d,f,S)=>{const I=b(d);function N(x,h,w,C){const j=s(S,h),D=s(f.getState(),h);!j&&D&&v(x,C,h,f,w)}if(r.pending.match(d)){const[x,h,w]=E(d);N(x,I,w,h)}else if(p.match(d))for(const{queryDescription:x,value:h}of d.payload){const{endpointName:w,originalArgs:C,queryCacheKey:j}=x;N(w,j,d.meta.requestId,C),_(j,h,{})}else if(i.pending.match(d)){if(f.getState()[t].mutations[I]){const[h,w,C]=E(d);v(h,w,I,f,C)}}else if(l(d))_(I,d.payload,d.meta.baseQueryMeta);else if(O.match(d)||g.match(d))m(I);else if(e.util.resetApiState.match(d))for(const x of Object.keys(y))m(x)};function b(d){return a(d)?d.meta.arg.queryCacheKey:u(d)?d.meta.arg.fixedCacheKey??d.meta.requestId:O.match(d)?d.payload.queryCacheKey:g.match(d)?ct(d.payload):""}function v(d,f,S,I,N){const x=$e(n,d),h=x==null?void 0:x.onCacheEntryAdded;if(!h)return;const w={},C=new Promise(A=>{w.cacheEntryRemoved=A}),j=Promise.race([new Promise(A=>{w.valueResolved=A}),C.then(()=>{throw Vr})]);j.catch(()=>{}),y[S]=w;const D=e.endpoints[d].select(Ut(x)?f:S),R=I.dispatch((A,V,F)=>F),Q={...I,getCacheEntry:()=>D(I.getState()),requestId:N,extra:R,updateCachedData:Ut(x)?A=>I.dispatch(e.util.updateQueryData(d,f,A)):void 0,cacheDataLoaded:j,cacheEntryRemoved:C},M=h(f,Q);Promise.resolve(M).catch(A=>{if(A!==Vr)throw A})}return k},Rc=({api:e,context:{apiUid:t},reducerPath:n})=>(r,i)=>{var o,s;e.util.resetApiState.match(r)&&i.dispatch(e.internalActions.middlewareRegistered(t)),typeof process<"u"&&process.env.NODE_ENV==="development"&&e.internalActions.middlewareRegistered.match(r)&&r.payload===t&&((s=(o=i.getState()[n])==null?void 0:o.config)==null?void 0:s.middlewareRegistered)==="conflict"&&console.warn(`There is a mismatch between slice and middleware for the reducerPath "${n}".
|
|
40
|
+
You can only have one api per reducer path, this will lead to crashes in various situations!${n==="api"?`
|
|
41
|
+
If you have multiple apis, you *have* to specify the reducerPath option when using createApi!`:""}`)},Mc=({reducerPath:e,context:t,context:{endpointDefinitions:n},mutationThunk:r,queryThunk:i,api:o,assertTagType:s,refetchQuery:c,internalState:a})=>{const{removeQueryResult:u}=o.internalActions,l=ge(Oe(r),Jt(r)),y=ge(Oe(i,r),Qe(i,r));let O=[],g=0;const p=(E,k)=>{(i.pending.match(E)||r.pending.match(E))&&g++,y(E)&&(g=Math.max(0,g-1)),l(E)?m(qi(E,"invalidatesTags",n,s),k):y(E)?m([],k):o.util.invalidateTags.match(E)&&m(Kn(E.payload,void 0,void 0,void 0,void 0,s),k)};function _(){return g>0}function m(E,k){const b=k.getState(),v=b[e];if(O.push(...E),v.config.invalidationBehavior==="delayed"&&_())return;const d=O;if(O=[],d.length===0)return;const f=o.util.selectInvalidatedBy(b,d);t.batch(()=>{const S=Array.from(f.values());for(const{queryCacheKey:I}of S){const N=v.queries[I],x=qt(a.currentSubscriptions,I,jn);N&&(x.size===0?k.dispatch(u({queryCacheKey:I})):N.status!==be&&k.dispatch(c(N)))}})}return p},Tc=({reducerPath:e,queryThunk:t,api:n,refetchQuery:r,internalState:i})=>{const{currentPolls:o,currentSubscriptions:s}=i,c=new Set;let a=null;const u=(m,E)=>{(n.internalActions.updateSubscriptionOptions.match(m)||n.internalActions.unsubscribeQueryResult.match(m))&&l(m.payload.queryCacheKey,E),(t.pending.match(m)||t.rejected.match(m)&&m.meta.condition)&&l(m.meta.arg.queryCacheKey,E),(t.fulfilled.match(m)||t.rejected.match(m)&&!m.meta.condition)&&y(m.meta.arg,E),n.util.resetApiState.match(m)&&(p(),a&&(clearTimeout(a),a=null),c.clear())};function l(m,E){c.add(m),a||(a=setTimeout(()=>{for(const k of c)O({queryCacheKey:k},E);c.clear(),a=null},0))}function y({queryCacheKey:m},E){const k=E.getState()[e],b=k.queries[m],v=s.get(m);if(!b||b.status===be)return;const{lowestPollingInterval:d,skipPollingIfUnfocused:f}=_(v);if(!Number.isFinite(d))return;const S=o.get(m);S!=null&&S.timeout&&(clearTimeout(S.timeout),S.timeout=void 0);const I=Date.now()+d;o.set(m,{nextPollTimestamp:I,pollingInterval:d,timeout:setTimeout(()=>{(k.config.focused||!f)&&E.dispatch(r(b)),y({queryCacheKey:m},E)},d)})}function O({queryCacheKey:m},E){const b=E.getState()[e].queries[m],v=s.get(m);if(!b||b.status===be)return;const{lowestPollingInterval:d}=_(v);if(process.env.NODE_ENV==="test"){const I=o.pollUpdateCounters??(o.pollUpdateCounters={});I[m]??(I[m]=0),I[m]++}if(!Number.isFinite(d)){g(m);return}const f=o.get(m),S=Date.now()+d;(!f||S<f.nextPollTimestamp)&&y({queryCacheKey:m},E)}function g(m){const E=o.get(m);E!=null&&E.timeout&&clearTimeout(E.timeout),o.delete(m)}function p(){for(const m of o.keys())g(m)}function _(m=new Map){let E=!1,k=Number.POSITIVE_INFINITY;for(const b of m.values())b.pollingInterval&&(k=Math.min(b.pollingInterval,k),E=b.skipPollingIfUnfocused||E);return{lowestPollingInterval:k,skipPollingIfUnfocused:E}}return u},Vc=({api:e,context:t,queryThunk:n,mutationThunk:r})=>{const i=qn(n,r),o=Qe(n,r),s=Oe(n,r),c={};return(u,l)=>{var y,O;if(i(u)){const{requestId:g,arg:{endpointName:p,originalArgs:_}}=u.meta,m=$e(t,p),E=m==null?void 0:m.onQueryStarted;if(E){const k={},b=new Promise((S,I)=>{k.resolve=S,k.reject=I});b.catch(()=>{}),c[g]=k;const v=e.endpoints[p].select(Ut(m)?_:g),d=l.dispatch((S,I,N)=>N),f={...l,getCacheEntry:()=>v(l.getState()),requestId:g,extra:d,updateCachedData:Ut(m)?S=>l.dispatch(e.util.updateQueryData(p,_,S)):void 0,queryFulfilled:b};E(_,f)}}else if(s(u)){const{requestId:g,baseQueryMeta:p}=u.meta;(y=c[g])==null||y.resolve({data:u.payload,meta:p}),delete c[g]}else if(o(u)){const{requestId:g,rejectedWithValue:p,baseQueryMeta:_}=u.meta;(O=c[g])==null||O.reject({error:u.payload??u.error,isUnhandledError:!p,meta:_}),delete c[g]}}},Fc=({reducerPath:e,context:t,api:n,refetchQuery:r,internalState:i})=>{const{removeQueryResult:o}=n.internalActions,s=(a,u)=>{Bn.match(a)&&c(u,"refetchOnFocus"),Hn.match(a)&&c(u,"refetchOnReconnect")};function c(a,u){const l=a.getState()[e],y=l.queries,O=i.currentSubscriptions;t.batch(()=>{for(const g of O.keys()){const p=y[g],_=O.get(g);if(!_||!p)continue;const m=[..._.values()];(m.some(k=>k[u]===!0)||m.every(k=>k[u]===void 0)&&l.config[u])&&(_.size===0?a.dispatch(o({queryCacheKey:g})):p.status!==be&&a.dispatch(r(p)))}})}return s};function Qc(e){const{reducerPath:t,queryThunk:n,api:r,context:i,getInternalState:o}=e,{apiUid:s}=i,c={invalidateTags:de(`${t}/invalidateTags`)},a=O=>O.type.startsWith(`${t}/`),u=[Rc,Ac,Mc,Tc,Dc,Vc];return{middleware:O=>{let g=!1;const p=o(O.dispatch),_={...e,internalState:p,refetchQuery:y,isThisApiSliceAction:a,mwApi:O},m=u.map(b=>b(_)),E=kc(_),k=Fc(_);return b=>v=>{if(!Fn(v))return b(v);g||(g=!0,O.dispatch(r.internalActions.middlewareRegistered(s)));const d={...O,next:b},f=O.getState(),[S,I]=E(v,d,f);let N;if(S?N=b(v):N=I,O.getState()[t]&&(k(v,d,f),a(v)||i.hasRehydrationInfo(v)))for(const x of m)x(v,d,f);return N}},actions:c};function y(O){return e.api.endpoints[O.endpointName].initiate(O.originalArgs,{subscribe:!1,forceRefetch:!0})}}var Fr=Symbol(),Wi=({createSelector:e=Ei}={})=>({name:Fr,init(t,{baseQuery:n,tagTypes:r,reducerPath:i,serializeQueryArgs:o,keepUnusedDataFor:s,refetchOnMountOrArgChange:c,refetchOnFocus:a,refetchOnReconnect:u,invalidationBehavior:l,onSchemaFailure:y,catchSchemaFailure:O,skipSchemaValidation:g},p){bs();const _=$=>(typeof process<"u"&&process.env.NODE_ENV==="development"&&(r.includes($.type)||console.error(`Tag type '${$.type}' was used, but not specified in \`tagTypes\`!`)),$);Object.assign(t,{reducerPath:i,endpoints:{},internalActions:{onOnline:Hn,onOffline:Ti,onFocus:Bn,onFocusLost:Mi},util:{}});const m=jc({serializeQueryArgs:o,reducerPath:i,createSelector:e}),{selectInvalidatedBy:E,selectCachedArgsForQuery:k,buildQuerySelector:b,buildInfiniteQuerySelector:v,buildMutationSelector:d}=m;pe(t.util,{selectInvalidatedBy:E,selectCachedArgsForQuery:k});const{queryThunk:f,infiniteQueryThunk:S,mutationThunk:I,patchQueryData:N,updateQueryData:x,upsertQueryData:h,prefetch:w,buildMatchThunkActions:C}=Ic({baseQuery:n,reducerPath:i,context:p,api:t,serializeQueryArgs:o,assertTagType:_,selectors:m,onSchemaFailure:y,catchSchemaFailure:O,skipSchemaValidation:g}),{reducer:j,actions:D}=Cc({context:p,queryThunk:f,mutationThunk:I,serializeQueryArgs:o,reducerPath:i,assertTagType:_,config:{refetchOnFocus:a,refetchOnReconnect:u,refetchOnMountOrArgChange:c,keepUnusedDataFor:s,reducerPath:i,invalidationBehavior:l}});pe(t.util,{patchQueryData:N,updateQueryData:x,upsertQueryData:h,prefetch:w,resetApiState:D.resetApiState,upsertQueryEntries:D.cacheEntriesUpserted}),pe(t.internalActions,D);const R=new WeakMap,Q=$=>qt(R,$,()=>({currentSubscriptions:new Map,currentPolls:new Map,runningQueries:new Map,runningMutations:new Map})),{buildInitiateQuery:M,buildInitiateInfiniteQuery:A,buildInitiateMutation:V,getRunningMutationThunk:F,getRunningMutationsThunk:B,getRunningQueriesThunk:K,getRunningQueryThunk:H}=Oc({queryThunk:f,mutationThunk:I,infiniteQueryThunk:S,api:t,serializeQueryArgs:o,context:p,getInternalState:Q});pe(t.util,{getRunningMutationThunk:F,getRunningMutationsThunk:B,getRunningQueryThunk:H,getRunningQueriesThunk:K});const{middleware:Y,actions:G}=Qc({reducerPath:i,context:p,queryThunk:f,mutationThunk:I,infiniteQueryThunk:S,api:t,assertTagType:_,selectors:m,getRunningQueryThunk:H,getInternalState:Q});return pe(t.util,G),pe(t,{reducer:j,middleware:Y}),{name:Fr,injectEndpoint($,W){var z;const te=(z=t.endpoints)[$]??(z[$]={});Zt(W)&&pe(te,{name:$,select:b($,W),initiate:M($,W)},C(f,$)),Sc(W)&&pe(te,{name:$,select:d(),initiate:V($)},C(I,$)),bt(W)&&pe(te,{name:$,select:v($,W),initiate:A($,W)},C(f,$))}}}});Wi();function It(e){return e.replace(e[0],e[0].toUpperCase())}function $c(e){let t=0;for(const n in e)t++;return t}var Lc="query",qc="mutation",Uc="infinitequery";function zc(e){return e.type===Lc}function Wc(e){return e.type===qc}function Bi(e){return e.type===Uc}function ze(e,...t){return Object.assign(e,...t)}var fn=Symbol();function dn(e){const t=T.useRef(e),n=T.useMemo(()=>zn(t.current,e),[e]);return T.useEffect(()=>{t.current!==n&&(t.current=n)},[n]),n}function Ve(e){const t=T.useRef(e);return T.useEffect(()=>{Ye(t.current,e)||(t.current=e)},[e]),Ye(t.current,e)?t.current:e}var Bc=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Hc=Bc(),Kc=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Gc=Kc(),Yc=()=>Hc||Gc?T.useLayoutEffect:T.useEffect,Jc=Yc(),Qr=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:e.data===void 0,status:Di.pending}:e;function mn(e,...t){const n={};return t.forEach(r=>{n[r]=e[r]}),n}var pn=["data","status","isLoading","isSuccess","isError","error"];function Xc({api:e,moduleOptions:{batch:t,hooks:{useDispatch:n,useSelector:r,useStore:i},unstable__sideEffectsInRender:o,createSelector:s},serializeQueryArgs:c,context:a}){const u=o?f=>f():T.useEffect,l=f=>{var S,I;return(I=(S=f.current)==null?void 0:S.unsubscribe)==null?void 0:I.call(S)},y=a.endpointDefinitions;return{buildQueryHooks:b,buildInfiniteQueryHooks:v,buildMutationHook:d,usePrefetch:p};function O(f,S,I){if(S!=null&&S.endpointName&&f.isUninitialized){const{endpointName:j}=S,D=y[j];I!==fe&&c({queryArgs:S.originalArgs,endpointDefinition:D,endpointName:j})===c({queryArgs:I,endpointDefinition:D,endpointName:j})&&(S=void 0)}let N=f.isSuccess?f.data:S==null?void 0:S.data;N===void 0&&(N=f.data);const x=N!==void 0,h=f.isLoading,w=(!S||S.isLoading||S.isUninitialized)&&!x&&h,C=f.isSuccess||x&&(h&&!(S!=null&&S.isError)||f.isUninitialized);return{...f,data:N,currentData:f.data,isFetching:h,isLoading:w,isSuccess:C}}function g(f,S,I){if(S!=null&&S.endpointName&&f.isUninitialized){const{endpointName:j}=S,D=y[j];I!==fe&&c({queryArgs:S.originalArgs,endpointDefinition:D,endpointName:j})===c({queryArgs:I,endpointDefinition:D,endpointName:j})&&(S=void 0)}let N=f.isSuccess?f.data:S==null?void 0:S.data;N===void 0&&(N=f.data);const x=N!==void 0,h=f.isLoading,w=(!S||S.isLoading||S.isUninitialized)&&!x&&h,C=f.isSuccess||x&&(h&&!(S!=null&&S.isError)||f.isUninitialized);return{...f,data:N,currentData:f.data,isFetching:h,isLoading:w,isSuccess:C}}function p(f,S){const I=n(),N=Ve(S);return T.useCallback((x,h)=>I(e.util.prefetch(f,x,{...N,...h})),[f,I,N])}function _(f,S,{refetchOnReconnect:I,refetchOnFocus:N,refetchOnMountOrArgChange:x,skip:h=!1,pollingInterval:w=0,skipPollingIfUnfocused:C=!1,...j}={}){const{initiate:D}=e.endpoints[f],R=n(),Q=T.useRef(void 0);if(!Q.current){const L=R(e.internalActions.internal_getRTKQSubscriptions());if(process.env.NODE_ENV!=="production"&&(typeof L!="object"||typeof(L==null?void 0:L.type)=="string"))throw new Error(process.env.NODE_ENV==="production"?U(37):`Warning: Middleware for RTK-Query API at reducerPath "${e.reducerPath}" has not been added to the store.
|
|
42
|
+
You must add the middleware for RTK-Query to function correctly!`);Q.current=L}const M=dn(h?fe:S),A=Ve({refetchOnReconnect:I,refetchOnFocus:N,pollingInterval:w,skipPollingIfUnfocused:C}),V=j.initialPageParam,F=Ve(V),B=j.refetchCachedPages,K=Ve(B),H=T.useRef(void 0);let{queryCacheKey:Y,requestId:G}=H.current||{},$=!1;Y&&G&&($=Q.current.isRequestSubscribed(Y,G));const W=!$&&H.current!==void 0;return u(()=>{W&&(H.current=void 0)},[W]),u(()=>{var z;const L=H.current;if(typeof process<"u"&&process.env.NODE_ENV==="removeMeOnCompilation"&&console.log(W),M===fe){L==null||L.unsubscribe(),H.current=void 0;return}const te=(z=H.current)==null?void 0:z.subscriptionOptions;if(!L||L.arg!==M){L==null||L.unsubscribe();const q=R(D(M,{subscriptionOptions:A,forceRefetch:x,...Bi(y[f])?{initialPageParam:F,refetchCachedPages:K}:{}}));H.current=q}else A!==te&&L.updateSubscriptionOptions(A)},[R,D,x,M,A,W,F,K,f]),[H,R,D,A]}function m(f,S){return(N,{skip:x=!1,selectFromResult:h}={})=>{const{select:w}=e.endpoints[f],C=dn(x?fe:N),j=T.useRef(void 0),D=T.useMemo(()=>s([w(C),(V,F)=>F,V=>C],S,{memoizeOptions:{resultEqualityCheck:Ye}}),[w,C]),R=T.useMemo(()=>h?s([D],h,{devModeChecks:{identityFunctionCheck:"never"}}):D,[D,h]),Q=r(V=>R(V,j.current),Ye),M=i(),A=D(M.getState(),j.current);return Jc(()=>{j.current=A},[A]),Q}}function E(f){T.useEffect(()=>()=>{l(f),f.current=void 0},[f])}function k(f){if(!f.current)throw new Error(process.env.NODE_ENV==="production"?U(38):"Cannot refetch a query that has not been started yet.");return f.current.refetch()}function b(f){const S=(x,h={})=>{const[w]=_(f,x,h);return E(w),T.useMemo(()=>({refetch:()=>k(w)}),[w])},I=({refetchOnReconnect:x,refetchOnFocus:h,pollingInterval:w=0,skipPollingIfUnfocused:C=!1}={})=>{const{initiate:j}=e.endpoints[f],D=n(),[R,Q]=T.useState(fn),M=T.useRef(void 0),A=Ve({refetchOnReconnect:x,refetchOnFocus:h,pollingInterval:w,skipPollingIfUnfocused:C});u(()=>{var H,Y;const K=(H=M.current)==null?void 0:H.subscriptionOptions;A!==K&&((Y=M.current)==null||Y.updateSubscriptionOptions(A))},[A]);const V=T.useRef(A);u(()=>{V.current=A},[A]);const F=T.useCallback(function(K,H=!1){let Y;return t(()=>{l(M),M.current=Y=D(j(K,{subscriptionOptions:V.current,forceRefetch:!H})),Q(K)}),Y},[D,j]),B=T.useCallback(()=>{var K,H;(K=M.current)!=null&&K.queryCacheKey&&D(e.internalActions.removeQueryResult({queryCacheKey:(H=M.current)==null?void 0:H.queryCacheKey}))},[D]);return T.useEffect(()=>()=>{l(M)},[]),T.useEffect(()=>{R!==fn&&!M.current&&F(R,!0)},[R,F]),T.useMemo(()=>[F,R,{reset:B}],[F,R,B])},N=m(f,O);return{useQueryState:N,useQuerySubscription:S,useLazyQuerySubscription:I,useLazyQuery(x){const[h,w,{reset:C}]=I(x),j=N(w,{...x,skip:w===fn}),D=T.useMemo(()=>({lastArg:w}),[w]);return T.useMemo(()=>[h,{...j,reset:C},D],[h,j,C,D])},useQuery(x,h){const w=S(x,h),C=N(x,{selectFromResult:x===fe||h!=null&&h.skip?void 0:Qr,...h}),j=mn(C,...pn);return T.useDebugValue(j),T.useMemo(()=>({...C,...w}),[C,w])}}}function v(f){const S=(N,x={})=>{const[h,w,C,j]=_(f,N,x),D=T.useRef(j);u(()=>{D.current=j},[j]);const R=x.refetchCachedPages,Q=Ve(R),M=T.useCallback(function(F,B){let K;return t(()=>{l(h),h.current=K=w(C(F,{subscriptionOptions:D.current,direction:B}))}),K},[h,w,C]);E(h);const A=dn(x.skip?fe:N),V=T.useCallback(F=>{if(!h.current)throw new Error(process.env.NODE_ENV==="production"?U(38):"Cannot refetch a query that has not been started yet.");const B={refetchCachedPages:(F==null?void 0:F.refetchCachedPages)??Q};return h.current.refetch(B)},[h,Q]);return T.useMemo(()=>({trigger:M,refetch:V,fetchNextPage:()=>M(A,"forward"),fetchPreviousPage:()=>M(A,"backward")}),[V,M,A])},I=m(f,g);return{useInfiniteQueryState:I,useInfiniteQuerySubscription:S,useInfiniteQuery(N,x){const{refetch:h,fetchNextPage:w,fetchPreviousPage:C}=S(N,x),j=I(N,{selectFromResult:N===fe||x!=null&&x.skip?void 0:Qr,...x}),D=mn(j,...pn,"hasNextPage","hasPreviousPage");return T.useDebugValue(D),T.useMemo(()=>({...j,fetchNextPage:w,fetchPreviousPage:C,refetch:h}),[j,w,C,h])}}}function d(f){return({selectFromResult:S,fixedCacheKey:I}={})=>{const{select:N,initiate:x}=e.endpoints[f],h=n(),[w,C]=T.useState();T.useEffect(()=>()=>{w!=null&&w.arg.fixedCacheKey||w==null||w.reset()},[w]);const j=T.useCallback(function(K){const H=h(x(K,{fixedCacheKey:I}));return C(H),H},[h,x,I]),{requestId:D}=w||{},R=T.useMemo(()=>N({fixedCacheKey:I,requestId:w==null?void 0:w.requestId}),[I,w,N]),Q=T.useMemo(()=>S?s([R],S):R,[S,R]),M=r(Q,Ye),A=I==null?w==null?void 0:w.arg.originalArgs:void 0,V=T.useCallback(()=>{t(()=>{w&&C(void 0),I&&h(e.internalActions.removeMutationResult({requestId:D,fixedCacheKey:I}))})},[h,I,w,D]),F=mn(M,...pn,"endpointName");T.useDebugValue(F);const B=T.useMemo(()=>({...M,originalArgs:A,reset:V}),[M,A,V]);return T.useMemo(()=>[j,B],[j,B])}}}var Zc=Symbol(),ea=({batch:e=qo,hooks:t={useDispatch:si,useSelector:ci,useStore:oi},createSelector:n=Ei,unstable__sideEffectsInRender:r=!1,...i}={})=>{if(process.env.NODE_ENV!=="production"){const o=["useDispatch","useSelector","useStore"];let s=!1;for(const c of o)if($c(i)>0&&(i[c]&&(s||(console.warn("As of RTK 2.0, the hooks now need to be specified as one object, provided under a `hooks` key:\n`reactHooksModule({ hooks: { useDispatch, useSelector, useStore } })`"),s=!0)),t[c]=i[c]),typeof t[c]!="function")throw new Error(process.env.NODE_ENV==="production"?U(36):`When using custom hooks for context, all ${o.length} hooks need to be provided: ${o.join(", ")}.
|
|
43
|
+
Hook ${c} was either not provided or not a function.`)}return{name:Zc,init(o,{serializeQueryArgs:s},c){const a=o,{buildQueryHooks:u,buildInfiniteQueryHooks:l,buildMutationHook:y,usePrefetch:O}=Xc({api:o,moduleOptions:{batch:e,hooks:t,unstable__sideEffectsInRender:r,createSelector:n},serializeQueryArgs:s,context:c});return ze(a,{usePrefetch:O}),ze(c,{batch:e}),{injectEndpoint(g,p){if(zc(p)){const{useQuery:_,useLazyQuery:m,useLazyQuerySubscription:E,useQueryState:k,useQuerySubscription:b}=u(g);ze(a.endpoints[g],{useQuery:_,useLazyQuery:m,useLazyQuerySubscription:E,useQueryState:k,useQuerySubscription:b}),o[`use${It(g)}Query`]=_,o[`useLazy${It(g)}Query`]=m}if(Wc(p)){const _=y(g);ze(a.endpoints[g],{useMutation:_}),o[`use${It(g)}Mutation`]=_}else if(Bi(p)){const{useInfiniteQuery:_,useInfiniteQuerySubscription:m,useInfiniteQueryState:E}=l(g);ze(a.endpoints[g],{useInfiniteQuery:_,useInfiniteQuerySubscription:m,useInfiniteQueryState:E}),o[`use${It(g)}InfiniteQuery`]=_}}}}}},ta=zi(Wi(),ea());const na=async(e,t,n)=>{const{baseUrl:r,getToken:i}=zo();return wc({baseUrl:r,prepareHeaders:async s=>{const c=await(i==null?void 0:i());return c&&s.set("Authorization",`Bearer ${c}`),s}})(e,t,n)},ra=["ChatHistory"],Hi={ChatHistory:"ChatHistory"},$r=e=>{var t,n;return{status:e==null?void 0:e.status,message:((t=e==null?void 0:e.data)==null?void 0:t.message)??((n=e==null?void 0:e.data)==null?void 0:n.error)??(e==null?void 0:e.error)??"Something went wrong. Please try again."}},ia={sendMessage:{getUrl:()=>"/chat/messages",method:"POST",transformResponse:e=>e,invalidatesTags:[Hi.ChatHistory]}},oa={getChatHistory:{getUrl:({conversationId:e})=>`/chat/conversations/${e}`,method:"GET",transformResponse:e=>e,providesTags:[Hi.ChatHistory]}},sa={submitFeedback:{getUrl:()=>"/chat/feedback",method:"POST",transformResponse:e=>e}},Lr={...ia,...sa},qr={...oa},kt=ta({reducerPath:"mintAiApi",baseQuery:na,tagTypes:ra,endpoints:e=>{const t={};return Object.keys(Lr).forEach(n=>{const r=Lr[n];t[n]=e.mutation({query:i=>({url:r.getUrl(i),method:r.method,body:i}),transformResponse:i=>r.transformResponse(i),transformErrorResponse:i=>{var o;return((o=r.transformErrorResponse)==null?void 0:o.call(r,i))??$r(i)},invalidatesTags:r.invalidatesTags??[]})}),Object.keys(qr).forEach(n=>{const r=qr[n];t[n]=e.query({query:i=>({url:r.getUrl(i),method:r.method}),transformResponse:i=>r.transformResponse(i),transformErrorResponse:i=>$r(i),providesTags:r.providesTags??[]})}),t}}),{useSendMessageMutation:ca}=kt,Ur={open:!1,expanded:!1,conversationId:void 0,messages:[],draft:""},Ki=je({name:"chatUi",initialState:Ur,reducers:{setOpen(e,t){e.open=t.payload,t.payload||(e.expanded=!1)},setExpanded(e,t){e.expanded=t.payload,t.payload&&(e.open=!0)},toggleOpen(e){e.open=!e.open,e.open||(e.expanded=!1)},setConversationId(e,t){e.conversationId=t.payload},setDraft(e,t){e.draft=t.payload},addMessage(e,t){e.messages.push(t.payload)},setMessages(e,t){e.messages=t.payload},resetChat(){return Ur}}}),{setOpen:An,setExpanded:Gi,toggleOpen:aa,setConversationId:ua,setDraft:Yi,addMessage:hn,setMessages:Vu,resetChat:Fu}=Ki.actions,la=Ki.reducer,fa=Ws({reducer:{[kt.reducerPath]:kt.reducer,chatUi:la},middleware:e=>e().concat(kt.middleware)});function da({config:e,children:t}){return P.jsx(Fo,{store:fa,children:P.jsx(Bo,{config:e,children:P.jsx("div",{className:"mint-ai-root",children:t})})})}const en=()=>si(),zt=ci;function Ji(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ji(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ma(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ji(e))&&(r&&(r+=" "),r+=t);return r}function ve(...e){return ma(e)}const Xi=Object.freeze({left:0,top:0,width:16,height:16}),Wt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Gn=Object.freeze({...Xi,...Wt}),Dn=Object.freeze({...Gn,body:"",hidden:!1});function pa(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function zr(e,t){const n=pa(e,t);for(const r in Dn)r in Wt?r in e&&!(r in n)&&(n[r]=Wt[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ha(e,t){const n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function o(s){if(n[s])return i[s]=[];if(!(s in i)){i[s]=null;const c=r[s]&&r[s].parent,a=c&&o(c);a&&(i[s]=[c].concat(a))}return i[s]}return Object.keys(n).concat(Object.keys(r)).forEach(o),i}function ya(e,t,n){const r=e.icons,i=e.aliases||Object.create(null);let o={};function s(c){o=zr(r[c]||i[c],o)}return s(t),n.forEach(s),zr(e,o)}function Zi(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(i=>{t(i,null),n.push(i)});const r=ha(e);for(const i in r){const o=r[i];o&&(t(i,ya(e,i,o)),n.push(i))}return n}const ga={provider:"",aliases:{},not_found:{},...Xi};function yn(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function eo(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!yn(e,ga))return null;const n=t.icons;for(const i in n){const o=n[i];if(!i||typeof o.body!="string"||!yn(o,Dn))return null}const r=t.aliases||Object.create(null);for(const i in r){const o=r[i],s=o.parent;if(!i||typeof s!="string"||!n[s]&&!r[s]||!yn(o,Dn))return null}return t}const to=/^[a-z0-9]+(-[a-z0-9]+)*$/,tn=(e,t,n,r="")=>{const i=e.split(":");if(e.slice(0,1)==="@"){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){const c=i.pop(),a=i.pop(),u={provider:i.length>0?i[0]:r,prefix:a,name:c};return t&&!Pt(u)?null:u}const o=i[0],s=o.split("-");if(s.length>1){const c={provider:r,prefix:s.shift(),name:s.join("-")};return t&&!Pt(c)?null:c}if(n&&r===""){const c={provider:r,prefix:"",name:o};return t&&!Pt(c,n)?null:c}return null},Pt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1,Wr=Object.create(null);function ba(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Le(e,t){const n=Wr[e]||(Wr[e]=Object.create(null));return n[t]||(n[t]=ba(e,t))}function no(e,t){return eo(t)?Zi(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function va(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}let at=!1;function ro(e){return typeof e=="boolean"&&(at=e),at}function Br(e){const t=typeof e=="string"?tn(e,!0,at):e;if(t){const n=Le(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function wa(e,t){const n=tn(e,!0,at);if(!n)return!1;const r=Le(n.provider,n.prefix);return t?va(r,n.name,t):(r.missing.add(n.name),!0)}function xa(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),at&&!t&&!e.prefix){let i=!1;return eo(e)&&(e.prefix="",Zi(e,(o,s)=>{wa(o,s)&&(i=!0)})),i}const n=e.prefix;if(!Pt({prefix:n,name:"a"}))return!1;const r=Le(t,n);return!!no(r,e)}const io=Object.freeze({width:null,height:null}),oo=Object.freeze({...io,...Wt}),Ea=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Sa=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Hr(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Ea);if(r===null||!r.length)return e;const i=[];let o=r.shift(),s=Sa.test(o);for(;;){if(s){const c=parseFloat(o);isNaN(c)?i.push(o):i.push(Math.ceil(c*t*n)/n)}else i.push(o);if(o=r.shift(),o===void 0)return i.join("");s=!s}}function Na(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const i=e.indexOf(">",r),o=e.indexOf("</"+t);if(i===-1||o===-1)break;const s=e.indexOf(">",o);if(s===-1)break;n+=e.slice(i+1,o).trim(),e=e.slice(0,r).trim()+e.slice(s+1)}return{defs:n,content:e}}function _a(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Oa(e,t,n){const r=Na(e);return _a(r.defs,t+r.content+n)}const Ia=e=>e==="unset"||e==="undefined"||e==="none";function Ca(e,t){const n={...Gn,...e},r={...oo,...t},i={left:n.left,top:n.top,width:n.width,height:n.height};let o=n.body;[n,r].forEach(_=>{const m=[],E=_.hFlip,k=_.vFlip;let b=_.rotate;E?k?b+=2:(m.push("translate("+(i.width+i.left).toString()+" "+(0-i.top).toString()+")"),m.push("scale(-1 1)"),i.top=i.left=0):k&&(m.push("translate("+(0-i.left).toString()+" "+(i.height+i.top).toString()+")"),m.push("scale(1 -1)"),i.top=i.left=0);let v;switch(b<0&&(b-=Math.floor(b/4)*4),b=b%4,b){case 1:v=i.height/2+i.top,m.unshift("rotate(90 "+v.toString()+" "+v.toString()+")");break;case 2:m.unshift("rotate(180 "+(i.width/2+i.left).toString()+" "+(i.height/2+i.top).toString()+")");break;case 3:v=i.width/2+i.left,m.unshift("rotate(-90 "+v.toString()+" "+v.toString()+")");break}b%2===1&&(i.left!==i.top&&(v=i.left,i.left=i.top,i.top=v),i.width!==i.height&&(v=i.width,i.width=i.height,i.height=v)),m.length&&(o=Oa(o,'<g transform="'+m.join(" ")+'">',"</g>"))});const s=r.width,c=r.height,a=i.width,u=i.height;let l,y;s===null?(y=c===null?"1em":c==="auto"?u:c,l=Hr(y,a/u)):(l=s==="auto"?a:s,y=c===null?Hr(l,u/a):c==="auto"?u:c);const O={},g=(_,m)=>{Ia(m)||(O[_]=m.toString())};g("width",l),g("height",y);const p=[i.left,i.top,a,u];return O.viewBox=p.join(" "),{attributes:O,viewBox:p,body:o}}const ja=/\sid="(\S+)"/g,ka="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Pa=0;function Aa(e,t=ka){const n=[];let r;for(;r=ja.exec(e);)n.push(r[1]);if(!n.length)return e;const i="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(o=>{const s=typeof t=="function"?t(o):t+(Pa++).toString(),c=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+c+')([")]|\\.[a-z])',"g"),"$1"+s+i+"$3")}),e=e.replace(new RegExp(i,"g"),""),e}const Rn=Object.create(null);function Da(e,t){Rn[e]=t}function Mn(e){return Rn[e]||Rn[""]}function Yn(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const Jn=Object.create(null),We=["https://api.simplesvg.com","https://api.unisvg.com"],At=[];for(;We.length>0;)We.length===1||Math.random()>.5?At.push(We.shift()):At.push(We.pop());Jn[""]=Yn({resources:["https://api.iconify.design"].concat(At)});function Ra(e,t){const n=Yn(t);return n===null?!1:(Jn[e]=n,!0)}function Xn(e){return Jn[e]}const Ma=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Kr=Ma();function Ta(e,t){const n=Xn(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let i=0;n.resources.forEach(s=>{i=Math.max(i,s.length)});const o=t+".json?icons=";r=n.maxURL-i-n.path.length-o.length}return r}function Va(e){return e===404}const Fa=(e,t,n)=>{const r=[],i=Ta(e,t),o="icons";let s={type:o,provider:e,prefix:t,icons:[]},c=0;return n.forEach((a,u)=>{c+=a.length+1,c>=i&&u>0&&(r.push(s),s={type:o,provider:e,prefix:t,icons:[]},c=a.length),s.icons.push(a)}),r.push(s),r};function Qa(e){if(typeof e=="string"){const t=Xn(e);if(t)return t.path}return"/"}const $a=(e,t,n)=>{if(!Kr){n("abort",424);return}let r=Qa(t.provider);switch(t.type){case"icons":{const o=t.prefix,c=t.icons.join(","),a=new URLSearchParams({icons:c});r+=o+".json?"+a.toString();break}case"custom":{const o=t.uri;r+=o.slice(0,1)==="/"?o.slice(1):o;break}default:n("abort",400);return}let i=503;Kr(e+r).then(o=>{const s=o.status;if(s!==200){setTimeout(()=>{n(Va(s)?"abort":"next",s)});return}return i=501,o.json()}).then(o=>{if(typeof o!="object"||o===null){setTimeout(()=>{o===404?n("abort",o):n("next",i)});return}setTimeout(()=>{n("success",o)})}).catch(()=>{n("next",i)})},La={prepare:Fa,send:$a};function qa(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((i,o)=>i.provider!==o.provider?i.provider.localeCompare(o.provider):i.prefix!==o.prefix?i.prefix.localeCompare(o.prefix):i.name.localeCompare(o.name));let r={provider:"",prefix:"",name:""};return e.forEach(i=>{if(r.name===i.name&&r.prefix===i.prefix&&r.provider===i.provider)return;r=i;const o=i.provider,s=i.prefix,c=i.name,a=n[o]||(n[o]=Object.create(null)),u=a[s]||(a[s]=Le(o,s));let l;c in u.icons?l=t.loaded:s===""||u.missing.has(c)?l=t.missing:l=t.pending;const y={provider:o,prefix:s,name:c};l.push(y)}),t}function so(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(i=>i.id!==t))})}function Ua(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,i=e.prefix;t.forEach(o=>{const s=o.icons,c=s.pending.length;s.pending=s.pending.filter(a=>{if(a.prefix!==i)return!0;const u=a.name;if(e.icons[u])s.loaded.push({provider:r,prefix:i,name:u});else if(e.missing.has(u))s.missing.push({provider:r,prefix:i,name:u});else return n=!0,!0;return!1}),s.pending.length!==c&&(n||so([e],o.id),o.callback(s.loaded.slice(0),s.missing.slice(0),s.pending.slice(0),o.abort))})}))}let za=0;function Wa(e,t,n){const r=za++,i=so.bind(null,n,r);if(!t.pending.length)return i;const o={id:r,icons:t,callback:e,abort:i};return n.forEach(s=>{(s.loaderCallbacks||(s.loaderCallbacks=[])).push(o)}),i}function Ba(e,t=!0,n=!1){const r=[];return e.forEach(i=>{const o=typeof i=="string"?tn(i,t,n):i;o&&r.push(o)}),r}var Ha={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ka(e,t,n,r){const i=e.resources.length,o=e.random?Math.floor(Math.random()*i):e.index;let s;if(e.random){let f=e.resources.slice(0);for(s=[];f.length>1;){const S=Math.floor(Math.random()*f.length);s.push(f[S]),f=f.slice(0,S).concat(f.slice(S+1))}s=s.concat(f)}else s=e.resources.slice(o).concat(e.resources.slice(0,o));const c=Date.now();let a="pending",u=0,l,y=null,O=[],g=[];typeof r=="function"&&g.push(r);function p(){y&&(clearTimeout(y),y=null)}function _(){a==="pending"&&(a="aborted"),p(),O.forEach(f=>{f.status==="pending"&&(f.status="aborted")}),O=[]}function m(f,S){S&&(g=[]),typeof f=="function"&&g.push(f)}function E(){return{startTime:c,payload:t,status:a,queriesSent:u,queriesPending:O.length,subscribe:m,abort:_}}function k(){a="failed",g.forEach(f=>{f(void 0,l)})}function b(){O.forEach(f=>{f.status==="pending"&&(f.status="aborted")}),O=[]}function v(f,S,I){const N=S!=="success";switch(O=O.filter(x=>x!==f),a){case"pending":break;case"failed":if(N||!e.dataAfterTimeout)return;break;default:return}if(S==="abort"){l=I,k();return}if(N){l=I,O.length||(s.length?d():k());return}if(p(),b(),!e.random){const x=e.resources.indexOf(f.resource);x!==-1&&x!==e.index&&(e.index=x)}a="completed",g.forEach(x=>{x(I)})}function d(){if(a!=="pending")return;p();const f=s.shift();if(f===void 0){if(O.length){y=setTimeout(()=>{p(),a==="pending"&&(b(),k())},e.timeout);return}k();return}const S={status:"pending",resource:f,callback:(I,N)=>{v(S,I,N)}};O.push(S),u++,y=setTimeout(d,e.rotate),n(f,t,S.callback)}return setTimeout(d),E}function co(e){const t={...Ha,...e};let n=[];function r(){n=n.filter(c=>c().status==="pending")}function i(c,a,u){const l=Ka(t,c,a,(y,O)=>{r(),u&&u(y,O)});return n.push(l),l}function o(c){return n.find(a=>c(a))||null}return{query:i,find:o,setIndex:c=>{t.index=c},getIndex:()=>t.index,cleanup:r}}function Gr(){}const gn=Object.create(null);function Ga(e){if(!gn[e]){const t=Xn(e);if(!t)return;const n=co(t),r={config:t,redundancy:n};gn[e]=r}return gn[e]}function Ya(e,t,n){let r,i;if(typeof e=="string"){const o=Mn(e);if(!o)return n(void 0,424),Gr;i=o.send;const s=Ga(e);s&&(r=s.redundancy)}else{const o=Yn(e);if(o){r=co(o);const s=e.resources?e.resources[0]:"",c=Mn(s);c&&(i=c.send)}}return!r||!i?(n(void 0,424),Gr):r.query(t,i,n)().abort}function Yr(){}function Ja(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Ua(e)}))}function Xa(e){const t=[],n=[];return e.forEach(r=>{(r.match(to)?t:n).push(r)}),{valid:t,invalid:n}}function Be(e,t,n){function r(){const i=e.pendingIcons;t.forEach(o=>{i&&i.delete(o),e.icons[o]||e.missing.add(o)})}if(n&&typeof n=="object")try{if(!no(e,n).length){r();return}}catch(i){console.error(i)}r(),Ja(e)}function Jr(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function Za(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,i=e.iconsToLoad;if(delete e.iconsToLoad,!i||!i.length)return;const o=e.loadIcon;if(e.loadIcons&&(i.length>1||!o)){Jr(e.loadIcons(i,r,n),l=>{Be(e,i,l)});return}if(o){i.forEach(l=>{const y=o(l,r,n);Jr(y,O=>{const g=O?{prefix:r,icons:{[l]:O}}:null;Be(e,[l],g)})});return}const{valid:s,invalid:c}=Xa(i);if(c.length&&Be(e,c,null),!s.length)return;const a=r.match(to)?Mn(n):null;if(!a){Be(e,s,null);return}a.prepare(n,r,s).forEach(l=>{Ya(n,l,y=>{Be(e,l.icons,y)})})}))}const eu=(e,t)=>{const n=Ba(e,!0,ro()),r=qa(n);if(!r.pending.length){let a=!0;return t&&setTimeout(()=>{a&&t(r.loaded,r.missing,r.pending,Yr)}),()=>{a=!1}}const i=Object.create(null),o=[];let s,c;return r.pending.forEach(a=>{const{provider:u,prefix:l}=a;if(l===c&&u===s)return;s=u,c=l,o.push(Le(u,l));const y=i[u]||(i[u]=Object.create(null));y[l]||(y[l]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:l,name:y}=a,O=Le(u,l),g=O.pendingIcons||(O.pendingIcons=new Set);g.has(y)||(g.add(y),i[u][l].push(y))}),o.forEach(a=>{const u=i[a.provider][a.prefix];u.length&&Za(a,u)}),t?Wa(t,r,o):Yr};function tu(e,t){const n={...e};for(const r in t){const i=t[r],o=typeof i;r in io?(i===null||i&&(o==="string"||o==="number"))&&(n[r]=i):o===typeof n[r]&&(n[r]=r==="rotate"?i%4:i)}return n}const nu=/[\s,]+/;function ru(e,t){t.split(nu).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function iu(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(i){for(;i<0;)i+=4;return i%4}if(n===""){const i=parseInt(e);return isNaN(i)?0:r(i)}else if(n!==e){let i=0;switch(n){case"%":i=25;break;case"deg":i=90}if(i){let o=parseFloat(e.slice(0,e.length-n.length));return isNaN(o)?0:(o=o/i,o%1===0?r(o):0)}}return t}function ou(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function su(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function cu(e){return"data:image/svg+xml,"+su(e)}function au(e){return'url("'+cu(e)+'")'}let et;function uu(){try{et=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{et=null}}function lu(e){return et===void 0&&uu(),et?et.createHTML(e):e}const ao={...oo,inline:!1},fu={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},du={display:"inline-block"},Tn={backgroundColor:"currentColor"},uo={backgroundColor:"transparent"},Xr={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Zr={WebkitMask:Tn,mask:Tn,background:uo};for(const e in Zr){const t=Zr[e];for(const n in Xr)t[e+n]=Xr[n]}const mu={...ao,inline:!0};function ei(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const pu=(e,t,n)=>{const r=t.inline?mu:ao,i=tu(r,t),o=t.mode||"svg",s={},c=t.style||{},a={...o==="svg"?fu:{}};if(n){const m=tn(n,!1,!0);if(m){const E=["iconify"],k=["provider","prefix"];for(const b of k)m[b]&&E.push("iconify--"+m[b]);a.className=E.join(" ")}}for(let m in t){const E=t[m];if(E!==void 0)switch(m){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":break;case"_ref":a.ref=E;break;case"className":a[m]=(a[m]?a[m]+" ":"")+E;break;case"inline":case"hFlip":case"vFlip":i[m]=E===!0||E==="true"||E===1;break;case"flip":typeof E=="string"&&ru(i,E);break;case"color":s.color=E;break;case"rotate":typeof E=="string"?i[m]=iu(E):typeof E=="number"&&(i[m]=E);break;case"ariaHidden":case"aria-hidden":E!==!0&&E!=="true"&&delete a["aria-hidden"];break;default:r[m]===void 0&&(a[m]=E)}}const u=Ca(e,i),l=u.attributes;if(i.inline&&(s.verticalAlign="-0.125em"),o==="svg"){a.style={...s,...c},Object.assign(a,l);let m=0,E=t.id;return typeof E=="string"&&(E=E.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:lu(Aa(u.body,E?()=>E+"ID"+m++:"iconifyReact"))},T.createElement("svg",a)}const{body:y,width:O,height:g}=e,p=o==="mask"||(o==="bg"?!1:y.indexOf("currentColor")!==-1),_=ou(y,{...l,width:O+"",height:g+""});return a.style={...s,"--svg":au(_),width:ei(l.width),height:ei(l.height),...du,...p?Tn:uo,...c},T.createElement("span",a)};ro(!0);Da("",La);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!xa(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const i=t[n];if(typeof i!="object"||!i||i.resources===void 0)continue;Ra(n,i)||console.error(r)}catch{console.error(r)}}}}function lo(e){const[t,n]=T.useState(!!e.ssr),[r,i]=T.useState({});function o(g){if(g){const p=e.icon;if(typeof p=="object")return{name:"",data:p};const _=Br(p);if(_)return{name:p,data:_}}return{name:""}}const[s,c]=T.useState(o(!!e.ssr));function a(){const g=r.callback;g&&(g(),i({}))}function u(g){if(JSON.stringify(s)!==JSON.stringify(g))return a(),c(g),!0}function l(){var g;const p=e.icon;if(typeof p=="object"){u({name:"",data:p});return}const _=Br(p);if(u({name:p,data:_}))if(_===void 0){const m=eu([p],l);i({callback:m})}else _&&((g=e.onLoad)===null||g===void 0||g.call(e,p))}T.useEffect(()=>(n(!0),a),[]),T.useEffect(()=>{t&&l()},[e.icon,t]);const{name:y,data:O}=s;return O?pu({...Gn,...O},e,y):e.children?e.children:e.fallback?e.fallback:T.createElement("span",{})}const hu=T.forwardRef((e,t)=>lo({...e,_ref:t}));T.forwardRef((e,t)=>lo({inline:!0,...e,_ref:t}));function X({className:e,width:t=20,...n}){return P.jsx(hu,{className:ve("mint-inline-block mint-shrink-0",e),width:t,height:t,...n})}const fo="ESM Sustainability AI",mo="AI assisted disclosure and operational data capture",yu="ESM Sustainability AI Expanded mode",gu="AI conversation with live form filling",bu=[{label:"Organization Carbon",icon:"solar:hexagon-linear"},{label:"Organization Energy",icon:"solar:bolt-bold"},{label:"Water Footprint",icon:"solar:waterdrop-linear"}],vu=[{id:"t1",role:"assistant",content:"I found the Energy Consumption form. Expand to review fields and submit evidence. Matched form Energy Consumption Confidence 94% • 5 fields"},{id:"t2",role:"user",content:"I mapped this to Scope 2 purchased electricity and filled the matching fields."}];function Bt({icon:e,label:t,onClick:n,className:r}){return P.jsx("button",{type:"button","aria-label":t,onClick:n,className:ve("mint-flex mint-h-10 mint-w-10 mint-shrink-0 mint-items-center mint-justify-center","mint-rounded-full mint-border-0 mint-bg-primary-light mint-p-0 mint-text-grey-800","mint-transition-transform hover:mint-scale-105",r),children:P.jsx(X,{icon:e,width:18})})}function po({title:e,subtitle:t,large:n,onClose:r}){return P.jsxs("div",{className:"mint-flex mint-items-start mint-justify-between mint-gap-3 mint-border-b mint-border-grey-200 mint-px-6 mint-py-5",children:[P.jsxs("div",{className:"mint-min-w-0",children:[P.jsx("h2",{className:ve("mint-truncate mint-font-bold mint-text-grey-900",n?"mint-text-3xl":"mint-text-2xl"),children:e}),P.jsx("p",{className:"mint-mt-1 mint-text-sm mint-text-grey-500",children:t})]}),P.jsxs("div",{className:"mint-flex mint-items-center mint-gap-2",children:[P.jsx(Bt,{icon:"mingcute:code-line",label:"Toggle code view"}),P.jsx(Bt,{icon:"mingcute:close-line",label:"Close",onClick:r})]})]})}function ho(){return P.jsx("span",{className:"mint-flex mint-h-12 mint-w-12 mint-shrink-0 mint-items-center mint-justify-center mint-rounded-full mint-bg-gradient-to-br mint-from-primary-light mint-to-primary mint-text-lg mint-font-semibold mint-text-primary-contrast",children:"M"})}function wu(){return P.jsx("span",{className:"mint-flex mint-h-12 mint-w-12 mint-shrink-0 mint-items-center mint-justify-center mint-overflow-hidden mint-rounded-full mint-bg-grey-300 mint-text-sm mint-font-semibold mint-text-grey-700",children:"HW"})}function Zn({leading:e="attach",compact:t}){return t?P.jsxs("div",{className:"mint-flex mint-h-11 mint-items-center mint-gap-2 mint-rounded-lg mint-border mint-border-grey-200 mint-bg-white mint-px-3 mint-shadow-widget",children:[P.jsx(X,{icon:"solar:magic-stars-bold",width:18,className:"mint-shrink-0 mint-text-primary-light"}),P.jsx("span",{className:"mint-flex-1 mint-text-xs mint-text-grey-500",children:"Ask the AI"}),P.jsx("button",{type:"button","aria-label":"Send",className:"mint-flex mint-h-7 mint-w-7 mint-items-center mint-justify-center mint-rounded-md mint-border-0 mint-bg-primary-light mint-p-0 mint-text-primary-contrast mint-shadow-sm mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:"solar:plain-2-bold",width:17})})]}):P.jsxs("div",{className:"mint-rounded-2xl mint-border mint-border-grey-300 mint-bg-white mint-px-5 mint-py-4 mint-shadow-sm",children:[P.jsxs("div",{className:"mint-flex mint-items-center mint-gap-2 mint-text-lg mint-text-grey-500",children:[P.jsx(X,{icon:"solar:magic-stars-bold",width:20,className:"mint-text-primary-light"}),P.jsx("span",{children:"Ask the AI"})]}),P.jsxs("div",{className:"mint-mt-4 mint-flex mint-items-end mint-justify-between",children:[P.jsx("button",{type:"button","aria-label":e==="attach"?"Attach file":"Add",className:"mint-flex mint-h-11 mint-w-11 mint-items-center mint-justify-center mint-rounded-full mint-border mint-border-primary-light mint-bg-transparent mint-p-0 mint-text-primary mint-transition-colors hover:mint-bg-primary-lighter",children:P.jsx(X,{icon:e==="attach"?"solar:paperclip-linear":"mingcute:add-line",width:20})}),P.jsx("button",{type:"button","aria-label":"Send",className:"mint-flex mint-h-11 mint-w-11 mint-items-center mint-justify-center mint-rounded-xl mint-border-0 mint-bg-primary-light mint-p-0 mint-text-primary-contrast mint-shadow-sm mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:"solar:arrow-up-linear",width:22})})]})]})}function yo({onClose:e}){return P.jsxs("div",{className:"mint-flex mint-h-[640px] mint-max-h-[85vh] mint-w-[420px] mint-max-w-[calc(100vw-32px)] mint-flex-col mint-overflow-hidden mint-rounded-2xl mint-bg-white mint-shadow-widget",children:[P.jsx(po,{title:fo,subtitle:mo,onClose:e}),P.jsxs("div",{className:"mint-flex mint-flex-1 mint-flex-col mint-items-center mint-justify-center mint-px-6",children:[P.jsx("h3",{className:"mint-text-center mint-text-3xl mint-font-bold mint-text-grey-900",children:"What can I help with?"}),P.jsx("div",{className:"mint-mt-6 mint-flex mint-flex-wrap mint-justify-center mint-gap-3",children:bu.map(t=>P.jsxs("button",{type:"button",className:"mint-flex mint-items-center mint-gap-2 mint-rounded-full mint-border mint-border-grey-300 mint-bg-white mint-px-4 mint-py-2 mint-text-sm mint-font-medium mint-text-grey-700 mint-transition-colors hover:mint-border-primary hover:mint-text-primary",children:[P.jsx(X,{icon:t.icon,width:16,className:"mint-text-grey-600"}),t.label]},t.label))})]}),P.jsx("div",{className:"mint-px-5 mint-pb-5",children:P.jsx(Zn,{leading:"attach"})})]})}function xu({role:e,children:t}){const n=e==="user";return P.jsxs("div",{className:ve("mint-flex mint-items-start mint-gap-3",n&&"mint-flex-row-reverse"),children:[n?P.jsx(wu,{}):P.jsx(ho,{}),P.jsx("div",{className:ve("mint-max-w-[78%] mint-rounded-2xl mint-px-4 mint-py-3 mint-text-sm mint-leading-relaxed",n?"mint-rounded-tr-sm mint-bg-grey-100 mint-text-grey-800":"mint-rounded-tl-sm mint-bg-primary-lighter/40 mint-text-grey-800"),children:t})]})}function go({onClose:e}){return P.jsxs("div",{className:"mint-flex mint-h-[640px] mint-max-h-[85vh] mint-w-[420px] mint-max-w-[calc(100vw-32px)] mint-flex-col mint-overflow-hidden mint-rounded-2xl mint-bg-white mint-shadow-widget",children:[P.jsx(po,{title:fo,subtitle:mo,onClose:e}),P.jsxs("div",{className:"mint-scroll mint-flex mint-flex-1 mint-flex-col mint-gap-5 mint-overflow-y-auto mint-px-5 mint-py-5",children:[vu.map(t=>P.jsx(xu,{role:t.role,children:t.content},t.id)),P.jsxs("div",{className:"mint-flex mint-items-start mint-gap-3",children:[P.jsx(ho,{}),P.jsxs("div",{className:"mint-max-w-[78%] mint-rounded-2xl mint-rounded-tl-sm mint-bg-primary-lighter/40 mint-px-4 mint-py-3",children:[P.jsx("p",{className:"mint-text-sm mint-font-semibold mint-text-grey-900",children:"AI conversation with live form filling"}),P.jsx("p",{className:"mint-mt-1 mint-text-sm mint-text-grey-700",children:"Expand to open the AI conversation and live form filling experience."}),P.jsxs("button",{type:"button",className:"mint-mt-3 mint-flex mint-items-center mint-gap-1.5 mint-rounded-lg mint-bg-gradient-to-br mint-from-primary-light mint-to-primary mint-px-3 mint-py-2 mint-text-xs mint-font-semibold mint-text-primary-contrast mint-transition-transform hover:mint-scale-105",children:[P.jsx(X,{icon:"mingcute:code-line",width:14}),"Open Expand mode"]})]})]})]}),P.jsx("div",{className:"mint-px-5 mint-pb-5",children:P.jsx(Zn,{leading:"attach"})})]})}function Eu(){return P.jsxs("aside",{className:"mint-flex mint-w-[226px] mint-shrink-0 mint-flex-col mint-gap-5 mint-rounded-xl mint-border mint-border-grey-200 mint-bg-white mint-p-4 mint-shadow-sm",children:[P.jsx("h1",{className:"mint-m-0 mint-text-[28px] mint-font-extrabold mint-leading-9 mint-text-grey-900",children:"MINT AI"}),P.jsxs("div",{className:"mint-flex mint-h-8 mint-items-center mint-gap-2 mint-rounded-lg mint-border mint-border-grey-200 mint-bg-white mint-px-3 mint-shadow-sm",children:[P.jsx(X,{icon:"solar:magnifer-linear",width:17,className:"mint-text-grey-500"}),P.jsx("span",{className:"mint-flex-1 mint-text-xs mint-text-grey-500",children:"Search"}),P.jsx(X,{icon:"solar:magic-stars-bold",width:16,className:"mint-text-primary-light"})]}),P.jsxs("button",{type:"button",className:"mint-flex mint-items-center mint-gap-2 mint-border-0 mint-bg-transparent mint-px-2 mint-text-xs mint-font-semibold mint-text-grey-800",children:[P.jsx(X,{icon:"solar:history-linear",width:17}),"History"]}),P.jsx("div",{className:"mint-flex mint-flex-1 mint-flex-col mint-gap-1",children:P.jsxs("div",{className:"mint-flex mint-items-center mint-gap-1 mint-px-2 mint-py-1 mint-text-xs mint-font-semibold mint-text-grey-700",children:["Recents",P.jsx(X,{icon:"mingcute:down-line",width:13,className:"mint-text-grey-500"})]})})]})}function er({onCollapse:e,onClose:t}){return P.jsxs("div",{className:"mint-flex mint-h-[min(92vh,614px)] mint-w-[min(1080px,calc(100vw-32px))] mint-gap-3 mint-rounded-2xl mint-bg-[#D9D9D9] mint-p-2",children:[P.jsx(Eu,{}),P.jsxs("section",{className:"mint-relative mint-flex mint-flex-1 mint-flex-col mint-overflow-hidden mint-rounded-xl mint-border mint-border-grey-200 mint-bg-white mint-shadow-sm",children:[P.jsxs("div",{className:"mint-flex mint-items-start mint-justify-between mint-gap-3 mint-px-6 mint-py-3",children:[P.jsxs("div",{className:"mint-min-w-0",children:[P.jsx("h2",{className:"mint-m-0 mint-truncate mint-text-[22px] mint-font-bold mint-leading-7 mint-text-grey-900",children:yu}),P.jsx("p",{className:"mint-m-0 mint-mt-1 mint-text-xs mint-leading-4 mint-text-grey-500",children:gu})]}),P.jsxs("div",{className:"mint-flex mint-items-center mint-gap-2",children:[P.jsx(Bt,{icon:"mingcute:code-line",label:"Back to normal mode",onClick:e,className:"mint-h-8 mint-w-8"}),P.jsx(Bt,{icon:"mingcute:close-line",label:"Close",onClick:t,className:"mint-h-8 mint-w-8"})]})]}),P.jsx("div",{className:"mint-mx-6 mint-h-px mint-shrink-0 mint-bg-grey-300"}),P.jsx("div",{className:"mint-scroll mint-flex mint-flex-1 mint-flex-col mint-overflow-y-auto mint-px-[66px] mint-pb-28 mint-pt-3"}),P.jsx("div",{className:"mint-absolute mint-bottom-8 mint-left-[66px] mint-right-[66px]",children:P.jsx(Zn,{leading:"add",compact:!0})})]})]})}const Su=[{id:"empty",label:"Empty"},{id:"conversation",label:"Conversation"},{id:"expanded",label:"Expand mode"}];function Nu({initial:e="empty"}){const[t,n]=T.useState(e);return P.jsxs("div",{className:"mint-ai-root mint-flex mint-min-h-screen mint-flex-col mint-items-center mint-gap-6 mint-bg-grey-200 mint-p-6",children:[P.jsx("div",{className:"mint-flex mint-gap-1 mint-rounded-full mint-bg-white mint-p-1 mint-shadow-sm",children:Su.map(r=>P.jsx("button",{type:"button",onClick:()=>n(r.id),className:ve("mint-rounded-full mint-px-4 mint-py-2 mint-text-sm mint-font-semibold mint-transition-colors",t===r.id?"mint-bg-primary mint-text-primary-contrast":"mint-text-grey-600 hover:mint-bg-grey-100"),children:r.label},r.id))}),P.jsxs("div",{className:"mint-flex mint-w-full mint-flex-1 mint-items-center mint-justify-center",children:[t==="empty"&&P.jsx(yo,{}),t==="conversation"&&P.jsx(go,{}),t==="expanded"&&P.jsx(er,{})]}),P.jsx("button",{type:"button","aria-label":"Close assistant",className:"mint-fixed mint-bottom-6 mint-right-6 mint-flex mint-h-14 mint-w-14 mint-items-center mint-justify-center mint-rounded-full mint-bg-primary-light mint-text-grey-800 mint-shadow-widget mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:"mingcute:close-line",width:24})})]})}function _u({open:e,onClick:t}){return P.jsx("button",{type:"button","aria-label":e?"Close assistant":"Open assistant",onClick:t,className:"mint-flex mint-h-12 mint-w-12 mint-items-center mint-justify-center mint-self-end mint-rounded-full mint-border-0 mint-bg-primary-light mint-p-0 mint-text-grey-800 mint-shadow-widget mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:e?"mingcute:close-line":"solar:chat-round-dots-bold",width:22})})}function ti(e="tmp"){return`${e}_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function Ou(e){const t=e.timestamp??e.createdAt??new Date().toISOString();return{...e,createdAt:t instanceof Date?t.toISOString():String(t),status:"sent"}}function bo(){const e=en(),{context:t}=ut(),{messages:n,draft:r,conversationId:i}=zt(a=>a.chatUi),[o,{isLoading:s}]=ca(),c=T.useCallback(async a=>{const u=(a??r).trim();if(!u||s)return;const l={id:ti("user"),role:"user",content:u,createdAt:new Date().toISOString(),status:"sending"};e(hn(l)),e(Yi(""));try{const y=await o({conversationId:i,message:u,context:t}).unwrap();i||e(ua(y.conversationId)),e(hn(Ou(y.reply)))}catch{e(hn({id:ti("err"),role:"system",content:"Failed to send. Please try again.",createdAt:new Date().toISOString(),status:"error"}))}},[r,s,e,o,i,t]);return{messages:n,draft:r,isLoading:s,send:c}}function Iu({onSend:e,disabled:t}){const n=en(),r=zt(s=>s.chatUi.draft),i=T.useRef(null),o=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),e())};return P.jsx("div",{className:"mint-px-5 mint-pb-5",children:P.jsxs("div",{className:"mint-flex mint-h-11 mint-items-center mint-gap-2 mint-rounded-lg mint-border mint-border-grey-200 mint-bg-white mint-px-3 mint-shadow-widget",children:[P.jsx(X,{icon:"solar:magic-stars-bold",width:21,className:"mint-shrink-0 mint-text-[#56E3AB]"}),P.jsx("textarea",{ref:i,rows:1,value:r,placeholder:"Ask the AI",onChange:s=>n(Yi(s.target.value)),onKeyDown:o,className:"mint-scroll mint-h-5 mint-max-h-20 mint-flex-1 mint-resize-none mint-border-0 mint-bg-transparent mint-p-0 mint-text-xs mint-leading-5 mint-text-grey-800 mint-outline-none placeholder:mint-text-grey-600"}),P.jsx("button",{type:"button","aria-label":"Send message",disabled:t||!r.trim(),onClick:e,className:"mint-flex mint-h-7 mint-w-7 mint-shrink-0 mint-items-center mint-justify-center mint-rounded-md mint-border-0 mint-bg-[#5EECB0] mint-p-0 mint-text-primary-contrast mint-transition-transform hover:mint-scale-105 disabled:mint-opacity-40 disabled:hover:mint-scale-100",children:P.jsx(X,{icon:"solar:plain-2-bold",width:17})})]})})}function Cu({message:e}){const t=e.role==="user";return e.role==="system"?P.jsx("div",{className:"mint-flex mint-justify-center mint-py-1",children:P.jsx("span",{className:"mint-rounded-full mint-bg-error/10 mint-px-3 mint-py-1 mint-text-xs mint-text-error",children:e.content})}):P.jsx("div",{className:ve("mint-flex mint-w-full",t?"mint-justify-end":"mint-justify-start"),children:P.jsx("div",{className:ve("mint-max-w-[78%] mint-whitespace-pre-wrap mint-break-words mint-rounded-2xl mint-px-4 mint-py-3 mint-text-sm mint-leading-relaxed",t?"mint-rounded-tr-sm mint-bg-grey-100 mint-text-grey-800":"mint-rounded-tl-sm mint-bg-primary-lighter/40 mint-text-grey-800",e.status==="sending"&&"mint-opacity-60"),children:e.content})})}const ju=[{label:"Organization Carbon",icon:"solar:buildings-3-line-duotone"},{label:"Organization Energy",icon:"solar:bolt-linear"},{label:"Water Footprint",icon:"solar:waterdrops-line-duotone"}];function ku({messages:e,isLoading:t}){const{welcomeMessage:n}=ut(),r=T.useRef(null);return T.useEffect(()=>{var i;(i=r.current)==null||i.scrollIntoView({behavior:"smooth"})},[e.length,t]),P.jsxs("div",{className:"mint-scroll mint-flex mint-flex-1 mint-flex-col mint-gap-5 mint-overflow-y-auto mint-px-5 mint-py-5",children:[e.length===0&&P.jsxs("div",{className:"mint-flex mint-flex-1 mint-flex-col mint-items-center mint-justify-center mint-px-1 mint-pb-[60px]",children:[P.jsx("h3",{className:"mint-text-center mint-text-[24px] mint-font-bold mint-leading-8 mint-text-grey-900",children:n}),P.jsx("div",{className:"mint-mt-2 mint-flex mint-w-fit mint-max-w-full mint-items-center mint-justify-center mint-gap-3",children:ju.map(i=>P.jsxs("button",{type:"button",className:"mint-inline-flex mint-h-6 mint-w-full mint-max-w-full mint-items-center mint-justify-center mint-gap-1 mint-whitespace-nowrap mint-rounded-lg mint-border mint-border-[#56E3AB] mint-bg-[#56E3AB]/[0.05] mint-px-2 mint-text-[10px] mint-font-normal mint-leading-none mint-text-grey-900 mint-transition-colors hover:mint-border-primary hover:mint-text-primary",children:[P.jsx(X,{icon:i.icon,width:12,className:"mint-shrink-0 mint-text-grey-700"}),i.label]},i.label))})]}),e.map(i=>P.jsx(Cu,{message:i},i.id)),t&&P.jsx("div",{className:"mint-flex mint-justify-start",children:P.jsxs("div",{className:"mint-flex mint-gap-1 mint-rounded-2xl mint-rounded-tl-sm mint-bg-primary-lighter/40 mint-px-4 mint-py-3",children:[P.jsx("span",{className:"mint-h-2 mint-w-2 mint-animate-bounce mint-rounded-full mint-bg-grey-500 [animation-delay:-0.3s]"}),P.jsx("span",{className:"mint-h-2 mint-w-2 mint-animate-bounce mint-rounded-full mint-bg-grey-500 [animation-delay:-0.15s]"}),P.jsx("span",{className:"mint-h-2 mint-w-2 mint-animate-bounce mint-rounded-full mint-bg-grey-500"})]})}),P.jsx("div",{ref:r})]})}function Pu(){const e=en(),{title:t}=ut(),{messages:n,isLoading:r,send:i}=bo();return P.jsx("div",{className:"mint-ai-shell",children:P.jsxs("div",{className:"mint-ai-panel mint-flex mint-flex-col mint-overflow-hidden mint-rounded-xl mint-bg-white",children:[P.jsxs("div",{className:"mint-mx-2 mint-flex mint-h-[82px] mint-shrink-0 mint-items-center mint-justify-between mint-gap-3 mint-px-3 mint-py-2",children:[P.jsxs("div",{className:"mint-min-w-0",children:[P.jsx("h2",{className:"mint-truncate mint-text-[21px] mint-font-bold mint-leading-6 mint-text-grey-900",children:t}),P.jsx("p",{className:"mint-mt-0 mint-text-[11px] mint-leading-4 mint-text-grey-600",children:"AI assisted disclosure and operational data capture"})]}),P.jsxs("div",{className:"mint-flex mint-shrink-0 mint-items-center mint-gap-2",children:[P.jsx("button",{type:"button","aria-label":"Open expand mode",onClick:()=>e(Gi(!0)),className:"mint-flex mint-h-7 mint-w-7 mint-shrink-0 mint-items-center mint-justify-center mint-rounded-full mint-border-0 mint-bg-[#5EECB0] mint-p-0 mint-text-grey-800 mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:"mingcute:code-line",width:14})}),P.jsx("button",{type:"button","aria-label":"Close assistant",onClick:()=>e(An(!1)),className:"mint-flex mint-h-7 mint-w-7 mint-shrink-0 mint-items-center mint-justify-center mint-rounded-full mint-border-0 mint-bg-[#5EECB0] mint-p-0 mint-text-grey-800 mint-transition-transform hover:mint-scale-105",children:P.jsx(X,{icon:"mingcute:close-line",width:14})})]})]}),P.jsx("div",{className:"mint-mx-2 mint-h-px mint-shrink-0 mint-bg-[#E5E7EB]"}),P.jsx(ku,{messages:n,isLoading:r}),P.jsx(Iu,{onSend:()=>i(),disabled:r})]})})}const Au={"bottom-right":"mint-bottom-4 mint-right-4 mint-items-end","bottom-left":"mint-bottom-4 mint-left-4 mint-items-start","top-right":"mint-top-4 mint-right-4 mint-items-end","top-left":"mint-top-4 mint-left-4 mint-items-start"},Du={"bottom-right":"mint-items-end mint-justify-start","bottom-left":"mint-items-start mint-justify-start","top-right":"mint-items-end mint-justify-start","top-left":"mint-items-start mint-justify-start"};function Ru(){const e=en(),{placement:t,defaultOpen:n}=ut(),r=zt(o=>o.chatUi.open),i=zt(o=>o.chatUi.expanded);return T.useEffect(()=>{n&&e(An(!0))},[n,e]),P.jsxs("div",{className:ve("mint-fixed mint-z-widget mint-flex mint-gap-3",i?`mint-inset-0 mint-flex-col mint-bg-black/20 mint-p-4 ${Du[t]}`:`mint-flex-col ${Au[t]}`),children:[r&&(i?P.jsx(er,{onCollapse:()=>e(Gi(!1)),onClose:()=>e(An(!1))}):P.jsx(Pu,{})),P.jsx("div",{className:i?"mint-absolute mint-bottom-4 mint-right-4":void 0,children:P.jsx(_u,{open:r,onClick:()=>e(aa())})})]})}function Mu({children:e,...t}){return P.jsxs(da,{config:t,children:[P.jsx(Ru,{}),e]})}exports.MintAIAssistant=Mu;exports.SampleConversationPanel=go;exports.SampleEmptyPanel=yo;exports.SampleExpandedMode=er;exports.SampleShowcase=Nu;exports.useChat=bo;exports.useConfig=ut;
|