@sanity/embeddings-index-ui 2.0.0 → 2.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/LICENSE +1 -1
- package/dist/index.d.mts +74 -0
- package/dist/index.js +1707 -2271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2353 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -39
- package/src/api/embeddingsApiHooks.ts +1 -1
- package/src/api/isEnabled.tsx +4 -3
- package/src/embeddingsIndexDashboard/EmbeddingsIndexTool.tsx +5 -4
- package/src/embeddingsIndexDashboard/IndexEditor.tsx +6 -4
- package/src/embeddingsIndexDashboard/IndexFormInput.tsx +3 -2
- package/src/embeddingsIndexDashboard/IndexInfo.tsx +4 -3
- package/src/embeddingsIndexDashboard/IndexList.tsx +2 -1
- package/src/embeddingsIndexDashboard/QueryIndex.tsx +3 -2
- package/src/embeddingsIndexDashboard/dashboardPlugin.ts +2 -1
- package/src/embeddingsIndexDashboard/hooks.ts +2 -1
- package/src/index.ts +2 -1
- package/src/preview/DocumentPreview.tsx +20 -12
- package/src/referenceInput/SemanticSearchAutocomplete.tsx +7 -4
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +5 -4
- package/src/referenceInput/referencePlugin.tsx +3 -2
- package/dist/index.cjs.mjs +0 -8
- package/dist/index.esm.js +0 -2900
- package/dist/index.esm.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,120 +1,547 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var sanity = require('sanity');
|
|
7
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var ui = require('@sanity/ui');
|
|
9
|
-
var icons = require('@sanity/icons');
|
|
10
|
-
var require$$0 = require('react');
|
|
11
|
-
var desk = require('sanity/desk');
|
|
12
|
-
var router = require('sanity/router');
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var icons = require("@sanity/icons"), sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), ui = require("@sanity/ui"), require$$0 = require("react"), router = require("sanity/router"), desk = require("sanity/desk");
|
|
13
4
|
function _interopDefaultCompat(e) {
|
|
14
|
-
return e && typeof e
|
|
15
|
-
default: e
|
|
16
|
-
};
|
|
5
|
+
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
17
6
|
}
|
|
18
|
-
var require$$0__default =
|
|
19
|
-
function
|
|
20
|
-
|
|
7
|
+
var require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0);
|
|
8
|
+
function queryIndex(queryConfig, client) {
|
|
9
|
+
const { query, indexName, maxResults, filter } = queryConfig, projectId = client.config().projectId, dataset = client.config().dataset, queryString = query?.trim();
|
|
10
|
+
return client.request({
|
|
11
|
+
method: "POST",
|
|
12
|
+
url: `/embeddings-index/query/${dataset}/${indexName}?projectId=${projectId}`,
|
|
13
|
+
body: {
|
|
14
|
+
query: queryString,
|
|
15
|
+
maxResults,
|
|
16
|
+
filter
|
|
17
|
+
}
|
|
18
|
+
});
|
|
21
19
|
}
|
|
22
|
-
function
|
|
23
|
-
const client =
|
|
24
|
-
|
|
20
|
+
function getIndexes(client) {
|
|
21
|
+
const projectId = client.config().projectId, dataset = client.config().dataset;
|
|
22
|
+
return client.request({
|
|
23
|
+
method: "GET",
|
|
24
|
+
url: `/embeddings-index/${dataset}?projectId=${projectId}`
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function deleteIndex(indexName, client) {
|
|
28
|
+
const projectId = client.config().projectId, dataset = client.config().dataset;
|
|
29
|
+
return client.request({
|
|
30
|
+
method: "DELETE",
|
|
31
|
+
url: `/embeddings-index/${dataset}/${indexName}?projectId=${projectId}`
|
|
25
32
|
});
|
|
33
|
+
}
|
|
34
|
+
function useApiClient() {
|
|
35
|
+
const client = sanity.useClient({ apiVersion: "vX" });
|
|
26
36
|
return require$$0.useMemo(() => {
|
|
27
37
|
const customHost = localStorage.getItem("embeddings-index-host");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return client;
|
|
38
|
+
return customHost ? client.withConfig({
|
|
39
|
+
apiHost: customHost,
|
|
40
|
+
useProjectHostname: !1,
|
|
41
|
+
withCredentials: !1
|
|
42
|
+
}) : client;
|
|
36
43
|
}, [client]);
|
|
37
44
|
}
|
|
38
45
|
const FeatureEnabledContext = require$$0.createContext("loading");
|
|
39
46
|
function useIsFeatureEnabled() {
|
|
40
|
-
const client = useApiClient();
|
|
41
|
-
|
|
42
|
-
require$$0.useEffect(() => {
|
|
47
|
+
const client = useApiClient(), [status, setStatus] = require$$0.useState("loading");
|
|
48
|
+
return require$$0.useEffect(() => {
|
|
43
49
|
client.request({
|
|
44
50
|
method: "GET",
|
|
45
51
|
url: "/embeddings-index/status"
|
|
46
|
-
}).then(response => {
|
|
52
|
+
}).then((response) => {
|
|
47
53
|
setStatus(response.enabled ? "enabled" : "disabled");
|
|
48
|
-
}).catch(err => {
|
|
49
|
-
console.error(err);
|
|
50
|
-
setStatus("error");
|
|
54
|
+
}).catch((err) => {
|
|
55
|
+
console.error(err), setStatus("error");
|
|
51
56
|
});
|
|
52
|
-
}, [client]);
|
|
53
|
-
return status;
|
|
57
|
+
}, [client]), status;
|
|
54
58
|
}
|
|
55
59
|
function FeatureEnabledProvider(props) {
|
|
56
60
|
const status = useIsFeatureEnabled();
|
|
57
|
-
return /* @__PURE__ */jsxRuntime.jsx(FeatureEnabledContext.Provider, {
|
|
58
|
-
value: status,
|
|
59
|
-
children: props.children
|
|
60
|
-
});
|
|
61
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FeatureEnabledContext.Provider, { value: status, children: props.children });
|
|
61
62
|
}
|
|
62
63
|
function useIsFeatureEnabledContext() {
|
|
63
64
|
return require$$0.useContext(FeatureEnabledContext);
|
|
64
65
|
}
|
|
65
66
|
function FeatureDisabledNotice(props) {
|
|
66
|
-
var _a;
|
|
67
67
|
const projectId = sanity.useProjectId();
|
|
68
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
size: 1,
|
|
74
|
-
children: ["\u{1F48E} Unlock semantic search with the Embeddings Index API \u2014 available on Team, Business, and Enterprise plans.", " ", /* @__PURE__ */jsxRuntime.jsx("a", {
|
|
75
|
-
href: "https://www.sanity.io/manage/project/".concat(projectId, "/plan").concat((_a = props.urlSuffix) != null ? _a : ""),
|
|
76
|
-
children: "Upgrade now \u2192"
|
|
77
|
-
})]
|
|
78
|
-
})
|
|
79
|
-
});
|
|
68
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { tone: "primary", border: !0, padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, children: [
|
|
69
|
+
"\u{1F48E} Unlock semantic search with the Embeddings Index API \u2014 available on Team, Business, and Enterprise plans.",
|
|
70
|
+
" ",
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: `https://www.sanity.io/manage/project/${projectId}/plan${props.urlSuffix ?? ""}`, children: "Upgrade now \u2192" })
|
|
72
|
+
] }) });
|
|
80
73
|
}
|
|
81
74
|
function FeatureError() {
|
|
82
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, border: !0, tone: "critical", children: "An error occurred. See console for details." });
|
|
76
|
+
}
|
|
77
|
+
function isType(schemaType, typeName) {
|
|
78
|
+
return schemaType.name === typeName ? !0 : schemaType.type ? isType(schemaType.type, typeName) : !1;
|
|
79
|
+
}
|
|
80
|
+
const defaultProjection = "{...}";
|
|
81
|
+
function useDefaultIndex(schema, dataset) {
|
|
82
|
+
const defaultFilter = require$$0.useMemo(
|
|
83
|
+
() => `_type in [${schema.getTypeNames().map((n) => schema.get(n)).filter(
|
|
84
|
+
(schemaType) => !!(schemaType && isType(schemaType, "document"))
|
|
85
|
+
).filter(
|
|
86
|
+
(documentType) => !documentType.name.startsWith("sanity.") && !documentType.name.startsWith("assist.") && documentType.name !== "document"
|
|
87
|
+
).map((documentType) => `"${documentType.name}"`).join(`,
|
|
88
|
+
`)}]`,
|
|
89
|
+
[schema]
|
|
90
|
+
);
|
|
91
|
+
return require$$0.useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
dataset,
|
|
94
|
+
projection: defaultProjection,
|
|
95
|
+
filter: defaultFilter
|
|
96
|
+
}),
|
|
97
|
+
[defaultFilter, dataset]
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function IndexFormInput(props) {
|
|
101
|
+
const { label, description, index, prop, onChange, readOnly, placeholder, type } = props, handleChange = require$$0.useCallback(
|
|
102
|
+
(propValue) => onChange((current) => ({ ...current, [prop]: propValue })),
|
|
103
|
+
[onChange, prop]
|
|
104
|
+
);
|
|
105
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
FormInput,
|
|
107
|
+
{
|
|
108
|
+
label,
|
|
109
|
+
description,
|
|
110
|
+
onChange: handleChange,
|
|
111
|
+
value: index[prop] ?? "",
|
|
112
|
+
readOnly,
|
|
113
|
+
placeholder,
|
|
114
|
+
type
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
function FormInput(props) {
|
|
119
|
+
const { label, description, onChange, value, readOnly, placeholder, type = "text" } = props, id = require$$0.useId(), handleChange = require$$0.useCallback(
|
|
120
|
+
(e) => onChange(e.currentTarget.value),
|
|
121
|
+
[onChange]
|
|
122
|
+
);
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, htmlFor: id, children: /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, children: label }) }),
|
|
125
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: description }) }),
|
|
126
|
+
type === "text" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
+
ui.TextInput,
|
|
128
|
+
{
|
|
129
|
+
id,
|
|
130
|
+
value,
|
|
131
|
+
onChange: handleChange,
|
|
132
|
+
readOnly,
|
|
133
|
+
placeholder
|
|
134
|
+
}
|
|
135
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
ui.TextArea,
|
|
137
|
+
{
|
|
138
|
+
id,
|
|
139
|
+
value,
|
|
140
|
+
rows: 3,
|
|
141
|
+
onChange: handleChange,
|
|
142
|
+
readOnly,
|
|
143
|
+
placeholder,
|
|
144
|
+
style: { resize: "vertical" }
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
function EditIndexDialog(props) {
|
|
150
|
+
const { open, onClose, onSubmit } = props, id = require$$0.useId(), ref = require$$0.useRef(null);
|
|
151
|
+
require$$0.useEffect(() => {
|
|
152
|
+
open && setTimeout(() => ref.current?.querySelector("input")?.focus());
|
|
153
|
+
}, [ref, open]);
|
|
154
|
+
const handleSubmit = require$$0.useCallback(
|
|
155
|
+
(index) => {
|
|
156
|
+
onSubmit(index), onClose();
|
|
157
|
+
},
|
|
158
|
+
[onSubmit, onClose]
|
|
159
|
+
);
|
|
160
|
+
return open ? /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { id, width: 1, ref, onClose, header: "Create embeddings index", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { padding: 4, space: 5, children: /* @__PURE__ */ jsxRuntime.jsx(IndexEditor, { readOnly: !1, onSubmit: handleSubmit }) }) }) : null;
|
|
161
|
+
}
|
|
162
|
+
function IndexEditor(props) {
|
|
163
|
+
const { readOnly, index: selectedIndex, onSubmit } = props, client = useApiClient(), schema = sanity.useSchema(), defaultIndex = useDefaultIndex(schema, client.config().dataset ?? ""), [errors, setErrors] = require$$0.useState(), [loading, setLoading] = require$$0.useState(), [index, setIndex] = require$$0.useState(() => ({
|
|
164
|
+
...defaultIndex,
|
|
165
|
+
...selectedIndex
|
|
166
|
+
}));
|
|
167
|
+
require$$0.useEffect(() => setIndex(selectedIndex ?? { ...defaultIndex }), [selectedIndex, defaultIndex]);
|
|
168
|
+
const handleSubmit = require$$0.useCallback(
|
|
169
|
+
(e) => {
|
|
170
|
+
if (e.preventDefault(), readOnly)
|
|
171
|
+
return;
|
|
172
|
+
const validationErrors = [];
|
|
173
|
+
if (index.indexName ? index.indexName.match(/^[a-zA-Z0-9-_]+$/g) || validationErrors.push("Index name can only contain the letters a-z, numbers - and _") : validationErrors.push("Index name is required"), index.dataset || validationErrors.push("Dataset is required"), index.filter || validationErrors.push("Filter is required"), index.projection || validationErrors.push("Projection is required"), validationErrors.length) {
|
|
174
|
+
setErrors(validationErrors);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const { projectId } = client.config();
|
|
178
|
+
setLoading(!0), client.request({
|
|
179
|
+
method: "POST",
|
|
180
|
+
url: `/embeddings-index/${index.dataset}?projectId=${projectId}`,
|
|
181
|
+
body: {
|
|
182
|
+
indexName: index.indexName,
|
|
183
|
+
projection: index.projection,
|
|
184
|
+
filter: index.filter
|
|
185
|
+
}
|
|
186
|
+
}).then((response) => {
|
|
187
|
+
onSubmit && onSubmit(response.index);
|
|
188
|
+
}).catch((err) => {
|
|
189
|
+
console.error(err), setErrors([err.message]);
|
|
190
|
+
}).finally(() => {
|
|
191
|
+
setLoading(!1);
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
[index, readOnly, onSubmit, client]
|
|
195
|
+
);
|
|
196
|
+
return /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
197
|
+
errors?.length ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { tone: "critical", border: !0, padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { style: { marginLeft: -10 }, children: errors?.map((error, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: error }, `${error}-${i}`)) }) }) }) : null,
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
199
|
+
IndexFormInput,
|
|
200
|
+
{
|
|
201
|
+
label: "Index name",
|
|
202
|
+
placeholder: "Name of index without spaces...",
|
|
203
|
+
index,
|
|
204
|
+
prop: "indexName",
|
|
205
|
+
onChange: setIndex,
|
|
206
|
+
readOnly
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx(IndexFormInput, { label: "Dataset", index, prop: "dataset", onChange: setIndex, readOnly: !0 }),
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
IndexFormInput,
|
|
212
|
+
{
|
|
213
|
+
label: "Filter",
|
|
214
|
+
description: "Must be a valid GROQ filter",
|
|
215
|
+
placeholder: defaultIndex.filter,
|
|
216
|
+
index,
|
|
217
|
+
prop: "filter",
|
|
218
|
+
onChange: setIndex,
|
|
219
|
+
readOnly,
|
|
220
|
+
type: "textarea"
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
224
|
+
IndexFormInput,
|
|
225
|
+
{
|
|
226
|
+
label: "Projection",
|
|
227
|
+
description: "Must be a valid GROQ projection, starting { and ending with }",
|
|
228
|
+
placeholder: defaultIndex.projection,
|
|
229
|
+
index,
|
|
230
|
+
prop: "projection",
|
|
231
|
+
onChange: setIndex,
|
|
232
|
+
readOnly,
|
|
233
|
+
type: "textarea"
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
onSubmit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
237
|
+
ui.Button,
|
|
238
|
+
{
|
|
239
|
+
type: "submit",
|
|
240
|
+
text: "Create index",
|
|
241
|
+
icon: loading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { marginTop: 5 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : icons.AddIcon,
|
|
242
|
+
disabled: readOnly || loading,
|
|
243
|
+
tone: "primary"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
] }) });
|
|
88
247
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
250
|
+
*
|
|
251
|
+
* This source code is licensed under the MIT license found in the
|
|
252
|
+
* LICENSE file in the root directory of this source tree.
|
|
253
|
+
*
|
|
254
|
+
* @lightSyntaxTransform
|
|
255
|
+
* @noflow
|
|
256
|
+
* @nolint
|
|
257
|
+
* @preventMunge
|
|
258
|
+
* @preserve-invariant-messages
|
|
259
|
+
*/
|
|
260
|
+
var dist, hasRequiredDist;
|
|
261
|
+
function requireDist() {
|
|
262
|
+
if (hasRequiredDist) return dist;
|
|
263
|
+
hasRequiredDist = 1;
|
|
264
|
+
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
|
|
265
|
+
for (var name in all)
|
|
266
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
267
|
+
}, __copyProps = (to, from2, except, desc) => {
|
|
268
|
+
if (from2 && typeof from2 == "object" || typeof from2 == "function")
|
|
269
|
+
for (let key of __getOwnPropNames(from2))
|
|
270
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
271
|
+
return to;
|
|
272
|
+
}, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
273
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
274
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
275
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
276
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
277
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
278
|
+
mod
|
|
279
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), index_exports = {};
|
|
280
|
+
__export(index_exports, {
|
|
281
|
+
$dispatcherGuard: () => $dispatcherGuard,
|
|
282
|
+
$makeReadOnly: () => $makeReadOnly,
|
|
283
|
+
$reset: () => $reset,
|
|
284
|
+
$structuralCheck: () => $structuralCheck,
|
|
285
|
+
c: () => c,
|
|
286
|
+
clearRenderCounterRegistry: () => clearRenderCounterRegistry,
|
|
287
|
+
renderCounterRegistry: () => renderCounterRegistry,
|
|
288
|
+
useRenderCounter: () => useRenderCounter
|
|
289
|
+
}), dist = __toCommonJS(index_exports);
|
|
290
|
+
var React = __toESM(require$$0__default.default), { useRef, useEffect, isValidElement } = React, _a, ReactSecretInternals = (
|
|
291
|
+
//@ts-ignore
|
|
292
|
+
(_a = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE) != null ? _a : React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
293
|
+
), $empty = Symbol.for("react.memo_cache_sentinel"), _a2, c = (
|
|
294
|
+
// @ts-expect-error
|
|
295
|
+
typeof ((_a2 = React.__COMPILER_RUNTIME) == null ? void 0 : _a2.c) == "function" ? (
|
|
296
|
+
// @ts-expect-error
|
|
297
|
+
React.__COMPILER_RUNTIME.c
|
|
298
|
+
) : function(size) {
|
|
299
|
+
return React.useMemo(() => {
|
|
300
|
+
const $ = new Array(size);
|
|
301
|
+
for (let ii = 0; ii < size; ii++)
|
|
302
|
+
$[ii] = $empty;
|
|
303
|
+
return $[$empty] = !0, $;
|
|
304
|
+
}, []);
|
|
305
|
+
}
|
|
306
|
+
), LazyGuardDispatcher = {};
|
|
307
|
+
[
|
|
308
|
+
"readContext",
|
|
309
|
+
"useCallback",
|
|
310
|
+
"useContext",
|
|
311
|
+
"useEffect",
|
|
312
|
+
"useImperativeHandle",
|
|
313
|
+
"useInsertionEffect",
|
|
314
|
+
"useLayoutEffect",
|
|
315
|
+
"useMemo",
|
|
316
|
+
"useReducer",
|
|
317
|
+
"useRef",
|
|
318
|
+
"useState",
|
|
319
|
+
"useDebugValue",
|
|
320
|
+
"useDeferredValue",
|
|
321
|
+
"useTransition",
|
|
322
|
+
"useMutableSource",
|
|
323
|
+
"useSyncExternalStore",
|
|
324
|
+
"useId",
|
|
325
|
+
"unstable_isNewReconciler",
|
|
326
|
+
"getCacheSignal",
|
|
327
|
+
"getCacheForType",
|
|
328
|
+
"useCacheRefresh"
|
|
329
|
+
].forEach((name) => {
|
|
330
|
+
LazyGuardDispatcher[name] = () => {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`[React] Unexpected React hook call (${name}) from a React compiled function. Check that all hooks are called directly and named according to convention ('use[A-Z]') `
|
|
333
|
+
);
|
|
334
|
+
};
|
|
335
|
+
});
|
|
336
|
+
var originalDispatcher = null;
|
|
337
|
+
LazyGuardDispatcher.useMemoCache = (count) => {
|
|
338
|
+
if (originalDispatcher == null)
|
|
339
|
+
throw new Error(
|
|
340
|
+
"React Compiler internal invariant violation: unexpected null dispatcher"
|
|
341
|
+
);
|
|
342
|
+
return originalDispatcher.useMemoCache(count);
|
|
113
343
|
};
|
|
114
|
-
|
|
344
|
+
function setCurrent(newDispatcher) {
|
|
345
|
+
return ReactSecretInternals.ReactCurrentDispatcher.current = newDispatcher, ReactSecretInternals.ReactCurrentDispatcher.current;
|
|
346
|
+
}
|
|
347
|
+
var guardFrames = [];
|
|
348
|
+
function $dispatcherGuard(kind) {
|
|
349
|
+
const curr = ReactSecretInternals.ReactCurrentDispatcher.current;
|
|
350
|
+
if (kind === 0) {
|
|
351
|
+
if (guardFrames.push(curr), guardFrames.length === 1 && (originalDispatcher = curr), curr === LazyGuardDispatcher)
|
|
352
|
+
throw new Error(
|
|
353
|
+
"[React] Unexpected call to custom hook or component from a React compiled function. Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') and (2) components are returned as JSX instead of being directly invoked."
|
|
354
|
+
);
|
|
355
|
+
setCurrent(LazyGuardDispatcher);
|
|
356
|
+
} else if (kind === 1) {
|
|
357
|
+
const lastFrame = guardFrames.pop();
|
|
358
|
+
if (lastFrame == null)
|
|
359
|
+
throw new Error(
|
|
360
|
+
"React Compiler internal error: unexpected null in guard stack"
|
|
361
|
+
);
|
|
362
|
+
guardFrames.length === 0 && (originalDispatcher = null), setCurrent(lastFrame);
|
|
363
|
+
} else if (kind === 2)
|
|
364
|
+
guardFrames.push(curr), setCurrent(originalDispatcher);
|
|
365
|
+
else if (kind === 3) {
|
|
366
|
+
const lastFrame = guardFrames.pop();
|
|
367
|
+
if (lastFrame == null)
|
|
368
|
+
throw new Error(
|
|
369
|
+
"React Compiler internal error: unexpected null in guard stack"
|
|
370
|
+
);
|
|
371
|
+
setCurrent(lastFrame);
|
|
372
|
+
} else
|
|
373
|
+
throw new Error("React Compiler internal error: unreachable block" + kind);
|
|
374
|
+
}
|
|
375
|
+
function $reset($) {
|
|
376
|
+
for (let ii = 0; ii < $.length; ii++)
|
|
377
|
+
$[ii] = $empty;
|
|
378
|
+
}
|
|
379
|
+
function $makeReadOnly() {
|
|
380
|
+
throw new Error("TODO: implement $makeReadOnly in react-compiler-runtime");
|
|
381
|
+
}
|
|
382
|
+
var renderCounterRegistry = /* @__PURE__ */ new Map();
|
|
383
|
+
function clearRenderCounterRegistry() {
|
|
384
|
+
for (const counters of renderCounterRegistry.values())
|
|
385
|
+
counters.forEach((counter) => {
|
|
386
|
+
counter.count = 0;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function registerRenderCounter(name, val) {
|
|
390
|
+
let counters = renderCounterRegistry.get(name);
|
|
391
|
+
counters == null && (counters = /* @__PURE__ */ new Set(), renderCounterRegistry.set(name, counters)), counters.add(val);
|
|
392
|
+
}
|
|
393
|
+
function removeRenderCounter(name, val) {
|
|
394
|
+
const counters = renderCounterRegistry.get(name);
|
|
395
|
+
counters?.delete(val);
|
|
396
|
+
}
|
|
397
|
+
function useRenderCounter(name) {
|
|
398
|
+
const val = useRef(null);
|
|
399
|
+
val.current != null && (val.current.count += 1), useEffect(() => {
|
|
400
|
+
if (val.current == null) {
|
|
401
|
+
const counter = { count: 0 };
|
|
402
|
+
registerRenderCounter(name, counter), val.current = counter;
|
|
403
|
+
}
|
|
404
|
+
return () => {
|
|
405
|
+
val.current !== null && removeRenderCounter(name, val.current);
|
|
406
|
+
};
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
var seenErrors = /* @__PURE__ */ new Set();
|
|
410
|
+
function $structuralCheck(oldValue, newValue, variableName, fnName, kind, loc) {
|
|
411
|
+
function error(l, r, path, depth) {
|
|
412
|
+
const str = `${fnName}:${loc} [${kind}] ${variableName}${path} changed from ${l} to ${r} at depth ${depth}`;
|
|
413
|
+
seenErrors.has(str) || (seenErrors.add(str), console.error(str));
|
|
414
|
+
}
|
|
415
|
+
const depthLimit = 2;
|
|
416
|
+
function recur(oldValue2, newValue2, path, depth) {
|
|
417
|
+
if (!(depth > depthLimit)) {
|
|
418
|
+
if (oldValue2 === newValue2)
|
|
419
|
+
return;
|
|
420
|
+
if (typeof oldValue2 != typeof newValue2)
|
|
421
|
+
error(`type ${typeof oldValue2}`, `type ${typeof newValue2}`, path, depth);
|
|
422
|
+
else if (typeof oldValue2 == "object") {
|
|
423
|
+
const oldArray = Array.isArray(oldValue2), newArray = Array.isArray(newValue2);
|
|
424
|
+
if (oldValue2 === null && newValue2 !== null)
|
|
425
|
+
error("null", `type ${typeof newValue2}`, path, depth);
|
|
426
|
+
else if (newValue2 === null)
|
|
427
|
+
error(`type ${typeof oldValue2}`, "null", path, depth);
|
|
428
|
+
else if (oldValue2 instanceof Map)
|
|
429
|
+
if (!(newValue2 instanceof Map))
|
|
430
|
+
error("Map instance", "other value", path, depth);
|
|
431
|
+
else if (oldValue2.size !== newValue2.size)
|
|
432
|
+
error(
|
|
433
|
+
`Map instance with size ${oldValue2.size}`,
|
|
434
|
+
`Map instance with size ${newValue2.size}`,
|
|
435
|
+
path,
|
|
436
|
+
depth
|
|
437
|
+
);
|
|
438
|
+
else
|
|
439
|
+
for (const [k, v] of oldValue2)
|
|
440
|
+
newValue2.has(k) ? recur(v, newValue2.get(k), `${path}.get(${k})`, depth + 1) : error(
|
|
441
|
+
`Map instance with key ${k}`,
|
|
442
|
+
`Map instance without key ${k}`,
|
|
443
|
+
path,
|
|
444
|
+
depth
|
|
445
|
+
);
|
|
446
|
+
else if (newValue2 instanceof Map)
|
|
447
|
+
error("other value", "Map instance", path, depth);
|
|
448
|
+
else if (oldValue2 instanceof Set)
|
|
449
|
+
if (!(newValue2 instanceof Set))
|
|
450
|
+
error("Set instance", "other value", path, depth);
|
|
451
|
+
else if (oldValue2.size !== newValue2.size)
|
|
452
|
+
error(
|
|
453
|
+
`Set instance with size ${oldValue2.size}`,
|
|
454
|
+
`Set instance with size ${newValue2.size}`,
|
|
455
|
+
path,
|
|
456
|
+
depth
|
|
457
|
+
);
|
|
458
|
+
else
|
|
459
|
+
for (const v of newValue2)
|
|
460
|
+
oldValue2.has(v) || error(
|
|
461
|
+
`Set instance without element ${v}`,
|
|
462
|
+
`Set instance with element ${v}`,
|
|
463
|
+
path,
|
|
464
|
+
depth
|
|
465
|
+
);
|
|
466
|
+
else if (newValue2 instanceof Set)
|
|
467
|
+
error("other value", "Set instance", path, depth);
|
|
468
|
+
else if (oldArray || newArray)
|
|
469
|
+
if (oldArray !== newArray)
|
|
470
|
+
error(
|
|
471
|
+
`type ${oldArray ? "array" : "object"}`,
|
|
472
|
+
`type ${newArray ? "array" : "object"}`,
|
|
473
|
+
path,
|
|
474
|
+
depth
|
|
475
|
+
);
|
|
476
|
+
else if (oldValue2.length !== newValue2.length)
|
|
477
|
+
error(
|
|
478
|
+
`array with length ${oldValue2.length}`,
|
|
479
|
+
`array with length ${newValue2.length}`,
|
|
480
|
+
path,
|
|
481
|
+
depth
|
|
482
|
+
);
|
|
483
|
+
else
|
|
484
|
+
for (let ii = 0; ii < oldValue2.length; ii++)
|
|
485
|
+
recur(oldValue2[ii], newValue2[ii], `${path}[${ii}]`, depth + 1);
|
|
486
|
+
else if (isValidElement(oldValue2) || isValidElement(newValue2))
|
|
487
|
+
isValidElement(oldValue2) !== isValidElement(newValue2) ? error(
|
|
488
|
+
`type ${isValidElement(oldValue2) ? "React element" : "object"}`,
|
|
489
|
+
`type ${isValidElement(newValue2) ? "React element" : "object"}`,
|
|
490
|
+
path,
|
|
491
|
+
depth
|
|
492
|
+
) : oldValue2.type !== newValue2.type ? error(
|
|
493
|
+
`React element of type ${oldValue2.type}`,
|
|
494
|
+
`React element of type ${newValue2.type}`,
|
|
495
|
+
path,
|
|
496
|
+
depth
|
|
497
|
+
) : recur(
|
|
498
|
+
oldValue2.props,
|
|
499
|
+
newValue2.props,
|
|
500
|
+
`[props of ${path}]`,
|
|
501
|
+
depth + 1
|
|
502
|
+
);
|
|
503
|
+
else {
|
|
504
|
+
for (const key in newValue2)
|
|
505
|
+
key in oldValue2 || error(
|
|
506
|
+
`object without key ${key}`,
|
|
507
|
+
`object with key ${key}`,
|
|
508
|
+
path,
|
|
509
|
+
depth
|
|
510
|
+
);
|
|
511
|
+
for (const key in oldValue2)
|
|
512
|
+
key in newValue2 ? recur(oldValue2[key], newValue2[key], `${path}.${key}`, depth + 1) : error(
|
|
513
|
+
`object with key ${key}`,
|
|
514
|
+
`object without key ${key}`,
|
|
515
|
+
path,
|
|
516
|
+
depth
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
} else {
|
|
520
|
+
if (typeof oldValue2 == "function")
|
|
521
|
+
return;
|
|
522
|
+
isNaN(oldValue2) || isNaN(newValue2) ? isNaN(oldValue2) !== isNaN(newValue2) && error(
|
|
523
|
+
`${isNaN(oldValue2) ? "NaN" : "non-NaN value"}`,
|
|
524
|
+
`${isNaN(newValue2) ? "NaN" : "non-NaN value"}`,
|
|
525
|
+
path,
|
|
526
|
+
depth
|
|
527
|
+
) : oldValue2 !== newValue2 && error(oldValue2, newValue2, path, depth);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
recur(oldValue, newValue, "", 0);
|
|
532
|
+
}
|
|
533
|
+
return dist;
|
|
534
|
+
}
|
|
535
|
+
var distExports = requireDist(), extendStatics = function(d, b) {
|
|
536
|
+
return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
537
|
+
d2.__proto__ = b2;
|
|
538
|
+
} || function(d2, b2) {
|
|
539
|
+
for (var p in b2) Object.prototype.hasOwnProperty.call(b2, p) && (d2[p] = b2[p]);
|
|
540
|
+
}, extendStatics(d, b);
|
|
115
541
|
};
|
|
116
542
|
function __extends(d, b) {
|
|
117
|
-
if (typeof b
|
|
543
|
+
if (typeof b != "function" && b !== null)
|
|
544
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
118
545
|
extendStatics(d, b);
|
|
119
546
|
function __() {
|
|
120
547
|
this.constructor = d;
|
|
@@ -123,11 +550,11 @@ function __extends(d, b) {
|
|
|
123
550
|
}
|
|
124
551
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
125
552
|
function adopt(value) {
|
|
126
|
-
return value instanceof P ? value : new P(function
|
|
553
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
127
554
|
resolve(value);
|
|
128
555
|
});
|
|
129
556
|
}
|
|
130
|
-
return new (P || (P = Promise))(function
|
|
557
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
131
558
|
function fulfilled(value) {
|
|
132
559
|
try {
|
|
133
560
|
step(generator.next(value));
|
|
@@ -137,7 +564,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
137
564
|
}
|
|
138
565
|
function rejected(value) {
|
|
139
566
|
try {
|
|
140
|
-
step(generator
|
|
567
|
+
step(generator.throw(value));
|
|
141
568
|
} catch (e) {
|
|
142
569
|
reject(e);
|
|
143
570
|
}
|
|
@@ -149,58 +576,37 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
149
576
|
});
|
|
150
577
|
}
|
|
151
578
|
function __generator(thisArg, body) {
|
|
152
|
-
var _ = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
trys: [],
|
|
159
|
-
ops: []
|
|
160
|
-
},
|
|
161
|
-
f,
|
|
162
|
-
y,
|
|
163
|
-
t,
|
|
164
|
-
g;
|
|
165
|
-
return g = {
|
|
166
|
-
next: verb(0),
|
|
167
|
-
"throw": verb(1),
|
|
168
|
-
"return": verb(2)
|
|
169
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
579
|
+
var _ = { label: 0, sent: function() {
|
|
580
|
+
if (t[0] & 1) throw t[1];
|
|
581
|
+
return t[1];
|
|
582
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
583
|
+
return g = { next: verb(0), throw: verb(1), return: verb(2) }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
|
170
584
|
return this;
|
|
171
585
|
}), g;
|
|
172
586
|
function verb(n) {
|
|
173
|
-
return function
|
|
587
|
+
return function(v) {
|
|
174
588
|
return step([n, v]);
|
|
175
589
|
};
|
|
176
590
|
}
|
|
177
591
|
function step(op) {
|
|
178
592
|
if (f) throw new TypeError("Generator is already executing.");
|
|
179
|
-
|
|
180
|
-
if (f = 1, y && (t = op[0] & 2 ? y
|
|
181
|
-
|
|
182
|
-
switch (op[0]) {
|
|
593
|
+
for (; g && (g = 0, op[0] && (_ = 0)), _; ) try {
|
|
594
|
+
if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
595
|
+
switch (y = 0, t && (op = [op[0] & 2, t.value]), op[0]) {
|
|
183
596
|
case 0:
|
|
184
597
|
case 1:
|
|
185
598
|
t = op;
|
|
186
599
|
break;
|
|
187
600
|
case 4:
|
|
188
|
-
_.label
|
|
189
|
-
return {
|
|
190
|
-
value: op[1],
|
|
191
|
-
done: false
|
|
192
|
-
};
|
|
601
|
+
return _.label++, { value: op[1], done: !1 };
|
|
193
602
|
case 5:
|
|
194
|
-
_.label
|
|
195
|
-
y = op[1];
|
|
196
|
-
op = [0];
|
|
603
|
+
_.label++, y = op[1], op = [0];
|
|
197
604
|
continue;
|
|
198
605
|
case 7:
|
|
199
|
-
op = _.ops.pop();
|
|
200
|
-
_.trys.pop();
|
|
606
|
+
op = _.ops.pop(), _.trys.pop();
|
|
201
607
|
continue;
|
|
202
608
|
default:
|
|
203
|
-
if (
|
|
609
|
+
if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
204
610
|
_ = 0;
|
|
205
611
|
continue;
|
|
206
612
|
}
|
|
@@ -209,97 +615,73 @@ function __generator(thisArg, body) {
|
|
|
209
615
|
break;
|
|
210
616
|
}
|
|
211
617
|
if (op[0] === 6 && _.label < t[1]) {
|
|
212
|
-
_.label = t[1];
|
|
213
|
-
t = op;
|
|
618
|
+
_.label = t[1], t = op;
|
|
214
619
|
break;
|
|
215
620
|
}
|
|
216
621
|
if (t && _.label < t[2]) {
|
|
217
|
-
_.label = t[2];
|
|
218
|
-
_.ops.push(op);
|
|
622
|
+
_.label = t[2], _.ops.push(op);
|
|
219
623
|
break;
|
|
220
624
|
}
|
|
221
|
-
|
|
222
|
-
_.trys.pop();
|
|
625
|
+
t[2] && _.ops.pop(), _.trys.pop();
|
|
223
626
|
continue;
|
|
224
627
|
}
|
|
225
628
|
op = body.call(thisArg, _);
|
|
226
629
|
} catch (e) {
|
|
227
|
-
op = [6, e];
|
|
228
|
-
y = 0;
|
|
630
|
+
op = [6, e], y = 0;
|
|
229
631
|
} finally {
|
|
230
632
|
f = t = 0;
|
|
231
633
|
}
|
|
232
634
|
if (op[0] & 5) throw op[1];
|
|
233
|
-
return {
|
|
234
|
-
value: op[0] ? op[1] : void 0,
|
|
235
|
-
done: true
|
|
236
|
-
};
|
|
635
|
+
return { value: op[0] ? op[1] : void 0, done: !0 };
|
|
237
636
|
}
|
|
238
637
|
}
|
|
239
638
|
function __values(o) {
|
|
240
|
-
var s = typeof Symbol
|
|
241
|
-
m = s && o[s],
|
|
242
|
-
i = 0;
|
|
639
|
+
var s = typeof Symbol == "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
243
640
|
if (m) return m.call(o);
|
|
244
|
-
if (o && typeof o.length
|
|
245
|
-
next: function
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
value: o && o[i++],
|
|
249
|
-
done: !o
|
|
250
|
-
};
|
|
641
|
+
if (o && typeof o.length == "number") return {
|
|
642
|
+
next: function() {
|
|
643
|
+
return o && i >= o.length && (o = void 0), { value: o && o[i++], done: !o };
|
|
251
644
|
}
|
|
252
645
|
};
|
|
253
646
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
254
647
|
}
|
|
255
648
|
function __read(o, n) {
|
|
256
|
-
var m = typeof Symbol
|
|
649
|
+
var m = typeof Symbol == "function" && o[Symbol.iterator];
|
|
257
650
|
if (!m) return o;
|
|
258
|
-
var i = m.call(o),
|
|
259
|
-
r,
|
|
260
|
-
ar = [],
|
|
261
|
-
e;
|
|
651
|
+
var i = m.call(o), r, ar = [], e;
|
|
262
652
|
try {
|
|
263
|
-
|
|
653
|
+
for (; (n === void 0 || n-- > 0) && !(r = i.next()).done; ) ar.push(r.value);
|
|
264
654
|
} catch (error) {
|
|
265
|
-
e = {
|
|
266
|
-
error: error
|
|
267
|
-
};
|
|
655
|
+
e = { error };
|
|
268
656
|
} finally {
|
|
269
657
|
try {
|
|
270
|
-
|
|
658
|
+
r && !r.done && (m = i.return) && m.call(i);
|
|
271
659
|
} finally {
|
|
272
660
|
if (e) throw e.error;
|
|
273
661
|
}
|
|
274
662
|
}
|
|
275
663
|
return ar;
|
|
276
664
|
}
|
|
277
|
-
function __spreadArray(to,
|
|
278
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
ar[i] = from[i];
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
665
|
+
function __spreadArray(to, from2, pack) {
|
|
666
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++)
|
|
667
|
+
(ar || !(i in from2)) && (ar || (ar = Array.prototype.slice.call(from2, 0, i)), ar[i] = from2[i]);
|
|
668
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
|
285
669
|
}
|
|
286
670
|
function __await(v) {
|
|
287
671
|
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
288
672
|
}
|
|
289
673
|
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
290
674
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
291
|
-
var g = generator.apply(thisArg, _arguments || []),
|
|
292
|
-
|
|
293
|
-
q = [];
|
|
294
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
|
675
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
676
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
295
677
|
return this;
|
|
296
678
|
}, i;
|
|
297
679
|
function verb(n) {
|
|
298
|
-
|
|
299
|
-
return new Promise(function
|
|
680
|
+
g[n] && (i[n] = function(v) {
|
|
681
|
+
return new Promise(function(a, b) {
|
|
300
682
|
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
301
683
|
});
|
|
302
|
-
};
|
|
684
|
+
});
|
|
303
685
|
}
|
|
304
686
|
function resume(n, v) {
|
|
305
687
|
try {
|
|
@@ -318,57 +700,44 @@ function __asyncGenerator(thisArg, _arguments, generator) {
|
|
|
318
700
|
resume("throw", value);
|
|
319
701
|
}
|
|
320
702
|
function settle(f, v) {
|
|
321
|
-
|
|
703
|
+
f(v), q.shift(), q.length && resume(q[0][0], q[0][1]);
|
|
322
704
|
}
|
|
323
705
|
}
|
|
324
706
|
function __asyncValues(o) {
|
|
325
707
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
326
|
-
var m = o[Symbol.asyncIterator],
|
|
327
|
-
|
|
328
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
|
708
|
+
var m = o[Symbol.asyncIterator], i;
|
|
709
|
+
return m ? m.call(o) : (o = typeof __values == "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
329
710
|
return this;
|
|
330
711
|
}, i);
|
|
331
712
|
function verb(n) {
|
|
332
|
-
i[n] = o[n] && function
|
|
333
|
-
return new Promise(function
|
|
713
|
+
i[n] = o[n] && function(v) {
|
|
714
|
+
return new Promise(function(resolve, reject) {
|
|
334
715
|
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
335
716
|
});
|
|
336
717
|
};
|
|
337
718
|
}
|
|
338
719
|
function settle(resolve, reject, d, v) {
|
|
339
|
-
Promise.resolve(v).then(function
|
|
340
|
-
resolve({
|
|
341
|
-
value: v,
|
|
342
|
-
done: d
|
|
343
|
-
});
|
|
720
|
+
Promise.resolve(v).then(function(v2) {
|
|
721
|
+
resolve({ value: v2, done: d });
|
|
344
722
|
}, reject);
|
|
345
723
|
}
|
|
346
724
|
}
|
|
347
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
348
|
-
var e = new Error(message);
|
|
349
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
350
|
-
};
|
|
351
725
|
function isFunction(value) {
|
|
352
|
-
return typeof value
|
|
726
|
+
return typeof value == "function";
|
|
353
727
|
}
|
|
354
728
|
function createErrorClass(createImpl) {
|
|
355
|
-
var _super = function
|
|
356
|
-
Error.call(instance);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
365
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
366
|
-
_super(this);
|
|
367
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) {
|
|
729
|
+
var _super = function(instance) {
|
|
730
|
+
Error.call(instance), instance.stack = new Error().stack;
|
|
731
|
+
}, ctorFunc = createImpl(_super);
|
|
732
|
+
return ctorFunc.prototype = Object.create(Error.prototype), ctorFunc.prototype.constructor = ctorFunc, ctorFunc;
|
|
733
|
+
}
|
|
734
|
+
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
735
|
+
return function(errors) {
|
|
736
|
+
_super(this), this.message = errors ? errors.length + ` errors occurred during unsubscription:
|
|
737
|
+
` + errors.map(function(err, i) {
|
|
368
738
|
return i + 1 + ") " + err.toString();
|
|
369
|
-
}).join(
|
|
370
|
-
|
|
371
|
-
this.errors = errors;
|
|
739
|
+
}).join(`
|
|
740
|
+
`) : "", this.name = "UnsubscriptionError", this.errors = errors;
|
|
372
741
|
};
|
|
373
742
|
});
|
|
374
743
|
function arrRemove(arr, item) {
|
|
@@ -377,50 +746,40 @@ function arrRemove(arr, item) {
|
|
|
377
746
|
0 <= index && arr.splice(index, 1);
|
|
378
747
|
}
|
|
379
748
|
}
|
|
380
|
-
var Subscription = function
|
|
381
|
-
function
|
|
382
|
-
this.initialTeardown = initialTeardown;
|
|
383
|
-
this.closed = false;
|
|
384
|
-
this._parentage = null;
|
|
385
|
-
this._finalizers = null;
|
|
749
|
+
var Subscription = function() {
|
|
750
|
+
function Subscription2(initialTeardown) {
|
|
751
|
+
this.initialTeardown = initialTeardown, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
386
752
|
}
|
|
387
|
-
|
|
388
|
-
var e_1, _a, e_2, _b;
|
|
389
|
-
var errors;
|
|
753
|
+
return Subscription2.prototype.unsubscribe = function() {
|
|
754
|
+
var e_1, _a, e_2, _b, errors;
|
|
390
755
|
if (!this.closed) {
|
|
391
|
-
this.closed =
|
|
756
|
+
this.closed = !0;
|
|
392
757
|
var _parentage = this._parentage;
|
|
393
|
-
if (_parentage)
|
|
394
|
-
this._parentage = null
|
|
395
|
-
if (Array.isArray(_parentage)) {
|
|
758
|
+
if (_parentage)
|
|
759
|
+
if (this._parentage = null, Array.isArray(_parentage))
|
|
396
760
|
try {
|
|
397
761
|
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
398
762
|
var parent_1 = _parentage_1_1.value;
|
|
399
763
|
parent_1.remove(this);
|
|
400
764
|
}
|
|
401
765
|
} catch (e_1_1) {
|
|
402
|
-
e_1 = {
|
|
403
|
-
error: e_1_1
|
|
404
|
-
};
|
|
766
|
+
e_1 = { error: e_1_1 };
|
|
405
767
|
} finally {
|
|
406
768
|
try {
|
|
407
|
-
|
|
769
|
+
_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return) && _a.call(_parentage_1);
|
|
408
770
|
} finally {
|
|
409
771
|
if (e_1) throw e_1.error;
|
|
410
772
|
}
|
|
411
773
|
}
|
|
412
|
-
|
|
774
|
+
else
|
|
413
775
|
_parentage.remove(this);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
776
|
var initialFinalizer = this.initialTeardown;
|
|
417
|
-
if (isFunction(initialFinalizer))
|
|
777
|
+
if (isFunction(initialFinalizer))
|
|
418
778
|
try {
|
|
419
779
|
initialFinalizer();
|
|
420
780
|
} catch (e) {
|
|
421
781
|
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
422
782
|
}
|
|
423
|
-
}
|
|
424
783
|
var _finalizers = this._finalizers;
|
|
425
784
|
if (_finalizers) {
|
|
426
785
|
this._finalizers = null;
|
|
@@ -430,330 +789,207 @@ var Subscription = function () {
|
|
|
430
789
|
try {
|
|
431
790
|
execFinalizer(finalizer);
|
|
432
791
|
} catch (err) {
|
|
433
|
-
errors = errors
|
|
434
|
-
if (err instanceof UnsubscriptionError) {
|
|
435
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
436
|
-
} else {
|
|
437
|
-
errors.push(err);
|
|
438
|
-
}
|
|
792
|
+
errors = errors ?? [], err instanceof UnsubscriptionError ? errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors)) : errors.push(err);
|
|
439
793
|
}
|
|
440
794
|
}
|
|
441
795
|
} catch (e_2_1) {
|
|
442
|
-
e_2 = {
|
|
443
|
-
error: e_2_1
|
|
444
|
-
};
|
|
796
|
+
e_2 = { error: e_2_1 };
|
|
445
797
|
} finally {
|
|
446
798
|
try {
|
|
447
|
-
|
|
799
|
+
_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return) && _b.call(_finalizers_1);
|
|
448
800
|
} finally {
|
|
449
801
|
if (e_2) throw e_2.error;
|
|
450
802
|
}
|
|
451
803
|
}
|
|
452
804
|
}
|
|
453
|
-
if (errors)
|
|
805
|
+
if (errors)
|
|
454
806
|
throw new UnsubscriptionError(errors);
|
|
455
|
-
}
|
|
456
807
|
}
|
|
457
|
-
}
|
|
458
|
-
Subscription.prototype.add = function (teardown) {
|
|
808
|
+
}, Subscription2.prototype.add = function(teardown) {
|
|
459
809
|
var _a;
|
|
460
|
-
if (teardown && teardown !== this)
|
|
461
|
-
if (this.closed)
|
|
810
|
+
if (teardown && teardown !== this)
|
|
811
|
+
if (this.closed)
|
|
462
812
|
execFinalizer(teardown);
|
|
463
|
-
|
|
464
|
-
if (teardown instanceof
|
|
465
|
-
if (teardown.closed || teardown._hasParent(this))
|
|
813
|
+
else {
|
|
814
|
+
if (teardown instanceof Subscription2) {
|
|
815
|
+
if (teardown.closed || teardown._hasParent(this))
|
|
466
816
|
return;
|
|
467
|
-
}
|
|
468
817
|
teardown._addParent(this);
|
|
469
818
|
}
|
|
470
819
|
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
471
820
|
}
|
|
472
|
-
|
|
473
|
-
};
|
|
474
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
821
|
+
}, Subscription2.prototype._hasParent = function(parent) {
|
|
475
822
|
var _parentage = this._parentage;
|
|
476
823
|
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
|
477
|
-
}
|
|
478
|
-
Subscription.prototype._addParent = function (parent) {
|
|
824
|
+
}, Subscription2.prototype._addParent = function(parent) {
|
|
479
825
|
var _parentage = this._parentage;
|
|
480
826
|
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
481
|
-
}
|
|
482
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
827
|
+
}, Subscription2.prototype._removeParent = function(parent) {
|
|
483
828
|
var _parentage = this._parentage;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
} else if (Array.isArray(_parentage)) {
|
|
487
|
-
arrRemove(_parentage, parent);
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
Subscription.prototype.remove = function (teardown) {
|
|
829
|
+
_parentage === parent ? this._parentage = null : Array.isArray(_parentage) && arrRemove(_parentage, parent);
|
|
830
|
+
}, Subscription2.prototype.remove = function(teardown) {
|
|
491
831
|
var _finalizers = this._finalizers;
|
|
492
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
var empty = new Subscription();
|
|
499
|
-
empty.closed = true;
|
|
500
|
-
return empty;
|
|
501
|
-
}();
|
|
502
|
-
return Subscription;
|
|
503
|
-
}();
|
|
504
|
-
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
832
|
+
_finalizers && arrRemove(_finalizers, teardown), teardown instanceof Subscription2 && teardown._removeParent(this);
|
|
833
|
+
}, Subscription2.EMPTY = function() {
|
|
834
|
+
var empty = new Subscription2();
|
|
835
|
+
return empty.closed = !0, empty;
|
|
836
|
+
}(), Subscription2;
|
|
837
|
+
}(), EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
505
838
|
function isSubscription(value) {
|
|
506
|
-
return value instanceof Subscription || value &&
|
|
839
|
+
return value instanceof Subscription || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
|
|
507
840
|
}
|
|
508
841
|
function execFinalizer(finalizer) {
|
|
509
|
-
|
|
510
|
-
finalizer();
|
|
511
|
-
} else {
|
|
512
|
-
finalizer.unsubscribe();
|
|
513
|
-
}
|
|
842
|
+
isFunction(finalizer) ? finalizer() : finalizer.unsubscribe();
|
|
514
843
|
}
|
|
515
844
|
var config = {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
useDeprecatedNextContext: false
|
|
521
|
-
};
|
|
522
|
-
var timeoutProvider = {
|
|
523
|
-
setTimeout: function (handler, timeout) {
|
|
524
|
-
var args = [];
|
|
525
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
845
|
+
Promise: void 0
|
|
846
|
+
}, timeoutProvider = {
|
|
847
|
+
setTimeout: function(handler, timeout) {
|
|
848
|
+
for (var args = [], _i = 2; _i < arguments.length; _i++)
|
|
526
849
|
args[_i - 2] = arguments[_i];
|
|
527
|
-
}
|
|
528
850
|
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
529
851
|
},
|
|
530
|
-
clearTimeout: function
|
|
852
|
+
clearTimeout: function(handle) {
|
|
531
853
|
return clearTimeout(handle);
|
|
532
854
|
},
|
|
533
|
-
delegate:
|
|
855
|
+
delegate: void 0
|
|
534
856
|
};
|
|
535
857
|
function reportUnhandledError(err) {
|
|
536
|
-
timeoutProvider.setTimeout(function
|
|
537
|
-
|
|
538
|
-
throw err;
|
|
539
|
-
}
|
|
858
|
+
timeoutProvider.setTimeout(function() {
|
|
859
|
+
throw err;
|
|
540
860
|
});
|
|
541
861
|
}
|
|
542
|
-
function noop() {
|
|
862
|
+
function noop() {
|
|
863
|
+
}
|
|
543
864
|
function errorContext(cb) {
|
|
544
|
-
|
|
545
|
-
cb();
|
|
546
|
-
}
|
|
865
|
+
cb();
|
|
547
866
|
}
|
|
548
|
-
var Subscriber = function
|
|
549
|
-
__extends(
|
|
550
|
-
function
|
|
867
|
+
var Subscriber = function(_super) {
|
|
868
|
+
__extends(Subscriber2, _super);
|
|
869
|
+
function Subscriber2(destination) {
|
|
551
870
|
var _this = _super.call(this) || this;
|
|
552
|
-
_this.isStopped =
|
|
553
|
-
if (destination) {
|
|
554
|
-
_this.destination = destination;
|
|
555
|
-
if (isSubscription(destination)) {
|
|
556
|
-
destination.add(_this);
|
|
557
|
-
}
|
|
558
|
-
} else {
|
|
559
|
-
_this.destination = EMPTY_OBSERVER;
|
|
560
|
-
}
|
|
561
|
-
return _this;
|
|
871
|
+
return _this.isStopped = !1, destination ? (_this.destination = destination, isSubscription(destination) && destination.add(_this)) : _this.destination = EMPTY_OBSERVER, _this;
|
|
562
872
|
}
|
|
563
|
-
|
|
873
|
+
return Subscriber2.create = function(next, error, complete) {
|
|
564
874
|
return new SafeSubscriber(next, error, complete);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
this._error(err);
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
Subscriber.prototype.complete = function () {
|
|
578
|
-
if (this.isStopped) ;else {
|
|
579
|
-
this.isStopped = true;
|
|
580
|
-
this._complete();
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
584
|
-
if (!this.closed) {
|
|
585
|
-
this.isStopped = true;
|
|
586
|
-
_super.prototype.unsubscribe.call(this);
|
|
587
|
-
this.destination = null;
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
Subscriber.prototype._next = function (value) {
|
|
875
|
+
}, Subscriber2.prototype.next = function(value) {
|
|
876
|
+
this.isStopped || this._next(value);
|
|
877
|
+
}, Subscriber2.prototype.error = function(err) {
|
|
878
|
+
this.isStopped || (this.isStopped = !0, this._error(err));
|
|
879
|
+
}, Subscriber2.prototype.complete = function() {
|
|
880
|
+
this.isStopped || (this.isStopped = !0, this._complete());
|
|
881
|
+
}, Subscriber2.prototype.unsubscribe = function() {
|
|
882
|
+
this.closed || (this.isStopped = !0, _super.prototype.unsubscribe.call(this), this.destination = null);
|
|
883
|
+
}, Subscriber2.prototype._next = function(value) {
|
|
591
884
|
this.destination.next(value);
|
|
592
|
-
}
|
|
593
|
-
Subscriber.prototype._error = function (err) {
|
|
885
|
+
}, Subscriber2.prototype._error = function(err) {
|
|
594
886
|
try {
|
|
595
887
|
this.destination.error(err);
|
|
596
888
|
} finally {
|
|
597
889
|
this.unsubscribe();
|
|
598
890
|
}
|
|
599
|
-
}
|
|
600
|
-
Subscriber.prototype._complete = function () {
|
|
891
|
+
}, Subscriber2.prototype._complete = function() {
|
|
601
892
|
try {
|
|
602
893
|
this.destination.complete();
|
|
603
894
|
} finally {
|
|
604
895
|
this.unsubscribe();
|
|
605
896
|
}
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
var _bind = Function.prototype.bind;
|
|
610
|
-
function bind(fn, thisArg) {
|
|
611
|
-
return _bind.call(fn, thisArg);
|
|
612
|
-
}
|
|
613
|
-
var ConsumerObserver = function () {
|
|
614
|
-
function ConsumerObserver(partialObserver) {
|
|
897
|
+
}, Subscriber2;
|
|
898
|
+
}(Subscription), ConsumerObserver = function() {
|
|
899
|
+
function ConsumerObserver2(partialObserver) {
|
|
615
900
|
this.partialObserver = partialObserver;
|
|
616
901
|
}
|
|
617
|
-
|
|
902
|
+
return ConsumerObserver2.prototype.next = function(value) {
|
|
618
903
|
var partialObserver = this.partialObserver;
|
|
619
|
-
if (partialObserver.next)
|
|
904
|
+
if (partialObserver.next)
|
|
620
905
|
try {
|
|
621
906
|
partialObserver.next(value);
|
|
622
907
|
} catch (error) {
|
|
623
908
|
handleUnhandledError(error);
|
|
624
909
|
}
|
|
625
|
-
|
|
626
|
-
};
|
|
627
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
910
|
+
}, ConsumerObserver2.prototype.error = function(err) {
|
|
628
911
|
var partialObserver = this.partialObserver;
|
|
629
|
-
if (partialObserver.error)
|
|
912
|
+
if (partialObserver.error)
|
|
630
913
|
try {
|
|
631
914
|
partialObserver.error(err);
|
|
632
915
|
} catch (error) {
|
|
633
916
|
handleUnhandledError(error);
|
|
634
917
|
}
|
|
635
|
-
|
|
918
|
+
else
|
|
636
919
|
handleUnhandledError(err);
|
|
637
|
-
|
|
638
|
-
};
|
|
639
|
-
ConsumerObserver.prototype.complete = function () {
|
|
920
|
+
}, ConsumerObserver2.prototype.complete = function() {
|
|
640
921
|
var partialObserver = this.partialObserver;
|
|
641
|
-
if (partialObserver.complete)
|
|
922
|
+
if (partialObserver.complete)
|
|
642
923
|
try {
|
|
643
924
|
partialObserver.complete();
|
|
644
925
|
} catch (error) {
|
|
645
926
|
handleUnhandledError(error);
|
|
646
927
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
var
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
partialObserver = {
|
|
658
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
|
|
659
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
660
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined
|
|
661
|
-
};
|
|
662
|
-
} else {
|
|
663
|
-
var context_1;
|
|
664
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
665
|
-
context_1 = Object.create(observerOrNext);
|
|
666
|
-
context_1.unsubscribe = function () {
|
|
667
|
-
return _this.unsubscribe();
|
|
668
|
-
};
|
|
669
|
-
partialObserver = {
|
|
670
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
671
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
672
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1)
|
|
673
|
-
};
|
|
674
|
-
} else {
|
|
675
|
-
partialObserver = observerOrNext;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
679
|
-
return _this;
|
|
928
|
+
}, ConsumerObserver2;
|
|
929
|
+
}(), SafeSubscriber = function(_super) {
|
|
930
|
+
__extends(SafeSubscriber2, _super);
|
|
931
|
+
function SafeSubscriber2(observerOrNext, error, complete) {
|
|
932
|
+
var _this = _super.call(this) || this, partialObserver;
|
|
933
|
+
return isFunction(observerOrNext) || !observerOrNext ? partialObserver = {
|
|
934
|
+
next: observerOrNext ?? void 0,
|
|
935
|
+
error: error ?? void 0,
|
|
936
|
+
complete: complete ?? void 0
|
|
937
|
+
} : partialObserver = observerOrNext, _this.destination = new ConsumerObserver(partialObserver), _this;
|
|
680
938
|
}
|
|
681
|
-
return
|
|
939
|
+
return SafeSubscriber2;
|
|
682
940
|
}(Subscriber);
|
|
683
941
|
function handleUnhandledError(error) {
|
|
684
|
-
|
|
685
|
-
reportUnhandledError(error);
|
|
686
|
-
}
|
|
942
|
+
reportUnhandledError(error);
|
|
687
943
|
}
|
|
688
944
|
function defaultErrorHandler(err) {
|
|
689
945
|
throw err;
|
|
690
946
|
}
|
|
691
947
|
var EMPTY_OBSERVER = {
|
|
692
|
-
closed:
|
|
948
|
+
closed: !0,
|
|
693
949
|
next: noop,
|
|
694
950
|
error: defaultErrorHandler,
|
|
695
951
|
complete: noop
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
|
952
|
+
}, observable = function() {
|
|
953
|
+
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
699
954
|
}();
|
|
700
955
|
function identity(x) {
|
|
701
956
|
return x;
|
|
702
957
|
}
|
|
703
958
|
function pipeFromArray(fns) {
|
|
704
|
-
|
|
705
|
-
return
|
|
706
|
-
}
|
|
707
|
-
if (fns.length === 1) {
|
|
708
|
-
return fns[0];
|
|
709
|
-
}
|
|
710
|
-
return function piped(input) {
|
|
711
|
-
return fns.reduce(function (prev, fn) {
|
|
959
|
+
return fns.length === 0 ? identity : fns.length === 1 ? fns[0] : function(input) {
|
|
960
|
+
return fns.reduce(function(prev, fn) {
|
|
712
961
|
return fn(prev);
|
|
713
962
|
}, input);
|
|
714
963
|
};
|
|
715
964
|
}
|
|
716
|
-
var Observable = function
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
this._subscribe = subscribe;
|
|
720
|
-
}
|
|
965
|
+
var Observable = function() {
|
|
966
|
+
function Observable2(subscribe) {
|
|
967
|
+
subscribe && (this._subscribe = subscribe);
|
|
721
968
|
}
|
|
722
|
-
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
var _this = this;
|
|
730
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
731
|
-
errorContext(function () {
|
|
732
|
-
var _a = _this,
|
|
733
|
-
operator = _a.operator,
|
|
734
|
-
source = _a.source;
|
|
969
|
+
return Observable2.prototype.lift = function(operator) {
|
|
970
|
+
var observable2 = new Observable2();
|
|
971
|
+
return observable2.source = this, observable2.operator = operator, observable2;
|
|
972
|
+
}, Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
973
|
+
var _this = this, subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
974
|
+
return errorContext(function() {
|
|
975
|
+
var _a = _this, operator = _a.operator, source = _a.source;
|
|
735
976
|
subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
};
|
|
739
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
977
|
+
}), subscriber;
|
|
978
|
+
}, Observable2.prototype._trySubscribe = function(sink) {
|
|
740
979
|
try {
|
|
741
980
|
return this._subscribe(sink);
|
|
742
981
|
} catch (err) {
|
|
743
982
|
sink.error(err);
|
|
744
983
|
}
|
|
745
|
-
}
|
|
746
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
984
|
+
}, Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
747
985
|
var _this = this;
|
|
748
|
-
promiseCtor = getPromiseCtor(promiseCtor)
|
|
749
|
-
return new promiseCtor(function (resolve, reject) {
|
|
986
|
+
return promiseCtor = getPromiseCtor(promiseCtor), new promiseCtor(function(resolve, reject) {
|
|
750
987
|
var subscriber = new SafeSubscriber({
|
|
751
|
-
next: function
|
|
988
|
+
next: function(value) {
|
|
752
989
|
try {
|
|
753
990
|
next(value);
|
|
754
991
|
} catch (err) {
|
|
755
|
-
reject(err);
|
|
756
|
-
subscriber.unsubscribe();
|
|
992
|
+
reject(err), subscriber.unsubscribe();
|
|
757
993
|
}
|
|
758
994
|
},
|
|
759
995
|
error: reject,
|
|
@@ -761,43 +997,34 @@ var Observable = function () {
|
|
|
761
997
|
});
|
|
762
998
|
_this.subscribe(subscriber);
|
|
763
999
|
});
|
|
764
|
-
}
|
|
765
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
1000
|
+
}, Observable2.prototype._subscribe = function(subscriber) {
|
|
766
1001
|
var _a;
|
|
767
1002
|
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
768
|
-
}
|
|
769
|
-
Observable.prototype[observable] = function () {
|
|
1003
|
+
}, Observable2.prototype[observable] = function() {
|
|
770
1004
|
return this;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
var operations = [];
|
|
774
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1005
|
+
}, Observable2.prototype.pipe = function() {
|
|
1006
|
+
for (var operations = [], _i = 0; _i < arguments.length; _i++)
|
|
775
1007
|
operations[_i] = arguments[_i];
|
|
776
|
-
}
|
|
777
1008
|
return pipeFromArray(operations)(this);
|
|
778
|
-
}
|
|
779
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
1009
|
+
}, Observable2.prototype.toPromise = function(promiseCtor) {
|
|
780
1010
|
var _this = this;
|
|
781
|
-
promiseCtor = getPromiseCtor(promiseCtor)
|
|
782
|
-
return new promiseCtor(function (resolve, reject) {
|
|
1011
|
+
return promiseCtor = getPromiseCtor(promiseCtor), new promiseCtor(function(resolve, reject) {
|
|
783
1012
|
var value;
|
|
784
|
-
_this.subscribe(function
|
|
1013
|
+
_this.subscribe(function(x) {
|
|
785
1014
|
return value = x;
|
|
786
|
-
}, function
|
|
1015
|
+
}, function(err) {
|
|
787
1016
|
return reject(err);
|
|
788
|
-
}, function
|
|
1017
|
+
}, function() {
|
|
789
1018
|
return resolve(value);
|
|
790
1019
|
});
|
|
791
1020
|
});
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
};
|
|
796
|
-
return Observable;
|
|
1021
|
+
}, Observable2.create = function(subscribe) {
|
|
1022
|
+
return new Observable2(subscribe);
|
|
1023
|
+
}, Observable2;
|
|
797
1024
|
}();
|
|
798
1025
|
function getPromiseCtor(promiseCtor) {
|
|
799
1026
|
var _a;
|
|
800
|
-
return (_a = promiseCtor
|
|
1027
|
+
return (_a = promiseCtor ?? config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
801
1028
|
}
|
|
802
1029
|
function isObserver(value) {
|
|
803
1030
|
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
@@ -806,48 +1033,43 @@ function isSubscriber(value) {
|
|
|
806
1033
|
return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
|
|
807
1034
|
}
|
|
808
1035
|
function hasLift(source) {
|
|
809
|
-
return isFunction(source
|
|
1036
|
+
return isFunction(source?.lift);
|
|
810
1037
|
}
|
|
811
1038
|
function operate(init) {
|
|
812
|
-
return function
|
|
813
|
-
if (hasLift(source))
|
|
814
|
-
return source.lift(function
|
|
1039
|
+
return function(source) {
|
|
1040
|
+
if (hasLift(source))
|
|
1041
|
+
return source.lift(function(liftedSource) {
|
|
815
1042
|
try {
|
|
816
1043
|
return init(liftedSource, this);
|
|
817
1044
|
} catch (err) {
|
|
818
1045
|
this.error(err);
|
|
819
1046
|
}
|
|
820
1047
|
});
|
|
821
|
-
|
|
822
|
-
throw new TypeError('Unable to lift unknown Observable type');
|
|
1048
|
+
throw new TypeError("Unable to lift unknown Observable type");
|
|
823
1049
|
};
|
|
824
1050
|
}
|
|
825
1051
|
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
826
1052
|
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
827
1053
|
}
|
|
828
|
-
var OperatorSubscriber = function
|
|
829
|
-
__extends(
|
|
830
|
-
function
|
|
1054
|
+
var OperatorSubscriber = function(_super) {
|
|
1055
|
+
__extends(OperatorSubscriber2, _super);
|
|
1056
|
+
function OperatorSubscriber2(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
831
1057
|
var _this = _super.call(this, destination) || this;
|
|
832
|
-
_this.onFinalize = onFinalize
|
|
833
|
-
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
834
|
-
_this._next = onNext ? function (value) {
|
|
1058
|
+
return _this.onFinalize = onFinalize, _this.shouldUnsubscribe = shouldUnsubscribe, _this._next = onNext ? function(value) {
|
|
835
1059
|
try {
|
|
836
1060
|
onNext(value);
|
|
837
1061
|
} catch (err) {
|
|
838
1062
|
destination.error(err);
|
|
839
1063
|
}
|
|
840
|
-
} : _super.prototype._next
|
|
841
|
-
_this._error = onError ? function (err) {
|
|
1064
|
+
} : _super.prototype._next, _this._error = onError ? function(err) {
|
|
842
1065
|
try {
|
|
843
1066
|
onError(err);
|
|
844
|
-
} catch (
|
|
845
|
-
destination.error(
|
|
1067
|
+
} catch (err2) {
|
|
1068
|
+
destination.error(err2);
|
|
846
1069
|
} finally {
|
|
847
1070
|
this.unsubscribe();
|
|
848
1071
|
}
|
|
849
|
-
} : _super.prototype._error
|
|
850
|
-
_this._complete = onComplete ? function () {
|
|
1072
|
+
} : _super.prototype._error, _this._complete = onComplete ? function() {
|
|
851
1073
|
try {
|
|
852
1074
|
onComplete();
|
|
853
1075
|
} catch (err) {
|
|
@@ -855,305 +1077,319 @@ var OperatorSubscriber = function (_super) {
|
|
|
855
1077
|
} finally {
|
|
856
1078
|
this.unsubscribe();
|
|
857
1079
|
}
|
|
858
|
-
} : _super.prototype._complete;
|
|
859
|
-
return _this;
|
|
1080
|
+
} : _super.prototype._complete, _this;
|
|
860
1081
|
}
|
|
861
|
-
|
|
1082
|
+
return OperatorSubscriber2.prototype.unsubscribe = function() {
|
|
862
1083
|
var _a;
|
|
863
1084
|
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
864
1085
|
var closed_1 = this.closed;
|
|
865
|
-
_super.prototype.unsubscribe.call(this);
|
|
866
|
-
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1086
|
+
_super.prototype.unsubscribe.call(this), !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 || _a.call(this));
|
|
867
1087
|
}
|
|
1088
|
+
}, OperatorSubscriber2;
|
|
1089
|
+
}(Subscriber), ObjectUnsubscribedError = createErrorClass(function(_super) {
|
|
1090
|
+
return function() {
|
|
1091
|
+
_super(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
868
1092
|
};
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
return function ObjectUnsubscribedErrorImpl() {
|
|
873
|
-
_super(this);
|
|
874
|
-
this.name = 'ObjectUnsubscribedError';
|
|
875
|
-
this.message = 'object unsubscribed';
|
|
876
|
-
};
|
|
877
|
-
});
|
|
878
|
-
var Subject = function (_super) {
|
|
879
|
-
__extends(Subject, _super);
|
|
880
|
-
function Subject() {
|
|
1093
|
+
}), Subject = function(_super) {
|
|
1094
|
+
__extends(Subject2, _super);
|
|
1095
|
+
function Subject2() {
|
|
881
1096
|
var _this = _super.call(this) || this;
|
|
882
|
-
_this.closed =
|
|
883
|
-
_this.currentObservers = null;
|
|
884
|
-
_this.observers = [];
|
|
885
|
-
_this.isStopped = false;
|
|
886
|
-
_this.hasError = false;
|
|
887
|
-
_this.thrownError = null;
|
|
888
|
-
return _this;
|
|
1097
|
+
return _this.closed = !1, _this.currentObservers = null, _this.observers = [], _this.isStopped = !1, _this.hasError = !1, _this.thrownError = null, _this;
|
|
889
1098
|
}
|
|
890
|
-
|
|
1099
|
+
return Subject2.prototype.lift = function(operator) {
|
|
891
1100
|
var subject = new AnonymousSubject(this, this);
|
|
892
|
-
subject.operator = operator;
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
Subject.prototype._throwIfClosed = function () {
|
|
896
|
-
if (this.closed) {
|
|
1101
|
+
return subject.operator = operator, subject;
|
|
1102
|
+
}, Subject2.prototype._throwIfClosed = function() {
|
|
1103
|
+
if (this.closed)
|
|
897
1104
|
throw new ObjectUnsubscribedError();
|
|
898
|
-
|
|
899
|
-
};
|
|
900
|
-
Subject.prototype.next = function (value) {
|
|
1105
|
+
}, Subject2.prototype.next = function(value) {
|
|
901
1106
|
var _this = this;
|
|
902
|
-
errorContext(function
|
|
1107
|
+
errorContext(function() {
|
|
903
1108
|
var e_1, _a;
|
|
904
|
-
_this._throwIfClosed()
|
|
905
|
-
|
|
906
|
-
if (!_this.currentObservers) {
|
|
907
|
-
_this.currentObservers = Array.from(_this.observers);
|
|
908
|
-
}
|
|
1109
|
+
if (_this._throwIfClosed(), !_this.isStopped) {
|
|
1110
|
+
_this.currentObservers || (_this.currentObservers = Array.from(_this.observers));
|
|
909
1111
|
try {
|
|
910
1112
|
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
911
1113
|
var observer = _c.value;
|
|
912
1114
|
observer.next(value);
|
|
913
1115
|
}
|
|
914
1116
|
} catch (e_1_1) {
|
|
915
|
-
e_1 = {
|
|
916
|
-
error: e_1_1
|
|
917
|
-
};
|
|
1117
|
+
e_1 = { error: e_1_1 };
|
|
918
1118
|
} finally {
|
|
919
1119
|
try {
|
|
920
|
-
|
|
1120
|
+
_c && !_c.done && (_a = _b.return) && _a.call(_b);
|
|
921
1121
|
} finally {
|
|
922
1122
|
if (e_1) throw e_1.error;
|
|
923
1123
|
}
|
|
924
1124
|
}
|
|
925
1125
|
}
|
|
926
1126
|
});
|
|
927
|
-
}
|
|
928
|
-
Subject.prototype.error = function (err) {
|
|
1127
|
+
}, Subject2.prototype.error = function(err) {
|
|
929
1128
|
var _this = this;
|
|
930
|
-
errorContext(function
|
|
931
|
-
_this._throwIfClosed()
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
_this.thrownError = err;
|
|
935
|
-
var observers = _this.observers;
|
|
936
|
-
while (observers.length) {
|
|
1129
|
+
errorContext(function() {
|
|
1130
|
+
if (_this._throwIfClosed(), !_this.isStopped) {
|
|
1131
|
+
_this.hasError = _this.isStopped = !0, _this.thrownError = err;
|
|
1132
|
+
for (var observers = _this.observers; observers.length; )
|
|
937
1133
|
observers.shift().error(err);
|
|
938
|
-
}
|
|
939
1134
|
}
|
|
940
1135
|
});
|
|
941
|
-
}
|
|
942
|
-
Subject.prototype.complete = function () {
|
|
1136
|
+
}, Subject2.prototype.complete = function() {
|
|
943
1137
|
var _this = this;
|
|
944
|
-
errorContext(function
|
|
945
|
-
_this._throwIfClosed()
|
|
946
|
-
|
|
947
|
-
_this.
|
|
948
|
-
var observers = _this.observers;
|
|
949
|
-
while (observers.length) {
|
|
1138
|
+
errorContext(function() {
|
|
1139
|
+
if (_this._throwIfClosed(), !_this.isStopped) {
|
|
1140
|
+
_this.isStopped = !0;
|
|
1141
|
+
for (var observers = _this.observers; observers.length; )
|
|
950
1142
|
observers.shift().complete();
|
|
951
|
-
}
|
|
952
1143
|
}
|
|
953
1144
|
});
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
};
|
|
959
|
-
Object.defineProperty(Subject.prototype, "observed", {
|
|
960
|
-
get: function () {
|
|
1145
|
+
}, Subject2.prototype.unsubscribe = function() {
|
|
1146
|
+
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
|
|
1147
|
+
}, Object.defineProperty(Subject2.prototype, "observed", {
|
|
1148
|
+
get: function() {
|
|
961
1149
|
var _a;
|
|
962
1150
|
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
963
1151
|
},
|
|
964
|
-
enumerable:
|
|
965
|
-
configurable:
|
|
966
|
-
})
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
return
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
this.
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
if (hasError || isStopped) {
|
|
983
|
-
return EMPTY_SUBSCRIPTION;
|
|
984
|
-
}
|
|
985
|
-
this.currentObservers = null;
|
|
986
|
-
observers.push(subscriber);
|
|
987
|
-
return new Subscription(function () {
|
|
988
|
-
_this.currentObservers = null;
|
|
989
|
-
arrRemove(observers, subscriber);
|
|
990
|
-
});
|
|
991
|
-
};
|
|
992
|
-
Subject.prototype._checkFinalizedStatuses = function (subscriber) {
|
|
993
|
-
var _a = this,
|
|
994
|
-
hasError = _a.hasError,
|
|
995
|
-
thrownError = _a.thrownError,
|
|
996
|
-
isStopped = _a.isStopped;
|
|
997
|
-
if (hasError) {
|
|
998
|
-
subscriber.error(thrownError);
|
|
999
|
-
} else if (isStopped) {
|
|
1000
|
-
subscriber.complete();
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
Subject.prototype.asObservable = function () {
|
|
1004
|
-
var observable = new Observable();
|
|
1005
|
-
observable.source = this;
|
|
1006
|
-
return observable;
|
|
1007
|
-
};
|
|
1008
|
-
Subject.create = function (destination, source) {
|
|
1152
|
+
enumerable: !1,
|
|
1153
|
+
configurable: !0
|
|
1154
|
+
}), Subject2.prototype._trySubscribe = function(subscriber) {
|
|
1155
|
+
return this._throwIfClosed(), _super.prototype._trySubscribe.call(this, subscriber);
|
|
1156
|
+
}, Subject2.prototype._subscribe = function(subscriber) {
|
|
1157
|
+
return this._throwIfClosed(), this._checkFinalizedStatuses(subscriber), this._innerSubscribe(subscriber);
|
|
1158
|
+
}, Subject2.prototype._innerSubscribe = function(subscriber) {
|
|
1159
|
+
var _this = this, _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
1160
|
+
return hasError || isStopped ? EMPTY_SUBSCRIPTION : (this.currentObservers = null, observers.push(subscriber), new Subscription(function() {
|
|
1161
|
+
_this.currentObservers = null, arrRemove(observers, subscriber);
|
|
1162
|
+
}));
|
|
1163
|
+
}, Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
|
|
1164
|
+
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
1165
|
+
hasError ? subscriber.error(thrownError) : isStopped && subscriber.complete();
|
|
1166
|
+
}, Subject2.prototype.asObservable = function() {
|
|
1167
|
+
var observable2 = new Observable();
|
|
1168
|
+
return observable2.source = this, observable2;
|
|
1169
|
+
}, Subject2.create = function(destination, source) {
|
|
1009
1170
|
return new AnonymousSubject(destination, source);
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
__extends(AnonymousSubject, _super);
|
|
1015
|
-
function AnonymousSubject(destination, source) {
|
|
1171
|
+
}, Subject2;
|
|
1172
|
+
}(Observable), AnonymousSubject = function(_super) {
|
|
1173
|
+
__extends(AnonymousSubject2, _super);
|
|
1174
|
+
function AnonymousSubject2(destination, source) {
|
|
1016
1175
|
var _this = _super.call(this) || this;
|
|
1017
|
-
_this.destination = destination;
|
|
1018
|
-
_this.source = source;
|
|
1019
|
-
return _this;
|
|
1176
|
+
return _this.destination = destination, _this.source = source, _this;
|
|
1020
1177
|
}
|
|
1021
|
-
|
|
1178
|
+
return AnonymousSubject2.prototype.next = function(value) {
|
|
1022
1179
|
var _a, _b;
|
|
1023
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0
|
|
1024
|
-
}
|
|
1025
|
-
AnonymousSubject.prototype.error = function (err) {
|
|
1180
|
+
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 || _b.call(_a, value);
|
|
1181
|
+
}, AnonymousSubject2.prototype.error = function(err) {
|
|
1026
1182
|
var _a, _b;
|
|
1027
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0
|
|
1028
|
-
}
|
|
1029
|
-
AnonymousSubject.prototype.complete = function () {
|
|
1183
|
+
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 || _b.call(_a, err);
|
|
1184
|
+
}, AnonymousSubject2.prototype.complete = function() {
|
|
1030
1185
|
var _a, _b;
|
|
1031
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0
|
|
1032
|
-
}
|
|
1033
|
-
AnonymousSubject.prototype._subscribe = function (subscriber) {
|
|
1186
|
+
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 || _b.call(_a);
|
|
1187
|
+
}, AnonymousSubject2.prototype._subscribe = function(subscriber) {
|
|
1034
1188
|
var _a, _b;
|
|
1035
1189
|
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1190
|
+
}, AnonymousSubject2;
|
|
1191
|
+
}(Subject), dateTimestampProvider = {
|
|
1192
|
+
now: function() {
|
|
1193
|
+
return Date.now();
|
|
1194
|
+
}
|
|
1195
|
+
}, Action = function(_super) {
|
|
1196
|
+
__extends(Action2, _super);
|
|
1197
|
+
function Action2(scheduler, work) {
|
|
1198
|
+
return _super.call(this) || this;
|
|
1199
|
+
}
|
|
1200
|
+
return Action2.prototype.schedule = function(state, delay) {
|
|
1201
|
+
return this;
|
|
1202
|
+
}, Action2;
|
|
1203
|
+
}(Subscription), intervalProvider = {
|
|
1204
|
+
setInterval: function(handler, timeout) {
|
|
1205
|
+
for (var args = [], _i = 2; _i < arguments.length; _i++)
|
|
1206
|
+
args[_i - 2] = arguments[_i];
|
|
1207
|
+
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1042
1208
|
},
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
_windowTime = Infinity;
|
|
1053
|
-
}
|
|
1054
|
-
if (_timestampProvider === void 0) {
|
|
1055
|
-
_timestampProvider = dateTimestampProvider;
|
|
1056
|
-
}
|
|
1057
|
-
var _this = _super.call(this) || this;
|
|
1058
|
-
_this._bufferSize = _bufferSize;
|
|
1059
|
-
_this._windowTime = _windowTime;
|
|
1060
|
-
_this._timestampProvider = _timestampProvider;
|
|
1061
|
-
_this._buffer = [];
|
|
1062
|
-
_this._infiniteTimeWindow = true;
|
|
1063
|
-
_this._infiniteTimeWindow = _windowTime === Infinity;
|
|
1064
|
-
_this._bufferSize = Math.max(1, _bufferSize);
|
|
1065
|
-
_this._windowTime = Math.max(1, _windowTime);
|
|
1066
|
-
return _this;
|
|
1209
|
+
clearInterval: function(handle) {
|
|
1210
|
+
return clearInterval(handle);
|
|
1211
|
+
},
|
|
1212
|
+
delegate: void 0
|
|
1213
|
+
}, AsyncAction = function(_super) {
|
|
1214
|
+
__extends(AsyncAction2, _super);
|
|
1215
|
+
function AsyncAction2(scheduler, work) {
|
|
1216
|
+
var _this = _super.call(this, scheduler, work) || this;
|
|
1217
|
+
return _this.scheduler = scheduler, _this.work = work, _this.pending = !1, _this;
|
|
1067
1218
|
}
|
|
1068
|
-
|
|
1069
|
-
var _a
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
this.
|
|
1085
|
-
var
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
};
|
|
1096
|
-
ReplaySubject.prototype._trimBuffer = function () {
|
|
1097
|
-
var _a = this,
|
|
1098
|
-
_bufferSize = _a._bufferSize,
|
|
1099
|
-
_timestampProvider = _a._timestampProvider,
|
|
1100
|
-
_buffer = _a._buffer,
|
|
1101
|
-
_infiniteTimeWindow = _a._infiniteTimeWindow;
|
|
1102
|
-
var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
|
|
1103
|
-
_bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
|
|
1104
|
-
if (!_infiniteTimeWindow) {
|
|
1105
|
-
var now = _timestampProvider.now();
|
|
1106
|
-
var last = 0;
|
|
1107
|
-
for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {
|
|
1108
|
-
last = i;
|
|
1109
|
-
}
|
|
1110
|
-
last && _buffer.splice(0, last + 1);
|
|
1219
|
+
return AsyncAction2.prototype.schedule = function(state, delay) {
|
|
1220
|
+
var _a;
|
|
1221
|
+
if (delay === void 0 && (delay = 0), this.closed)
|
|
1222
|
+
return this;
|
|
1223
|
+
this.state = state;
|
|
1224
|
+
var id = this.id, scheduler = this.scheduler;
|
|
1225
|
+
return id != null && (this.id = this.recycleAsyncId(scheduler, id, delay)), this.pending = !0, this.delay = delay, this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay), this;
|
|
1226
|
+
}, AsyncAction2.prototype.requestAsyncId = function(scheduler, _id, delay) {
|
|
1227
|
+
return delay === void 0 && (delay = 0), intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1228
|
+
}, AsyncAction2.prototype.recycleAsyncId = function(_scheduler, id, delay) {
|
|
1229
|
+
if (delay === void 0 && (delay = 0), delay != null && this.delay === delay && this.pending === !1)
|
|
1230
|
+
return id;
|
|
1231
|
+
id != null && intervalProvider.clearInterval(id);
|
|
1232
|
+
}, AsyncAction2.prototype.execute = function(state, delay) {
|
|
1233
|
+
if (this.closed)
|
|
1234
|
+
return new Error("executing a cancelled action");
|
|
1235
|
+
this.pending = !1;
|
|
1236
|
+
var error = this._execute(state, delay);
|
|
1237
|
+
if (error)
|
|
1238
|
+
return error;
|
|
1239
|
+
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
|
|
1240
|
+
}, AsyncAction2.prototype._execute = function(state, _delay) {
|
|
1241
|
+
var errored = !1, errorValue;
|
|
1242
|
+
try {
|
|
1243
|
+
this.work(state);
|
|
1244
|
+
} catch (e) {
|
|
1245
|
+
errored = !0, errorValue = e || new Error("Scheduled action threw falsy error");
|
|
1111
1246
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}(
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1247
|
+
if (errored)
|
|
1248
|
+
return this.unsubscribe(), errorValue;
|
|
1249
|
+
}, AsyncAction2.prototype.unsubscribe = function() {
|
|
1250
|
+
if (!this.closed) {
|
|
1251
|
+
var _a = this, id = _a.id, scheduler = _a.scheduler, actions = scheduler.actions;
|
|
1252
|
+
this.work = this.state = this.scheduler = null, this.pending = !1, arrRemove(actions, this), id != null && (this.id = this.recycleAsyncId(scheduler, id, null)), this.delay = null, _super.prototype.unsubscribe.call(this);
|
|
1253
|
+
}
|
|
1254
|
+
}, AsyncAction2;
|
|
1255
|
+
}(Action), nextHandle = 1, resolved, activeHandles = {};
|
|
1256
|
+
function findAndClearHandle(handle) {
|
|
1257
|
+
return handle in activeHandles ? (delete activeHandles[handle], !0) : !1;
|
|
1258
|
+
}
|
|
1259
|
+
var Immediate = {
|
|
1260
|
+
setImmediate: function(cb) {
|
|
1261
|
+
var handle = nextHandle++;
|
|
1262
|
+
return activeHandles[handle] = !0, resolved || (resolved = Promise.resolve()), resolved.then(function() {
|
|
1263
|
+
return findAndClearHandle(handle) && cb();
|
|
1264
|
+
}), handle;
|
|
1265
|
+
},
|
|
1266
|
+
clearImmediate: function(handle) {
|
|
1267
|
+
findAndClearHandle(handle);
|
|
1268
|
+
}
|
|
1269
|
+
}, setImmediate = Immediate.setImmediate, clearImmediate = Immediate.clearImmediate, immediateProvider = {
|
|
1270
|
+
setImmediate: function() {
|
|
1271
|
+
for (var args = [], _i = 0; _i < arguments.length; _i++)
|
|
1272
|
+
args[_i] = arguments[_i];
|
|
1273
|
+
var delegate = immediateProvider.delegate;
|
|
1274
|
+
return (delegate?.setImmediate || setImmediate).apply(void 0, __spreadArray([], __read(args)));
|
|
1275
|
+
},
|
|
1276
|
+
clearImmediate: function(handle) {
|
|
1277
|
+
return clearImmediate(handle);
|
|
1278
|
+
},
|
|
1279
|
+
delegate: void 0
|
|
1280
|
+
}, AsapAction = function(_super) {
|
|
1281
|
+
__extends(AsapAction2, _super);
|
|
1282
|
+
function AsapAction2(scheduler, work) {
|
|
1283
|
+
var _this = _super.call(this, scheduler, work) || this;
|
|
1284
|
+
return _this.scheduler = scheduler, _this.work = work, _this;
|
|
1285
|
+
}
|
|
1286
|
+
return AsapAction2.prototype.requestAsyncId = function(scheduler, id, delay) {
|
|
1287
|
+
return delay === void 0 && (delay = 0), delay !== null && delay > 0 ? _super.prototype.requestAsyncId.call(this, scheduler, id, delay) : (scheduler.actions.push(this), scheduler._scheduled || (scheduler._scheduled = immediateProvider.setImmediate(scheduler.flush.bind(scheduler, void 0))));
|
|
1288
|
+
}, AsapAction2.prototype.recycleAsyncId = function(scheduler, id, delay) {
|
|
1289
|
+
var _a;
|
|
1290
|
+
if (delay === void 0 && (delay = 0), delay != null ? delay > 0 : this.delay > 0)
|
|
1291
|
+
return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
|
|
1292
|
+
var actions = scheduler.actions;
|
|
1293
|
+
id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id && (immediateProvider.clearImmediate(id), scheduler._scheduled === id && (scheduler._scheduled = void 0));
|
|
1294
|
+
}, AsapAction2;
|
|
1295
|
+
}(AsyncAction), Scheduler = function() {
|
|
1296
|
+
function Scheduler2(schedulerActionCtor, now) {
|
|
1297
|
+
now === void 0 && (now = Scheduler2.now), this.schedulerActionCtor = schedulerActionCtor, this.now = now;
|
|
1298
|
+
}
|
|
1299
|
+
return Scheduler2.prototype.schedule = function(work, delay, state) {
|
|
1300
|
+
return delay === void 0 && (delay = 0), new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1301
|
+
}, Scheduler2.now = dateTimestampProvider.now, Scheduler2;
|
|
1302
|
+
}(), AsyncScheduler = function(_super) {
|
|
1303
|
+
__extends(AsyncScheduler2, _super);
|
|
1304
|
+
function AsyncScheduler2(SchedulerAction, now) {
|
|
1305
|
+
now === void 0 && (now = Scheduler.now);
|
|
1306
|
+
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1307
|
+
return _this.actions = [], _this._active = !1, _this;
|
|
1308
|
+
}
|
|
1309
|
+
return AsyncScheduler2.prototype.flush = function(action) {
|
|
1310
|
+
var actions = this.actions;
|
|
1311
|
+
if (this._active) {
|
|
1312
|
+
actions.push(action);
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
var error;
|
|
1316
|
+
this._active = !0;
|
|
1317
|
+
do
|
|
1318
|
+
if (error = action.execute(action.state, action.delay))
|
|
1319
|
+
break;
|
|
1320
|
+
while (action = actions.shift());
|
|
1321
|
+
if (this._active = !1, error) {
|
|
1322
|
+
for (; action = actions.shift(); )
|
|
1323
|
+
action.unsubscribe();
|
|
1324
|
+
throw error;
|
|
1325
|
+
}
|
|
1326
|
+
}, AsyncScheduler2;
|
|
1327
|
+
}(Scheduler), AsapScheduler = function(_super) {
|
|
1328
|
+
__extends(AsapScheduler2, _super);
|
|
1329
|
+
function AsapScheduler2() {
|
|
1330
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1331
|
+
}
|
|
1332
|
+
return AsapScheduler2.prototype.flush = function(action) {
|
|
1333
|
+
this._active = !0;
|
|
1334
|
+
var flushId = this._scheduled;
|
|
1335
|
+
this._scheduled = void 0;
|
|
1336
|
+
var actions = this.actions, error;
|
|
1337
|
+
action = action || actions.shift();
|
|
1338
|
+
do
|
|
1339
|
+
if (error = action.execute(action.state, action.delay))
|
|
1340
|
+
break;
|
|
1341
|
+
while ((action = actions[0]) && action.id === flushId && actions.shift());
|
|
1342
|
+
if (this._active = !1, error) {
|
|
1343
|
+
for (; (action = actions[0]) && action.id === flushId && actions.shift(); )
|
|
1344
|
+
action.unsubscribe();
|
|
1345
|
+
throw error;
|
|
1346
|
+
}
|
|
1347
|
+
}, AsapScheduler2;
|
|
1348
|
+
}(AsyncScheduler), asapScheduler = new AsapScheduler(AsapAction), asyncScheduler = new AsyncScheduler(AsyncAction), async = asyncScheduler;
|
|
1349
|
+
function isScheduler(value) {
|
|
1350
|
+
return value && isFunction(value.schedule);
|
|
1351
|
+
}
|
|
1352
|
+
function last(arr) {
|
|
1353
|
+
return arr[arr.length - 1];
|
|
1354
|
+
}
|
|
1355
|
+
function popScheduler(args) {
|
|
1356
|
+
return isScheduler(last(args)) ? args.pop() : void 0;
|
|
1357
|
+
}
|
|
1358
|
+
var isArrayLike = function(x) {
|
|
1359
|
+
return x && typeof x.length == "number" && typeof x != "function";
|
|
1360
|
+
};
|
|
1361
|
+
function isPromise(value) {
|
|
1362
|
+
return isFunction(value?.then);
|
|
1120
1363
|
}
|
|
1121
1364
|
function isInteropObservable(input) {
|
|
1122
1365
|
return isFunction(input[observable]);
|
|
1123
1366
|
}
|
|
1124
1367
|
function isAsyncIterable(obj) {
|
|
1125
|
-
return Symbol.asyncIterator && isFunction(obj
|
|
1368
|
+
return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);
|
|
1126
1369
|
}
|
|
1127
1370
|
function createInvalidObservableTypeError(input) {
|
|
1128
|
-
return new TypeError("You provided " + (input !== null && typeof input
|
|
1371
|
+
return new TypeError("You provided " + (input !== null && typeof input == "object" ? "an invalid object" : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
1129
1372
|
}
|
|
1130
1373
|
function getSymbolIterator() {
|
|
1131
|
-
|
|
1132
|
-
return '@@iterator';
|
|
1133
|
-
}
|
|
1134
|
-
return Symbol.iterator;
|
|
1374
|
+
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
1135
1375
|
}
|
|
1136
1376
|
var iterator = getSymbolIterator();
|
|
1137
1377
|
function isIterable(input) {
|
|
1138
|
-
return isFunction(input
|
|
1378
|
+
return isFunction(input?.[iterator]);
|
|
1139
1379
|
}
|
|
1140
1380
|
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
1141
|
-
return __asyncGenerator(this, arguments, function
|
|
1381
|
+
return __asyncGenerator(this, arguments, function() {
|
|
1142
1382
|
var reader, _a, value, done;
|
|
1143
|
-
return __generator(this, function
|
|
1383
|
+
return __generator(this, function(_b) {
|
|
1144
1384
|
switch (_b.label) {
|
|
1145
1385
|
case 0:
|
|
1146
|
-
reader = readableStream.getReader();
|
|
1147
|
-
_b.label = 1;
|
|
1386
|
+
reader = readableStream.getReader(), _b.label = 1;
|
|
1148
1387
|
case 1:
|
|
1149
|
-
_b.trys.push([1
|
|
1150
|
-
_b.label = 2;
|
|
1388
|
+
_b.trys.push([1, , 9, 10]), _b.label = 2;
|
|
1151
1389
|
case 2:
|
|
1152
1390
|
return [4, __await(reader.read())];
|
|
1153
1391
|
case 3:
|
|
1154
|
-
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
1155
|
-
if (!done) return [3, 5];
|
|
1156
|
-
return [4, __await(void 0)];
|
|
1392
|
+
return _a = _b.sent(), value = _a.value, done = _a.done, done ? [4, __await(void 0)] : [3, 5];
|
|
1157
1393
|
case 4:
|
|
1158
1394
|
return [2, _b.sent()];
|
|
1159
1395
|
case 5:
|
|
@@ -1161,13 +1397,11 @@ function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
|
1161
1397
|
case 6:
|
|
1162
1398
|
return [4, _b.sent()];
|
|
1163
1399
|
case 7:
|
|
1164
|
-
_b.sent();
|
|
1165
|
-
return [3, 2];
|
|
1400
|
+
return _b.sent(), [3, 2];
|
|
1166
1401
|
case 8:
|
|
1167
1402
|
return [3, 10];
|
|
1168
1403
|
case 9:
|
|
1169
|
-
reader.releaseLock();
|
|
1170
|
-
return [7];
|
|
1404
|
+
return reader.releaseLock(), [7];
|
|
1171
1405
|
case 10:
|
|
1172
1406
|
return [2];
|
|
1173
1407
|
}
|
|
@@ -1175,81 +1409,65 @@ function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
|
1175
1409
|
});
|
|
1176
1410
|
}
|
|
1177
1411
|
function isReadableStreamLike(obj) {
|
|
1178
|
-
return isFunction(obj
|
|
1412
|
+
return isFunction(obj?.getReader);
|
|
1179
1413
|
}
|
|
1180
1414
|
function innerFrom(input) {
|
|
1181
|
-
if (input instanceof Observable)
|
|
1415
|
+
if (input instanceof Observable)
|
|
1182
1416
|
return input;
|
|
1183
|
-
}
|
|
1184
1417
|
if (input != null) {
|
|
1185
|
-
if (isInteropObservable(input))
|
|
1418
|
+
if (isInteropObservable(input))
|
|
1186
1419
|
return fromInteropObservable(input);
|
|
1187
|
-
|
|
1188
|
-
if (isArrayLike(input)) {
|
|
1420
|
+
if (isArrayLike(input))
|
|
1189
1421
|
return fromArrayLike(input);
|
|
1190
|
-
|
|
1191
|
-
if (isPromise(input)) {
|
|
1422
|
+
if (isPromise(input))
|
|
1192
1423
|
return fromPromise(input);
|
|
1193
|
-
|
|
1194
|
-
if (isAsyncIterable(input)) {
|
|
1424
|
+
if (isAsyncIterable(input))
|
|
1195
1425
|
return fromAsyncIterable(input);
|
|
1196
|
-
|
|
1197
|
-
if (isIterable(input)) {
|
|
1426
|
+
if (isIterable(input))
|
|
1198
1427
|
return fromIterable(input);
|
|
1199
|
-
|
|
1200
|
-
if (isReadableStreamLike(input)) {
|
|
1428
|
+
if (isReadableStreamLike(input))
|
|
1201
1429
|
return fromReadableStreamLike(input);
|
|
1202
|
-
}
|
|
1203
1430
|
}
|
|
1204
1431
|
throw createInvalidObservableTypeError(input);
|
|
1205
1432
|
}
|
|
1206
1433
|
function fromInteropObservable(obj) {
|
|
1207
|
-
return new Observable(function
|
|
1434
|
+
return new Observable(function(subscriber) {
|
|
1208
1435
|
var obs = obj[observable]();
|
|
1209
|
-
if (isFunction(obs.subscribe))
|
|
1436
|
+
if (isFunction(obs.subscribe))
|
|
1210
1437
|
return obs.subscribe(subscriber);
|
|
1211
|
-
|
|
1212
|
-
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
1438
|
+
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
1213
1439
|
});
|
|
1214
1440
|
}
|
|
1215
1441
|
function fromArrayLike(array) {
|
|
1216
|
-
return new Observable(function
|
|
1217
|
-
for (var i = 0; i < array.length && !subscriber.closed; i++)
|
|
1442
|
+
return new Observable(function(subscriber) {
|
|
1443
|
+
for (var i = 0; i < array.length && !subscriber.closed; i++)
|
|
1218
1444
|
subscriber.next(array[i]);
|
|
1219
|
-
}
|
|
1220
1445
|
subscriber.complete();
|
|
1221
1446
|
});
|
|
1222
1447
|
}
|
|
1223
1448
|
function fromPromise(promise) {
|
|
1224
|
-
return new Observable(function
|
|
1225
|
-
promise.then(function
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
subscriber.complete();
|
|
1229
|
-
}
|
|
1230
|
-
}, function (err) {
|
|
1449
|
+
return new Observable(function(subscriber) {
|
|
1450
|
+
promise.then(function(value) {
|
|
1451
|
+
subscriber.closed || (subscriber.next(value), subscriber.complete());
|
|
1452
|
+
}, function(err) {
|
|
1231
1453
|
return subscriber.error(err);
|
|
1232
1454
|
}).then(null, reportUnhandledError);
|
|
1233
1455
|
});
|
|
1234
1456
|
}
|
|
1235
1457
|
function fromIterable(iterable) {
|
|
1236
|
-
return new Observable(function
|
|
1458
|
+
return new Observable(function(subscriber) {
|
|
1237
1459
|
var e_1, _a;
|
|
1238
1460
|
try {
|
|
1239
1461
|
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
1240
1462
|
var value = iterable_1_1.value;
|
|
1241
|
-
subscriber.next(value)
|
|
1242
|
-
if (subscriber.closed) {
|
|
1463
|
+
if (subscriber.next(value), subscriber.closed)
|
|
1243
1464
|
return;
|
|
1244
|
-
}
|
|
1245
1465
|
}
|
|
1246
1466
|
} catch (e_1_1) {
|
|
1247
|
-
e_1 = {
|
|
1248
|
-
error: e_1_1
|
|
1249
|
-
};
|
|
1467
|
+
e_1 = { error: e_1_1 };
|
|
1250
1468
|
} finally {
|
|
1251
1469
|
try {
|
|
1252
|
-
|
|
1470
|
+
iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return) && _a.call(iterable_1);
|
|
1253
1471
|
} finally {
|
|
1254
1472
|
if (e_1) throw e_1.error;
|
|
1255
1473
|
}
|
|
@@ -1258,8 +1476,8 @@ function fromIterable(iterable) {
|
|
|
1258
1476
|
});
|
|
1259
1477
|
}
|
|
1260
1478
|
function fromAsyncIterable(asyncIterable) {
|
|
1261
|
-
return new Observable(function
|
|
1262
|
-
process
|
|
1479
|
+
return new Observable(function(subscriber) {
|
|
1480
|
+
process(asyncIterable, subscriber).catch(function(err) {
|
|
1263
1481
|
return subscriber.error(err);
|
|
1264
1482
|
});
|
|
1265
1483
|
});
|
|
@@ -1267,44 +1485,31 @@ function fromAsyncIterable(asyncIterable) {
|
|
|
1267
1485
|
function fromReadableStreamLike(readableStream) {
|
|
1268
1486
|
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
1269
1487
|
}
|
|
1270
|
-
function process
|
|
1271
|
-
var asyncIterable_1, asyncIterable_1_1;
|
|
1272
|
-
|
|
1273
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1488
|
+
function process(asyncIterable, subscriber) {
|
|
1489
|
+
var asyncIterable_1, asyncIterable_1_1, e_2, _a;
|
|
1490
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1274
1491
|
var value, e_2_1;
|
|
1275
|
-
return __generator(this, function
|
|
1492
|
+
return __generator(this, function(_b) {
|
|
1276
1493
|
switch (_b.label) {
|
|
1277
1494
|
case 0:
|
|
1278
|
-
_b.trys.push([0, 5, 6, 11]);
|
|
1279
|
-
asyncIterable_1 = __asyncValues(asyncIterable);
|
|
1280
|
-
_b.label = 1;
|
|
1495
|
+
_b.trys.push([0, 5, 6, 11]), asyncIterable_1 = __asyncValues(asyncIterable), _b.label = 1;
|
|
1281
1496
|
case 1:
|
|
1282
1497
|
return [4, asyncIterable_1.next()];
|
|
1283
1498
|
case 2:
|
|
1284
|
-
if (
|
|
1285
|
-
value = asyncIterable_1_1.value
|
|
1286
|
-
subscriber.next(value);
|
|
1287
|
-
if (subscriber.closed) {
|
|
1499
|
+
if (asyncIterable_1_1 = _b.sent(), !!asyncIterable_1_1.done) return [3, 4];
|
|
1500
|
+
if (value = asyncIterable_1_1.value, subscriber.next(value), subscriber.closed)
|
|
1288
1501
|
return [2];
|
|
1289
|
-
}
|
|
1290
1502
|
_b.label = 3;
|
|
1291
1503
|
case 3:
|
|
1292
1504
|
return [3, 1];
|
|
1293
1505
|
case 4:
|
|
1294
1506
|
return [3, 11];
|
|
1295
1507
|
case 5:
|
|
1296
|
-
e_2_1 = _b.sent();
|
|
1297
|
-
e_2 = {
|
|
1298
|
-
error: e_2_1
|
|
1299
|
-
};
|
|
1300
|
-
return [3, 11];
|
|
1508
|
+
return e_2_1 = _b.sent(), e_2 = { error: e_2_1 }, [3, 11];
|
|
1301
1509
|
case 6:
|
|
1302
|
-
_b.trys.push([6
|
|
1303
|
-
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
|
1304
|
-
return [4, _a.call(asyncIterable_1)];
|
|
1510
|
+
return _b.trys.push([6, , 9, 10]), asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return) ? [4, _a.call(asyncIterable_1)] : [3, 8];
|
|
1305
1511
|
case 7:
|
|
1306
|
-
_b.sent();
|
|
1307
|
-
_b.label = 8;
|
|
1512
|
+
_b.sent(), _b.label = 8;
|
|
1308
1513
|
case 8:
|
|
1309
1514
|
return [3, 10];
|
|
1310
1515
|
case 9:
|
|
@@ -1313,654 +1518,383 @@ function process$1(asyncIterable, subscriber) {
|
|
|
1313
1518
|
case 10:
|
|
1314
1519
|
return [7];
|
|
1315
1520
|
case 11:
|
|
1316
|
-
subscriber.complete();
|
|
1317
|
-
return [2];
|
|
1521
|
+
return subscriber.complete(), [2];
|
|
1318
1522
|
}
|
|
1319
1523
|
});
|
|
1320
1524
|
});
|
|
1321
1525
|
}
|
|
1322
|
-
function
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1526
|
+
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1527
|
+
delay === void 0 && (delay = 0), repeat === void 0 && (repeat = !1);
|
|
1528
|
+
var scheduleSubscription = scheduler.schedule(function() {
|
|
1529
|
+
work(), repeat ? parentSubscription.add(this.schedule(null, delay)) : this.unsubscribe();
|
|
1530
|
+
}, delay);
|
|
1531
|
+
if (parentSubscription.add(scheduleSubscription), !repeat)
|
|
1532
|
+
return scheduleSubscription;
|
|
1533
|
+
}
|
|
1534
|
+
function observeOn(scheduler, delay) {
|
|
1535
|
+
return delay === void 0 && (delay = 0), operate(function(source, subscriber) {
|
|
1536
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
1537
|
+
return executeSchedule(subscriber, scheduler, function() {
|
|
1538
|
+
return subscriber.next(value);
|
|
1539
|
+
}, delay);
|
|
1540
|
+
}, function() {
|
|
1541
|
+
return executeSchedule(subscriber, scheduler, function() {
|
|
1542
|
+
return subscriber.complete();
|
|
1543
|
+
}, delay);
|
|
1544
|
+
}, function(err) {
|
|
1545
|
+
return executeSchedule(subscriber, scheduler, function() {
|
|
1546
|
+
return subscriber.error(err);
|
|
1547
|
+
}, delay);
|
|
1548
|
+
}));
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
function subscribeOn(scheduler, delay) {
|
|
1552
|
+
return delay === void 0 && (delay = 0), operate(function(source, subscriber) {
|
|
1553
|
+
subscriber.add(scheduler.schedule(function() {
|
|
1554
|
+
return source.subscribe(subscriber);
|
|
1555
|
+
}, delay));
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
function scheduleObservable(input, scheduler) {
|
|
1559
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1560
|
+
}
|
|
1561
|
+
function schedulePromise(input, scheduler) {
|
|
1562
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1563
|
+
}
|
|
1564
|
+
function scheduleArray(input, scheduler) {
|
|
1565
|
+
return new Observable(function(subscriber) {
|
|
1566
|
+
var i = 0;
|
|
1567
|
+
return scheduler.schedule(function() {
|
|
1568
|
+
i === input.length ? subscriber.complete() : (subscriber.next(input[i++]), subscriber.closed || this.schedule());
|
|
1569
|
+
});
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
function scheduleIterable(input, scheduler) {
|
|
1573
|
+
return new Observable(function(subscriber) {
|
|
1574
|
+
var iterator$1;
|
|
1575
|
+
return executeSchedule(subscriber, scheduler, function() {
|
|
1576
|
+
iterator$1 = input[iterator](), executeSchedule(subscriber, scheduler, function() {
|
|
1577
|
+
var _a, value, done;
|
|
1578
|
+
try {
|
|
1579
|
+
_a = iterator$1.next(), value = _a.value, done = _a.done;
|
|
1580
|
+
} catch (err) {
|
|
1581
|
+
subscriber.error(err);
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
done ? subscriber.complete() : subscriber.next(value);
|
|
1585
|
+
}, 0, !0);
|
|
1586
|
+
}), function() {
|
|
1587
|
+
return isFunction(iterator$1?.return) && iterator$1.return();
|
|
1351
1588
|
};
|
|
1352
|
-
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
function scheduleAsyncIterable(input, scheduler) {
|
|
1592
|
+
if (!input)
|
|
1593
|
+
throw new Error("Iterable cannot be null");
|
|
1594
|
+
return new Observable(function(subscriber) {
|
|
1595
|
+
executeSchedule(subscriber, scheduler, function() {
|
|
1596
|
+
var iterator2 = input[Symbol.asyncIterator]();
|
|
1597
|
+
executeSchedule(subscriber, scheduler, function() {
|
|
1598
|
+
iterator2.next().then(function(result) {
|
|
1599
|
+
result.done ? subscriber.complete() : subscriber.next(result.value);
|
|
1600
|
+
});
|
|
1601
|
+
}, 0, !0);
|
|
1602
|
+
});
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
function scheduleReadableStreamLike(input, scheduler) {
|
|
1606
|
+
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1607
|
+
}
|
|
1608
|
+
function scheduled(input, scheduler) {
|
|
1609
|
+
if (input != null) {
|
|
1610
|
+
if (isInteropObservable(input))
|
|
1611
|
+
return scheduleObservable(input, scheduler);
|
|
1612
|
+
if (isArrayLike(input))
|
|
1613
|
+
return scheduleArray(input, scheduler);
|
|
1614
|
+
if (isPromise(input))
|
|
1615
|
+
return schedulePromise(input, scheduler);
|
|
1616
|
+
if (isAsyncIterable(input))
|
|
1617
|
+
return scheduleAsyncIterable(input, scheduler);
|
|
1618
|
+
if (isIterable(input))
|
|
1619
|
+
return scheduleIterable(input, scheduler);
|
|
1620
|
+
if (isReadableStreamLike(input))
|
|
1621
|
+
return scheduleReadableStreamLike(input, scheduler);
|
|
1622
|
+
}
|
|
1623
|
+
throw createInvalidObservableTypeError(input);
|
|
1624
|
+
}
|
|
1625
|
+
function from(input, scheduler) {
|
|
1626
|
+
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1627
|
+
}
|
|
1628
|
+
function of() {
|
|
1629
|
+
for (var args = [], _i = 0; _i < arguments.length; _i++)
|
|
1630
|
+
args[_i] = arguments[_i];
|
|
1631
|
+
var scheduler = popScheduler(args);
|
|
1632
|
+
return from(args, scheduler);
|
|
1633
|
+
}
|
|
1634
|
+
function isValidDate(value) {
|
|
1635
|
+
return value instanceof Date && !isNaN(value);
|
|
1636
|
+
}
|
|
1637
|
+
function map(project, thisArg) {
|
|
1638
|
+
return operate(function(source, subscriber) {
|
|
1639
|
+
var index = 0;
|
|
1640
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
1641
|
+
subscriber.next(project.call(thisArg, value, index++));
|
|
1642
|
+
}));
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1646
|
+
scheduler === void 0 && (scheduler = async);
|
|
1647
|
+
var intervalDuration = -1;
|
|
1648
|
+
return intervalOrScheduler != null && (isScheduler(intervalOrScheduler) ? scheduler = intervalOrScheduler : intervalDuration = intervalOrScheduler), new Observable(function(subscriber) {
|
|
1649
|
+
var due = isValidDate(dueTime) ? 0 - scheduler.now() : dueTime;
|
|
1650
|
+
due < 0 && (due = 0);
|
|
1651
|
+
var n = 0;
|
|
1652
|
+
return scheduler.schedule(function() {
|
|
1653
|
+
subscriber.closed || (subscriber.next(n++), 0 <= intervalDuration ? this.schedule(void 0, intervalDuration) : subscriber.complete());
|
|
1654
|
+
}, due);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
function catchError(selector) {
|
|
1658
|
+
return operate(function(source, subscriber) {
|
|
1659
|
+
var innerSub = null, syncUnsub = !1, handledResult;
|
|
1660
|
+
innerSub = source.subscribe(createOperatorSubscriber(subscriber, void 0, void 0, function(err) {
|
|
1661
|
+
handledResult = innerFrom(selector(err, catchError(selector)(source))), innerSub ? (innerSub.unsubscribe(), innerSub = null, handledResult.subscribe(subscriber)) : syncUnsub = !0;
|
|
1662
|
+
})), syncUnsub && (innerSub.unsubscribe(), innerSub = null, handledResult.subscribe(subscriber));
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
function finalize(callback) {
|
|
1666
|
+
return operate(function(source, subscriber) {
|
|
1667
|
+
try {
|
|
1668
|
+
source.subscribe(subscriber);
|
|
1669
|
+
} finally {
|
|
1670
|
+
subscriber.add(callback);
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
function share(options) {
|
|
1675
|
+
options === void 0 && (options = {});
|
|
1676
|
+
var _a = options.connector, connector = _a === void 0 ? function() {
|
|
1677
|
+
return new Subject();
|
|
1678
|
+
} : _a, _b = options.resetOnError, resetOnError = _b === void 0 ? !0 : _b, _c = options.resetOnComplete, resetOnComplete = _c === void 0 ? !0 : _c, _d = options.resetOnRefCountZero, resetOnRefCountZero = _d === void 0 ? !0 : _d;
|
|
1679
|
+
return function(wrapperSource) {
|
|
1680
|
+
var connection, resetConnection, subject, refCount = 0, hasCompleted = !1, hasErrored = !1, cancelReset = function() {
|
|
1681
|
+
resetConnection?.unsubscribe(), resetConnection = void 0;
|
|
1682
|
+
}, reset = function() {
|
|
1683
|
+
cancelReset(), connection = subject = void 0, hasCompleted = hasErrored = !1;
|
|
1684
|
+
}, resetAndUnsubscribe = function() {
|
|
1353
1685
|
var conn = connection;
|
|
1354
|
-
reset();
|
|
1355
|
-
conn === null || conn === void 0 ? void 0 : conn.unsubscribe();
|
|
1686
|
+
reset(), conn?.unsubscribe();
|
|
1356
1687
|
};
|
|
1357
|
-
return operate(function
|
|
1358
|
-
refCount
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1688
|
+
return operate(function(source, subscriber) {
|
|
1689
|
+
refCount++, !hasErrored && !hasCompleted && cancelReset();
|
|
1690
|
+
var dest = subject = subject ?? connector();
|
|
1691
|
+
subscriber.add(function() {
|
|
1692
|
+
refCount--, refCount === 0 && !hasErrored && !hasCompleted && (resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero));
|
|
1693
|
+
}), dest.subscribe(subscriber), !connection && refCount > 0 && (connection = new SafeSubscriber({
|
|
1694
|
+
next: function(value) {
|
|
1695
|
+
return dest.next(value);
|
|
1696
|
+
},
|
|
1697
|
+
error: function(err) {
|
|
1698
|
+
hasErrored = !0, cancelReset(), resetConnection = handleReset(reset, resetOnError, err), dest.error(err);
|
|
1699
|
+
},
|
|
1700
|
+
complete: function() {
|
|
1701
|
+
hasCompleted = !0, cancelReset(), resetConnection = handleReset(reset, resetOnComplete), dest.complete();
|
|
1367
1702
|
}
|
|
1368
|
-
});
|
|
1369
|
-
dest.subscribe(subscriber);
|
|
1370
|
-
if (!connection && refCount > 0) {
|
|
1371
|
-
connection = new SafeSubscriber({
|
|
1372
|
-
next: function (value) {
|
|
1373
|
-
return dest.next(value);
|
|
1374
|
-
},
|
|
1375
|
-
error: function (err) {
|
|
1376
|
-
hasErrored = true;
|
|
1377
|
-
cancelReset();
|
|
1378
|
-
resetConnection = handleReset(reset, resetOnError, err);
|
|
1379
|
-
dest.error(err);
|
|
1380
|
-
},
|
|
1381
|
-
complete: function () {
|
|
1382
|
-
hasCompleted = true;
|
|
1383
|
-
cancelReset();
|
|
1384
|
-
resetConnection = handleReset(reset, resetOnComplete);
|
|
1385
|
-
dest.complete();
|
|
1386
|
-
}
|
|
1387
|
-
});
|
|
1388
|
-
innerFrom(source).subscribe(connection);
|
|
1389
|
-
}
|
|
1703
|
+
}), innerFrom(source).subscribe(connection));
|
|
1390
1704
|
})(wrapperSource);
|
|
1391
1705
|
};
|
|
1392
1706
|
}
|
|
1393
1707
|
function handleReset(reset, on) {
|
|
1394
|
-
var args = [];
|
|
1395
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1708
|
+
for (var args = [], _i = 2; _i < arguments.length; _i++)
|
|
1396
1709
|
args[_i - 2] = arguments[_i];
|
|
1397
|
-
|
|
1398
|
-
if (on === true) {
|
|
1710
|
+
if (on === !0) {
|
|
1399
1711
|
reset();
|
|
1400
1712
|
return;
|
|
1401
1713
|
}
|
|
1402
|
-
if (on
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
}
|
|
1410
|
-
});
|
|
1411
|
-
return innerFrom(on.apply(void 0, __spreadArray([], __read(args)))).subscribe(onSubscriber);
|
|
1412
|
-
}
|
|
1413
|
-
function shareReplay(configOrBufferSize, windowTime, scheduler) {
|
|
1414
|
-
var _a, _b, _c;
|
|
1415
|
-
var bufferSize;
|
|
1416
|
-
var refCount = false;
|
|
1417
|
-
if (configOrBufferSize && typeof configOrBufferSize === 'object') {
|
|
1418
|
-
_a = configOrBufferSize.bufferSize, bufferSize = _a === void 0 ? Infinity : _a, _b = configOrBufferSize.windowTime, windowTime = _b === void 0 ? Infinity : _b, _c = configOrBufferSize.refCount, refCount = _c === void 0 ? false : _c, scheduler = configOrBufferSize.scheduler;
|
|
1419
|
-
} else {
|
|
1420
|
-
bufferSize = configOrBufferSize !== null && configOrBufferSize !== void 0 ? configOrBufferSize : Infinity;
|
|
1714
|
+
if (on !== !1) {
|
|
1715
|
+
var onSubscriber = new SafeSubscriber({
|
|
1716
|
+
next: function() {
|
|
1717
|
+
onSubscriber.unsubscribe(), reset();
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
return innerFrom(on.apply(void 0, __spreadArray([], __read(args)))).subscribe(onSubscriber);
|
|
1421
1721
|
}
|
|
1422
|
-
return share({
|
|
1423
|
-
connector: function () {
|
|
1424
|
-
return new ReplaySubject(bufferSize, windowTime, scheduler);
|
|
1425
|
-
},
|
|
1426
|
-
resetOnError: true,
|
|
1427
|
-
resetOnComplete: false,
|
|
1428
|
-
resetOnRefCountZero: refCount
|
|
1429
|
-
});
|
|
1430
1722
|
}
|
|
1431
1723
|
function tap(observerOrNext, error, complete) {
|
|
1432
|
-
var tapObserver = isFunction(observerOrNext) || error || complete ? {
|
|
1433
|
-
|
|
1434
|
-
error: error,
|
|
1435
|
-
complete: complete
|
|
1436
|
-
} : observerOrNext;
|
|
1437
|
-
return tapObserver ? operate(function (source, subscriber) {
|
|
1724
|
+
var tapObserver = isFunction(observerOrNext) || error || complete ? { next: observerOrNext, error, complete } : observerOrNext;
|
|
1725
|
+
return tapObserver ? operate(function(source, subscriber) {
|
|
1438
1726
|
var _a;
|
|
1439
|
-
(_a = tapObserver.subscribe) === null || _a === void 0
|
|
1440
|
-
var isUnsub =
|
|
1441
|
-
source.subscribe(createOperatorSubscriber(subscriber, function
|
|
1442
|
-
var
|
|
1443
|
-
(
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
subscriber.
|
|
1450
|
-
}, function
|
|
1451
|
-
var
|
|
1452
|
-
isUnsub =
|
|
1453
|
-
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
|
1454
|
-
subscriber.error(err);
|
|
1455
|
-
}, function () {
|
|
1456
|
-
var _a, _b;
|
|
1457
|
-
if (isUnsub) {
|
|
1458
|
-
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1459
|
-
}
|
|
1460
|
-
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
|
1727
|
+
(_a = tapObserver.subscribe) === null || _a === void 0 || _a.call(tapObserver);
|
|
1728
|
+
var isUnsub = !0;
|
|
1729
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
1730
|
+
var _a2;
|
|
1731
|
+
(_a2 = tapObserver.next) === null || _a2 === void 0 || _a2.call(tapObserver, value), subscriber.next(value);
|
|
1732
|
+
}, function() {
|
|
1733
|
+
var _a2;
|
|
1734
|
+
isUnsub = !1, (_a2 = tapObserver.complete) === null || _a2 === void 0 || _a2.call(tapObserver), subscriber.complete();
|
|
1735
|
+
}, function(err) {
|
|
1736
|
+
var _a2;
|
|
1737
|
+
isUnsub = !1, (_a2 = tapObserver.error) === null || _a2 === void 0 || _a2.call(tapObserver, err), subscriber.error(err);
|
|
1738
|
+
}, function() {
|
|
1739
|
+
var _a2, _b;
|
|
1740
|
+
isUnsub && ((_a2 = tapObserver.unsubscribe) === null || _a2 === void 0 || _a2.call(tapObserver)), (_b = tapObserver.finalize) === null || _b === void 0 || _b.call(tapObserver);
|
|
1461
1741
|
}));
|
|
1462
1742
|
}) : identity;
|
|
1463
1743
|
}
|
|
1464
|
-
var shim = {
|
|
1465
|
-
exports: {}
|
|
1466
|
-
};
|
|
1467
|
-
var useSyncExternalStoreShim_production_min = {};
|
|
1468
|
-
|
|
1469
|
-
/**
|
|
1470
|
-
* @license React
|
|
1471
|
-
* use-sync-external-store-shim.production.min.js
|
|
1472
|
-
*
|
|
1473
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1474
|
-
*
|
|
1475
|
-
* This source code is licensed under the MIT license found in the
|
|
1476
|
-
* LICENSE file in the root directory of this source tree.
|
|
1477
|
-
*/
|
|
1478
|
-
|
|
1479
|
-
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
1480
|
-
function requireUseSyncExternalStoreShim_production_min() {
|
|
1481
|
-
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
1482
|
-
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
1483
|
-
var e = require$$0__default.default;
|
|
1484
|
-
function h(a, b) {
|
|
1485
|
-
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
1486
|
-
}
|
|
1487
|
-
var k = "function" === typeof Object.is ? Object.is : h,
|
|
1488
|
-
l = e.useState,
|
|
1489
|
-
m = e.useEffect,
|
|
1490
|
-
n = e.useLayoutEffect,
|
|
1491
|
-
p = e.useDebugValue;
|
|
1492
|
-
function q(a, b) {
|
|
1493
|
-
var d = b(),
|
|
1494
|
-
f = l({
|
|
1495
|
-
inst: {
|
|
1496
|
-
value: d,
|
|
1497
|
-
getSnapshot: b
|
|
1498
|
-
}
|
|
1499
|
-
}),
|
|
1500
|
-
c = f[0].inst,
|
|
1501
|
-
g = f[1];
|
|
1502
|
-
n(function () {
|
|
1503
|
-
c.value = d;
|
|
1504
|
-
c.getSnapshot = b;
|
|
1505
|
-
r(c) && g({
|
|
1506
|
-
inst: c
|
|
1507
|
-
});
|
|
1508
|
-
}, [a, d, b]);
|
|
1509
|
-
m(function () {
|
|
1510
|
-
r(c) && g({
|
|
1511
|
-
inst: c
|
|
1512
|
-
});
|
|
1513
|
-
return a(function () {
|
|
1514
|
-
r(c) && g({
|
|
1515
|
-
inst: c
|
|
1516
|
-
});
|
|
1517
|
-
});
|
|
1518
|
-
}, [a]);
|
|
1519
|
-
p(d);
|
|
1520
|
-
return d;
|
|
1521
|
-
}
|
|
1522
|
-
function r(a) {
|
|
1523
|
-
var b = a.getSnapshot;
|
|
1524
|
-
a = a.value;
|
|
1525
|
-
try {
|
|
1526
|
-
var d = b();
|
|
1527
|
-
return !k(a, d);
|
|
1528
|
-
} catch (f) {
|
|
1529
|
-
return !0;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
function t(a, b) {
|
|
1533
|
-
return b();
|
|
1534
|
-
}
|
|
1535
|
-
var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
|
|
1536
|
-
useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
|
|
1537
|
-
return useSyncExternalStoreShim_production_min;
|
|
1538
|
-
}
|
|
1539
|
-
var useSyncExternalStoreShim_development = {};
|
|
1540
|
-
|
|
1541
|
-
/**
|
|
1542
|
-
* @license React
|
|
1543
|
-
* use-sync-external-store-shim.development.js
|
|
1544
|
-
*
|
|
1545
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1546
|
-
*
|
|
1547
|
-
* This source code is licensed under the MIT license found in the
|
|
1548
|
-
* LICENSE file in the root directory of this source tree.
|
|
1549
|
-
*/
|
|
1550
|
-
|
|
1551
|
-
var hasRequiredUseSyncExternalStoreShim_development;
|
|
1552
|
-
function requireUseSyncExternalStoreShim_development() {
|
|
1553
|
-
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
1554
|
-
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
1555
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1556
|
-
(function () {
|
|
1557
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
1558
|
-
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === 'function') {
|
|
1559
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
1560
|
-
}
|
|
1561
|
-
var React = require$$0__default.default;
|
|
1562
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
1563
|
-
function error(format) {
|
|
1564
|
-
{
|
|
1565
|
-
{
|
|
1566
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1567
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1568
|
-
}
|
|
1569
|
-
printWarning('error', format, args);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
function printWarning(level, format, args) {
|
|
1574
|
-
// When changing this logic, you might want to also
|
|
1575
|
-
// update consoleWithStackDev.www.js as well.
|
|
1576
|
-
{
|
|
1577
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1578
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
1579
|
-
if (stack !== '') {
|
|
1580
|
-
format += '%s';
|
|
1581
|
-
args = args.concat([stack]);
|
|
1582
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
1583
|
-
|
|
1584
|
-
var argsWithFormat = args.map(function (item) {
|
|
1585
|
-
return String(item);
|
|
1586
|
-
}); // Careful: RN currently depends on this prefix
|
|
1587
|
-
|
|
1588
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
1589
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
1590
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
1591
|
-
|
|
1592
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
/**
|
|
1597
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
1598
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
1599
|
-
*/
|
|
1600
|
-
function is(x, y) {
|
|
1601
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
1602
|
-
;
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
1606
|
-
|
|
1607
|
-
// dispatch for CommonJS interop named imports.
|
|
1608
|
-
|
|
1609
|
-
var useState = React.useState,
|
|
1610
|
-
useEffect = React.useEffect,
|
|
1611
|
-
useLayoutEffect = React.useLayoutEffect,
|
|
1612
|
-
useDebugValue = React.useDebugValue;
|
|
1613
|
-
var didWarnOld18Alpha = false;
|
|
1614
|
-
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
1615
|
-
// because of a very particular set of implementation details and assumptions
|
|
1616
|
-
// -- change any one of them and it will break. The most important assumption
|
|
1617
|
-
// is that updates are always synchronous, because concurrent rendering is
|
|
1618
|
-
// only available in versions of React that also have a built-in
|
|
1619
|
-
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
1620
|
-
// does not exist.
|
|
1621
|
-
//
|
|
1622
|
-
// Do not assume that the clever hacks used by this hook also work in general.
|
|
1623
|
-
// The point of this shim is to replace the need for hacks by other libraries.
|
|
1624
|
-
|
|
1625
|
-
function useSyncExternalStore(subscribe, getSnapshot,
|
|
1626
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
1627
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
1628
|
-
// will need to track that themselves and return the correct value
|
|
1629
|
-
// from `getSnapshot`.
|
|
1630
|
-
getServerSnapshot) {
|
|
1631
|
-
{
|
|
1632
|
-
if (!didWarnOld18Alpha) {
|
|
1633
|
-
if (React.startTransition !== undefined) {
|
|
1634
|
-
didWarnOld18Alpha = true;
|
|
1635
|
-
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
} // Read the current snapshot from the store on every render. Again, this
|
|
1639
|
-
// breaks the rules of React, and only works here because of specific
|
|
1640
|
-
// implementation details, most importantly that updates are
|
|
1641
|
-
// always synchronous.
|
|
1642
|
-
|
|
1643
|
-
var value = getSnapshot();
|
|
1644
|
-
{
|
|
1645
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
1646
|
-
var cachedValue = getSnapshot();
|
|
1647
|
-
if (!objectIs(value, cachedValue)) {
|
|
1648
|
-
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
1649
|
-
didWarnUncachedGetSnapshot = true;
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
1653
|
-
// re-render whenever the subscribed state changes by updating an some
|
|
1654
|
-
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
1655
|
-
// the current value.
|
|
1656
|
-
//
|
|
1657
|
-
// Because we don't actually use the state returned by the useState hook, we
|
|
1658
|
-
// can save a bit of memory by storing other stuff in that slot.
|
|
1659
|
-
//
|
|
1660
|
-
// To implement the early bailout, we need to track some things on a mutable
|
|
1661
|
-
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
1662
|
-
// our useState hook instead.
|
|
1663
|
-
//
|
|
1664
|
-
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
1665
|
-
// new object always fails an equality check.
|
|
1666
|
-
|
|
1667
|
-
var _useState = useState({
|
|
1668
|
-
inst: {
|
|
1669
|
-
value: value,
|
|
1670
|
-
getSnapshot: getSnapshot
|
|
1671
|
-
}
|
|
1672
|
-
}),
|
|
1673
|
-
inst = _useState[0].inst,
|
|
1674
|
-
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
1675
|
-
// in the layout phase so we can access it during the tearing check that
|
|
1676
|
-
// happens on subscribe.
|
|
1677
|
-
|
|
1678
|
-
useLayoutEffect(function () {
|
|
1679
|
-
inst.value = value;
|
|
1680
|
-
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
1681
|
-
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
1682
|
-
// this can happen all the time, but even in synchronous mode, an earlier
|
|
1683
|
-
// effect may have mutated the store.
|
|
1684
|
-
|
|
1685
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
1686
|
-
// Force a re-render.
|
|
1687
|
-
forceUpdate({
|
|
1688
|
-
inst: inst
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
}, [subscribe, value, getSnapshot]);
|
|
1692
|
-
useEffect(function () {
|
|
1693
|
-
// Check for changes right before subscribing. Subsequent changes will be
|
|
1694
|
-
// detected in the subscription handler.
|
|
1695
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
1696
|
-
// Force a re-render.
|
|
1697
|
-
forceUpdate({
|
|
1698
|
-
inst: inst
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
var handleStoreChange = function () {
|
|
1702
|
-
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
1703
|
-
// up to the consumer of this library to wrap their subscription event
|
|
1704
|
-
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
1705
|
-
// the case and print a warning in development?
|
|
1706
|
-
// The store changed. Check if the snapshot changed since the last time we
|
|
1707
|
-
// read from the store.
|
|
1708
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
1709
|
-
// Force a re-render.
|
|
1710
|
-
forceUpdate({
|
|
1711
|
-
inst: inst
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
}; // Subscribe to the store and return a clean-up function.
|
|
1715
|
-
|
|
1716
|
-
return subscribe(handleStoreChange);
|
|
1717
|
-
}, [subscribe]);
|
|
1718
|
-
useDebugValue(value);
|
|
1719
|
-
return value;
|
|
1720
|
-
}
|
|
1721
|
-
function checkIfSnapshotChanged(inst) {
|
|
1722
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
1723
|
-
var prevValue = inst.value;
|
|
1724
|
-
try {
|
|
1725
|
-
var nextValue = latestGetSnapshot();
|
|
1726
|
-
return !objectIs(prevValue, nextValue);
|
|
1727
|
-
} catch (error) {
|
|
1728
|
-
return true;
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
1732
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
1733
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
1734
|
-
// will need to track that themselves and return the correct value
|
|
1735
|
-
// from `getSnapshot`.
|
|
1736
|
-
return getSnapshot();
|
|
1737
|
-
}
|
|
1738
|
-
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
1739
|
-
var isServerEnvironment = !canUseDOM;
|
|
1740
|
-
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
1741
|
-
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
1742
|
-
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
1743
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
1744
|
-
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === 'function') {
|
|
1745
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
1746
|
-
}
|
|
1747
|
-
})();
|
|
1748
|
-
}
|
|
1749
|
-
return useSyncExternalStoreShim_development;
|
|
1750
|
-
}
|
|
1751
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1752
|
-
shim.exports = requireUseSyncExternalStoreShim_production_min();
|
|
1753
|
-
} else {
|
|
1754
|
-
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
1755
|
-
}
|
|
1756
|
-
var shimExports = shim.exports;
|
|
1757
1744
|
function getValue(value) {
|
|
1758
|
-
return typeof value
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
function
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
store.subscription = store.observable.subscribe();
|
|
1745
|
+
return typeof value == "function" ? value() : value;
|
|
1746
|
+
}
|
|
1747
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
1748
|
+
function useObservable(observable2, initialValue) {
|
|
1749
|
+
const $ = distExports.c(9);
|
|
1750
|
+
let t0;
|
|
1751
|
+
if (!cache.has(observable2)) {
|
|
1752
|
+
const state = {
|
|
1753
|
+
didEmit: !1
|
|
1754
|
+
}, entry = {
|
|
1755
|
+
state,
|
|
1756
|
+
observable: observable2.pipe(map(_temp$1), catchError(_temp2), tap((t12) => {
|
|
1757
|
+
const {
|
|
1758
|
+
snapshot,
|
|
1759
|
+
error: error_0
|
|
1760
|
+
} = t12;
|
|
1761
|
+
state.didEmit = !0, state.snapshot = snapshot, state.error = error_0;
|
|
1762
|
+
}), map(_temp3), finalize(() => cache.delete(observable2)), share({
|
|
1763
|
+
resetOnRefCountZero: _temp4
|
|
1764
|
+
})),
|
|
1765
|
+
getSnapshot: (initialValue_0) => {
|
|
1766
|
+
if (state.error)
|
|
1767
|
+
throw state.error;
|
|
1768
|
+
return state.didEmit ? state.snapshot : getValue(initialValue_0);
|
|
1783
1769
|
}
|
|
1784
|
-
return [function getSnapshot() {
|
|
1785
|
-
// @TODO: perf opt opportunity: we could do `store.subscription.unsubscribe()` here to clear up some memory, as this subscription is only needed to provide a sync initialValue.
|
|
1786
|
-
return store.currentValue;
|
|
1787
|
-
}, function subscribe(callback) {
|
|
1788
|
-
// @TODO: perf opt opportunity: we could do `store.subscription.unsubscribe()` here as we only need 1 subscription active to keep the observer alive
|
|
1789
|
-
var sub = store.observable.subscribe(callback);
|
|
1790
|
-
return function () {
|
|
1791
|
-
sub.unsubscribe();
|
|
1792
|
-
};
|
|
1793
|
-
}];
|
|
1794
|
-
}, [observable]),
|
|
1795
|
-
getSnapshot = _a[0],
|
|
1796
|
-
subscribe = _a[1];
|
|
1797
|
-
var shouldRestoreSubscriptionRef = require$$0.useRef(false);
|
|
1798
|
-
require$$0.useEffect(function () {
|
|
1799
|
-
var store = getOrCreateStore(observable, getValue(initialValue));
|
|
1800
|
-
if (shouldRestoreSubscriptionRef.current) {
|
|
1801
|
-
if (store.subscription.closed) {
|
|
1802
|
-
store.subscription = store.observable.subscribe();
|
|
1803
|
-
}
|
|
1804
|
-
shouldRestoreSubscriptionRef.current = false;
|
|
1805
|
-
}
|
|
1806
|
-
return function () {
|
|
1807
|
-
// React StrictMode will call effects as `setup + teardown + setup` thus we can't trust this callback as "react is about to unmount"
|
|
1808
|
-
// Tracking this ref lets us set the subscription back up on the next `setup` call if needed, and if it really did unmounted then all is well
|
|
1809
|
-
shouldRestoreSubscriptionRef.current = !store.subscription.closed;
|
|
1810
|
-
store.subscription.unsubscribe();
|
|
1811
1770
|
};
|
|
1812
|
-
|
|
1813
|
-
return shimExports.useSyncExternalStore(subscribe, getSnapshot);
|
|
1814
|
-
}
|
|
1815
|
-
function useMemoObservable(observableOrFactory, deps, initialValue) {
|
|
1816
|
-
return useObservable(require$$0.useMemo(function () {
|
|
1817
|
-
return getValue(observableOrFactory);
|
|
1818
|
-
}, deps), initialValue);
|
|
1819
|
-
}
|
|
1820
|
-
function DocumentPreview(_ref) {
|
|
1821
|
-
let {
|
|
1822
|
-
documentId,
|
|
1823
|
-
style,
|
|
1824
|
-
schemaTypeName,
|
|
1825
|
-
...buttonProps
|
|
1826
|
-
} = _ref;
|
|
1827
|
-
const schema = sanity.useSchema();
|
|
1828
|
-
const schemaType = schemaTypeName ? schema.get(schemaTypeName) : void 0;
|
|
1829
|
-
if (!schemaTypeName) {
|
|
1830
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
1831
|
-
style: {
|
|
1832
|
-
minHeight: "36px"
|
|
1833
|
-
},
|
|
1834
|
-
children: /* @__PURE__ */jsxRuntime.jsx(sanity.DefaultPreview, {
|
|
1835
|
-
withShadow: false,
|
|
1836
|
-
withBorder: false,
|
|
1837
|
-
title: "Loading...",
|
|
1838
|
-
schemaType,
|
|
1839
|
-
isPlaceholder: true
|
|
1840
|
-
})
|
|
1841
|
-
});
|
|
1771
|
+
entry.observable.subscribe().unsubscribe(), cache.set(observable2, entry);
|
|
1842
1772
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
return
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1773
|
+
let t1;
|
|
1774
|
+
$[0] !== observable2 ? (t1 = cache.get(observable2), $[0] = observable2, $[1] = t1) : t1 = $[1], t0 = t1;
|
|
1775
|
+
const instance = t0;
|
|
1776
|
+
let t2;
|
|
1777
|
+
$[2] !== instance.observable ? (t2 = (onStoreChange) => {
|
|
1778
|
+
const subscription_0 = instance.observable.subscribe(onStoreChange);
|
|
1779
|
+
return () => {
|
|
1780
|
+
subscription_0.unsubscribe();
|
|
1781
|
+
};
|
|
1782
|
+
}, $[2] = instance.observable, $[3] = t2) : t2 = $[3];
|
|
1783
|
+
const subscribe = t2;
|
|
1784
|
+
let t3;
|
|
1785
|
+
$[4] !== initialValue || $[5] !== instance ? (t3 = () => instance.getSnapshot(initialValue), $[4] = initialValue, $[5] = instance, $[6] = t3) : t3 = $[6];
|
|
1786
|
+
let t4;
|
|
1787
|
+
return $[7] !== initialValue ? (t4 = typeof initialValue > "u" ? void 0 : () => getValue(initialValue), $[7] = initialValue, $[8] = t4) : t4 = $[8], require$$0.useSyncExternalStore(subscribe, t3, t4);
|
|
1788
|
+
}
|
|
1789
|
+
function _temp4() {
|
|
1790
|
+
return timer(0, asapScheduler);
|
|
1791
|
+
}
|
|
1792
|
+
function _temp3(value_0) {
|
|
1793
|
+
}
|
|
1794
|
+
function _temp2(error) {
|
|
1795
|
+
return of({
|
|
1796
|
+
snapshot: void 0,
|
|
1797
|
+
error
|
|
1863
1798
|
});
|
|
1864
1799
|
}
|
|
1865
|
-
function
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1800
|
+
function _temp$1(value) {
|
|
1801
|
+
return {
|
|
1802
|
+
snapshot: value,
|
|
1803
|
+
error: void 0
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
function DocumentPreview({
|
|
1807
|
+
documentId,
|
|
1808
|
+
style,
|
|
1809
|
+
schemaTypeName,
|
|
1810
|
+
...buttonProps
|
|
1811
|
+
}) {
|
|
1812
|
+
const schema = sanity.useSchema(), schemaType = schemaTypeName ? schema.get(schemaTypeName) : void 0;
|
|
1813
|
+
return schemaTypeName ? schemaType ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1814
|
+
DocumentPreviewInner,
|
|
1815
|
+
{
|
|
1816
|
+
documentId,
|
|
1817
|
+
schemaTypeName,
|
|
1818
|
+
schemaType,
|
|
1819
|
+
style,
|
|
1820
|
+
...buttonProps
|
|
1821
|
+
}
|
|
1822
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1823
|
+
sanity.DefaultPreview,
|
|
1824
|
+
{
|
|
1825
|
+
withShadow: !1,
|
|
1826
|
+
withBorder: !1,
|
|
1827
|
+
media: () => /* @__PURE__ */ jsxRuntime.jsx(icons.ErrorOutlineIcon, {}),
|
|
1828
|
+
title: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1829
|
+
"Unknown type ",
|
|
1830
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: schemaTypeName ?? "N/A" }),
|
|
1831
|
+
" for ",
|
|
1832
|
+
documentId
|
|
1833
|
+
] })
|
|
1834
|
+
}
|
|
1835
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { style: { minHeight: "36px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1836
|
+
sanity.DefaultPreview,
|
|
1837
|
+
{
|
|
1838
|
+
withShadow: !1,
|
|
1839
|
+
withBorder: !1,
|
|
1840
|
+
title: "Loading...",
|
|
1841
|
+
schemaType,
|
|
1842
|
+
isPlaceholder: !0
|
|
1843
|
+
}
|
|
1844
|
+
) });
|
|
1845
|
+
}
|
|
1846
|
+
function DocumentPreviewInner({
|
|
1847
|
+
documentId,
|
|
1848
|
+
schemaType,
|
|
1849
|
+
style,
|
|
1850
|
+
button
|
|
1851
|
+
}) {
|
|
1852
|
+
const documentPreviewStore = sanity.useDocumentPreviewStore(), previewStateObservable = require$$0.useMemo(
|
|
1853
|
+
() => sanity.getPreviewStateObservable(documentPreviewStore, schemaType, documentId),
|
|
1854
|
+
[documentId, documentPreviewStore, schemaType]
|
|
1855
|
+
), {
|
|
1856
|
+
snapshot,
|
|
1857
|
+
original,
|
|
1858
|
+
isLoading: previewIsLoading
|
|
1859
|
+
} = useObservable(previewStateObservable, {
|
|
1860
|
+
snapshot: null,
|
|
1861
|
+
isLoading: !0,
|
|
1862
|
+
original: null
|
|
1863
|
+
}), sanityDocument = require$$0.useMemo(() => ({
|
|
1864
|
+
_id: documentId,
|
|
1865
|
+
_type: schemaType?.name
|
|
1866
|
+
}), [documentId, schemaType?.name]), { onClick: onIntentClick, href } = router.useIntentLink({
|
|
1888
1867
|
intent: "edit",
|
|
1889
1868
|
params: {
|
|
1890
1869
|
id: documentId,
|
|
1891
|
-
type: schemaType
|
|
1870
|
+
type: schemaType?.name
|
|
1892
1871
|
}
|
|
1893
|
-
})
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1872
|
+
}), preview = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1873
|
+
sanity.SanityDefaultPreview,
|
|
1874
|
+
{
|
|
1875
|
+
...sanity.getPreviewValueWithFallback({
|
|
1876
|
+
snapshot,
|
|
1877
|
+
original,
|
|
1878
|
+
fallback: sanityDocument
|
|
1879
|
+
}),
|
|
1880
|
+
isPlaceholder: previewIsLoading ?? !0,
|
|
1881
|
+
layout: "default",
|
|
1882
|
+
icon: schemaType?.icon
|
|
1883
|
+
}
|
|
1884
|
+
);
|
|
1885
|
+
return button ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1886
|
+
ui.Button,
|
|
1887
|
+
{
|
|
1906
1888
|
as: "a",
|
|
1907
1889
|
href,
|
|
1908
1890
|
onClick: onIntentClick,
|
|
1909
1891
|
mode: "ghost",
|
|
1910
|
-
style: {
|
|
1911
|
-
width: "100%",
|
|
1912
|
-
...style
|
|
1913
|
-
},
|
|
1892
|
+
style: { width: "100%", ...style },
|
|
1914
1893
|
children: preview
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1918
|
-
style: {
|
|
1919
|
-
width: "100%"
|
|
1920
|
-
},
|
|
1921
|
-
children: preview
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
function queryIndex(queryConfig, client) {
|
|
1925
|
-
const {
|
|
1926
|
-
query,
|
|
1927
|
-
indexName,
|
|
1928
|
-
maxResults,
|
|
1929
|
-
filter
|
|
1930
|
-
} = queryConfig;
|
|
1931
|
-
const projectId = client.config().projectId;
|
|
1932
|
-
const dataset = client.config().dataset;
|
|
1933
|
-
const queryString = query == null ? void 0 : query.trim();
|
|
1934
|
-
return client.request({
|
|
1935
|
-
method: "POST",
|
|
1936
|
-
url: "/embeddings-index/query/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId),
|
|
1937
|
-
body: {
|
|
1938
|
-
query: queryString,
|
|
1939
|
-
maxResults,
|
|
1940
|
-
filter
|
|
1941
1894
|
}
|
|
1942
|
-
});
|
|
1943
|
-
}
|
|
1944
|
-
function getIndexes(client) {
|
|
1945
|
-
const projectId = client.config().projectId;
|
|
1946
|
-
const dataset = client.config().dataset;
|
|
1947
|
-
return client.request({
|
|
1948
|
-
method: "GET",
|
|
1949
|
-
url: "/embeddings-index/".concat(dataset, "?projectId=").concat(projectId)
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
function deleteIndex(indexName, client) {
|
|
1953
|
-
const projectId = client.config().projectId;
|
|
1954
|
-
const dataset = client.config().dataset;
|
|
1955
|
-
return client.request({
|
|
1956
|
-
method: "DELETE",
|
|
1957
|
-
url: "/embeddings-index/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId)
|
|
1958
|
-
});
|
|
1895
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { width: "100%" }, children: preview });
|
|
1959
1896
|
}
|
|
1960
|
-
const NO_RESULTS_VALUE = ""
|
|
1961
|
-
const NO_OPTIONS = [];
|
|
1962
|
-
const NO_FILTER = () => true;
|
|
1963
|
-
const SemanticSearchAutocomplete = require$$0.forwardRef(function SemanticSearchAutocomplete2(props, ref) {
|
|
1897
|
+
const NO_RESULTS_VALUE = "", NO_OPTIONS = [], NO_FILTER = () => !0, SemanticSearchAutocomplete = require$$0.forwardRef(function(props, ref) {
|
|
1964
1898
|
const {
|
|
1965
1899
|
indexConfig,
|
|
1966
1900
|
filterResult,
|
|
@@ -1970,943 +1904,445 @@ const SemanticSearchAutocomplete = require$$0.forwardRef(function SemanticSearch
|
|
|
1970
1904
|
onBlur,
|
|
1971
1905
|
onSelect,
|
|
1972
1906
|
typeFilter
|
|
1973
|
-
} = props
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
filter: {
|
|
1995
|
-
type: typeFilter
|
|
1996
|
-
}
|
|
1997
|
-
}, client).then(result => {
|
|
1998
|
-
if (queryRef.current === queryString) {
|
|
1999
|
-
setSearching(false);
|
|
2000
|
-
setOptions([]);
|
|
2001
|
-
const resultOptions = result.filter(hit => filterResult ? filterResult(hit) : true).map(r => sanity.typed({
|
|
2002
|
-
result: r,
|
|
2003
|
-
value: r.value.documentId
|
|
2004
|
-
}));
|
|
2005
|
-
if (resultOptions.length) {
|
|
2006
|
-
setOptions(resultOptions);
|
|
2007
|
-
} else {
|
|
2008
|
-
setOptions([{
|
|
2009
|
-
value: NO_RESULTS_VALUE
|
|
2010
|
-
}]);
|
|
1907
|
+
} = props, id = require$$0.useId(), [query, setQuery] = require$$0.useState(""), queryRef = require$$0.useRef(query), debouncedQuery = useDebouncedValue(query, 300), prevDebouncedQuery = require$$0.useRef(debouncedQuery), [searching, setSearching] = require$$0.useState(!1), [options, setOptions] = require$$0.useState(NO_OPTIONS), client = useApiClient(), runIndexQuery = require$$0.useCallback(
|
|
1908
|
+
(queryString) => {
|
|
1909
|
+
setSearching(!0);
|
|
1910
|
+
const indexName = indexConfig?.indexName, maxResults = indexConfig?.maxResults;
|
|
1911
|
+
if (!indexName)
|
|
1912
|
+
throw new Error("Reference option embeddingsIndex.indexName is required, but was missing");
|
|
1913
|
+
queryIndex(
|
|
1914
|
+
{
|
|
1915
|
+
query: queryString.trim().length ? queryString : getEmptySearchValue() ?? "",
|
|
1916
|
+
indexName,
|
|
1917
|
+
maxResults,
|
|
1918
|
+
filter: {
|
|
1919
|
+
type: typeFilter
|
|
1920
|
+
}
|
|
1921
|
+
},
|
|
1922
|
+
client
|
|
1923
|
+
).then((result) => {
|
|
1924
|
+
if (queryRef.current === queryString) {
|
|
1925
|
+
setSearching(!1), setOptions([]), setOptions([]);
|
|
1926
|
+
const resultOptions = result.filter((hit) => filterResult ? filterResult(hit) : !0).map((r) => sanity.typed({ result: r, value: r.value.documentId }));
|
|
1927
|
+
resultOptions.length ? setOptions(resultOptions) : setOptions([{ value: NO_RESULTS_VALUE }]);
|
|
2011
1928
|
}
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
});
|
|
2019
|
-
}, [client, indexConfig, getEmptySearchValue, filterResult, typeFilter]);
|
|
1929
|
+
}).catch((e) => {
|
|
1930
|
+
throw queryRef.current === queryString && setSearching(!1), e;
|
|
1931
|
+
});
|
|
1932
|
+
},
|
|
1933
|
+
[client, indexConfig, getEmptySearchValue, filterResult, typeFilter]
|
|
1934
|
+
);
|
|
2020
1935
|
require$$0.useEffect(() => {
|
|
2021
|
-
|
|
2022
|
-
runIndexQuery(debouncedQuery);
|
|
2023
|
-
}
|
|
2024
|
-
prevDebouncedQuery.current = debouncedQuery;
|
|
1936
|
+
prevDebouncedQuery.current !== debouncedQuery && runIndexQuery(debouncedQuery), prevDebouncedQuery.current = debouncedQuery;
|
|
2025
1937
|
}, [debouncedQuery, runIndexQuery]);
|
|
2026
|
-
const openButtonConfig = require$$0.useMemo(
|
|
2027
|
-
onClick: () => runIndexQuery(queryRef.current)
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
1938
|
+
const openButtonConfig = require$$0.useMemo(
|
|
1939
|
+
() => ({ onClick: () => runIndexQuery(queryRef.current) }),
|
|
1940
|
+
[runIndexQuery, queryRef]
|
|
1941
|
+
), handleQueryChange = require$$0.useCallback(
|
|
1942
|
+
(newValue) => {
|
|
1943
|
+
const newQuery = newValue ?? "";
|
|
1944
|
+
queryRef.current = newQuery, setQuery(newQuery);
|
|
1945
|
+
},
|
|
1946
|
+
[setQuery]
|
|
1947
|
+
), handleChange = require$$0.useCallback(
|
|
1948
|
+
(value) => {
|
|
1949
|
+
if (value === NO_RESULTS_VALUE) {
|
|
1950
|
+
setOptions(NO_OPTIONS);
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
const option = options.filter((r) => "result" in r).find((r) => r.result.value.documentId === value);
|
|
1954
|
+
option && onSelect && onSelect(option.result);
|
|
1955
|
+
},
|
|
1956
|
+
[onSelect, options]
|
|
1957
|
+
);
|
|
1958
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1959
|
+
ui.Autocomplete,
|
|
1960
|
+
{
|
|
1961
|
+
id,
|
|
1962
|
+
ref,
|
|
1963
|
+
"data-testid": "semantic-autocomplete",
|
|
1964
|
+
placeholder: "Type to search...",
|
|
1965
|
+
openButton: openButtonConfig,
|
|
1966
|
+
onFocus,
|
|
1967
|
+
onChange: handleChange,
|
|
1968
|
+
loading: searching,
|
|
1969
|
+
onBlur,
|
|
1970
|
+
readOnly,
|
|
1971
|
+
filterOption: NO_FILTER,
|
|
1972
|
+
onQueryChange: handleQueryChange,
|
|
1973
|
+
options,
|
|
1974
|
+
renderOption: AutocompleteOption
|
|
2042
1975
|
}
|
|
2043
|
-
|
|
2044
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Autocomplete, {
|
|
2045
|
-
id,
|
|
2046
|
-
ref,
|
|
2047
|
-
"data-testid": "semantic-autocomplete",
|
|
2048
|
-
placeholder: "Type to search...",
|
|
2049
|
-
openButton: openButtonConfig,
|
|
2050
|
-
onFocus,
|
|
2051
|
-
onChange: handleChange,
|
|
2052
|
-
loading: searching,
|
|
2053
|
-
onBlur,
|
|
2054
|
-
readOnly,
|
|
2055
|
-
filterOption: NO_FILTER,
|
|
2056
|
-
onQueryChange: handleQueryChange,
|
|
2057
|
-
options,
|
|
2058
|
-
renderOption: AutocompleteOption
|
|
2059
|
-
});
|
|
1976
|
+
);
|
|
2060
1977
|
});
|
|
2061
1978
|
function AutocompleteOption(props) {
|
|
2062
1979
|
if ("result" in props) {
|
|
2063
1980
|
const value = props.result.value;
|
|
2064
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2065
|
-
|
|
2066
|
-
padding: 1,
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
gap: 2,
|
|
2072
|
-
align: "center",
|
|
2073
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2074
|
-
flex: 1,
|
|
2075
|
-
children: /* @__PURE__ */jsxRuntime.jsx(DocumentPreview, {
|
|
2076
|
-
documentId: value.documentId,
|
|
2077
|
-
schemaTypeName: value.type
|
|
2078
|
-
})
|
|
2079
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2080
|
-
padding: 2,
|
|
2081
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
2082
|
-
size: 1,
|
|
2083
|
-
muted: true,
|
|
2084
|
-
title: "Relevance",
|
|
2085
|
-
children: [Math.floor(props.result.score * 100), "%"]
|
|
2086
|
-
})
|
|
2087
|
-
})]
|
|
2088
|
-
})
|
|
2089
|
-
});
|
|
1981
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "bleed", padding: 1, style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
1982
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentPreview, { documentId: value.documentId, schemaTypeName: value.type }) }),
|
|
1983
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, title: "Relevance", children: [
|
|
1984
|
+
Math.floor(props.result.score * 100),
|
|
1985
|
+
"%"
|
|
1986
|
+
] }) })
|
|
1987
|
+
] }) });
|
|
2090
1988
|
}
|
|
2091
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2092
|
-
mode: "bleed",
|
|
2093
|
-
padding: 1,
|
|
2094
|
-
style: {
|
|
2095
|
-
width: "100%"
|
|
2096
|
-
},
|
|
2097
|
-
disabled: true,
|
|
2098
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
2099
|
-
gap: 2,
|
|
2100
|
-
align: "center",
|
|
2101
|
-
children: "No results."
|
|
2102
|
-
})
|
|
2103
|
-
});
|
|
1989
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "bleed", padding: 1, style: { width: "100%" }, disabled: !0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 2, align: "center", children: "No results." }) });
|
|
2104
1990
|
}
|
|
2105
1991
|
function useDebouncedValue(value, ms) {
|
|
2106
1992
|
const [debouncedValue, setDebouncedValue] = require$$0.useState(value);
|
|
2107
|
-
require$$0.useEffect(() => {
|
|
1993
|
+
return require$$0.useEffect(() => {
|
|
2108
1994
|
const timeoutId = setTimeout(() => {
|
|
2109
1995
|
setDebouncedValue(value);
|
|
2110
1996
|
}, ms);
|
|
2111
1997
|
return () => clearTimeout(timeoutId);
|
|
2112
|
-
}, [value, ms]);
|
|
2113
|
-
return debouncedValue;
|
|
2114
|
-
}
|
|
2115
|
-
function useEmeddingsConfig(embeddingsIndexConfig, defaultConfig) {
|
|
2116
|
-
return require$$0.useMemo(() => {
|
|
2117
|
-
if (embeddingsIndexConfig === true || !embeddingsIndexConfig) {
|
|
2118
|
-
if (!(defaultConfig == null ? void 0 : defaultConfig.indexName)) {
|
|
2119
|
-
throw new Error("Default embeddingsIndex config is missing. When options.embeddingsIndex: true, embeddingsIndexReferenceInput plugin config is required.");
|
|
2120
|
-
}
|
|
2121
|
-
return defaultConfig;
|
|
2122
|
-
}
|
|
2123
|
-
const finalConfig = {
|
|
2124
|
-
...defaultConfig,
|
|
2125
|
-
...embeddingsIndexConfig
|
|
2126
|
-
};
|
|
2127
|
-
if (!(finalConfig == null ? void 0 : finalConfig.indexName)) {
|
|
2128
|
-
throw new Error("indexName is missing. Either set it in options.embeddingsIndex or configure defaults using plugin config.");
|
|
2129
|
-
}
|
|
2130
|
-
return finalConfig;
|
|
2131
|
-
}, [defaultConfig, embeddingsIndexConfig]);
|
|
2132
|
-
}
|
|
2133
|
-
function SemanticSearchReferenceInput(props) {
|
|
2134
|
-
var _a, _b;
|
|
2135
|
-
const embeddingsIndexConfig = (_b = (_a = props.schemaType) == null ? void 0 : _a.options) == null ? void 0 : _b.embeddingsIndex;
|
|
2136
|
-
const config = useEmeddingsConfig(embeddingsIndexConfig, props.defaultConfig);
|
|
2137
|
-
const defaultEnabled = config.searchMode === "embeddings";
|
|
2138
|
-
const featureState = useIsFeatureEnabledContext();
|
|
2139
|
-
const [semantic, setSemantic] = require$$0.useState(defaultEnabled);
|
|
2140
|
-
const toggleSemantic = require$$0.useCallback(() => setSemantic(current => !current), []);
|
|
2141
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2142
|
-
gap: 2,
|
|
2143
|
-
flex: 1,
|
|
2144
|
-
style: {
|
|
2145
|
-
width: "100%"
|
|
2146
|
-
},
|
|
2147
|
-
children: [semantic && featureState == "loading" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2148
|
-
padding: 2,
|
|
2149
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
|
|
2150
|
-
}) : null, semantic && featureState == "disabled" ? /* @__PURE__ */jsxRuntime.jsx(FeatureDisabledNotice, {
|
|
2151
|
-
urlSuffix: "?ref=embeddings-ref"
|
|
2152
|
-
}) : null, semantic && featureState === "error" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2153
|
-
padding: 4,
|
|
2154
|
-
children: /* @__PURE__ */jsxRuntime.jsx(FeatureError, {})
|
|
2155
|
-
}) : null, /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2156
|
-
flex: 1,
|
|
2157
|
-
style: {
|
|
2158
|
-
maxHeight: 36,
|
|
2159
|
-
overflow: "hidden"
|
|
2160
|
-
},
|
|
2161
|
-
children: semantic && featureState == "enabled" ? /* @__PURE__ */jsxRuntime.jsx(SemanticSearchInput, {
|
|
2162
|
-
...props,
|
|
2163
|
-
indexConfig: config
|
|
2164
|
-
}) : props.renderDefault(props)
|
|
2165
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2166
|
-
icon: semantic ? icons.EarthGlobeIcon : icons.LinkIcon,
|
|
2167
|
-
onClick: toggleSemantic,
|
|
2168
|
-
mode: "bleed",
|
|
2169
|
-
title: semantic ? "Switch to standard reference search" : "Switch to semantic reference search"
|
|
2170
|
-
})]
|
|
2171
|
-
});
|
|
2172
|
-
}
|
|
2173
|
-
function SemanticSearchInput(props) {
|
|
2174
|
-
const {
|
|
2175
|
-
indexConfig,
|
|
2176
|
-
onPathFocus,
|
|
2177
|
-
onChange,
|
|
2178
|
-
readOnly,
|
|
2179
|
-
schemaType,
|
|
2180
|
-
value
|
|
2181
|
-
} = props;
|
|
2182
|
-
const {
|
|
2183
|
-
value: currentDocument
|
|
2184
|
-
} = desk.useDocumentPane();
|
|
2185
|
-
const docRef = require$$0.useRef(currentDocument);
|
|
2186
|
-
const autocompleteRef = require$$0.useRef(null);
|
|
2187
|
-
require$$0.useEffect(() => {
|
|
2188
|
-
docRef.current = currentDocument;
|
|
2189
|
-
}, [currentDocument]);
|
|
2190
|
-
require$$0.useEffect(() => {
|
|
2191
|
-
var _a;
|
|
2192
|
-
if (value == null ? void 0 : value._ref) {
|
|
2193
|
-
(_a = autocompleteRef.current) == null ? void 0 : _a.focus();
|
|
2194
|
-
}
|
|
2195
|
-
}, []);
|
|
2196
|
-
const handleFocus = require$$0.useCallback(() => onPathFocus(["_ref"]), [onPathFocus]);
|
|
2197
|
-
const handleBlur = require$$0.useCallback(() => onPathFocus([]), [onPathFocus]);
|
|
2198
|
-
const handleChange = require$$0.useCallback(result => {
|
|
2199
|
-
if (!result) {
|
|
2200
|
-
onChange(sanity.unset());
|
|
2201
|
-
onPathFocus([]);
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2204
|
-
const patches = [sanity.setIfMissing({}), sanity.set(schemaType.name, ["_type"]), sanity.set(publicId(result.value.documentId), ["_ref"]), sanity.unset(["_weak"]), sanity.unset(["_strengthenOnPublish"])];
|
|
2205
|
-
onChange(patches);
|
|
2206
|
-
onPathFocus([]);
|
|
2207
|
-
}, [onChange, onPathFocus, schemaType.name]);
|
|
2208
|
-
const filterResult = require$$0.useCallback(r => r.value.documentId !== publicId(docRef.current._id), [docRef]);
|
|
2209
|
-
const getEmptySearchValue = require$$0.useCallback(() => JSON.stringify(docRef.current), [docRef]);
|
|
2210
|
-
const typeFilter = require$$0.useMemo(() => schemaType.to.map(refType => refType.name), [schemaType]);
|
|
2211
|
-
return /* @__PURE__ */jsxRuntime.jsx(SemanticSearchAutocomplete, {
|
|
2212
|
-
ref: autocompleteRef,
|
|
2213
|
-
typeFilter,
|
|
2214
|
-
indexConfig,
|
|
2215
|
-
onSelect: handleChange,
|
|
2216
|
-
onFocus: handleFocus,
|
|
2217
|
-
onBlur: handleBlur,
|
|
2218
|
-
getEmptySearchValue,
|
|
2219
|
-
filterResult,
|
|
2220
|
-
readOnly
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
function isType(schemaType, typeName) {
|
|
2224
|
-
if (schemaType.name === typeName) {
|
|
2225
|
-
return true;
|
|
2226
|
-
}
|
|
2227
|
-
if (!schemaType.type) {
|
|
2228
|
-
return false;
|
|
2229
|
-
}
|
|
2230
|
-
return isType(schemaType.type, typeName);
|
|
2231
|
-
}
|
|
2232
|
-
const embeddingsIndexReferenceInput = sanity.definePlugin(defaultConfig => {
|
|
2233
|
-
const config = typeof defaultConfig === "object" ? defaultConfig : void 0;
|
|
2234
|
-
return {
|
|
2235
|
-
name: "@sanity/embeddings-index-reference-input",
|
|
2236
|
-
studio: {
|
|
2237
|
-
components: {
|
|
2238
|
-
layout: props => {
|
|
2239
|
-
return /* @__PURE__ */jsxRuntime.jsx(FeatureEnabledProvider, {
|
|
2240
|
-
children: props.renderDefault(props)
|
|
2241
|
-
});
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
},
|
|
2245
|
-
form: {
|
|
2246
|
-
components: {
|
|
2247
|
-
input: props => {
|
|
2248
|
-
var _a, _b;
|
|
2249
|
-
const embeddingsIndexConfig = (_b = (_a = props.schemaType) == null ? void 0 : _a.options) == null ? void 0 : _b.embeddingsIndex;
|
|
2250
|
-
if (sanity.isObjectInputProps(props) && isType(props.schemaType, "reference") && (embeddingsIndexConfig === true || (embeddingsIndexConfig == null ? void 0 : embeddingsIndexConfig.indexName))) {
|
|
2251
|
-
return /* @__PURE__ */jsxRuntime.jsx(SemanticSearchReferenceInput, {
|
|
2252
|
-
...props,
|
|
2253
|
-
defaultConfig: config
|
|
2254
|
-
});
|
|
2255
|
-
}
|
|
2256
|
-
return props.renderDefault(props);
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
};
|
|
2261
|
-
});
|
|
2262
|
-
const defaultProjection = "{...}";
|
|
2263
|
-
function useDefaultIndex(schema, dataset) {
|
|
2264
|
-
const defaultFilter = require$$0.useMemo(() => "_type in [".concat(schema.getTypeNames().map(n => schema.get(n)).filter(schemaType => Boolean(schemaType && isType(schemaType, "document"))).filter(documentType => !documentType.name.startsWith("sanity.") && !documentType.name.startsWith("assist.") && documentType.name !== "document").map(documentType => '"'.concat(documentType.name, '"')).join(",\n"), "]"), [schema]);
|
|
2265
|
-
return require$$0.useMemo(() => ({
|
|
2266
|
-
dataset,
|
|
2267
|
-
projection: defaultProjection,
|
|
2268
|
-
filter: defaultFilter
|
|
2269
|
-
}), [defaultFilter, dataset]);
|
|
2270
|
-
}
|
|
2271
|
-
function IndexFormInput(props) {
|
|
2272
|
-
var _a;
|
|
2273
|
-
const {
|
|
2274
|
-
label,
|
|
2275
|
-
description,
|
|
2276
|
-
index,
|
|
2277
|
-
prop,
|
|
2278
|
-
onChange,
|
|
2279
|
-
readOnly,
|
|
2280
|
-
placeholder,
|
|
2281
|
-
type
|
|
2282
|
-
} = props;
|
|
2283
|
-
const handleChange = require$$0.useCallback(propValue => onChange(current => ({
|
|
2284
|
-
...current,
|
|
2285
|
-
[prop]: propValue
|
|
2286
|
-
})), [onChange, prop]);
|
|
2287
|
-
return /* @__PURE__ */jsxRuntime.jsx(FormInput, {
|
|
2288
|
-
label,
|
|
2289
|
-
description,
|
|
2290
|
-
onChange: handleChange,
|
|
2291
|
-
value: (_a = index[prop]) != null ? _a : "",
|
|
2292
|
-
readOnly,
|
|
2293
|
-
placeholder,
|
|
2294
|
-
type
|
|
2295
|
-
});
|
|
2296
|
-
}
|
|
2297
|
-
function FormInput(props) {
|
|
2298
|
-
const {
|
|
2299
|
-
label,
|
|
2300
|
-
description,
|
|
2301
|
-
onChange,
|
|
2302
|
-
value,
|
|
2303
|
-
readOnly,
|
|
2304
|
-
placeholder,
|
|
2305
|
-
type = "text"
|
|
2306
|
-
} = props;
|
|
2307
|
-
const id = require$$0.useId();
|
|
2308
|
-
const handleChange = require$$0.useCallback(e => onChange(e.currentTarget.value), [onChange]);
|
|
2309
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2310
|
-
space: 3,
|
|
2311
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2312
|
-
muted: true,
|
|
2313
|
-
htmlFor: id,
|
|
2314
|
-
children: /* @__PURE__ */jsxRuntime.jsx("label", {
|
|
2315
|
-
htmlFor: id,
|
|
2316
|
-
children: label
|
|
2317
|
-
})
|
|
2318
|
-
}), description && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2319
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2320
|
-
size: 1,
|
|
2321
|
-
muted: true,
|
|
2322
|
-
children: description
|
|
2323
|
-
})
|
|
2324
|
-
}), type === "text" ? /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
|
|
2325
|
-
id,
|
|
2326
|
-
value,
|
|
2327
|
-
onChange: handleChange,
|
|
2328
|
-
readOnly,
|
|
2329
|
-
placeholder
|
|
2330
|
-
}) : /* @__PURE__ */jsxRuntime.jsx(ui.TextArea, {
|
|
2331
|
-
id,
|
|
2332
|
-
value,
|
|
2333
|
-
rows: 3,
|
|
2334
|
-
onChange: handleChange,
|
|
2335
|
-
readOnly,
|
|
2336
|
-
placeholder,
|
|
2337
|
-
style: {
|
|
2338
|
-
resize: "vertical"
|
|
2339
|
-
}
|
|
2340
|
-
})]
|
|
2341
|
-
});
|
|
2342
|
-
}
|
|
2343
|
-
function EditIndexDialog(props) {
|
|
2344
|
-
const {
|
|
2345
|
-
open,
|
|
2346
|
-
onClose,
|
|
2347
|
-
onSubmit
|
|
2348
|
-
} = props;
|
|
2349
|
-
const id = require$$0.useId();
|
|
2350
|
-
const ref = require$$0.useRef(null);
|
|
2351
|
-
require$$0.useEffect(() => {
|
|
2352
|
-
if (!open) {
|
|
2353
|
-
return;
|
|
2354
|
-
}
|
|
2355
|
-
setTimeout(() => {
|
|
2356
|
-
var _a, _b;
|
|
2357
|
-
return (_b = (_a = ref.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus();
|
|
2358
|
-
});
|
|
2359
|
-
}, [ref, open]);
|
|
2360
|
-
const handleSubmit = require$$0.useCallback(index => {
|
|
2361
|
-
onSubmit(index);
|
|
2362
|
-
onClose();
|
|
2363
|
-
}, [onSubmit, onClose]);
|
|
2364
|
-
return open ? /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
2365
|
-
id,
|
|
2366
|
-
width: 1,
|
|
2367
|
-
ref,
|
|
2368
|
-
onClose,
|
|
2369
|
-
header: "Create embeddings index",
|
|
2370
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
2371
|
-
padding: 4,
|
|
2372
|
-
space: 5,
|
|
2373
|
-
children: /* @__PURE__ */jsxRuntime.jsx(IndexEditor, {
|
|
2374
|
-
readOnly: false,
|
|
2375
|
-
onSubmit: handleSubmit
|
|
2376
|
-
})
|
|
2377
|
-
})
|
|
2378
|
-
}) : null;
|
|
2379
|
-
}
|
|
2380
|
-
function IndexEditor(props) {
|
|
2381
|
-
var _a;
|
|
2382
|
-
const {
|
|
2383
|
-
readOnly,
|
|
2384
|
-
index: selectedIndex,
|
|
2385
|
-
onSubmit
|
|
2386
|
-
} = props;
|
|
2387
|
-
const client = useApiClient();
|
|
2388
|
-
const schema = sanity.useSchema();
|
|
2389
|
-
const defaultIndex = useDefaultIndex(schema, (_a = client.config().dataset) != null ? _a : "");
|
|
2390
|
-
const [errors, setErrors] = require$$0.useState();
|
|
2391
|
-
const [loading, setLoading] = require$$0.useState();
|
|
2392
|
-
const [index, setIndex] = require$$0.useState(() => ({
|
|
2393
|
-
...defaultIndex,
|
|
2394
|
-
...selectedIndex
|
|
2395
|
-
}));
|
|
2396
|
-
require$$0.useEffect(() => setIndex(selectedIndex != null ? selectedIndex : {
|
|
2397
|
-
...defaultIndex
|
|
2398
|
-
}), [selectedIndex, defaultIndex]);
|
|
2399
|
-
const handleSubmit = require$$0.useCallback(e => {
|
|
2400
|
-
e.preventDefault();
|
|
2401
|
-
if (readOnly) {
|
|
2402
|
-
return;
|
|
2403
|
-
}
|
|
2404
|
-
const validationErrors = [];
|
|
2405
|
-
if (!index.indexName) {
|
|
2406
|
-
validationErrors.push("Index name is required");
|
|
2407
|
-
} else if (!index.indexName.match(/^[a-zA-Z0-9-_]+$/g)) {
|
|
2408
|
-
validationErrors.push("Index name can only contain the letters a-z, numbers - and _");
|
|
2409
|
-
}
|
|
2410
|
-
if (!index.dataset) {
|
|
2411
|
-
validationErrors.push("Dataset is required");
|
|
2412
|
-
}
|
|
2413
|
-
if (!index.filter) {
|
|
2414
|
-
validationErrors.push("Filter is required");
|
|
2415
|
-
}
|
|
2416
|
-
if (!index.projection) {
|
|
2417
|
-
validationErrors.push("Projection is required");
|
|
2418
|
-
}
|
|
2419
|
-
if (validationErrors.length) {
|
|
2420
|
-
setErrors(validationErrors);
|
|
2421
|
-
return;
|
|
2422
|
-
}
|
|
2423
|
-
const {
|
|
2424
|
-
projectId
|
|
2425
|
-
} = client.config();
|
|
2426
|
-
setLoading(true);
|
|
2427
|
-
client.request({
|
|
2428
|
-
method: "POST",
|
|
2429
|
-
url: "/embeddings-index/".concat(index.dataset, "?projectId=").concat(projectId),
|
|
2430
|
-
body: {
|
|
2431
|
-
indexName: index.indexName,
|
|
2432
|
-
projection: index.projection,
|
|
2433
|
-
filter: index.filter
|
|
2434
|
-
}
|
|
2435
|
-
}).then(response => {
|
|
2436
|
-
if (onSubmit) {
|
|
2437
|
-
onSubmit(response.index);
|
|
2438
|
-
}
|
|
2439
|
-
}).catch(err => {
|
|
2440
|
-
console.error(err);
|
|
2441
|
-
setErrors([err.message]);
|
|
2442
|
-
}).finally(() => {
|
|
2443
|
-
setLoading(false);
|
|
2444
|
-
});
|
|
2445
|
-
}, [index, readOnly, onSubmit, client]);
|
|
2446
|
-
return /* @__PURE__ */jsxRuntime.jsx("form", {
|
|
2447
|
-
onSubmit: handleSubmit,
|
|
2448
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2449
|
-
space: 4,
|
|
2450
|
-
children: [(errors == null ? void 0 : errors.length) ? /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2451
|
-
tone: "critical",
|
|
2452
|
-
border: true,
|
|
2453
|
-
padding: 2,
|
|
2454
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2455
|
-
children: /* @__PURE__ */jsxRuntime.jsx("ul", {
|
|
2456
|
-
style: {
|
|
2457
|
-
marginLeft: -10
|
|
2458
|
-
},
|
|
2459
|
-
children: errors == null ? void 0 : errors.map((error, i) => /* @__PURE__ */jsxRuntime.jsx("li", {
|
|
2460
|
-
children: error
|
|
2461
|
-
}, "".concat(error, "-").concat(i)))
|
|
2462
|
-
})
|
|
2463
|
-
})
|
|
2464
|
-
}) : null, /* @__PURE__ */jsxRuntime.jsx(IndexFormInput, {
|
|
2465
|
-
label: "Index name",
|
|
2466
|
-
placeholder: "Name of index without spaces...",
|
|
2467
|
-
index,
|
|
2468
|
-
prop: "indexName",
|
|
2469
|
-
onChange: setIndex,
|
|
2470
|
-
readOnly
|
|
2471
|
-
}), /* @__PURE__ */jsxRuntime.jsx(IndexFormInput, {
|
|
2472
|
-
label: "Dataset",
|
|
2473
|
-
index,
|
|
2474
|
-
prop: "dataset",
|
|
2475
|
-
onChange: setIndex,
|
|
2476
|
-
readOnly: true
|
|
2477
|
-
}), /* @__PURE__ */jsxRuntime.jsx(IndexFormInput, {
|
|
2478
|
-
label: "Filter",
|
|
2479
|
-
description: "Must be a valid GROQ filter",
|
|
2480
|
-
placeholder: defaultIndex.filter,
|
|
2481
|
-
index,
|
|
2482
|
-
prop: "filter",
|
|
2483
|
-
onChange: setIndex,
|
|
2484
|
-
readOnly,
|
|
2485
|
-
type: "textarea"
|
|
2486
|
-
}), /* @__PURE__ */jsxRuntime.jsx(IndexFormInput, {
|
|
2487
|
-
label: "Projection",
|
|
2488
|
-
description: "Must be a valid GROQ projection, starting { and ending with }",
|
|
2489
|
-
placeholder: defaultIndex.projection,
|
|
2490
|
-
index,
|
|
2491
|
-
prop: "projection",
|
|
2492
|
-
onChange: setIndex,
|
|
2493
|
-
readOnly,
|
|
2494
|
-
type: "textarea"
|
|
2495
|
-
}), onSubmit && /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2496
|
-
type: "submit",
|
|
2497
|
-
text: "Create index",
|
|
2498
|
-
icon: loading ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2499
|
-
style: {
|
|
2500
|
-
marginTop: 5
|
|
2501
|
-
},
|
|
2502
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
|
|
2503
|
-
}) : icons.AddIcon,
|
|
2504
|
-
disabled: readOnly || loading,
|
|
2505
|
-
tone: "primary"
|
|
2506
|
-
})]
|
|
2507
|
-
})
|
|
2508
|
-
});
|
|
2509
|
-
}
|
|
2510
|
-
function IndexList(props) {
|
|
2511
|
-
const {
|
|
2512
|
-
loading,
|
|
2513
|
-
selectedIndex,
|
|
2514
|
-
indexes,
|
|
2515
|
-
onIndexSelected
|
|
2516
|
-
} = props;
|
|
2517
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2518
|
-
tone: "default",
|
|
2519
|
-
style: {
|
|
2520
|
-
opacity: loading ? 0.5 : 1
|
|
2521
|
-
},
|
|
2522
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2523
|
-
space: 2,
|
|
2524
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2525
|
-
borderBottom: true,
|
|
2526
|
-
flex: 1,
|
|
2527
|
-
paddingBottom: 2,
|
|
2528
|
-
padding: 3,
|
|
2529
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2530
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2531
|
-
flex: 1,
|
|
2532
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2533
|
-
muted: true,
|
|
2534
|
-
children: "Index name"
|
|
2535
|
-
})
|
|
2536
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2537
|
-
flex: 1,
|
|
2538
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2539
|
-
muted: true,
|
|
2540
|
-
children: "Dataset"
|
|
2541
|
-
})
|
|
2542
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2543
|
-
flex: 1,
|
|
2544
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2545
|
-
muted: true,
|
|
2546
|
-
children: "Status"
|
|
2547
|
-
})
|
|
2548
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2549
|
-
flex: 1,
|
|
2550
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2551
|
-
muted: true,
|
|
2552
|
-
children: "Progress"
|
|
2553
|
-
})
|
|
2554
|
-
})]
|
|
2555
|
-
})
|
|
2556
|
-
}), indexes.length ? /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
2557
|
-
space: 2,
|
|
2558
|
-
style: {
|
|
2559
|
-
maxHeight: 200,
|
|
2560
|
-
overflow: "auto"
|
|
2561
|
-
},
|
|
2562
|
-
children: indexes.map(index => /* @__PURE__ */jsxRuntime.jsx(IndexRow, {
|
|
2563
|
-
selectedIndex,
|
|
2564
|
-
index,
|
|
2565
|
-
onIndexSelected
|
|
2566
|
-
}, index.indexName))
|
|
2567
|
-
}) : /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2568
|
-
muted: true,
|
|
2569
|
-
children: "No indexes found."
|
|
2570
|
-
})]
|
|
2571
|
-
})
|
|
2572
|
-
});
|
|
2573
|
-
}
|
|
2574
|
-
function IndexRow(props) {
|
|
2575
|
-
const {
|
|
2576
|
-
selectedIndex,
|
|
2577
|
-
index,
|
|
2578
|
-
onIndexSelected
|
|
2579
|
-
} = props;
|
|
2580
|
-
const onSelect = require$$0.useCallback(() => onIndexSelected(index), [onIndexSelected, index]);
|
|
2581
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2582
|
-
tone: (selectedIndex == null ? void 0 : selectedIndex.indexName) === index.indexName ? "primary" : "default",
|
|
2583
|
-
mode: (selectedIndex == null ? void 0 : selectedIndex.indexName) === index.indexName ? "default" : "ghost",
|
|
2584
|
-
onClick: onSelect,
|
|
2585
|
-
padding: 3,
|
|
2586
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2587
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2588
|
-
flex: 1,
|
|
2589
|
-
children: /* @__PURE__ */jsxRuntime.jsx("strong", {
|
|
2590
|
-
children: index.indexName
|
|
2591
|
-
})
|
|
2592
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2593
|
-
flex: 1,
|
|
2594
|
-
children: index.dataset
|
|
2595
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2596
|
-
flex: 1,
|
|
2597
|
-
children: index.status
|
|
2598
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Box, {
|
|
2599
|
-
flex: 1,
|
|
2600
|
-
children: [index.startDocumentCount ? Math.floor((index.startDocumentCount - index.remainingDocumentCount) / index.startDocumentCount * 100) : "?", "%"]
|
|
2601
|
-
})]
|
|
2602
|
-
})
|
|
2603
|
-
}, index.indexName);
|
|
1998
|
+
}, [value, ms]), debouncedValue;
|
|
2604
1999
|
}
|
|
2605
2000
|
function QueryIndex(props) {
|
|
2606
|
-
const {
|
|
2607
|
-
indexName
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
resolveIntentLink,
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
button: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2654
|
-
title: "Open index actions",
|
|
2655
|
-
icon: icons.EllipsisVerticalIcon,
|
|
2656
|
-
padding: 2,
|
|
2657
|
-
mode: "ghost"
|
|
2658
|
-
}),
|
|
2659
|
-
id: "button-".concat(selectedIndex.indexName),
|
|
2660
|
-
menu: /* @__PURE__ */jsxRuntime.jsx(ui.Menu, {
|
|
2661
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
2001
|
+
const { indexName } = props, getEmpty = require$$0.useCallback(() => "anything", []), indexConfig = require$$0.useMemo(
|
|
2002
|
+
() => ({ indexName, maxResults: 8 }),
|
|
2003
|
+
[indexName]
|
|
2004
|
+
), { resolveIntentLink, navigateUrl } = router.useRouter(), onSelect = require$$0.useCallback(
|
|
2005
|
+
(hit) => {
|
|
2006
|
+
navigateUrl({
|
|
2007
|
+
path: resolveIntentLink("edit", { id: hit.value.documentId, type: hit.value.type })
|
|
2008
|
+
});
|
|
2009
|
+
},
|
|
2010
|
+
[resolveIntentLink, navigateUrl]
|
|
2011
|
+
);
|
|
2012
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2013
|
+
SemanticSearchAutocomplete,
|
|
2014
|
+
{
|
|
2015
|
+
getEmptySearchValue: getEmpty,
|
|
2016
|
+
indexConfig,
|
|
2017
|
+
onSelect
|
|
2018
|
+
}
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
function IndexInfo({ selectedIndex, onDeleteIndex }) {
|
|
2022
|
+
const handleDelete = require$$0.useCallback(
|
|
2023
|
+
() => onDeleteIndex(selectedIndex),
|
|
2024
|
+
[selectedIndex, onDeleteIndex]
|
|
2025
|
+
);
|
|
2026
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, flex: 1, children: [
|
|
2027
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", flex: 1, gap: 2, children: [
|
|
2028
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Heading, { children: [
|
|
2029
|
+
"Index: ",
|
|
2030
|
+
selectedIndex?.indexName ?? "Untitled"
|
|
2031
|
+
] }) }),
|
|
2032
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2033
|
+
ui.MenuButton,
|
|
2034
|
+
{
|
|
2035
|
+
button: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2036
|
+
ui.Button,
|
|
2037
|
+
{
|
|
2038
|
+
title: "Open index actions",
|
|
2039
|
+
icon: icons.EllipsisVerticalIcon,
|
|
2040
|
+
padding: 2,
|
|
2041
|
+
mode: "ghost"
|
|
2042
|
+
}
|
|
2043
|
+
),
|
|
2044
|
+
id: `button-${selectedIndex.indexName}`,
|
|
2045
|
+
menu: /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2046
|
+
ui.MenuItem,
|
|
2047
|
+
{
|
|
2662
2048
|
text: "Delete index",
|
|
2663
2049
|
icon: icons.TrashIcon,
|
|
2664
2050
|
tone: "critical",
|
|
2665
2051
|
onClick: handleDelete
|
|
2666
|
-
}
|
|
2667
|
-
}),
|
|
2668
|
-
popover: {
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2052
|
+
}
|
|
2053
|
+
) }),
|
|
2054
|
+
popover: { placement: "right" }
|
|
2055
|
+
}
|
|
2056
|
+
) })
|
|
2057
|
+
] }),
|
|
2058
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 6, children: [
|
|
2059
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, flex: 1, style: { maxWidth: 600 }, children: [
|
|
2060
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(IndexEditor, { index: selectedIndex, readOnly: !0 }) }),
|
|
2061
|
+
/* @__PURE__ */ jsxRuntime.jsx(IndexStatus, { selectedIndex })
|
|
2062
|
+
] }),
|
|
2063
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, flex: 1, children: [
|
|
2064
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, children: "Query index" }),
|
|
2065
|
+
/* @__PURE__ */ jsxRuntime.jsx(QueryIndex, { indexName: selectedIndex.indexName }, selectedIndex.indexName)
|
|
2066
|
+
] })
|
|
2067
|
+
] })
|
|
2068
|
+
] });
|
|
2069
|
+
}
|
|
2070
|
+
function IndexStatus({ selectedIndex }) {
|
|
2071
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, flex: 1, children: [
|
|
2072
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
2073
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: 1, muted: !0, children: "Status" }) }),
|
|
2074
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: selectedIndex.status }) })
|
|
2075
|
+
] }),
|
|
2076
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 5, align: "center", children: [
|
|
2077
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: 1, muted: !0, children: "Indexing progress" }) }),
|
|
2078
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
|
|
2079
|
+
selectedIndex.startDocumentCount - selectedIndex.remainingDocumentCount,
|
|
2080
|
+
" /",
|
|
2081
|
+
" ",
|
|
2082
|
+
selectedIndex.startDocumentCount
|
|
2083
|
+
] }) })
|
|
2084
|
+
] }),
|
|
2085
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 5, align: "center", children: [
|
|
2086
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: 1, muted: !0, children: "Failed documents" }) }),
|
|
2087
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: selectedIndex.failedDocumentCount }) })
|
|
2088
|
+
] })
|
|
2089
|
+
] });
|
|
2701
2090
|
}
|
|
2702
|
-
function
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
})
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
flex: 1,
|
|
2746
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
2747
|
-
size: 1,
|
|
2748
|
-
muted: true,
|
|
2749
|
-
children: "Failed documents"
|
|
2750
|
-
})
|
|
2751
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
2752
|
-
space: 2,
|
|
2753
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2754
|
-
children: selectedIndex.failedDocumentCount
|
|
2755
|
-
})
|
|
2756
|
-
})]
|
|
2757
|
-
})]
|
|
2758
|
-
});
|
|
2091
|
+
function IndexList(props) {
|
|
2092
|
+
const { loading, selectedIndex, indexes, onIndexSelected } = props;
|
|
2093
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { tone: "default", style: { opacity: loading ? 0.5 : 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
2094
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { borderBottom: !0, flex: 1, paddingBottom: 2, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [
|
|
2095
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, children: "Index name" }) }),
|
|
2096
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, children: "Dataset" }) }),
|
|
2097
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, children: "Status" }) }),
|
|
2098
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, children: "Progress" }) })
|
|
2099
|
+
] }) }),
|
|
2100
|
+
indexes.length ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, style: { maxHeight: 200, overflow: "auto" }, children: indexes.map((index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2101
|
+
IndexRow,
|
|
2102
|
+
{
|
|
2103
|
+
selectedIndex,
|
|
2104
|
+
index,
|
|
2105
|
+
onIndexSelected
|
|
2106
|
+
},
|
|
2107
|
+
index.indexName
|
|
2108
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, children: "No indexes found." })
|
|
2109
|
+
] }) });
|
|
2110
|
+
}
|
|
2111
|
+
function IndexRow(props) {
|
|
2112
|
+
const { selectedIndex, index, onIndexSelected } = props, onSelect = require$$0.useCallback(() => onIndexSelected(index), [onIndexSelected, index]);
|
|
2113
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2114
|
+
ui.Button,
|
|
2115
|
+
{
|
|
2116
|
+
tone: selectedIndex?.indexName === index.indexName ? "primary" : "default",
|
|
2117
|
+
mode: selectedIndex?.indexName === index.indexName ? "default" : "ghost",
|
|
2118
|
+
onClick: onSelect,
|
|
2119
|
+
padding: 3,
|
|
2120
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [
|
|
2121
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: index.indexName }) }),
|
|
2122
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: index.dataset }),
|
|
2123
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: index.status }),
|
|
2124
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, children: [
|
|
2125
|
+
index.startDocumentCount ? Math.floor(
|
|
2126
|
+
(index.startDocumentCount - index.remainingDocumentCount) / index.startDocumentCount * 100
|
|
2127
|
+
) : "?",
|
|
2128
|
+
"%"
|
|
2129
|
+
] })
|
|
2130
|
+
] })
|
|
2131
|
+
},
|
|
2132
|
+
index.indexName
|
|
2133
|
+
);
|
|
2759
2134
|
}
|
|
2760
2135
|
function EmbeddingsIndexTool() {
|
|
2761
2136
|
const featureState = useIsFeatureEnabled();
|
|
2762
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
padding: 4,
|
|
2769
|
-
children: /* @__PURE__ */jsxRuntime.jsx(FeatureError, {})
|
|
2770
|
-
}) : null, featureState === "disabled" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2771
|
-
padding: 4,
|
|
2772
|
-
children: /* @__PURE__ */jsxRuntime.jsx(FeatureDisabledNotice, {
|
|
2773
|
-
urlSuffix: "?ref=embeddings-tab"
|
|
2774
|
-
})
|
|
2775
|
-
}) : null, featureState === "loading" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2776
|
-
padding: 6,
|
|
2777
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
2778
|
-
size: 4
|
|
2779
|
-
})
|
|
2780
|
-
}) : null, featureState === "enabled" ? /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2781
|
-
flex: 1,
|
|
2782
|
-
style: {
|
|
2783
|
-
maxWidth: 1200
|
|
2784
|
-
},
|
|
2785
|
-
padding: 5,
|
|
2786
|
-
children: /* @__PURE__ */jsxRuntime.jsx(Indexes, {})
|
|
2787
|
-
}) : null]
|
|
2788
|
-
})
|
|
2789
|
-
});
|
|
2137
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "center", flex: 1, children: [
|
|
2138
|
+
featureState === "error" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(FeatureError, {}) }) : null,
|
|
2139
|
+
featureState === "disabled" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(FeatureDisabledNotice, { urlSuffix: "?ref=embeddings-tab" }) }) : null,
|
|
2140
|
+
featureState === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { size: 4 }) }) : null,
|
|
2141
|
+
featureState === "enabled" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { flex: 1, style: { maxWidth: 1200 }, padding: 5, children: /* @__PURE__ */ jsxRuntime.jsx(Indexes, {}) }) : null
|
|
2142
|
+
] }) });
|
|
2790
2143
|
}
|
|
2791
2144
|
const NO_INDEXES = [];
|
|
2792
2145
|
function Indexes() {
|
|
2793
|
-
const client = useApiClient();
|
|
2794
|
-
const [indexes, setIndexes] = require$$0.useState(NO_INDEXES);
|
|
2795
|
-
const [loading, setLoading] = require$$0.useState(false);
|
|
2796
|
-
const [error, setError] = require$$0.useState(false);
|
|
2797
|
-
const [createIndexOpen, setCreateIndexOpen] = require$$0.useState(false);
|
|
2798
|
-
const [selectedIndex, setSelectedIndex] = require$$0.useState(void 0);
|
|
2799
|
-
const onCreateIndexClose = require$$0.useCallback(() => setCreateIndexOpen(false), []);
|
|
2146
|
+
const client = useApiClient(), [indexes, setIndexes] = require$$0.useState(NO_INDEXES), [loading, setLoading] = require$$0.useState(!1), [error, setError] = require$$0.useState(!1), [createIndexOpen, setCreateIndexOpen] = require$$0.useState(!1), [selectedIndex, setSelectedIndex] = require$$0.useState(void 0), onCreateIndexClose = require$$0.useCallback(() => setCreateIndexOpen(!1), []);
|
|
2800
2147
|
require$$0.useEffect(() => {
|
|
2801
|
-
setSelectedIndex(indexes.find(i => i.indexName ===
|
|
2148
|
+
setSelectedIndex(indexes.find((i) => i.indexName === selectedIndex?.indexName));
|
|
2802
2149
|
}, [indexes, selectedIndex]);
|
|
2803
2150
|
const updateIndexes = require$$0.useCallback(() => {
|
|
2804
|
-
setLoading(
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
setIndexes(response);
|
|
2809
|
-
}).catch(e => {
|
|
2810
|
-
console.error(e);
|
|
2811
|
-
setError(true);
|
|
2151
|
+
setLoading(!0), setError(!1), getIndexes(client).then((response) => {
|
|
2152
|
+
setLoading(!1), setIndexes(response);
|
|
2153
|
+
}).catch((e) => {
|
|
2154
|
+
console.error(e), setError(!0);
|
|
2812
2155
|
}).finally(() => {
|
|
2813
|
-
setLoading(
|
|
2156
|
+
setLoading(!1);
|
|
2814
2157
|
});
|
|
2815
|
-
}, [client])
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
}, [client, updateIndexes]);
|
|
2833
|
-
const onSelectIndex = require$$0.useCallback(index => {
|
|
2834
|
-
setSelectedIndex(index);
|
|
2835
|
-
updateIndexes();
|
|
2836
|
-
}, [setSelectedIndex, updateIndexes]);
|
|
2158
|
+
}, [client]), deleteNamedIndex = require$$0.useCallback(
|
|
2159
|
+
(index) => {
|
|
2160
|
+
confirm(`Are you sure you want to delete ${index.indexName} for dataset ${index.dataset}?`) && (setLoading(!0), setError(!1), deleteIndex(index.indexName, client).then(() => {
|
|
2161
|
+
setTimeout(() => updateIndexes());
|
|
2162
|
+
}).catch((e) => {
|
|
2163
|
+
console.error(e), setError(!0);
|
|
2164
|
+
}).finally(() => {
|
|
2165
|
+
setLoading(!1);
|
|
2166
|
+
}));
|
|
2167
|
+
},
|
|
2168
|
+
[client, updateIndexes]
|
|
2169
|
+
), onSelectIndex = require$$0.useCallback(
|
|
2170
|
+
(index) => {
|
|
2171
|
+
setSelectedIndex(index), updateIndexes();
|
|
2172
|
+
},
|
|
2173
|
+
[setSelectedIndex, updateIndexes]
|
|
2174
|
+
);
|
|
2837
2175
|
require$$0.useEffect(() => {
|
|
2838
2176
|
updateIndexes();
|
|
2839
2177
|
}, [updateIndexes]);
|
|
2840
|
-
const openCreate = require$$0.useCallback(() => setCreateIndexOpen(
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
updateIndexes
|
|
2845
|
-
|
|
2846
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
height: 30
|
|
2853
|
-
},
|
|
2854
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2855
|
-
flex: 1,
|
|
2856
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
|
|
2857
|
-
size: 1,
|
|
2858
|
-
children: "Embeddings indexes"
|
|
2859
|
-
})
|
|
2860
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2861
|
-
style: {
|
|
2862
|
-
justifySelf: "flex-end"
|
|
2863
|
-
},
|
|
2864
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2178
|
+
const openCreate = require$$0.useCallback(() => setCreateIndexOpen(!0), []), onSubmit = require$$0.useCallback(
|
|
2179
|
+
(index) => {
|
|
2180
|
+
setIndexes((current) => [...current, index]), setSelectedIndex(index), updateIndexes();
|
|
2181
|
+
},
|
|
2182
|
+
[updateIndexes]
|
|
2183
|
+
);
|
|
2184
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
2185
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", style: { height: 30 }, children: [
|
|
2186
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { size: 1, children: "Embeddings indexes" }) }),
|
|
2187
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { justifySelf: "flex-end" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2188
|
+
ui.Button,
|
|
2189
|
+
{
|
|
2865
2190
|
icon: icons.AddIcon,
|
|
2866
2191
|
text: "New index",
|
|
2867
2192
|
tone: "default",
|
|
2868
2193
|
mode: "ghost",
|
|
2869
2194
|
onClick: openCreate
|
|
2870
|
-
}
|
|
2871
|
-
}),
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
});
|
|
2195
|
+
}
|
|
2196
|
+
) }),
|
|
2197
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2198
|
+
ui.Button,
|
|
2199
|
+
{
|
|
2200
|
+
size: 1,
|
|
2201
|
+
icon: loading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) : icons.UndoIcon,
|
|
2202
|
+
title: "Refresh index list",
|
|
2203
|
+
tone: "default",
|
|
2204
|
+
mode: "bleed",
|
|
2205
|
+
onClick: updateIndexes,
|
|
2206
|
+
disabled: loading
|
|
2207
|
+
}
|
|
2208
|
+
)
|
|
2209
|
+
] }),
|
|
2210
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { tone: "critical", padding: 2, border: !0, children: "An error occurred. See console for details." }) : null,
|
|
2211
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2212
|
+
IndexList,
|
|
2213
|
+
{
|
|
2214
|
+
loading,
|
|
2215
|
+
indexes,
|
|
2216
|
+
selectedIndex,
|
|
2217
|
+
onIndexSelected: onSelectIndex
|
|
2218
|
+
}
|
|
2219
|
+
),
|
|
2220
|
+
selectedIndex && /* @__PURE__ */ jsxRuntime.jsx(IndexInfo, { selectedIndex, onDeleteIndex: deleteNamedIndex }),
|
|
2221
|
+
/* @__PURE__ */ jsxRuntime.jsx(EditIndexDialog, { open: createIndexOpen, onClose: onCreateIndexClose, onSubmit })
|
|
2222
|
+
] });
|
|
2899
2223
|
}
|
|
2900
2224
|
const embeddingsIndexTool = {
|
|
2901
2225
|
name: "embeddings-index",
|
|
2902
2226
|
title: "Embeddings",
|
|
2903
2227
|
icon: icons.EarthGlobeIcon,
|
|
2904
2228
|
component: EmbeddingsIndexTool
|
|
2905
|
-
}
|
|
2906
|
-
const embeddingsIndexDashboard = sanity.definePlugin({
|
|
2229
|
+
}, embeddingsIndexDashboard = sanity.definePlugin({
|
|
2907
2230
|
name: "@sanity/embeddings-index-dashboard",
|
|
2908
2231
|
tools: [embeddingsIndexTool]
|
|
2909
2232
|
});
|
|
2233
|
+
function publicId(id) {
|
|
2234
|
+
return id.replace("drafts.", "");
|
|
2235
|
+
}
|
|
2236
|
+
function useEmeddingsConfig(embeddingsIndexConfig, defaultConfig) {
|
|
2237
|
+
return require$$0.useMemo(() => {
|
|
2238
|
+
if (embeddingsIndexConfig === !0 || !embeddingsIndexConfig) {
|
|
2239
|
+
if (!defaultConfig?.indexName)
|
|
2240
|
+
throw new Error(
|
|
2241
|
+
"Default embeddingsIndex config is missing. When options.embeddingsIndex: true, embeddingsIndexReferenceInput plugin config is required."
|
|
2242
|
+
);
|
|
2243
|
+
return defaultConfig;
|
|
2244
|
+
}
|
|
2245
|
+
const finalConfig = {
|
|
2246
|
+
...defaultConfig,
|
|
2247
|
+
...embeddingsIndexConfig
|
|
2248
|
+
};
|
|
2249
|
+
if (!finalConfig?.indexName)
|
|
2250
|
+
throw new Error(
|
|
2251
|
+
"indexName is missing. Either set it in options.embeddingsIndex or configure defaults using plugin config."
|
|
2252
|
+
);
|
|
2253
|
+
return finalConfig;
|
|
2254
|
+
}, [defaultConfig, embeddingsIndexConfig]);
|
|
2255
|
+
}
|
|
2256
|
+
function SemanticSearchReferenceInput(props) {
|
|
2257
|
+
const embeddingsIndexConfig = props.schemaType?.options?.embeddingsIndex, config2 = useEmeddingsConfig(embeddingsIndexConfig, props.defaultConfig), defaultEnabled = config2.searchMode === "embeddings", featureState = useIsFeatureEnabledContext(), [semantic, setSemantic] = require$$0.useState(defaultEnabled), toggleSemantic = require$$0.useCallback(() => setSemantic((current) => !current), []);
|
|
2258
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, flex: 1, style: { width: "100%" }, children: [
|
|
2259
|
+
semantic && featureState == "loading" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : null,
|
|
2260
|
+
semantic && featureState == "disabled" ? /* @__PURE__ */ jsxRuntime.jsx(FeatureDisabledNotice, { urlSuffix: "?ref=embeddings-ref" }) : null,
|
|
2261
|
+
semantic && featureState === "error" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(FeatureError, {}) }) : null,
|
|
2262
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, style: { maxHeight: 36, overflow: "hidden" }, children: semantic && featureState == "enabled" ? /* @__PURE__ */ jsxRuntime.jsx(SemanticSearchInput, { ...props, indexConfig: config2 }) : props.renderDefault(props) }),
|
|
2263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2264
|
+
ui.Button,
|
|
2265
|
+
{
|
|
2266
|
+
icon: semantic ? icons.EarthGlobeIcon : icons.LinkIcon,
|
|
2267
|
+
onClick: toggleSemantic,
|
|
2268
|
+
mode: "bleed",
|
|
2269
|
+
title: semantic ? "Switch to standard reference search" : "Switch to semantic reference search"
|
|
2270
|
+
}
|
|
2271
|
+
)
|
|
2272
|
+
] });
|
|
2273
|
+
}
|
|
2274
|
+
function SemanticSearchInput(props) {
|
|
2275
|
+
const { indexConfig, onPathFocus, onChange, readOnly, schemaType, value } = props, { value: currentDocument } = desk.useDocumentPane(), docRef = require$$0.useRef(currentDocument), autocompleteRef = require$$0.useRef(null);
|
|
2276
|
+
require$$0.useEffect(() => {
|
|
2277
|
+
docRef.current = currentDocument;
|
|
2278
|
+
}, [currentDocument]), require$$0.useEffect(() => {
|
|
2279
|
+
value?._ref && autocompleteRef.current?.focus();
|
|
2280
|
+
}, []);
|
|
2281
|
+
const handleFocus = require$$0.useCallback(() => onPathFocus(["_ref"]), [onPathFocus]), handleBlur = require$$0.useCallback(() => onPathFocus([]), [onPathFocus]), handleChange = require$$0.useCallback(
|
|
2282
|
+
(result) => {
|
|
2283
|
+
if (!result) {
|
|
2284
|
+
onChange(sanity.unset()), onPathFocus([]);
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const patches = [
|
|
2288
|
+
sanity.setIfMissing({}),
|
|
2289
|
+
sanity.set(schemaType.name, ["_type"]),
|
|
2290
|
+
sanity.set(publicId(result.value.documentId), ["_ref"]),
|
|
2291
|
+
sanity.unset(["_weak"]),
|
|
2292
|
+
sanity.unset(["_strengthenOnPublish"])
|
|
2293
|
+
];
|
|
2294
|
+
onChange(patches), onPathFocus([]);
|
|
2295
|
+
},
|
|
2296
|
+
[onChange, onPathFocus, schemaType.name]
|
|
2297
|
+
), filterResult = require$$0.useCallback(
|
|
2298
|
+
(r) => r.value.documentId !== publicId(docRef.current._id),
|
|
2299
|
+
[docRef]
|
|
2300
|
+
), getEmptySearchValue = require$$0.useCallback(() => JSON.stringify(docRef.current), [docRef]), typeFilter = require$$0.useMemo(
|
|
2301
|
+
() => schemaType.to.map((refType) => refType.name),
|
|
2302
|
+
[schemaType]
|
|
2303
|
+
);
|
|
2304
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2305
|
+
SemanticSearchAutocomplete,
|
|
2306
|
+
{
|
|
2307
|
+
ref: autocompleteRef,
|
|
2308
|
+
typeFilter,
|
|
2309
|
+
indexConfig,
|
|
2310
|
+
onSelect: handleChange,
|
|
2311
|
+
onFocus: handleFocus,
|
|
2312
|
+
onBlur: handleBlur,
|
|
2313
|
+
getEmptySearchValue,
|
|
2314
|
+
filterResult,
|
|
2315
|
+
readOnly
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
const embeddingsIndexReferenceInput = sanity.definePlugin(
|
|
2320
|
+
(defaultConfig) => {
|
|
2321
|
+
const config2 = typeof defaultConfig == "object" ? defaultConfig : void 0;
|
|
2322
|
+
return {
|
|
2323
|
+
name: "@sanity/embeddings-index-reference-input",
|
|
2324
|
+
studio: {
|
|
2325
|
+
components: {
|
|
2326
|
+
layout: (props) => /* @__PURE__ */ jsxRuntime.jsx(FeatureEnabledProvider, { children: props.renderDefault(props) })
|
|
2327
|
+
}
|
|
2328
|
+
},
|
|
2329
|
+
form: {
|
|
2330
|
+
components: {
|
|
2331
|
+
input: (props) => {
|
|
2332
|
+
const embeddingsIndexConfig = props.schemaType?.options?.embeddingsIndex;
|
|
2333
|
+
return sanity.isObjectInputProps(props) && isType(props.schemaType, "reference") && (embeddingsIndexConfig === !0 || embeddingsIndexConfig?.indexName) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2334
|
+
SemanticSearchReferenceInput,
|
|
2335
|
+
{
|
|
2336
|
+
...props,
|
|
2337
|
+
defaultConfig: config2
|
|
2338
|
+
}
|
|
2339
|
+
) : props.renderDefault(props);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
);
|
|
2910
2346
|
exports.deleteIndex = deleteIndex;
|
|
2911
2347
|
exports.embeddingsIndexDashboard = embeddingsIndexDashboard;
|
|
2912
2348
|
exports.embeddingsIndexReferenceInput = embeddingsIndexReferenceInput;
|