@outmarket-ai/react-sdk 0.5.0-beta.0 → 0.6.0-alpha.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 +148 -6
- package/dist/index.d.ts +46 -6
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @outmarket-ai/react-sdk
|
|
2
2
|
|
|
3
|
-
Embed Outmarket
|
|
4
|
-
conversation, signed in as your user.
|
|
3
|
+
Embed Outmarket in your React app: the workflow catalog, each workflow's form and its
|
|
4
|
+
conversation, and the Vault, signed in as your user.
|
|
5
5
|
|
|
6
6
|
For a minimal working app, see [Outmarket-AI/react-sdk-example](https://github.com/Outmarket-AI/react-sdk-example).
|
|
7
7
|
|
|
@@ -92,7 +92,7 @@ Mount it once and put the components inside it.
|
|
|
92
92
|
| Prop | Type | Description |
|
|
93
93
|
| --- | --- | --- |
|
|
94
94
|
| `session` | `OutmarketSession` | Required. The `201` body from step 4, unchanged. |
|
|
95
|
-
| `onReady` | `({ workflowsByModule }) => void` | Called once the user's workflows have loaded, and again if they change
|
|
95
|
+
| `onReady` | `({ workflowsByModule, features }) => void` | Called once the user's workflows have loaded, and again if they change. `workflowsByModule`: the workflows the components can show, grouped by module, minus any your plan doesn't include. `features.vault`: whether the user can open the Vault. |
|
|
96
96
|
| `colorMode` | `'light' \| 'dark' \| 'system'` | Color mode of the components. |
|
|
97
97
|
| `theme` | `{ primary?: string }` | Your brand color, as hex. |
|
|
98
98
|
|
|
@@ -103,10 +103,145 @@ Mount it once and put the components inside it.
|
|
|
103
103
|
| `OutmarketWorkflowsList` | `module`: `'commercial_lines'`, `'personal_lines'` or `'benefits'`. `onSelectWorkflow(workflowId)`: called when the user picks a workflow. |
|
|
104
104
|
| `OutmarketWorkflowForm` | `workflowId`. `onConversationCreated(conversationId)`: called when the user runs the workflow. |
|
|
105
105
|
| `OutmarketWorkflowConversation` | `conversationId`. |
|
|
106
|
-
| `OutmarketWorkflowHistory` | `workflowId
|
|
106
|
+
| `OutmarketWorkflowHistory` | `workflowId`, or `vault` for the user's past Vault chats (see [Past chats](#past-chats)). `onSelectConversation(conversationId)`: called when the user opens a past run or chat. |
|
|
107
|
+
| `OutmarketVault` | All optional. `location`: `{ tab: 'my' \| 'shared' \| 'team', path }`. `onLocationChange(location)`: called when the user opens a folder or switches tab. `onOpenConversation(conversationId)`: called when the user starts a chat. See [The Vault](#the-vault). |
|
|
107
108
|
|
|
108
109
|
The SDK has no routing: your app decides what to show after each callback.
|
|
109
110
|
|
|
111
|
+
### The Vault
|
|
112
|
+
|
|
113
|
+
`<OutmarketVault>` is the Outmarket Vault: the My, Shared and Team tabs, where the user browses,
|
|
114
|
+
searches and sorts, uploads files and folders, creates folders, renames, moves, deletes, downloads
|
|
115
|
+
and previews, and chats with documents. It leaves out the integration tabs (Applied Epic, the AMS
|
|
116
|
+
tabs, Google Drive and OneDrive), Start Workflow, Train Expert and the folder-template settings.
|
|
117
|
+
|
|
118
|
+
- **Offer it only when `features.vault` is true** (from `onReady`). Otherwise your workspace or
|
|
119
|
+
plan doesn't include the Vault for this user, and the component shows "Vault unavailable".
|
|
120
|
+
- **Give it a bounded height.** It fills its parent: give the parent a height, or make the parent
|
|
121
|
+
a flex item with `flex: 1; min-height: 0` in a container that has a height. Put straight inside
|
|
122
|
+
an `<OutmarketProvider>` whose parent is not a flex container, it is only as tall as its content.
|
|
123
|
+
|
|
124
|
+
#### Keep the folder in your URL
|
|
125
|
+
|
|
126
|
+
The Vault never touches your page's URL or history. To keep the folder there, so a reload or a
|
|
127
|
+
link opens it and the browser's Back button walks back through folders, store what
|
|
128
|
+
`onLocationChange` reports and pass it back as `location`. Render this inside your
|
|
129
|
+
`<OutmarketProvider>`:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { useEffect, useState } from 'react';
|
|
133
|
+
import {
|
|
134
|
+
OutmarketVault,
|
|
135
|
+
OutmarketWorkflowConversation,
|
|
136
|
+
type OutmarketVaultLocation,
|
|
137
|
+
type OutmarketVaultTab,
|
|
138
|
+
} from '@outmarket-ai/react-sdk';
|
|
139
|
+
|
|
140
|
+
const TABS: OutmarketVaultTab[] = ['my', 'shared', 'team'];
|
|
141
|
+
|
|
142
|
+
// The folder in this page's URL (?tab=shared&path=Clients%2FTest+Client), or Shared's root.
|
|
143
|
+
function readLocation(): OutmarketVaultLocation {
|
|
144
|
+
// Server rendering has no URL; the provider renders only its spinner there.
|
|
145
|
+
if (typeof window === 'undefined') return { tab: 'shared', path: '' };
|
|
146
|
+
const params = new URLSearchParams(window.location.search);
|
|
147
|
+
const tab = TABS.find((t) => t === params.get('tab')) ?? 'shared';
|
|
148
|
+
return { tab, path: params.get('path') ?? '' };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function Vault() {
|
|
152
|
+
const [location, setLocation] = useState(readLocation);
|
|
153
|
+
const [conversationId, setConversationId] = useState<string | null>(null);
|
|
154
|
+
|
|
155
|
+
// Back and Forward: hand the URL's folder to the Vault.
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
const onPopState = () => setLocation(readLocation());
|
|
158
|
+
window.addEventListener('popstate', onPopState);
|
|
159
|
+
return () => window.removeEventListener('popstate', onPopState);
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
if (conversationId) {
|
|
163
|
+
return (
|
|
164
|
+
<div style={{ height: 600, display: 'flex', flexDirection: 'column' }}>
|
|
165
|
+
<button onClick={() => setConversationId(null)}>Back to the Vault</button>
|
|
166
|
+
<OutmarketWorkflowConversation conversationId={conversationId} />
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div style={{ height: 600 }}>
|
|
173
|
+
<OutmarketVault
|
|
174
|
+
location={location}
|
|
175
|
+
onLocationChange={(next) => {
|
|
176
|
+
setLocation(next);
|
|
177
|
+
const url = new URL(window.location.href);
|
|
178
|
+
url.searchParams.set('tab', next.tab);
|
|
179
|
+
url.searchParams.set('path', next.path);
|
|
180
|
+
window.history.pushState(null, '', url);
|
|
181
|
+
}}
|
|
182
|
+
onOpenConversation={setConversationId}
|
|
183
|
+
/>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
It starts from a location, not `undefined`, because Back to the page's first entry would otherwise
|
|
190
|
+
set `location` back to `undefined`, which never moves the Vault.
|
|
191
|
+
|
|
192
|
+
Folder names are often client names. In your URL they reach your logs, analytics and `Referer`
|
|
193
|
+
headers; if that matters, keep the location in state or `sessionStorage` instead.
|
|
194
|
+
|
|
195
|
+
How the Vault treats `location`:
|
|
196
|
+
|
|
197
|
+
- It reads `location` when it mounts, and moves whenever its `tab` or `path` changes.
|
|
198
|
+
- Passing back the location it just reported does nothing.
|
|
199
|
+
- A move you cause never calls `onLocationChange`, so you push no entry during Back.
|
|
200
|
+
- It never waits for you: the user's move happens at once, whether or not you pass it back.
|
|
201
|
+
- `location` going back to `undefined` does not move it. Without a `location` when it mounts, it
|
|
202
|
+
opens the user's default tab (Shared, or My when Outmarket set it so) at its root.
|
|
203
|
+
- `path` is relative to the tab's root: `''` is the root, `Clients/Test Client` a folder in it. On
|
|
204
|
+
the Team tab, it starts with the team's folder. Sort and search are not part of the location.
|
|
205
|
+
- A folder that no longer exists opens empty, with a Go back button.
|
|
206
|
+
|
|
207
|
+
#### Chats
|
|
208
|
+
|
|
209
|
+
`onOpenConversation(conversationId)` fires when the user starts a chat with documents. Mount
|
|
210
|
+
`<OutmarketWorkflowConversation conversationId>` to show it: in place of the Vault, as above,
|
|
211
|
+
beside it or in a modal.
|
|
212
|
+
|
|
213
|
+
- A new chat starts its first answer only once that component mounts.
|
|
214
|
+
- If your workspace uses Outmarket's agent chat, a new chat opens empty and the user sends the
|
|
215
|
+
first message, as in Outmarket.
|
|
216
|
+
- Keep the location while the chat is open, so the user comes back to the same folder.
|
|
217
|
+
- Leave `onOpenConversation` out to hide Chat.
|
|
218
|
+
|
|
219
|
+
#### Past chats
|
|
220
|
+
|
|
221
|
+
The Vault has no History sidebar. To list the user's past Vault chats, render
|
|
222
|
+
`<OutmarketWorkflowHistory vault>` wherever you want them, beside the Vault or on a page of its own,
|
|
223
|
+
and open the one they pick the same way:
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
<div style={{ display: 'flex', height: 600 }}>
|
|
227
|
+
<div style={{ width: 280 }}>
|
|
228
|
+
<OutmarketWorkflowHistory vault onSelectConversation={setConversationId} />
|
|
229
|
+
</div>
|
|
230
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
231
|
+
<OutmarketVault onOpenConversation={setConversationId} />
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- It lists the user's own chats, newest first, and refreshes when the Vault starts a new one.
|
|
237
|
+
- It shows "Vault unavailable" when `features.vault` is false.
|
|
238
|
+
|
|
239
|
+
#### Previews
|
|
240
|
+
|
|
241
|
+
Word, PowerPoint and `.xls` files preview in an iframe from Microsoft's Office viewer,
|
|
242
|
+
`https://view.officeapps.live.com`, whose servers load the file from a link to show it. Other files,
|
|
243
|
+
`.xlsx` included, preview without it.
|
|
244
|
+
|
|
110
245
|
### `signOut()`
|
|
111
246
|
|
|
112
247
|
Call it in your own logout, then discard the session you passed. It clears the session from your
|
|
@@ -116,6 +251,11 @@ page; it does not end the session at Outmarket.
|
|
|
116
251
|
|
|
117
252
|
- The SDK keeps the session in your page's `localStorage`, so any script running on that page can
|
|
118
253
|
read it. Protect the page against cross-site scripting (XSS).
|
|
254
|
+
- It keeps three Vault keys there too, none with a token in it: `om:vault:lastAccessedPath` and
|
|
255
|
+
`om:vault:lastSelectedTab`, the folder and tab a "Select from Vault" picker last opened, and
|
|
256
|
+
`om_vault_sort`, that picker's sort. A folder path can hold your clients' names.
|
|
257
|
+
`<OutmarketVault>` keeps its own folder and sort in memory; it sets `om:vault:lastSelectedTab`
|
|
258
|
+
only when the user opens a search result on another tab.
|
|
119
259
|
- When a session ends (after 30 days, or if Outmarket ends it), the components show a "session has
|
|
120
260
|
ended" message. Mint a new session the next time the user signs in.
|
|
121
261
|
- A session minted this way is single-factor, so users with two-factor verification turned on are
|
|
@@ -142,8 +282,9 @@ CDN, `https://embed.outmarket.ai`, when the first `<OutmarketProvider>` mounts (
|
|
|
142
282
|
|
|
143
283
|
### Styling
|
|
144
284
|
|
|
145
|
-
Each component renders in a shadow root of its own, where you place it
|
|
146
|
-
popovers and tooltips
|
|
285
|
+
Each component renders in a shadow root of its own, where you place it. Its dialogs, menus,
|
|
286
|
+
popovers and tooltips, the toasts (bottom left) and the upload and download panel (bottom right)
|
|
287
|
+
render in one more at the end of your page's `body`. So:
|
|
147
288
|
|
|
148
289
|
- Your page's CSS does not reach the components: a global `button`, `*:focus` or `div` rule does
|
|
149
290
|
not change them. Use `colorMode` and `theme` on `<OutmarketProvider>` to fit them to your app.
|
|
@@ -171,6 +312,7 @@ If your page has a Content Security Policy, loading the components from the CDN
|
|
|
171
312
|
| `font-src` | `https://embed.outmarket.ai` |
|
|
172
313
|
| `worker-src` | `https://embed.outmarket.ai` and `blob:` (the PDF worker starts from a `blob:` URL) |
|
|
173
314
|
| `connect-src` | `https://embed.outmarket.ai` (the components' stylesheets are fetched) and the Outmarket APIs of your `environment` |
|
|
315
|
+
| `frame-src` | `https://view.officeapps.live.com` (the Vault's previews of Word, PowerPoint and `.xls` files) |
|
|
174
316
|
|
|
175
317
|
The Outmarket APIs of each environment:
|
|
176
318
|
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface OutmarketWorkflowInfo {
|
|
|
18
18
|
* components can render, minus the plan-locked ones, grouped by module. */
|
|
19
19
|
export interface OutmarketReadyPayload {
|
|
20
20
|
workflowsByModule: Record<OutmarketModule, OutmarketWorkflowInfo[]>;
|
|
21
|
+
/** What else the session can open. `vault`: the user has the Vault and the plan includes it. */
|
|
22
|
+
features: { vault: boolean };
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** Friendly title for each module. */
|
|
@@ -193,11 +195,49 @@ export interface OutmarketWorkflowConversationProps {
|
|
|
193
195
|
|
|
194
196
|
export declare function OutmarketWorkflowConversation(props: OutmarketWorkflowConversationProps): ReactNode;
|
|
195
197
|
|
|
196
|
-
/** The user's previous conversations
|
|
197
|
-
* `onSelectConversation` so the host can mount the conversation view. */
|
|
198
|
-
export
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
/** The user's previous conversations: one workflow's runs (`workflowId`), or their past Vault chats
|
|
199
|
+
* (`vault`). Clicking one fires `onSelectConversation` so the host can mount the conversation view. */
|
|
200
|
+
export type OutmarketWorkflowHistoryProps =
|
|
201
|
+
| {
|
|
202
|
+
/** The workflow whose past runs to list. */
|
|
203
|
+
workflowId: string;
|
|
204
|
+
vault?: never;
|
|
205
|
+
onSelectConversation: (conversationId: string) => void;
|
|
206
|
+
}
|
|
207
|
+
| {
|
|
208
|
+
/** List the user's own past Vault chats, the chats `<OutmarketVault>` starts. Shows "Vault
|
|
209
|
+
* unavailable" when `features.vault` is false. */
|
|
210
|
+
vault: true;
|
|
211
|
+
workflowId?: never;
|
|
212
|
+
onSelectConversation: (conversationId: string) => void;
|
|
213
|
+
};
|
|
202
214
|
|
|
203
215
|
export declare function OutmarketWorkflowHistory(props: OutmarketWorkflowHistoryProps): ReactNode;
|
|
216
|
+
|
|
217
|
+
export type OutmarketVaultTab = 'my' | 'shared' | 'team';
|
|
218
|
+
|
|
219
|
+
/** Where the user is in the Vault. `path` is relative to the tab's root ('' = the root). */
|
|
220
|
+
export interface OutmarketVaultLocation {
|
|
221
|
+
tab: OutmarketVaultTab;
|
|
222
|
+
path: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** The full Vault: the My, Shared and Team tabs, with browse, search, sort, upload, folders, preview and
|
|
226
|
+
* chat with documents. It fills its parent, which must have a bounded height. */
|
|
227
|
+
export interface OutmarketVaultProps {
|
|
228
|
+
/** Where the Vault is. Read when it mounts, and followed whenever it changes: change it to move the
|
|
229
|
+
* Vault (your own breadcrumbs, browser Back). Passing back the location `onLocationChange` just
|
|
230
|
+
* reported does nothing. Omit it to open the user's default tab (Shared, or My when Outmarket set
|
|
231
|
+
* it so) at its root. */
|
|
232
|
+
location?: OutmarketVaultLocation;
|
|
233
|
+
/** Fires when the user opens a folder or switches tab, never for a move `location` caused. Store it
|
|
234
|
+
* (in state, in your URL) and pass it back as `location`. The Vault moves on its own and never waits
|
|
235
|
+
* for you to pass it back. Sort and search are not part of the location. */
|
|
236
|
+
onLocationChange?: (location: OutmarketVaultLocation) => void;
|
|
237
|
+
/** Fires with a conversation id when the user starts a chat with documents. Mount
|
|
238
|
+
* `<OutmarketWorkflowConversation conversationId>` to show it: a new chat starts its first answer
|
|
239
|
+
* only once that component mounts. The Vault lists no past chats: render
|
|
240
|
+
* `<OutmarketWorkflowHistory vault>` where you want them. Omit it to hide Chat. */
|
|
241
|
+
onOpenConversation?: (conversationId: string) => void;
|
|
242
|
+
}
|
|
243
|
+
export declare function OutmarketVault(props: OutmarketVaultProps): ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as Q,jsx as c}from"react/jsx-runtime";import{lazy as tt,useState as et,useLayoutEffect as rt,useSyncExternalStore as nt,Suspense as k}from"react";const g="production",N=["production","qa","staging"],O={api:"NEXT_PUBLIC_API_BASE_URL",nexus:"NEXT_PUBLIC_NEXUS_BASE_URL",gateway:"NEXT_PUBLIC_GATEWAY_BASE_URL"},R={NODE_ENV:"production",NEXT_PUBLIC_PDF_WORKER_URL:"https://cdn.jsdelivr.net/npm/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs"},w={production:{NEXT_PUBLIC_APP_ENV:"production",NEXT_PUBLIC_API_BASE_URL:"https://api.prod.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus.prod.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"},qa:{NEXT_PUBLIC_APP_ENV:"qa",NEXT_PUBLIC_API_BASE_URL:"https://api-qa.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus-qa.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.stage.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"},staging:{NEXT_PUBLIC_APP_ENV:"staging",NEXT_PUBLIC_API_BASE_URL:"https://api-g.stage.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus.stage.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.stage.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"}},ot={production:{...R,...w.production}},it=ot.production,h="[@outmarket-ai/react-sdk]",y='an absolute http(s) URL ("https://host/path") or a root-relative path ("/path")',B="http://root-relative.invalid",at=t=>typeof t=="string"&&N.includes(t),st=Object.keys(O),ct=t=>st.includes(t),C=t=>typeof t=="string"?JSON.stringify(t):t===null?"null":typeof t;function ut(t,e){try{return new URL(t,e)}catch{return null}}function lt(t){if(typeof t!="string")return{error:`expected a string, got ${C(t)}`};const e=t.trim();if(!e)return{error:"it is empty"};const r=e.startsWith("/"),o=ut(e,r?B:void 0);if(!o)return{error:`expected ${y}`};if(r&&o.origin!==B)return{error:`a path must start with a single "/" (a value starting "//" points at another host); expected ${y}`};if(!r&&o.protocol!=="http:"&&o.protocol!=="https:")return{error:`only http and https are supported; expected ${y}`};if(o.username||o.password)return{error:"it must not carry credentials"};if(e.includes("?")||e.includes("#"))return{error:"it must not carry a query or fragment"};const n=(r?e:o.href).replace(/\/+$/,"");return n?{url:n}:{error:'a bare "/" is not a base URL; include the path, e.g. "/proxy/api/v1"'}}function dt(t,e){return t===void 0||at(t)?t??g:(e(`${h} Ignoring environment ${C(t)}: expected ${N.map(r=>`'${r}'`).join(", ")}. Using '${g}'.`),g)}function _t(t,e,r){if(t===void 0)return{};if(t===null||typeof t!="object"||Array.isArray(t))return r(`${h} Ignoring apiUrls: expected an object such as { nexus: 'https://\u2026' }.`),{};const o={};for(const[n,i]of Object.entries(t)){if(!ct(n)){r(`${h} Ignoring apiUrls.${n}: not an Outmarket API (expected api, nexus or gateway).`);continue}if(i===void 0)continue;const a=O[n],s=lt(i);if(s.url!==void 0){o[a]=s.url;continue}r(`${h} Ignoring apiUrls.${n}: ${s.error}. Using the '${e}' URL instead: ${w[e][a]}.`)}return o}function mt(t){return t===void 0?!1:t===null||typeof t!="object"||Array.isArray(t)?!0:Object.values(t).some(e=>e!==void 0)}function ft(t,e){const{environment:r,apiUrls:o}=t;if(r===void 0&&!mt(o))return{};const n=dt(r,e);return{...w[n],..._t(o,n,e)}}const S="__OM_EMBED_CONFIG__",pt="[@outmarket-ai/react-sdk]";function T(){const t=globalThis;return t[S]||(t[S]={}),t[S]}function b(){if(typeof globalThis>"u")return;const t=T();for(const[e,r]of Object.entries(it))t[e]===void 0&&r!==void 0&&(t[e]=r)}let m=null,X=!1;const M=new Set;function ht(t){M.has(t)||(M.add(t),console.error(t))}function x(t){return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}function Et(t){X||(X=!0,console.warn(`${pt} OutmarketProvider got an environment or apiUrls that differs from the configuration this page already uses. The SDK applies its configuration once per page load (when the first OutmarketProvider mounts, or on the first signOut() if that came first); reload the page to use the new one. Still using api ${t.NEXT_PUBLIC_API_BASE_URL}, nexus ${t.NEXT_PUBLIC_NEXUS_BASE_URL}, gateway ${t.NEXT_PUBLIC_GATEWAY_BASE_URL}.`))}function v(t){const e=ft(t,ht),r=T();if(m===null){b();const o={...r};Object.assign(r,e),m={base:o,signature:x(r)};return}x({...m.base,...e})!==m.signature&&Et(r)}function Ut(){m===null&&v({})}b();const Lt="245 84% 64%",j="14 100% 57%",A=`hsl(var(--om-primary, ${Lt}))`,gt=/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function wt({colorMode:t="light",theme:e}={}){var r;const o=(r=e==null?void 0:e.primary)==null?void 0:r.trim(),n=o?gt.exec(o):null;return n?`#${n[1]}`:t==="dark"?`hsl(${j})`:t==="system"?`light-dark(${A}, hsl(${j}))`:A}const W={flex:1,minHeight:320,display:"flex",alignItems:"center",justifyContent:"center"},yt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Y=40,St="light dark";function F({color:t=A}){return Q("div",{role:"status","aria-live":"polite","data-testid":"om-embed-loading",style:W,children:[c("span",{style:yt,children:"Loading\u2026"}),c("svg",{"aria-hidden":"true","data-testid":"om-embed-loading-spinner",width:Y,height:Y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{color:t,colorScheme:St},children:c("path",{d:"M21 12a9 9 0 1 1-6.219-8.56",children:c("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"1s",repeatCount:"indefinite"})})})]})}function Tt(){return c("div",{role:"alert","data-testid":"om-embed-load-failed",style:{...W,padding:16,textAlign:"center"},children:"Outmarket could not load. Check your connection and reload the page."})}const G="OM_SDK_RUNTIME_CDN_URL",vt="OM_SDK_RUNTIME_VERSION",$="https://embed.outmarket.ai/react-sdk",At=new Set(["localhost","127.0.0.1"]);function $t(t){if(typeof t!="string")return null;let e;try{e=new URL(t)}catch{return null}return!(e.protocol==="https:"||e.protocol==="http:"&&At.has(e.hostname))||e.username||e.password||e.search||e.hash?null:`${e.origin}${e.pathname.replace(/\/+$/,"")}`}function It(t,e){if(t===void 0||t==="")return $;const r=$t(t);return r!==null?r:(e(`[@outmarket-ai/react-sdk] Ignoring ${G} ${JSON.stringify(t)}: expected an https: URL (or http: on localhost / 127.0.0.1) without credentials, query or fragment. Using ${$}.`),$)}function Pt(t,e=console.error){const r=t[vt];return{base:It(t[G],e),pin:r===void 0||r===""?void 0:String(r),appEnv:t.NEXT_PUBLIC_APP_ENV}}async function K(t,{timeoutMs:e,cache:r,fetchImpl:o=globalThis.fetch}){const n=new AbortController,i=setTimeout(()=>n.abort(),e);try{let a;try{a=await o(t,{cache:r,credentials:"omit",signal:n.signal})}catch(s){throw new Error(n.signal.aborted?`${t} did not answer within ${e} ms`:`${t} could not be fetched: ${String(s)}`)}if(!a.ok)throw new Error(`${t} answered HTTP ${a.status}`);try{return await a.json()}catch{throw new Error(n.signal.aborted?`${t} did not answer within ${e} ms`:`${t} is not JSON`)}}finally{clearTimeout(i)}}async function kt(){const[t,e,r,o,n]=await Promise.all([import("react"),import("react/jsx-runtime"),import("react-dom"),import("react-dom/client"),import("react-dom/server")]);return{react:t,"react/jsx-runtime":e,"react-dom":r,"react-dom/client":o,"react-dom/server":n}}function Nt(t){return import(/* webpackIgnore: true */ /* turbopackIgnore: true */ /* @vite-ignore */ t)}const Ot=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/,Rt=1e4;function Bt(t){return t==="staging"?"alpha":t==="qa"?"beta":"stable"}function D(t,e){if(typeof t=="string"&&Ot.test(t))return t;throw new Error(`${e} is ${JSON.stringify(t)??String(t)}, not a runtime version`)}async function Ct({base:t,pin:e,appEnv:r,fetchImpl:o,timeoutMs:n=Rt}){if(e!==void 0)return D(e,"OM_SDK_RUNTIME_VERSION");const i=`${t}/versions.json`,a=await K(i,{cache:"no-cache",timeoutMs:n,fetchImpl:o});if(a===null||typeof a!="object"||Array.isArray(a))throw new Error(`${i} is not an object of versions`);const s=Bt(r);return D(a[s],`${i} "${s}"`)}const H="data-om-embed-runtime",E=Symbol.for("outmarket.embed.stylesheetWaiters");function bt(t,e){return[...e.querySelectorAll(`link[${H}]`)].find(r=>r.getAttribute("href")===t)}function Xt(t,e,r){const o=bt(t,r);if(o!=null&&o.sheet)return Promise.resolve();const n=o??r.createElement("link");return n[E]=(n[E]??0)+1,new Promise((i,a)=>{const s=l=>{clearTimeout(p),n.removeEventListener("load",d),n.removeEventListener("error",u);const _=(n[E]??1)-1;if(n[E]=_,l==="load"){i();return}(l==="error"||_===0)&&n.remove(),a(new Error(l==="error"?`${t} could not be loaded`:`${t} did not load within ${e} ms`))},d=()=>s("load"),u=()=>s("error"),p=setTimeout(()=>s("timeout"),e);n.addEventListener("load",d),n.addEventListener("error",u),o||(n.rel="stylesheet",n.href=t,n.setAttribute(H,""),r.head.appendChild(n))})}async function Mt(t,e,r=document){await Promise.all(t.map(o=>Xt(o,e,r)))}const V=1,xt=()=>({fetchImpl:globalThis.fetch,loadHostReact:kt,importModule:Nt,document,timeouts:{versionsMs:1e4,manifestMs:1e4,cssMs:3e4,entryMs:3e4}});let U;const jt=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/,I=t=>typeof t=="string"&&t.split("/").every(e=>jt.test(e));function Wt(t,e,r){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${r} is not a runtime manifest`);const o=t;if(o.version!==e)throw new Error(`${r} is for version ${JSON.stringify(o.version)}, not ${e}`);const{entry:n,worker:i,css:a}=o;if(!I(n))throw new Error(`${r} has no valid "entry"`);if(!I(i))throw new Error(`${r} has no valid "worker"`);if(!Array.isArray(a)||!a.every(I))throw new Error(`${r} has no valid "css"`);return{version:e,entry:n,worker:i,css:a}}async function Yt(t,e,r,o){const n=t==null?void 0:t.boot;if(typeof n!="function")throw new Error(`${e} does not export boot()`);const i=await n(r);if((i==null?void 0:i.contractVersion)!==V)throw new Error(`the CDN runtime ${o} implements runtime contract ${String(i==null?void 0:i.contractVersion)}; this SDK needs ${V}`);return i}async function Ft(t,e,r){const[o,n]=await Promise.all([t.loadHostReact(),t.importModule(e)]);return Yt(n,e,o,r)}function Gt(t,e,r){let o;const n=new Promise((i,a)=>{o=setTimeout(()=>a(new Error(r)),e)});return Promise.race([t,n]).finally(()=>clearTimeout(o))}async function Kt(t,e,r={}){const o={...xt(),...r},{fetchImpl:n,timeouts:i}=o,a=await Ct({...t,fetchImpl:n,timeoutMs:i.versionsMs}),s=`${t.base}/${a}`,d=`${s}/manifest.json`,u=Wt(await K(d,{timeoutMs:i.manifestMs,fetchImpl:n}),a,d),p=Mt(u.css.map(Z=>`${s}/${Z}`),i.cssMs,o.document);p.catch(()=>{});const l=e.NEXT_PUBLIC_PDF_WORKER_URL;(l===R.NEXT_PUBLIC_PDF_WORKER_URL||U!==void 0&&l===U)&&(U=`${s}/${u.worker}`,e.NEXT_PUBLIC_PDF_WORKER_URL=U);const _=`${s}/${u.entry}`,J=await Gt(Ft(o,_,a),i.entryMs,`${_} did not load within ${i.entryMs} ms`);return await p,globalThis.__OM_EMBED__={source:"cdn",base:t.base,version:a},J}let f=null,P=null;function z(){if(f===null){Ut();const t=T();P??(P=Pt(t));const e=Kt(P,t);e.catch(()=>{f===e&&(f=null)}),f=e}return f}function q(t){return tt(async()=>{try{return{default:await t(await z())}}catch(e){return console.error("[@outmarket-ai/react-sdk] Could not load the Outmarket components.",e),{default:Tt}}})}function Dt(t,e){const[r,o]=et(!1);return rt(()=>{v({environment:t,apiUrls:e}),o(!0)},[t,e]),r}const Ht=q(t=>t.OutmarketProviderTree),Vt=()=>()=>{},zt=()=>!0,qt=()=>!1;function Jt({environment:t,apiUrls:e,...r}){const o=nt(Vt,zt,qt),n=Dt(t,e),i=c(F,{color:wt(r)});return!o||!n?i:c(k,{fallback:i,children:c(Ht,{...r})})}async function Zt(t){typeof window>"u"||(t&&v({environment:t.environment,apiUrls:t.apiUrls}),await(await z()).signOut())}function L(t,e){const r=q(n=>e(n.surfaces));function o(n){return c(k,{fallback:c(F,{}),children:c(r,{...n})})}return o.displayName=t,o}const Qt=L("OutmarketWorkflowsList",t=>t.OutmarketWorkflowsList()),te=L("OutmarketWorkflowForm",t=>t.OutmarketWorkflowForm()),ee=L("OutmarketWorkflowConversation",t=>t.OutmarketWorkflowConversation()),re=L("OutmarketWorkflowHistory",t=>t.OutmarketWorkflowHistory()),ne={commercial_lines:"Commercial Insurance",personal_lines:"Personal Lines",benefits:"Employee Benefits"};export{ne as MODULE_TITLE,Jt as OutmarketProvider,ee as OutmarketWorkflowConversation,te as OutmarketWorkflowForm,re as OutmarketWorkflowHistory,Qt as OutmarketWorkflowsList,Zt as signOut};
|
|
1
|
+
import{jsxs as tt,jsx as u}from"react/jsx-runtime";import{lazy as et,useState as rt,useLayoutEffect as P,useSyncExternalStore as nt,Suspense as O,useRef as ot,useCallback as it}from"react";const g="production",R=["production","qa","staging"],N={api:"NEXT_PUBLIC_API_BASE_URL",nexus:"NEXT_PUBLIC_NEXUS_BASE_URL",gateway:"NEXT_PUBLIC_GATEWAY_BASE_URL"},C={NODE_ENV:"production",NEXT_PUBLIC_PDF_WORKER_URL:"https://cdn.jsdelivr.net/npm/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs"},w={production:{NEXT_PUBLIC_APP_ENV:"production",NEXT_PUBLIC_API_BASE_URL:"https://api.prod.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus.prod.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"},qa:{NEXT_PUBLIC_APP_ENV:"qa",NEXT_PUBLIC_API_BASE_URL:"https://api-qa.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus-qa.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.stage.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"},staging:{NEXT_PUBLIC_APP_ENV:"staging",NEXT_PUBLIC_API_BASE_URL:"https://api-g.stage.outmarket.ai/v1",NEXT_PUBLIC_NEXUS_BASE_URL:"https://nexus.stage.outmarket.ai/api/v1",NEXT_PUBLIC_GATEWAY_BASE_URL:"https://gateway.stage.outmarket.ai/api/v1",NEXT_PUBLIC_USE_OPTIMUS:"true",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX:"@outmarket",NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY:"OYgxUAznYZZjedB08lRQ9i7BR5QaTRVF",NEXT_PUBLIC_STATSIG_CLIENT_KEY:"client-acTBiSi4StL0uGJe2dzAwS306PfF0hNLrMbYSmm3K2W"}},at={production:{...C,...w.production}},st=at.production,E="[@outmarket-ai/react-sdk]",y='an absolute http(s) URL ("https://host/path") or a root-relative path ("/path")',B="http://root-relative.invalid",ut=t=>typeof t=="string"&&R.includes(t),ct=Object.keys(N),lt=t=>ct.includes(t),b=t=>typeof t=="string"?JSON.stringify(t):t===null?"null":typeof t;function dt(t,e){try{return new URL(t,e)}catch{return null}}function ft(t){if(typeof t!="string")return{error:`expected a string, got ${b(t)}`};const e=t.trim();if(!e)return{error:"it is empty"};const r=e.startsWith("/"),o=dt(e,r?B:void 0);if(!o)return{error:`expected ${y}`};if(r&&o.origin!==B)return{error:`a path must start with a single "/" (a value starting "//" points at another host); expected ${y}`};if(!r&&o.protocol!=="http:"&&o.protocol!=="https:")return{error:`only http and https are supported; expected ${y}`};if(o.username||o.password)return{error:"it must not carry credentials"};if(e.includes("?")||e.includes("#"))return{error:"it must not carry a query or fragment"};const n=(r?e:o.href).replace(/\/+$/,"");return n?{url:n}:{error:'a bare "/" is not a base URL; include the path, e.g. "/proxy/api/v1"'}}function mt(t,e){return t===void 0||ut(t)?t??g:(e(`${E} Ignoring environment ${b(t)}: expected ${R.map(r=>`'${r}'`).join(", ")}. Using '${g}'.`),g)}function _t(t,e,r){if(t===void 0)return{};if(t===null||typeof t!="object"||Array.isArray(t))return r(`${E} Ignoring apiUrls: expected an object such as { nexus: 'https://\u2026' }.`),{};const o={};for(const[n,i]of Object.entries(t)){if(!lt(n)){r(`${E} Ignoring apiUrls.${n}: not an Outmarket API (expected api, nexus or gateway).`);continue}if(i===void 0)continue;const a=N[n],s=ft(i);if(s.url!==void 0){o[a]=s.url;continue}r(`${E} Ignoring apiUrls.${n}: ${s.error}. Using the '${e}' URL instead: ${w[e][a]}.`)}return o}function pt(t){return t===void 0?!1:t===null||typeof t!="object"||Array.isArray(t)?!0:Object.values(t).some(e=>e!==void 0)}function ht(t,e){const{environment:r,apiUrls:o}=t;if(r===void 0&&!pt(o))return{};const n=mt(r,e);return{...w[n],..._t(o,n,e)}}const v="__OM_EMBED_CONFIG__",Et="[@outmarket-ai/react-sdk]";function S(){const t=globalThis;return t[v]||(t[v]={}),t[v]}function X(){if(typeof globalThis>"u")return;const t=S();for(const[e,r]of Object.entries(st))t[e]===void 0&&r!==void 0&&(t[e]=r)}let m=null,M=!1;const x=new Set;function Ut(t){x.has(t)||(x.add(t),console.error(t))}function j(t){return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}function Lt(t){M||(M=!0,console.warn(`${Et} OutmarketProvider got an environment or apiUrls that differs from the configuration this page already uses. The SDK applies its configuration once per page load (when the first OutmarketProvider mounts, or on the first signOut() if that came first); reload the page to use the new one. Still using api ${t.NEXT_PUBLIC_API_BASE_URL}, nexus ${t.NEXT_PUBLIC_NEXUS_BASE_URL}, gateway ${t.NEXT_PUBLIC_GATEWAY_BASE_URL}.`))}function T(t){const e=ht(t,Ut),r=S();if(m===null){X();const o={...r};Object.assign(r,e),m={base:o,signature:j(r)};return}j({...m.base,...e})!==m.signature&&Lt(r)}function gt(){m===null&&T({})}X();const wt="245 84% 64%",W="14 100% 57%",A=`hsl(var(--om-primary, ${wt}))`,yt=/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function vt({colorMode:t="light",theme:e}={}){var r;const o=(r=e==null?void 0:e.primary)==null?void 0:r.trim(),n=o?yt.exec(o):null;return n?`#${n[1]}`:t==="dark"?`hsl(${W})`:t==="system"?`light-dark(${A}, hsl(${W}))`:A}const Y={flex:1,minHeight:320,display:"flex",alignItems:"center",justifyContent:"center"},St={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},F=40,Tt="light dark";function G({color:t=A}){return tt("div",{role:"status","aria-live":"polite","data-testid":"om-embed-loading",style:Y,children:[u("span",{style:St,children:"Loading\u2026"}),u("svg",{"aria-hidden":"true","data-testid":"om-embed-loading-spinner",width:F,height:F,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{color:t,colorScheme:Tt},children:u("path",{d:"M21 12a9 9 0 1 1-6.219-8.56",children:u("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"1s",repeatCount:"indefinite"})})})]})}function At(){return u("div",{role:"alert","data-testid":"om-embed-load-failed",style:{...Y,padding:16,textAlign:"center"},children:"Outmarket could not load. Check your connection and reload the page."})}const K="OM_SDK_RUNTIME_CDN_URL",kt="OM_SDK_RUNTIME_VERSION",k="https://embed.outmarket.ai/react-sdk",$t=new Set(["localhost","127.0.0.1"]);function It(t){if(typeof t!="string")return null;let e;try{e=new URL(t)}catch{return null}return!(e.protocol==="https:"||e.protocol==="http:"&&$t.has(e.hostname))||e.username||e.password||e.search||e.hash?null:`${e.origin}${e.pathname.replace(/\/+$/,"")}`}function Pt(t,e){if(t===void 0||t==="")return k;const r=It(t);return r!==null?r:(e(`[@outmarket-ai/react-sdk] Ignoring ${K} ${JSON.stringify(t)}: expected an https: URL (or http: on localhost / 127.0.0.1) without credentials, query or fragment. Using ${k}.`),k)}function Ot(t,e=console.error){const r=t[kt];return{base:Pt(t[K],e),pin:r===void 0||r===""?void 0:String(r),appEnv:t.NEXT_PUBLIC_APP_ENV}}async function D(t,{timeoutMs:e,cache:r,fetchImpl:o=globalThis.fetch}){const n=new AbortController,i=setTimeout(()=>n.abort(),e);try{let a;try{a=await o(t,{cache:r,credentials:"omit",signal:n.signal})}catch(s){throw new Error(n.signal.aborted?`${t} did not answer within ${e} ms`:`${t} could not be fetched: ${String(s)}`)}if(!a.ok)throw new Error(`${t} answered HTTP ${a.status}`);try{return await a.json()}catch{throw new Error(n.signal.aborted?`${t} did not answer within ${e} ms`:`${t} is not JSON`)}}finally{clearTimeout(i)}}async function Rt(){const[t,e,r,o,n]=await Promise.all([import("react"),import("react/jsx-runtime"),import("react-dom"),import("react-dom/client"),import("react-dom/server")]);return{react:t,"react/jsx-runtime":e,"react-dom":r,"react-dom/client":o,"react-dom/server":n}}function Nt(t){return import(/* webpackIgnore: true */ /* turbopackIgnore: true */ /* @vite-ignore */ t)}const Ct=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/,Bt=1e4;function bt(t){return t==="staging"?"alpha":t==="qa"?"beta":"stable"}function V(t,e){if(typeof t=="string"&&Ct.test(t))return t;throw new Error(`${e} is ${JSON.stringify(t)??String(t)}, not a runtime version`)}async function Xt({base:t,pin:e,appEnv:r,fetchImpl:o,timeoutMs:n=Bt}){if(e!==void 0)return V(e,"OM_SDK_RUNTIME_VERSION");const i=`${t}/versions.json`,a=await D(i,{cache:"no-cache",timeoutMs:n,fetchImpl:o});if(a===null||typeof a!="object"||Array.isArray(a))throw new Error(`${i} is not an object of versions`);const s=bt(r);return V(a[s],`${i} "${s}"`)}const H="data-om-embed-runtime",U=Symbol.for("outmarket.embed.stylesheetWaiters");function Mt(t,e){return[...e.querySelectorAll(`link[${H}]`)].find(r=>r.getAttribute("href")===t)}function xt(t,e,r){const o=Mt(t,r);if(o!=null&&o.sheet)return Promise.resolve();const n=o??r.createElement("link");return n[U]=(n[U]??0)+1,new Promise((i,a)=>{const s=l=>{clearTimeout(h),n.removeEventListener("load",d),n.removeEventListener("error",c);const f=(n[U]??1)-1;if(n[U]=f,l==="load"){i();return}(l==="error"||f===0)&&n.remove(),a(new Error(l==="error"?`${t} could not be loaded`:`${t} did not load within ${e} ms`))},d=()=>s("load"),c=()=>s("error"),h=setTimeout(()=>s("timeout"),e);n.addEventListener("load",d),n.addEventListener("error",c),o||(n.rel="stylesheet",n.href=t,n.setAttribute(H,""),r.head.appendChild(n))})}async function jt(t,e,r=document){await Promise.all(t.map(o=>xt(o,e,r)))}const z=1,Wt=()=>({fetchImpl:globalThis.fetch,loadHostReact:Rt,importModule:Nt,document,timeouts:{versionsMs:1e4,manifestMs:1e4,cssMs:3e4,entryMs:3e4}});let L;const Yt=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/,$=t=>typeof t=="string"&&t.split("/").every(e=>Yt.test(e));function Ft(t,e,r){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${r} is not a runtime manifest`);const o=t;if(o.version!==e)throw new Error(`${r} is for version ${JSON.stringify(o.version)}, not ${e}`);const{entry:n,worker:i,css:a}=o;if(!$(n))throw new Error(`${r} has no valid "entry"`);if(!$(i))throw new Error(`${r} has no valid "worker"`);if(!Array.isArray(a)||!a.every($))throw new Error(`${r} has no valid "css"`);return{version:e,entry:n,worker:i,css:a}}async function Gt(t,e,r,o){const n=t==null?void 0:t.boot;if(typeof n!="function")throw new Error(`${e} does not export boot()`);const i=await n(r);if((i==null?void 0:i.contractVersion)!==z)throw new Error(`the CDN runtime ${o} implements runtime contract ${String(i==null?void 0:i.contractVersion)}; this SDK needs ${z}`);return i}async function Kt(t,e,r){const[o,n]=await Promise.all([t.loadHostReact(),t.importModule(e)]);return Gt(n,e,o,r)}function Dt(t,e,r){let o;const n=new Promise((i,a)=>{o=setTimeout(()=>a(new Error(r)),e)});return Promise.race([t,n]).finally(()=>clearTimeout(o))}async function Vt(t,e,r={}){const o={...Wt(),...r},{fetchImpl:n,timeouts:i}=o,a=await Xt({...t,fetchImpl:n,timeoutMs:i.versionsMs}),s=`${t.base}/${a}`,d=`${s}/manifest.json`,c=Ft(await D(d,{timeoutMs:i.manifestMs,fetchImpl:n}),a,d),h=jt(c.css.map(Q=>`${s}/${Q}`),i.cssMs,o.document);h.catch(()=>{});const l=e.NEXT_PUBLIC_PDF_WORKER_URL;(l===C.NEXT_PUBLIC_PDF_WORKER_URL||L!==void 0&&l===L)&&(L=`${s}/${c.worker}`,e.NEXT_PUBLIC_PDF_WORKER_URL=L);const f=`${s}/${c.entry}`,Z=await Dt(Kt(o,f,a),i.entryMs,`${f} did not load within ${i.entryMs} ms`);return await h,globalThis.__OM_EMBED__={source:"cdn",base:t.base,version:a},Z}let _=null,I=null;function q(){if(_===null){gt();const t=S();I??(I=Ot(t));const e=Vt(I,t);e.catch(()=>{_===e&&(_=null)}),_=e}return _}function J(t){return et(async()=>{try{return{default:await t(await q())}}catch(e){return console.error("[@outmarket-ai/react-sdk] Could not load the Outmarket components.",e),{default:At}}})}const Ht={vault:!1};function zt(t){return{...t,features:{...Ht,...t.features}}}function qt(t,e){const[r,o]=rt(!1);return P(()=>{T({environment:t,apiUrls:e}),o(!0)},[t,e]),r}const Jt=J(t=>t.OutmarketProviderTree),Zt=()=>()=>{},Qt=()=>!0,te=()=>!1;function ee(t){const e=ot(t);P(()=>{e.current=t});const r=it(o=>{var n;return(n=e.current)==null?void 0:n.call(e,zt(o))},[]);return t?r:void 0}function re({environment:t,apiUrls:e,...r}){const o=ee(r.onReady),n=nt(Zt,Qt,te),i=qt(t,e),a=u(G,{color:vt(r)});return!n||!i?a:u(O,{fallback:a,children:u(Jt,{...r,onReady:o})})}async function ne(t){typeof window>"u"||(t&&T({environment:t.environment,apiUrls:t.apiUrls}),await(await q()).signOut())}function p(t,e){const r=J(n=>e(n.surfaces));function o(n){return u(O,{fallback:u(G,{}),children:u(r,{...n})})}return o.displayName=t,o}const oe=p("OutmarketWorkflowsList",t=>t.OutmarketWorkflowsList()),ie=p("OutmarketWorkflowForm",t=>t.OutmarketWorkflowForm()),ae=p("OutmarketWorkflowConversation",t=>t.OutmarketWorkflowConversation()),se=p("OutmarketWorkflowHistory",t=>t.OutmarketWorkflowHistory()),ue=p("OutmarketVault",t=>t.OutmarketVault()),ce={commercial_lines:"Commercial Insurance",personal_lines:"Personal Lines",benefits:"Employee Benefits"};export{ce as MODULE_TITLE,re as OutmarketProvider,ue as OutmarketVault,ae as OutmarketWorkflowConversation,ie as OutmarketWorkflowForm,se as OutmarketWorkflowHistory,oe as OutmarketWorkflowsList,ne as signOut};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outmarket-ai/react-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Embed the real Outmarket
|
|
3
|
+
"version": "0.6.0-alpha.0",
|
|
4
|
+
"description": "Embed the real Outmarket workflows and Vault in any React app.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"sideEffects": [
|
|
12
12
|
"./dist/index.js",
|
|
13
13
|
"./src/embedConfig.ts",
|
|
14
|
+
"./src/enterEmbedMode.ts",
|
|
14
15
|
"**/*.css"
|
|
15
16
|
],
|
|
16
17
|
"exports": {
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"url": "git+https://github.com/Outmarket-AI/outmarket-monorepo.git",
|
|
62
63
|
"directory": "apps/product-frontend/packages/outmarket-react-sdk"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "61ad2cf0b3d26be8e2b075e752adaa8a362b9fa6"
|
|
65
66
|
}
|