@sanity/assist 1.2.16 → 2.0.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/README.md +551 -30
- package/dist/index.cjs.mjs +1 -0
- package/dist/index.d.ts +253 -11
- package/dist/index.esm.js +2385 -373
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2379 -366
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- package/src/_lib/form/DocumentForm.tsx +2 -1
- package/src/_lib/form/constants.ts +1 -0
- package/src/assistDocument/AssistDocumentInput.tsx +24 -4
- package/src/assistDocument/RequestRunInstructionProvider.tsx +37 -21
- package/src/assistDocument/components/instruction/InstructionInput.tsx +5 -4
- package/src/assistDocument/components/instruction/InstructionOutputField.tsx +45 -0
- package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +205 -0
- package/src/assistDocument/hooks/useStudioAssistDocument.ts +5 -32
- package/src/assistFormComponents/AssistField.tsx +11 -5
- package/src/assistFormComponents/AssistFormBlock.tsx +2 -3
- package/src/assistFormComponents/validation/listItem.tsx +2 -2
- package/src/assistInspector/AssistInspector.tsx +6 -0
- package/src/assistInspector/FieldAutocomplete.tsx +1 -0
- package/src/assistInspector/helpers.ts +9 -11
- package/src/assistLayout/AssistLayout.tsx +9 -9
- package/src/components/ImageContext.tsx +19 -9
- package/src/components/SafeValueInput.tsx +4 -1
- package/src/fieldActions/assistFieldActions.tsx +42 -13
- package/src/fieldActions/generateCaptionActions.tsx +2 -2
- package/src/fieldActions/generateImageActions.tsx +57 -0
- package/src/helpers/assistSupported.ts +10 -16
- package/src/helpers/conditionalMembers.test.ts +200 -0
- package/src/helpers/conditionalMembers.ts +127 -0
- package/src/helpers/typeUtils.ts +19 -5
- package/src/index.ts +3 -0
- package/src/plugin.tsx +14 -5
- package/src/schemas/assistDocumentSchema.tsx +40 -1
- package/src/schemas/serialize/serializeSchema.test.ts +239 -8
- package/src/schemas/serialize/serializeSchema.ts +77 -10
- package/src/schemas/typeDefExtensions.ts +89 -5
- package/src/translate/FieldTranslationProvider.tsx +360 -0
- package/src/translate/getLanguageParams.ts +26 -0
- package/src/translate/languageStore.ts +18 -0
- package/src/translate/paths.test.ts +133 -0
- package/src/translate/paths.ts +175 -0
- package/src/translate/translateActions.tsx +188 -0
- package/src/translate/types.ts +160 -0
- package/src/types.ts +33 -12
- package/src/useApiClient.ts +130 -2
- package/src/assistLayout/AlphaMigration.tsx +0 -310
- package/src/legacy-types.ts +0 -72
package/dist/index.esm.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches,
|
|
3
|
-
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
2
|
+
import { useClient, isArraySchemaType, typed, useSchema, isKeySegment, isDocumentSchemaType, pathToString, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, isObjectSchemaType, stringToPath as stringToPath$2, useEditState, useCurrentUser, StatusButton, FormFieldHeaderText, PatchEvent, unset, set, useFormCallbacks, FormCallbacksProvider, FormInput, setIfMissing, insert, PresenceOverlay, VirtualizerScrollInstanceProvider, useColorSchemeValue, ObjectInputMember, defineType, defineField, defineArrayMember, isArrayOfObjectsSchemaType, getPublishedId, useSyncState, definePlugin } from 'sanity';
|
|
3
|
+
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, Checkbox, Radio, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { useState, useRef, useEffect, useMemo, useCallback, createContext, useReducer, forwardRef, createElement, useContext, useId } from 'react';
|
|
5
|
-
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, ControlsIcon } from '@sanity/icons';
|
|
5
|
+
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, TranslateIcon, ControlsIcon } from '@sanity/icons';
|
|
6
6
|
import { mergeMap, share, take, filter, distinctUntilChanged, catchError, tap } from 'rxjs/operators';
|
|
7
7
|
import isEqual from 'react-fast-compare';
|
|
8
8
|
import { throwError, of, partition, merge, switchMap, delay, defer } from 'rxjs';
|
|
9
9
|
import { exhaustMapToWithTrailing } from 'rxjs-exhaustmap-with-trailing';
|
|
10
|
-
import { useDocumentPane, usePaneRouter, DocumentInspectorHeader, DocumentPaneProvider } from 'sanity/desk';
|
|
11
10
|
import { extractWithPath } from '@sanity/mutator';
|
|
11
|
+
import { useDocumentPane, usePaneRouter, DocumentInspectorHeader, DocumentPaneProvider } from 'sanity/desk';
|
|
12
12
|
import styled, { keyframes } from 'styled-components';
|
|
13
13
|
import { minutesToMilliseconds, isAfter, addSeconds } from 'date-fns';
|
|
14
14
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
|
@@ -28,6 +28,8 @@ const instructionTaskTypeName = "sanity.assist.instructionTask";
|
|
|
28
28
|
const fieldPresenceTypeName = "sanity.assist.instructionTask.presence";
|
|
29
29
|
const assistSerializedTypeName = "sanity.assist.serialized.type";
|
|
30
30
|
const assistSerializedFieldTypeName = "sanity.assist.serialized.field";
|
|
31
|
+
const outputFieldTypeName = "sanity.assist.output.field";
|
|
32
|
+
const outputTypeTypeName = "sanity.assist.output.type";
|
|
31
33
|
const fieldPathParam = "pathKey";
|
|
32
34
|
const instructionParam = "instruction";
|
|
33
35
|
const documentRootKey = "<document>";
|
|
@@ -124,49 +126,59 @@ function isType(schemaType, typeName) {
|
|
|
124
126
|
function isImage(schemaType) {
|
|
125
127
|
return isType(schemaType, "image");
|
|
126
128
|
}
|
|
127
|
-
function
|
|
128
|
-
var _a;
|
|
129
|
+
function getDescriptionFieldOption(schemaType) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
if (!schemaType) {
|
|
132
|
+
return void 0;
|
|
133
|
+
}
|
|
134
|
+
const descriptionField = (_b = (_a = schemaType.options) == null ? void 0 : _a.aiAssist) == null ? void 0 : _b.imageDescriptionField;
|
|
135
|
+
if (descriptionField) {
|
|
136
|
+
return descriptionField;
|
|
137
|
+
}
|
|
138
|
+
return getDescriptionFieldOption(schemaType.type);
|
|
139
|
+
}
|
|
140
|
+
function getImageInstructionFieldOption(schemaType) {
|
|
141
|
+
var _a, _b;
|
|
129
142
|
if (!schemaType) {
|
|
130
143
|
return void 0;
|
|
131
144
|
}
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
145
|
+
const imageInstructionField = (_b = (_a = schemaType.options) == null ? void 0 : _a.aiAssist) == null ? void 0 : _b.imageInstructionField;
|
|
146
|
+
if (imageInstructionField) {
|
|
147
|
+
return imageInstructionField;
|
|
135
148
|
}
|
|
136
|
-
return
|
|
149
|
+
return getImageInstructionFieldOption(schemaType.type);
|
|
137
150
|
}
|
|
138
151
|
function isSchemaAssistEnabled(type) {
|
|
139
152
|
var _a, _b;
|
|
140
|
-
return !((_b = (_a = type.options) == null ? void 0 : _a.
|
|
153
|
+
return !((_b = (_a = type.options) == null ? void 0 : _a.aiAssist) == null ? void 0 : _b.exclude);
|
|
141
154
|
}
|
|
142
155
|
function isAssistSupported(type) {
|
|
143
|
-
let allowReadonlyHidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
144
156
|
if (!isSchemaAssistEnabled(type)) {
|
|
145
157
|
return false;
|
|
146
158
|
}
|
|
147
|
-
if (isDisabled(type
|
|
159
|
+
if (isDisabled(type)) {
|
|
148
160
|
return false;
|
|
149
161
|
}
|
|
150
162
|
if (type.jsonType === "array") {
|
|
151
|
-
const unsupportedArray = type.of.every(t => isDisabled(t
|
|
163
|
+
const unsupportedArray = type.of.every(t => isDisabled(t));
|
|
152
164
|
return !unsupportedArray;
|
|
153
165
|
}
|
|
154
166
|
if (type.jsonType === "object") {
|
|
155
|
-
const unsupportedObject = type.fields.every(field => isDisabled(field.type
|
|
167
|
+
const unsupportedObject = type.fields.every(field => isDisabled(field.type));
|
|
156
168
|
return !unsupportedObject;
|
|
157
169
|
}
|
|
158
170
|
return true;
|
|
159
171
|
}
|
|
160
|
-
function isDisabled(type
|
|
161
|
-
|
|
162
|
-
return !isSchemaAssistEnabled(type) || isUnsupportedType(type) || !allowReadonlyHidden && readonlyHidden;
|
|
172
|
+
function isDisabled(type) {
|
|
173
|
+
return !isSchemaAssistEnabled(type) || isUnsupportedType(type);
|
|
163
174
|
}
|
|
164
175
|
function isUnsupportedType(type) {
|
|
165
|
-
|
|
176
|
+
var _a, _b;
|
|
177
|
+
return type.jsonType === "number" || type.name === "sanity.imageCrop" || type.name === "sanity.imageHotspot" || isType(type, "reference") && !((_b = (_a = type == null ? void 0 : type.options) == null ? void 0 : _a.aiAssist) == null ? void 0 : _b.embeddingsIndex) || isType(type, "crossDatasetReference") || isType(type, "slug") || isType(type, "url") || isType(type, "date") || isType(type, "datetime") || isType(type, "file");
|
|
166
178
|
}
|
|
167
179
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
168
180
|
function serializeSchema(schema, options) {
|
|
169
|
-
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).
|
|
181
|
+
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).map(t => getSchemaStub(t, schema, options)).filter(t => {
|
|
170
182
|
if ("to" in t && t.to && !t.to.length) {
|
|
171
183
|
return false;
|
|
172
184
|
}
|
|
@@ -204,26 +216,41 @@ function getSchemaStub(schemaType, schema, options) {
|
|
|
204
216
|
return removeUndef(baseSchema);
|
|
205
217
|
}
|
|
206
218
|
function getBaseFields(schema, type, typeName, options) {
|
|
207
|
-
var _a, _b, _c;
|
|
208
|
-
const
|
|
219
|
+
var _a, _b, _c, _d, _e, _f;
|
|
220
|
+
const schemaOptions = removeUndef({
|
|
221
|
+
imagePromptField: (_b = (_a = type.options) == null ? void 0 : _a.aiAssist) == null ? void 0 : _b.imageInstructionField,
|
|
222
|
+
embeddingsIndex: (_d = (_c = type.options) == null ? void 0 : _c.aiAssist) == null ? void 0 : _d.embeddingsIndex
|
|
223
|
+
});
|
|
209
224
|
return removeUndef({
|
|
210
|
-
options:
|
|
211
|
-
|
|
212
|
-
} : void 0,
|
|
213
|
-
values: Array.isArray((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
|
|
225
|
+
options: Object.keys(schemaOptions).length ? schemaOptions : void 0,
|
|
226
|
+
values: Array.isArray((_e = type == null ? void 0 : type.options) == null ? void 0 : _e.list) ? (_f = type == null ? void 0 : type.options) == null ? void 0 : _f.list.map(v => {
|
|
214
227
|
var _a2;
|
|
215
228
|
return typeof v === "string" ? v : (_a2 = v.value) != null ? _a2 : "".concat(v.title);
|
|
216
229
|
}) : void 0,
|
|
217
230
|
of: "of" in type && typeName === "array" ? arrayOf(type, schema, options) : void 0,
|
|
218
231
|
to: "to" in type && typeName === "reference" ? refToTypeNames(type) : void 0,
|
|
219
|
-
fields: "fields" in type && inlineTypes.includes(typeName) ? serializeFields(schema, type, options) : void 0
|
|
232
|
+
fields: "fields" in type && inlineTypes.includes(typeName) ? serializeFields(schema, type, options) : void 0,
|
|
233
|
+
annotations: typeName === "block" && "fields" in type ? serializeAnnotations(type, schema, options) : void 0,
|
|
234
|
+
inlineOf: typeName === "block" && "fields" in type ? serializeInlineOf(type, schema, options) : void 0,
|
|
235
|
+
hidden: typeof type.hidden === "function" ? "function" : type.hidden ? true : void 0,
|
|
236
|
+
readOnly: typeof type.readOnly === "function" ? "function" : type.readOnly ? true : void 0
|
|
220
237
|
});
|
|
221
238
|
}
|
|
222
239
|
function serializeFields(schema, schemaType, options) {
|
|
223
|
-
|
|
240
|
+
const fields = schemaType.fieldsets ? schemaType.fieldsets.flatMap(fs => fs.single ? fs.field : fs.fields.map(f => ({
|
|
241
|
+
...f,
|
|
242
|
+
type: {
|
|
243
|
+
...f.type,
|
|
244
|
+
// if fieldset is (conditionally) hidden, the field must be considered the same way
|
|
245
|
+
// ie, if the field does not show up in conditionalMembers, it is hidden
|
|
246
|
+
// regardless of weather or not it is the field function or the fieldset function that hides it
|
|
247
|
+
hidden: typeof fs.hidden === "function" ? fs.hidden : fs.hidden ? true : f.type.hidden
|
|
248
|
+
}
|
|
249
|
+
}))) : schemaType.fields;
|
|
250
|
+
return fields.filter(f => {
|
|
224
251
|
var _a, _b;
|
|
225
252
|
return !["sanity.imageHotspot", "sanity.imageCrop"].includes((_b = (_a = f.type) == null ? void 0 : _a.name) != null ? _b : "");
|
|
226
|
-
}).filter(f => isAssistSupported(f.type)).
|
|
253
|
+
}).filter(f => isAssistSupported(f.type)).map(field => serializeMember(schema, field.type, field.name, options));
|
|
227
254
|
}
|
|
228
255
|
function serializeMember(schema, type, name, options) {
|
|
229
256
|
var _a, _b;
|
|
@@ -239,6 +266,25 @@ function serializeMember(schema, type, name, options) {
|
|
|
239
266
|
...getBaseFields(schema, type, typeName, options)
|
|
240
267
|
});
|
|
241
268
|
}
|
|
269
|
+
function serializeInlineOf(blockSchemaType, schema, options) {
|
|
270
|
+
const childrenField = blockSchemaType.fields.find(f => f.name === "children");
|
|
271
|
+
const childrenType = childrenField == null ? void 0 : childrenField.type;
|
|
272
|
+
if (!childrenType || !isArraySchemaType(childrenType)) {
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
return arrayOf({
|
|
276
|
+
...childrenType,
|
|
277
|
+
of: childrenType.of.filter(t => !isType(t, "span"))
|
|
278
|
+
}, schema, options);
|
|
279
|
+
}
|
|
280
|
+
function serializeAnnotations(blockSchemaType, schema, options) {
|
|
281
|
+
const markDefs = blockSchemaType.fields.find(f => f.name === "markDefs");
|
|
282
|
+
const marksType = markDefs == null ? void 0 : markDefs.type;
|
|
283
|
+
if (!marksType || !isArraySchemaType(marksType)) {
|
|
284
|
+
return void 0;
|
|
285
|
+
}
|
|
286
|
+
return arrayOf(marksType, schema, options);
|
|
287
|
+
}
|
|
242
288
|
function arrayOf(arrayType, schema, options) {
|
|
243
289
|
return arrayType.of.filter(type => isAssistSupported(type)).map(t => {
|
|
244
290
|
return serializeMember(schema, t, t.name, options);
|
|
@@ -357,7 +403,111 @@ function SchemaEntry(_ref) {
|
|
|
357
403
|
children: out
|
|
358
404
|
});
|
|
359
405
|
}
|
|
406
|
+
const MAX_DEPTH$1 = 6;
|
|
407
|
+
function getDocumentMembersFlat(doc, schemaType) {
|
|
408
|
+
if (!isDocumentSchemaType(schemaType)) {
|
|
409
|
+
console.error("Schema type is not a document");
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
return extractPaths(doc, schemaType, [], MAX_DEPTH$1);
|
|
413
|
+
}
|
|
414
|
+
function extractPaths(doc, schemaType, path, maxDepth) {
|
|
415
|
+
if (path.length >= maxDepth) {
|
|
416
|
+
return [];
|
|
417
|
+
}
|
|
418
|
+
return schemaType.fields.reduce((acc, field) => {
|
|
419
|
+
var _a, _b;
|
|
420
|
+
const fieldPath = [...path, field.name];
|
|
421
|
+
const fieldSchema = field.type;
|
|
422
|
+
const {
|
|
423
|
+
value
|
|
424
|
+
} = (_a = extractWithPath(pathToString(fieldPath), doc)[0]) != null ? _a : {};
|
|
425
|
+
if (!value) {
|
|
426
|
+
return acc;
|
|
427
|
+
}
|
|
428
|
+
const thisFieldWithPath = {
|
|
429
|
+
path: fieldPath,
|
|
430
|
+
name: field.name,
|
|
431
|
+
schemaType: fieldSchema,
|
|
432
|
+
value
|
|
433
|
+
};
|
|
434
|
+
if (fieldSchema.jsonType === "object") {
|
|
435
|
+
const innerFields = extractPaths(doc, fieldSchema, fieldPath, maxDepth);
|
|
436
|
+
return [...acc, thisFieldWithPath, ...innerFields];
|
|
437
|
+
} else if (fieldSchema.jsonType === "array" && fieldSchema.of.length && fieldSchema.of.some(item => "fields" in item)) {
|
|
438
|
+
const {
|
|
439
|
+
value: arrayValue
|
|
440
|
+
} = (_b = extractWithPath(pathToString(fieldPath), doc)[0]) != null ? _b : {};
|
|
441
|
+
let arrayPaths = [];
|
|
442
|
+
if (arrayValue == null ? void 0 : arrayValue.length) {
|
|
443
|
+
for (const item of arrayValue) {
|
|
444
|
+
const itemPath = [...fieldPath, {
|
|
445
|
+
_key: item._key
|
|
446
|
+
}];
|
|
447
|
+
let itemSchema = fieldSchema.of.find(t => t.name === item._type);
|
|
448
|
+
if (!item._type) {
|
|
449
|
+
itemSchema = fieldSchema.of[0];
|
|
450
|
+
console.warn("Array item is missing _type - using the first defined type in the array.of schema", {
|
|
451
|
+
itemPath,
|
|
452
|
+
item,
|
|
453
|
+
itemSchema
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (item._key && itemSchema) {
|
|
457
|
+
const innerFields = extractPaths(doc, itemSchema, itemPath, maxDepth);
|
|
458
|
+
const arrayMember = {
|
|
459
|
+
path: itemPath,
|
|
460
|
+
name: item._key,
|
|
461
|
+
schemaType: itemSchema,
|
|
462
|
+
value: item
|
|
463
|
+
};
|
|
464
|
+
arrayPaths = [...arrayPaths, arrayMember, ...innerFields];
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return [...acc, thisFieldWithPath, ...arrayPaths];
|
|
469
|
+
}
|
|
470
|
+
return [...acc, thisFieldWithPath];
|
|
471
|
+
}, []);
|
|
472
|
+
}
|
|
473
|
+
const defaultLanguageOutputs = function (member, enclosingType, translateFromLanguageId, translateToLanguageIds) {
|
|
474
|
+
if (member.schemaType.jsonType === "object" && member.schemaType.name.startsWith("internationalizedArray")) {
|
|
475
|
+
const pathEnd = member.path.slice(-1);
|
|
476
|
+
const language = isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null;
|
|
477
|
+
return language === translateFromLanguageId ? translateToLanguageIds.map(translateToId => ({
|
|
478
|
+
id: translateToId,
|
|
479
|
+
outputPath: [...member.path.slice(0, -1), {
|
|
480
|
+
_key: translateToId
|
|
481
|
+
}]
|
|
482
|
+
})) : void 0;
|
|
483
|
+
}
|
|
484
|
+
if (enclosingType.jsonType === "object" && enclosingType.name.startsWith("locale")) {
|
|
485
|
+
return translateFromLanguageId === member.name ? translateToLanguageIds.map(translateToId => ({
|
|
486
|
+
id: translateToId,
|
|
487
|
+
outputPath: [...member.path.slice(0, -1), translateToId]
|
|
488
|
+
})) : void 0;
|
|
489
|
+
}
|
|
490
|
+
return void 0;
|
|
491
|
+
};
|
|
492
|
+
function getFieldLanguageMap(documentSchema, documentMembers, translateFromLanguageId, outputLanguageIds, langFn) {
|
|
493
|
+
var _a, _b, _c;
|
|
494
|
+
const translationMaps = [];
|
|
495
|
+
for (const member of documentMembers) {
|
|
496
|
+
const parentPath = member.path.slice(0, -1);
|
|
497
|
+
const enclosingType = (_b = (_a = documentMembers.find(m => pathToString(m.path) === pathToString(parentPath))) == null ? void 0 : _a.schemaType) != null ? _b : documentSchema;
|
|
498
|
+
const translations = (_c = langFn(member, enclosingType, translateFromLanguageId, outputLanguageIds)) == null ? void 0 : _c.filter(translation => translation.id !== translateFromLanguageId);
|
|
499
|
+
if (translations) {
|
|
500
|
+
translationMaps.push({
|
|
501
|
+
inputLanguageId: translateFromLanguageId,
|
|
502
|
+
inputPath: member.path,
|
|
503
|
+
outputs: translations
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return translationMaps;
|
|
508
|
+
}
|
|
360
509
|
const aiInspectorId = "ai-assistance";
|
|
510
|
+
const assistFormId = "assist";
|
|
361
511
|
const preventDefault = ev => ev.preventDefault();
|
|
362
512
|
function DocumentForm(props) {
|
|
363
513
|
var _a;
|
|
@@ -453,7 +603,7 @@ function DocumentForm(props) {
|
|
|
453
603
|
changed: formState.changed,
|
|
454
604
|
focused: formState.focused,
|
|
455
605
|
groups: formState.groups,
|
|
456
|
-
id:
|
|
606
|
+
id: assistFormId,
|
|
457
607
|
members: formState.members,
|
|
458
608
|
onChange,
|
|
459
609
|
onFieldGroupSelect: onSetActiveFieldGroup,
|
|
@@ -551,7 +701,7 @@ function getFieldRefs(schemaType, parent) {
|
|
|
551
701
|
};
|
|
552
702
|
const fields = field.type.jsonType === "object" ? getFieldRefs(field.type, fieldRef, depth + 1) : [];
|
|
553
703
|
const syntheticFields = field.type.jsonType === "array" ? getSyntheticFields(field.type, fieldRef, depth + 1) : [];
|
|
554
|
-
if (!isAssistSupported(field.type
|
|
704
|
+
if (!isAssistSupported(field.type)) {
|
|
555
705
|
return [...fields, ...syntheticFields];
|
|
556
706
|
}
|
|
557
707
|
return [fieldRef, ...fields, ...syntheticFields];
|
|
@@ -578,7 +728,7 @@ function getSyntheticFields(schemaType, parent) {
|
|
|
578
728
|
synthetic: true
|
|
579
729
|
};
|
|
580
730
|
const fields = itemType.jsonType === "object" ? getFieldRefs(itemType, fieldRef, depth + 1) : [];
|
|
581
|
-
if (!isAssistSupported(itemType
|
|
731
|
+
if (!isAssistSupported(itemType)) {
|
|
582
732
|
return fields;
|
|
583
733
|
}
|
|
584
734
|
return [fieldRef, ...fields];
|
|
@@ -588,7 +738,7 @@ function getTypePath(doc, pathString) {
|
|
|
588
738
|
if (!pathString) {
|
|
589
739
|
return void 0;
|
|
590
740
|
}
|
|
591
|
-
const path = stringToPath(pathString);
|
|
741
|
+
const path = stringToPath$2(pathString);
|
|
592
742
|
const currentPath = [];
|
|
593
743
|
let valid = true;
|
|
594
744
|
const syntheticPath = path.map(segment => {
|
|
@@ -667,7 +817,6 @@ function useStudioAssistDocument(_ref2) {
|
|
|
667
817
|
} = _ref2;
|
|
668
818
|
const documentTypeName = schemaType.name;
|
|
669
819
|
const currentUser = useCurrentUser();
|
|
670
|
-
const validation = useValidationStatus(publicId(documentId), schemaType.name).validation;
|
|
671
820
|
const assistDocument = useDocumentState(assistDocumentId(documentTypeName), assistDocumentTypeName);
|
|
672
821
|
const assistTasksStatus = useDocumentState(assistTasksStatusId(documentId != null ? documentId : ""), assistTasksStatusTypeName);
|
|
673
822
|
const client = useClient({
|
|
@@ -692,7 +841,7 @@ function useStudioAssistDocument(_ref2) {
|
|
|
692
841
|
return {
|
|
693
842
|
...assistField,
|
|
694
843
|
tasks: tasks.filter(task => task.path === assistField.path),
|
|
695
|
-
instructions: (_a2 = assistField.instructions) == null ? void 0 : _a2.filter(p => !p.userId || p.userId === (currentUser == null ? void 0 : currentUser.id)).map(instruction => asStudioInstruction(instruction, tasks
|
|
844
|
+
instructions: (_a2 = assistField.instructions) == null ? void 0 : _a2.filter(p => !p.userId || p.userId === (currentUser == null ? void 0 : currentUser.id)).map(instruction => asStudioInstruction(instruction, tasks))
|
|
696
845
|
};
|
|
697
846
|
});
|
|
698
847
|
return typed({
|
|
@@ -707,21 +856,12 @@ function useStudioAssistDocument(_ref2) {
|
|
|
707
856
|
}),
|
|
708
857
|
fields
|
|
709
858
|
});
|
|
710
|
-
}, [assistDocument, assistTasksStatus, currentUser
|
|
859
|
+
}, [assistDocument, assistTasksStatus, currentUser]);
|
|
711
860
|
}
|
|
712
|
-
function asStudioInstruction(instruction, run
|
|
713
|
-
var _a;
|
|
714
|
-
const errors = validation.filter(marker => marker.level === "error");
|
|
715
|
-
const fieldRefs = ((_a = instruction == null ? void 0 : instruction.prompt) != null ? _a : []).flatMap(block => {
|
|
716
|
-
if (block._type === "block") {
|
|
717
|
-
return block.children.filter(c => c._type === fieldReferenceTypeName);
|
|
718
|
-
}
|
|
719
|
-
return [];
|
|
720
|
-
});
|
|
861
|
+
function asStudioInstruction(instruction, run) {
|
|
721
862
|
return {
|
|
722
863
|
...instruction,
|
|
723
|
-
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
724
|
-
validation: errors.filter(marker => fieldRefs.map(r => r.path).filter(p => !!p).find(path => pathToString(marker.path) === path))
|
|
864
|
+
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
725
865
|
};
|
|
726
866
|
}
|
|
727
867
|
function useInterval(ms) {
|
|
@@ -965,6 +1105,54 @@ function useApiClient(customApiClient) {
|
|
|
965
1105
|
});
|
|
966
1106
|
return useMemo(() => customApiClient ? customApiClient(client) : client, [client, customApiClient]);
|
|
967
1107
|
}
|
|
1108
|
+
function useTranslate(apiClient) {
|
|
1109
|
+
const [loading, setLoading] = useState(false);
|
|
1110
|
+
const user = useCurrentUser();
|
|
1111
|
+
const schema = useSchema();
|
|
1112
|
+
const types = useMemo(() => serializeSchema(schema, {
|
|
1113
|
+
leanFormat: true
|
|
1114
|
+
}), [schema]);
|
|
1115
|
+
const toast = useToast();
|
|
1116
|
+
const translate = useCallback(_ref4 => {
|
|
1117
|
+
let {
|
|
1118
|
+
documentId,
|
|
1119
|
+
languagePath,
|
|
1120
|
+
translatePath,
|
|
1121
|
+
fieldLanguageMap,
|
|
1122
|
+
conditionalMembers
|
|
1123
|
+
} = _ref4;
|
|
1124
|
+
setLoading(true);
|
|
1125
|
+
return apiClient.request({
|
|
1126
|
+
method: "POST",
|
|
1127
|
+
url: "/assist/tasks/translate/".concat(apiClient.config().dataset, "?projectId=").concat(apiClient.config().projectId),
|
|
1128
|
+
body: {
|
|
1129
|
+
documentId,
|
|
1130
|
+
types,
|
|
1131
|
+
languagePath,
|
|
1132
|
+
fieldLanguageMap,
|
|
1133
|
+
conditionalMembers,
|
|
1134
|
+
translatePath: translatePath.length === 0 ? documentRootKey : pathToString(translatePath),
|
|
1135
|
+
userId: user == null ? void 0 : user.id
|
|
1136
|
+
}
|
|
1137
|
+
}).catch(e => {
|
|
1138
|
+
toast.push({
|
|
1139
|
+
status: "error",
|
|
1140
|
+
title: "Translate failed",
|
|
1141
|
+
description: e.message
|
|
1142
|
+
});
|
|
1143
|
+
setLoading(false);
|
|
1144
|
+
throw e;
|
|
1145
|
+
}).finally(() => {
|
|
1146
|
+
setTimeout(() => {
|
|
1147
|
+
setLoading(false);
|
|
1148
|
+
}, 2e3);
|
|
1149
|
+
});
|
|
1150
|
+
}, [setLoading, apiClient, toast, user, types]);
|
|
1151
|
+
return useMemo(() => ({
|
|
1152
|
+
translate,
|
|
1153
|
+
loading
|
|
1154
|
+
}), [translate, loading]);
|
|
1155
|
+
}
|
|
968
1156
|
function useGenerateCaption(apiClient) {
|
|
969
1157
|
const [loading, setLoading] = useState(false);
|
|
970
1158
|
const user = useCurrentUser();
|
|
@@ -973,11 +1161,11 @@ function useGenerateCaption(apiClient) {
|
|
|
973
1161
|
leanFormat: true
|
|
974
1162
|
}), [schema]);
|
|
975
1163
|
const toast = useToast();
|
|
976
|
-
const generateCaption = useCallback(
|
|
1164
|
+
const generateCaption = useCallback(_ref5 => {
|
|
977
1165
|
let {
|
|
978
1166
|
path,
|
|
979
1167
|
documentId
|
|
980
|
-
} =
|
|
1168
|
+
} = _ref5;
|
|
981
1169
|
setLoading(true);
|
|
982
1170
|
return apiClient.request({
|
|
983
1171
|
method: "POST",
|
|
@@ -991,7 +1179,7 @@ function useGenerateCaption(apiClient) {
|
|
|
991
1179
|
}).catch(e => {
|
|
992
1180
|
toast.push({
|
|
993
1181
|
status: "error",
|
|
994
|
-
title: "Generate
|
|
1182
|
+
title: "Generate image description failed",
|
|
995
1183
|
description: e.message
|
|
996
1184
|
});
|
|
997
1185
|
setLoading(false);
|
|
@@ -1007,6 +1195,48 @@ function useGenerateCaption(apiClient) {
|
|
|
1007
1195
|
loading
|
|
1008
1196
|
}), [generateCaption, loading]);
|
|
1009
1197
|
}
|
|
1198
|
+
function useGenerateImage(apiClient) {
|
|
1199
|
+
const [loading, setLoading] = useState(false);
|
|
1200
|
+
const user = useCurrentUser();
|
|
1201
|
+
const schema = useSchema();
|
|
1202
|
+
const types = useMemo(() => serializeSchema(schema, {
|
|
1203
|
+
leanFormat: true
|
|
1204
|
+
}), [schema]);
|
|
1205
|
+
const toast = useToast();
|
|
1206
|
+
const generateImage = useCallback(_ref6 => {
|
|
1207
|
+
let {
|
|
1208
|
+
path,
|
|
1209
|
+
documentId
|
|
1210
|
+
} = _ref6;
|
|
1211
|
+
setLoading(true);
|
|
1212
|
+
return apiClient.request({
|
|
1213
|
+
method: "POST",
|
|
1214
|
+
url: "/assist/tasks/generate-image/".concat(apiClient.config().dataset, "?projectId=").concat(apiClient.config().projectId),
|
|
1215
|
+
body: {
|
|
1216
|
+
path,
|
|
1217
|
+
documentId,
|
|
1218
|
+
types,
|
|
1219
|
+
userId: user == null ? void 0 : user.id
|
|
1220
|
+
}
|
|
1221
|
+
}).catch(e => {
|
|
1222
|
+
toast.push({
|
|
1223
|
+
status: "error",
|
|
1224
|
+
title: "Generate image from prompt failed",
|
|
1225
|
+
description: e.message
|
|
1226
|
+
});
|
|
1227
|
+
setLoading(false);
|
|
1228
|
+
throw e;
|
|
1229
|
+
}).finally(() => {
|
|
1230
|
+
setTimeout(() => {
|
|
1231
|
+
setLoading(false);
|
|
1232
|
+
}, 2e3);
|
|
1233
|
+
});
|
|
1234
|
+
}, [setLoading, apiClient, toast, user, types]);
|
|
1235
|
+
return useMemo(() => ({
|
|
1236
|
+
generateImage,
|
|
1237
|
+
loading
|
|
1238
|
+
}), [generateImage, loading]);
|
|
1239
|
+
}
|
|
1010
1240
|
function useGetInstructStatus(apiClient) {
|
|
1011
1241
|
const [loading, setLoading] = useState(true);
|
|
1012
1242
|
const getInstructStatus = useCallback(async () => {
|
|
@@ -1196,8 +1426,8 @@ function RunInstructionProvider(props) {
|
|
|
1196
1426
|
runInstructionRequest({
|
|
1197
1427
|
...request,
|
|
1198
1428
|
instructionKey: instruction._key,
|
|
1199
|
-
userTexts: Object.entries(inputs).map(
|
|
1200
|
-
let [key, value] =
|
|
1429
|
+
userTexts: Object.entries(inputs).map(_ref7 => {
|
|
1430
|
+
let [key, value] = _ref7;
|
|
1201
1431
|
return {
|
|
1202
1432
|
blockKey: key,
|
|
1203
1433
|
userInput: value
|
|
@@ -1210,8 +1440,8 @@ function RunInstructionProvider(props) {
|
|
|
1210
1440
|
const open = !!runRequest;
|
|
1211
1441
|
const runDisabled = useMemo(() => {
|
|
1212
1442
|
var _a2, _b;
|
|
1213
|
-
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(
|
|
1214
|
-
let [, value] =
|
|
1443
|
+
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(_ref8 => {
|
|
1444
|
+
let [, value] = _ref8;
|
|
1215
1445
|
return !!value;
|
|
1216
1446
|
}).length;
|
|
1217
1447
|
}, [runRequest == null ? void 0 : runRequest.userInputBlocks, inputs]);
|
|
@@ -1322,29 +1552,37 @@ function getAssistableDocId(documentSchemaType, documentId) {
|
|
|
1322
1552
|
return documentSchemaType.liveEdit ? baseId : "drafts.".concat(baseId);
|
|
1323
1553
|
}
|
|
1324
1554
|
function useRequestRunInstruction(args) {
|
|
1325
|
-
const {
|
|
1326
|
-
documentOnChange,
|
|
1327
|
-
isDocAssistable: isDocAssistable2
|
|
1328
|
-
} = args;
|
|
1329
1555
|
const {
|
|
1330
1556
|
runInstruction,
|
|
1331
1557
|
instructionLoading
|
|
1332
1558
|
} = useRunInstruction();
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
setQueuedTask(void 0);
|
|
1338
|
-
}
|
|
1339
|
-
}, [queuedTask, isDocAssistable2, runInstruction]);
|
|
1559
|
+
const requestRunInstruction = useDraftDelayedTask({
|
|
1560
|
+
...args,
|
|
1561
|
+
task: runInstruction
|
|
1562
|
+
});
|
|
1340
1563
|
return {
|
|
1341
1564
|
instructionLoading,
|
|
1342
|
-
requestRunInstruction
|
|
1343
|
-
documentOnChange(PatchEvent.from([unset(["_force_document_creation"])]));
|
|
1344
|
-
setQueuedTask(task);
|
|
1345
|
-
}, [setQueuedTask, documentOnChange])
|
|
1565
|
+
requestRunInstruction
|
|
1346
1566
|
};
|
|
1347
1567
|
}
|
|
1568
|
+
function useDraftDelayedTask(args) {
|
|
1569
|
+
const {
|
|
1570
|
+
documentOnChange,
|
|
1571
|
+
isDocAssistable: isDocAssistable2,
|
|
1572
|
+
task
|
|
1573
|
+
} = args;
|
|
1574
|
+
const [queuedArgs, setQueuedArgs] = useState(void 0);
|
|
1575
|
+
useEffect(() => {
|
|
1576
|
+
if (queuedArgs && isDocAssistable2) {
|
|
1577
|
+
task(queuedArgs);
|
|
1578
|
+
setQueuedArgs(void 0);
|
|
1579
|
+
}
|
|
1580
|
+
}, [queuedArgs, isDocAssistable2, task]);
|
|
1581
|
+
return useCallback(taskArgs => {
|
|
1582
|
+
documentOnChange(PatchEvent.from([unset(["_force_document_creation"])]));
|
|
1583
|
+
setQueuedArgs(taskArgs);
|
|
1584
|
+
}, [setQueuedArgs, documentOnChange]);
|
|
1585
|
+
}
|
|
1348
1586
|
const SparklesIllustration = styled(SparklesIcon)({
|
|
1349
1587
|
fontSize: "3.125em",
|
|
1350
1588
|
"& path": {
|
|
@@ -1576,7 +1814,7 @@ function useSelectedSchema(fieldPath, documentSchema) {
|
|
|
1576
1814
|
if (fieldPath === documentRootKey) {
|
|
1577
1815
|
return documentSchema;
|
|
1578
1816
|
}
|
|
1579
|
-
const path = stringToPath(fieldPath);
|
|
1817
|
+
const path = stringToPath$2(fieldPath);
|
|
1580
1818
|
let currentSchema = documentSchema;
|
|
1581
1819
|
for (let i = 0; i < path.length; i++) {
|
|
1582
1820
|
const segment = path[i];
|
|
@@ -1595,13 +1833,13 @@ function useSelectedSchema(fieldPath, documentSchema) {
|
|
|
1595
1833
|
return currentSchema;
|
|
1596
1834
|
}, [documentSchema, fieldPath]);
|
|
1597
1835
|
}
|
|
1598
|
-
function FieldsInitializer(
|
|
1836
|
+
function FieldsInitializer(_ref9) {
|
|
1599
1837
|
let {
|
|
1600
1838
|
pathKey,
|
|
1601
1839
|
activePath,
|
|
1602
1840
|
fieldExists,
|
|
1603
1841
|
onChange
|
|
1604
|
-
} =
|
|
1842
|
+
} = _ref9;
|
|
1605
1843
|
const initialized = useRef(false);
|
|
1606
1844
|
useEffect(() => {
|
|
1607
1845
|
if (initialized.current || fieldExists || activePath || !pathKey) {
|
|
@@ -1632,7 +1870,7 @@ function FieldAutocomplete(props) {
|
|
|
1632
1870
|
return getFieldRefs(schemaType);
|
|
1633
1871
|
}, [schemaType, includeDocument]);
|
|
1634
1872
|
const currentField = useMemo(() => fieldRefs.find(f => f.key === fieldPath), [fieldPath, fieldRefs]);
|
|
1635
|
-
const autocompleteOptions = useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).map(field => ({
|
|
1873
|
+
const autocompleteOptions = useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).filter(f => !isType(f.schemaType, "reference")).map(field => ({
|
|
1636
1874
|
value: field.key,
|
|
1637
1875
|
field
|
|
1638
1876
|
})), [fieldRefs, filter]);
|
|
@@ -1745,6 +1983,78 @@ function FieldTitle(props) {
|
|
|
1745
1983
|
})
|
|
1746
1984
|
});
|
|
1747
1985
|
}
|
|
1986
|
+
const MAX_DEPTH = 8;
|
|
1987
|
+
function getConditionalMembers(docState) {
|
|
1988
|
+
const doc = {
|
|
1989
|
+
path: "",
|
|
1990
|
+
hidden: false,
|
|
1991
|
+
readOnly: !!docState.readOnly,
|
|
1992
|
+
conditional: typeof docState.schemaType.hidden === "function"
|
|
1993
|
+
};
|
|
1994
|
+
return [doc, ...extractConditionalPaths(docState, MAX_DEPTH)].filter(v => v.conditional).map(_ref10 => {
|
|
1995
|
+
let {
|
|
1996
|
+
conditional,
|
|
1997
|
+
...state
|
|
1998
|
+
} = _ref10;
|
|
1999
|
+
return {
|
|
2000
|
+
...state
|
|
2001
|
+
};
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
function isConditional(schemaType) {
|
|
2005
|
+
return typeof schemaType.hidden === "function" || typeof schemaType.readOnly === "function";
|
|
2006
|
+
}
|
|
2007
|
+
function conditionalState(memberState) {
|
|
2008
|
+
return {
|
|
2009
|
+
path: pathToString(memberState.path),
|
|
2010
|
+
readOnly: !!memberState.readOnly,
|
|
2011
|
+
hidden: false,
|
|
2012
|
+
// if its in members, its not hidden
|
|
2013
|
+
conditional: isConditional(memberState.schemaType)
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
function extractConditionalPaths(node, maxDepth) {
|
|
2017
|
+
if (node.path.length >= maxDepth) {
|
|
2018
|
+
return [];
|
|
2019
|
+
}
|
|
2020
|
+
return node.members.reduce((acc, member) => {
|
|
2021
|
+
var _a, _b;
|
|
2022
|
+
if (member.kind === "error") {
|
|
2023
|
+
return acc;
|
|
2024
|
+
}
|
|
2025
|
+
if (member.kind === "field") {
|
|
2026
|
+
const schemaType = member.field.schemaType;
|
|
2027
|
+
if (schemaType.jsonType === "object") {
|
|
2028
|
+
const innerFields = member.field.readOnly ? [] : extractConditionalPaths(member.field, maxDepth);
|
|
2029
|
+
return [...acc, conditionalState(member.field), ...innerFields];
|
|
2030
|
+
} else if (schemaType.jsonType === "array") {
|
|
2031
|
+
const array = member.field;
|
|
2032
|
+
let arrayPaths = [];
|
|
2033
|
+
const isObjectsArray = array.members.some(m => m.kind === "item" && isObjectSchemaType(m.item.schemaType));
|
|
2034
|
+
if (!array.readOnly) {
|
|
2035
|
+
for (const arrayMember of array.members) {
|
|
2036
|
+
if (arrayMember.kind === "error") {
|
|
2037
|
+
continue;
|
|
2038
|
+
}
|
|
2039
|
+
const innerFields = isObjectsArray && !arrayMember.item.readOnly ? extractConditionalPaths(arrayMember.item, maxDepth) : [];
|
|
2040
|
+
arrayPaths = [...arrayPaths, conditionalState(arrayMember.item), ...innerFields];
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return [...acc, conditionalState(array), ...arrayPaths];
|
|
2044
|
+
}
|
|
2045
|
+
return [...acc, conditionalState(member.field)];
|
|
2046
|
+
} else if (member.kind === "fieldSet") {
|
|
2047
|
+
const conditionalFieldset = !!((_b = (_a = node.schemaType) == null ? void 0 : _a.fieldsets) == null ? void 0 : _b.some(f => !f.single && f.name === member.fieldSet.name && typeof f.hidden === "function"));
|
|
2048
|
+
const innerFields = extractConditionalPaths(member.fieldSet, maxDepth).map(f => ({
|
|
2049
|
+
...f,
|
|
2050
|
+
// if fieldset is conditional, visible fields must also be considered conditional
|
|
2051
|
+
conditional: conditionalFieldset != null ? conditionalFieldset : f.conditional
|
|
2052
|
+
}));
|
|
2053
|
+
return [...acc, ...innerFields];
|
|
2054
|
+
}
|
|
2055
|
+
return acc;
|
|
2056
|
+
}, []);
|
|
2057
|
+
}
|
|
1748
2058
|
var __freeze$4 = Object.freeze;
|
|
1749
2059
|
var __defProp$4 = Object.defineProperty;
|
|
1750
2060
|
var __template$4 = (cooked, raw) => __freeze$4(__defProp$4(cooked, "raw", {
|
|
@@ -1884,12 +2194,15 @@ function AssistInspector(props) {
|
|
|
1884
2194
|
documentType,
|
|
1885
2195
|
value: docValue,
|
|
1886
2196
|
schemaType,
|
|
1887
|
-
onChange: documentOnChange
|
|
2197
|
+
onChange: documentOnChange,
|
|
2198
|
+
formState
|
|
1888
2199
|
} = documentPane;
|
|
1889
2200
|
const {
|
|
1890
2201
|
published,
|
|
1891
2202
|
draft
|
|
1892
2203
|
} = useEditState(documentId, documentType, "low");
|
|
2204
|
+
const formStateRef = useRef(formState);
|
|
2205
|
+
formStateRef.current = formState;
|
|
1893
2206
|
const assistableDocId = getAssistableDocId(schemaType, documentId);
|
|
1894
2207
|
const {
|
|
1895
2208
|
instructionLoading,
|
|
@@ -1943,7 +2256,8 @@ function AssistInspector(props) {
|
|
|
1943
2256
|
path: pathKey,
|
|
1944
2257
|
typePath,
|
|
1945
2258
|
assistDocumentId: assistDocumentId(documentType),
|
|
1946
|
-
instruction
|
|
2259
|
+
instruction,
|
|
2260
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
1947
2261
|
}), [pathKey, instruction, typePath, documentType, assistableDocId, requestRunInstruction]);
|
|
1948
2262
|
const Region = useCallback(_props => {
|
|
1949
2263
|
return /* @__PURE__ */jsx("div", {
|
|
@@ -2129,10 +2443,10 @@ const assistInspector = {
|
|
|
2129
2443
|
showAsAction: false
|
|
2130
2444
|
}),
|
|
2131
2445
|
component: AssistInspectorWrapper,
|
|
2132
|
-
onClose(
|
|
2446
|
+
onClose(_ref11) {
|
|
2133
2447
|
let {
|
|
2134
2448
|
params
|
|
2135
|
-
} =
|
|
2449
|
+
} = _ref11;
|
|
2136
2450
|
return {
|
|
2137
2451
|
params: typed({
|
|
2138
2452
|
...params,
|
|
@@ -2164,7 +2478,7 @@ function useAssistPresence(path, showFocusWithin) {
|
|
|
2164
2478
|
if (!presence.path || !path.length) {
|
|
2165
2479
|
return false;
|
|
2166
2480
|
}
|
|
2167
|
-
const statusPath = stringToPath(presence.path);
|
|
2481
|
+
const statusPath = stringToPath$2(presence.path);
|
|
2168
2482
|
if (!showFocusWithin && statusPath.length !== path.length) {
|
|
2169
2483
|
return false;
|
|
2170
2484
|
}
|
|
@@ -2205,11 +2519,11 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$3(cooked, "raw", {
|
|
|
2205
2519
|
var _a$3, _b$1;
|
|
2206
2520
|
const fadeIn = keyframes(_a$3 || (_a$3 = __template$3(["\n 0% {\n opacity: 0;\n transform: scale(0.75);\n }\n 40% {\n opacity: 0;\n transform: scale(0.75);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n"])));
|
|
2207
2521
|
const FadeInDiv = styled.div(_b$1 || (_b$1 = __template$3(["\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n"])), fadeIn);
|
|
2208
|
-
const FadeInContent = forwardRef(function FadeInContent2(
|
|
2522
|
+
const FadeInContent = forwardRef(function FadeInContent2(_ref12, ref) {
|
|
2209
2523
|
let {
|
|
2210
2524
|
children,
|
|
2211
2525
|
durationMs = 250
|
|
2212
|
-
} =
|
|
2526
|
+
} = _ref12;
|
|
2213
2527
|
return /* @__PURE__ */jsx(FadeInDiv, {
|
|
2214
2528
|
ref,
|
|
2215
2529
|
style: {
|
|
@@ -2462,7 +2776,7 @@ function AssistFieldWrapper(props) {
|
|
|
2462
2776
|
if (!isSupported || schemaType.name.startsWith("sanity.") || schemaType.name === contextDocumentTypeName) {
|
|
2463
2777
|
return props.renderDefault(props);
|
|
2464
2778
|
}
|
|
2465
|
-
if (!isType(props.schemaType, "document") && props.inputId !== "root") {
|
|
2779
|
+
if (!isType(props.schemaType, "document") && props.inputId !== "root" && props.inputId !== assistFormId) {
|
|
2466
2780
|
return /* @__PURE__ */jsx(AssistField, {
|
|
2467
2781
|
...props,
|
|
2468
2782
|
children: props.children
|
|
@@ -2482,15 +2796,16 @@ function AssistField(props) {
|
|
|
2482
2796
|
showOnboarding,
|
|
2483
2797
|
dismissOnboarding
|
|
2484
2798
|
} = useOnboardingFeature(fieldOnboardingKey);
|
|
2799
|
+
const singlePresence = presence[0];
|
|
2485
2800
|
const actions = /* @__PURE__ */jsxs(Flex, {
|
|
2486
2801
|
gap: 2,
|
|
2487
2802
|
align: "center",
|
|
2488
2803
|
justify: "space-between",
|
|
2489
|
-
children: [
|
|
2804
|
+
children: [singlePresence && /* @__PURE__ */jsx(Box, {
|
|
2490
2805
|
children: /* @__PURE__ */jsx(AiFieldPresence, {
|
|
2491
|
-
presence:
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2806
|
+
presence: singlePresence
|
|
2807
|
+
})
|
|
2808
|
+
}), isFirstAssisted && showOnboarding && /* @__PURE__ */jsx(AssistOnboardingPopover, {
|
|
2494
2809
|
dismiss: dismissOnboarding
|
|
2495
2810
|
})]
|
|
2496
2811
|
});
|
|
@@ -2970,253 +3285,1500 @@ function AssistConnectorsOverlay(props) {
|
|
|
2970
3285
|
}), DEBUG]
|
|
2971
3286
|
});
|
|
2972
3287
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3288
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3289
|
+
function getDefaultExportFromCjs(x) {
|
|
3290
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
/**
|
|
3294
|
+
* Checks if `value` is classified as an `Array` object.
|
|
3295
|
+
*
|
|
3296
|
+
* @static
|
|
3297
|
+
* @memberOf _
|
|
3298
|
+
* @since 0.1.0
|
|
3299
|
+
* @category Lang
|
|
3300
|
+
* @param {*} value The value to check.
|
|
3301
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
3302
|
+
* @example
|
|
3303
|
+
*
|
|
3304
|
+
* _.isArray([1, 2, 3]);
|
|
3305
|
+
* // => true
|
|
3306
|
+
*
|
|
3307
|
+
* _.isArray(document.body.children);
|
|
3308
|
+
* // => false
|
|
3309
|
+
*
|
|
3310
|
+
* _.isArray('abc');
|
|
3311
|
+
* // => false
|
|
3312
|
+
*
|
|
3313
|
+
* _.isArray(_.noop);
|
|
3314
|
+
* // => false
|
|
3315
|
+
*/
|
|
3316
|
+
|
|
3317
|
+
var isArray$3 = Array.isArray;
|
|
3318
|
+
var isArray_1 = isArray$3;
|
|
3319
|
+
|
|
3320
|
+
/** Detect free variable `global` from Node.js. */
|
|
3321
|
+
|
|
3322
|
+
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
3323
|
+
var _freeGlobal = freeGlobal$1;
|
|
3324
|
+
var freeGlobal = _freeGlobal;
|
|
3325
|
+
|
|
3326
|
+
/** Detect free variable `self`. */
|
|
3327
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
3328
|
+
|
|
3329
|
+
/** Used as a reference to the global object. */
|
|
3330
|
+
var root$3 = freeGlobal || freeSelf || Function('return this')();
|
|
3331
|
+
var _root = root$3;
|
|
3332
|
+
var root$2 = _root;
|
|
3333
|
+
|
|
3334
|
+
/** Built-in value references. */
|
|
3335
|
+
var Symbol$3 = root$2.Symbol;
|
|
3336
|
+
var _Symbol = Symbol$3;
|
|
3337
|
+
var Symbol$2 = _Symbol;
|
|
3338
|
+
|
|
3339
|
+
/** Used for built-in method references. */
|
|
3340
|
+
var objectProto$4 = Object.prototype;
|
|
3341
|
+
|
|
3342
|
+
/** Used to check objects for own properties. */
|
|
3343
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
3344
|
+
|
|
3345
|
+
/**
|
|
3346
|
+
* Used to resolve the
|
|
3347
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3348
|
+
* of values.
|
|
3349
|
+
*/
|
|
3350
|
+
var nativeObjectToString$1 = objectProto$4.toString;
|
|
3351
|
+
|
|
3352
|
+
/** Built-in value references. */
|
|
3353
|
+
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
3354
|
+
|
|
3355
|
+
/**
|
|
3356
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
3357
|
+
*
|
|
3358
|
+
* @private
|
|
3359
|
+
* @param {*} value The value to query.
|
|
3360
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
3361
|
+
*/
|
|
3362
|
+
function getRawTag$1(value) {
|
|
3363
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
|
|
3364
|
+
tag = value[symToStringTag$1];
|
|
3365
|
+
try {
|
|
3366
|
+
value[symToStringTag$1] = undefined;
|
|
3367
|
+
var unmasked = true;
|
|
3368
|
+
} catch (e) {}
|
|
3369
|
+
var result = nativeObjectToString$1.call(value);
|
|
3370
|
+
if (unmasked) {
|
|
3371
|
+
if (isOwn) {
|
|
3372
|
+
value[symToStringTag$1] = tag;
|
|
3373
|
+
} else {
|
|
3374
|
+
delete value[symToStringTag$1];
|
|
3033
3375
|
}
|
|
3034
|
-
}, [contextDocs, client, alphaAssistDocs, staleStatusDocIds, setProgress, toast]);
|
|
3035
|
-
if ((alphaAssistDocs.length || staleStatusDocIds.length || contextDocs.length) && (!progress || progress < 1)) {
|
|
3036
|
-
return /* @__PURE__ */jsx(Dialog, {
|
|
3037
|
-
id: "outdated-assist-docs",
|
|
3038
|
-
header: pluginTitle,
|
|
3039
|
-
children: /* @__PURE__ */jsx(Card, {
|
|
3040
|
-
padding: 3,
|
|
3041
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
3042
|
-
space: 4,
|
|
3043
|
-
style: {
|
|
3044
|
-
maxWidth: 500
|
|
3045
|
-
},
|
|
3046
|
-
children: [/* @__PURE__ */jsxs(Text, {
|
|
3047
|
-
size: 1,
|
|
3048
|
-
children: ["It seems like this workspace contains documents from an", " ", /* @__PURE__ */jsxs("strong", {
|
|
3049
|
-
children: ["older version of ", pluginTitle]
|
|
3050
|
-
}), "."]
|
|
3051
|
-
}), /* @__PURE__ */jsx(Text, {
|
|
3052
|
-
size: 1,
|
|
3053
|
-
children: "Cleanup is required."
|
|
3054
|
-
}), error ? /* @__PURE__ */jsxs(Card, {
|
|
3055
|
-
padding: 2,
|
|
3056
|
-
tone: "critical",
|
|
3057
|
-
border: true,
|
|
3058
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
3059
|
-
size: 1,
|
|
3060
|
-
children: "An error occurred. See console for details."
|
|
3061
|
-
}), " "]
|
|
3062
|
-
}) : null, /* @__PURE__ */jsx(Button, {
|
|
3063
|
-
icon: progress ? /* @__PURE__ */jsx(Box, {
|
|
3064
|
-
style: {
|
|
3065
|
-
marginTop: 5
|
|
3066
|
-
},
|
|
3067
|
-
children: /* @__PURE__ */jsx(Spinner, {})
|
|
3068
|
-
}) : CheckmarkIcon,
|
|
3069
|
-
disabled: !!progress,
|
|
3070
|
-
text: progress ? "".concat(Math.floor(progress * 100), "%") : "Ok, convert to new format!",
|
|
3071
|
-
tone: "primary",
|
|
3072
|
-
onClick: convert
|
|
3073
|
-
})]
|
|
3074
|
-
})
|
|
3075
|
-
})
|
|
3076
|
-
});
|
|
3077
3376
|
}
|
|
3078
|
-
return
|
|
3377
|
+
return result;
|
|
3079
3378
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3379
|
+
var _getRawTag = getRawTag$1;
|
|
3380
|
+
|
|
3381
|
+
/** Used for built-in method references. */
|
|
3382
|
+
|
|
3383
|
+
var objectProto$3 = Object.prototype;
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* Used to resolve the
|
|
3387
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3388
|
+
* of values.
|
|
3389
|
+
*/
|
|
3390
|
+
var nativeObjectToString = objectProto$3.toString;
|
|
3391
|
+
|
|
3392
|
+
/**
|
|
3393
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
3394
|
+
*
|
|
3395
|
+
* @private
|
|
3396
|
+
* @param {*} value The value to convert.
|
|
3397
|
+
* @returns {string} Returns the converted string.
|
|
3398
|
+
*/
|
|
3399
|
+
function objectToString$1(value) {
|
|
3400
|
+
return nativeObjectToString.call(value);
|
|
3401
|
+
}
|
|
3402
|
+
var _objectToString = objectToString$1;
|
|
3403
|
+
var Symbol$1 = _Symbol,
|
|
3404
|
+
getRawTag = _getRawTag,
|
|
3405
|
+
objectToString = _objectToString;
|
|
3406
|
+
|
|
3407
|
+
/** `Object#toString` result references. */
|
|
3408
|
+
var nullTag = '[object Null]',
|
|
3409
|
+
undefinedTag = '[object Undefined]';
|
|
3410
|
+
|
|
3411
|
+
/** Built-in value references. */
|
|
3412
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
3413
|
+
|
|
3414
|
+
/**
|
|
3415
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
3416
|
+
*
|
|
3417
|
+
* @private
|
|
3418
|
+
* @param {*} value The value to query.
|
|
3419
|
+
* @returns {string} Returns the `toStringTag`.
|
|
3420
|
+
*/
|
|
3421
|
+
function baseGetTag$2(value) {
|
|
3422
|
+
if (value == null) {
|
|
3423
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
3089
3424
|
}
|
|
3425
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
3090
3426
|
}
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3427
|
+
var _baseGetTag = baseGetTag$2;
|
|
3428
|
+
|
|
3429
|
+
/**
|
|
3430
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
3431
|
+
* and has a `typeof` result of "object".
|
|
3432
|
+
*
|
|
3433
|
+
* @static
|
|
3434
|
+
* @memberOf _
|
|
3435
|
+
* @since 4.0.0
|
|
3436
|
+
* @category Lang
|
|
3437
|
+
* @param {*} value The value to check.
|
|
3438
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
3439
|
+
* @example
|
|
3440
|
+
*
|
|
3441
|
+
* _.isObjectLike({});
|
|
3442
|
+
* // => true
|
|
3443
|
+
*
|
|
3444
|
+
* _.isObjectLike([1, 2, 3]);
|
|
3445
|
+
* // => true
|
|
3446
|
+
*
|
|
3447
|
+
* _.isObjectLike(_.noop);
|
|
3448
|
+
* // => false
|
|
3449
|
+
*
|
|
3450
|
+
* _.isObjectLike(null);
|
|
3451
|
+
* // => false
|
|
3452
|
+
*/
|
|
3453
|
+
|
|
3454
|
+
function isObjectLike$1(value) {
|
|
3455
|
+
return value != null && typeof value == 'object';
|
|
3456
|
+
}
|
|
3457
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
3458
|
+
var baseGetTag$1 = _baseGetTag,
|
|
3459
|
+
isObjectLike = isObjectLike_1;
|
|
3460
|
+
|
|
3461
|
+
/** `Object#toString` result references. */
|
|
3462
|
+
var symbolTag = '[object Symbol]';
|
|
3463
|
+
|
|
3464
|
+
/**
|
|
3465
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
3466
|
+
*
|
|
3467
|
+
* @static
|
|
3468
|
+
* @memberOf _
|
|
3469
|
+
* @since 4.0.0
|
|
3470
|
+
* @category Lang
|
|
3471
|
+
* @param {*} value The value to check.
|
|
3472
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
3473
|
+
* @example
|
|
3474
|
+
*
|
|
3475
|
+
* _.isSymbol(Symbol.iterator);
|
|
3476
|
+
* // => true
|
|
3477
|
+
*
|
|
3478
|
+
* _.isSymbol('abc');
|
|
3479
|
+
* // => false
|
|
3480
|
+
*/
|
|
3481
|
+
function isSymbol$3(value) {
|
|
3482
|
+
return typeof value == 'symbol' || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
3483
|
+
}
|
|
3484
|
+
var isSymbol_1 = isSymbol$3;
|
|
3485
|
+
var isArray$2 = isArray_1,
|
|
3486
|
+
isSymbol$2 = isSymbol_1;
|
|
3487
|
+
|
|
3488
|
+
/** Used to match property names within property paths. */
|
|
3489
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
3490
|
+
reIsPlainProp = /^\w*$/;
|
|
3491
|
+
|
|
3492
|
+
/**
|
|
3493
|
+
* Checks if `value` is a property name and not a property path.
|
|
3494
|
+
*
|
|
3495
|
+
* @private
|
|
3496
|
+
* @param {*} value The value to check.
|
|
3497
|
+
* @param {Object} [object] The object to query keys on.
|
|
3498
|
+
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
3499
|
+
*/
|
|
3500
|
+
function isKey$1(value, object) {
|
|
3501
|
+
if (isArray$2(value)) {
|
|
3502
|
+
return false;
|
|
3105
3503
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
const chunkSize = 10;
|
|
3110
|
-
for (let i = 0; i < docs.length; i += chunkSize) {
|
|
3111
|
-
const progressCount = Math.min(docs.length, i + chunkSize);
|
|
3112
|
-
const chunk = docs.slice(i, progressCount);
|
|
3113
|
-
const trans = client.transaction();
|
|
3114
|
-
const contextDocs = await client.fetch('*[_type=="'.concat(contextDocumentTypeName, '" && _alphaId != null]{_id, _alphaId}'));
|
|
3115
|
-
chunk.forEach(oldDoc => {
|
|
3116
|
-
var _a;
|
|
3117
|
-
const documentType = oldDoc._id.replace(new RegExp("^(".concat(legacyAssistDocumentIdPrefix, "|").concat(assistDocumentIdPrefix, ")")), "");
|
|
3118
|
-
const id = assistDocumentId(documentType);
|
|
3119
|
-
const fields = ((_a = oldDoc.fields) != null ? _a : []).filter(field => {
|
|
3120
|
-
var _a2;
|
|
3121
|
-
return (_a2 = field.instructions) == null ? void 0 : _a2.length;
|
|
3122
|
-
}).map(oldField => {
|
|
3123
|
-
var _a2;
|
|
3124
|
-
const instructions = ((_a2 = oldField.instructions) != null ? _a2 : []).map(inst => {
|
|
3125
|
-
var _a3;
|
|
3126
|
-
const prompt = ((_a3 = inst.prompt) != null ? _a3 : []).map(block => {
|
|
3127
|
-
return mapBlock(block, contextDocs);
|
|
3128
|
-
});
|
|
3129
|
-
return {
|
|
3130
|
-
...inst,
|
|
3131
|
-
_type: instructionTypeName,
|
|
3132
|
-
prompt
|
|
3133
|
-
};
|
|
3134
|
-
});
|
|
3135
|
-
return {
|
|
3136
|
-
...oldField,
|
|
3137
|
-
_type: assistFieldTypeName,
|
|
3138
|
-
instructions
|
|
3139
|
-
};
|
|
3140
|
-
});
|
|
3141
|
-
if (fields.length) {
|
|
3142
|
-
trans.createOrReplace({
|
|
3143
|
-
_id: id,
|
|
3144
|
-
_type: assistDocumentTypeName,
|
|
3145
|
-
fields
|
|
3146
|
-
});
|
|
3147
|
-
}
|
|
3148
|
-
trans.delete(oldDoc._id);
|
|
3149
|
-
});
|
|
3150
|
-
await trans.commit();
|
|
3151
|
-
updateProgress(progressCount / docs.length);
|
|
3504
|
+
var type = typeof value;
|
|
3505
|
+
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
|
|
3506
|
+
return true;
|
|
3152
3507
|
}
|
|
3508
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
3153
3509
|
}
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3510
|
+
var _isKey = isKey$1;
|
|
3511
|
+
|
|
3512
|
+
/**
|
|
3513
|
+
* Checks if `value` is the
|
|
3514
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
3515
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
3516
|
+
*
|
|
3517
|
+
* @static
|
|
3518
|
+
* @memberOf _
|
|
3519
|
+
* @since 0.1.0
|
|
3520
|
+
* @category Lang
|
|
3521
|
+
* @param {*} value The value to check.
|
|
3522
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
3523
|
+
* @example
|
|
3524
|
+
*
|
|
3525
|
+
* _.isObject({});
|
|
3526
|
+
* // => true
|
|
3527
|
+
*
|
|
3528
|
+
* _.isObject([1, 2, 3]);
|
|
3529
|
+
* // => true
|
|
3530
|
+
*
|
|
3531
|
+
* _.isObject(_.noop);
|
|
3532
|
+
* // => true
|
|
3533
|
+
*
|
|
3534
|
+
* _.isObject(null);
|
|
3535
|
+
* // => false
|
|
3536
|
+
*/
|
|
3537
|
+
|
|
3538
|
+
function isObject$2(value) {
|
|
3539
|
+
var type = typeof value;
|
|
3540
|
+
return value != null && (type == 'object' || type == 'function');
|
|
3165
3541
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3542
|
+
var isObject_1 = isObject$2;
|
|
3543
|
+
var baseGetTag = _baseGetTag,
|
|
3544
|
+
isObject$1 = isObject_1;
|
|
3545
|
+
|
|
3546
|
+
/** `Object#toString` result references. */
|
|
3547
|
+
var asyncTag = '[object AsyncFunction]',
|
|
3548
|
+
funcTag = '[object Function]',
|
|
3549
|
+
genTag = '[object GeneratorFunction]',
|
|
3550
|
+
proxyTag = '[object Proxy]';
|
|
3551
|
+
|
|
3552
|
+
/**
|
|
3553
|
+
* Checks if `value` is classified as a `Function` object.
|
|
3554
|
+
*
|
|
3555
|
+
* @static
|
|
3556
|
+
* @memberOf _
|
|
3557
|
+
* @since 0.1.0
|
|
3558
|
+
* @category Lang
|
|
3559
|
+
* @param {*} value The value to check.
|
|
3560
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
3561
|
+
* @example
|
|
3562
|
+
*
|
|
3563
|
+
* _.isFunction(_);
|
|
3564
|
+
* // => true
|
|
3565
|
+
*
|
|
3566
|
+
* _.isFunction(/abc/);
|
|
3567
|
+
* // => false
|
|
3568
|
+
*/
|
|
3569
|
+
function isFunction$1(value) {
|
|
3570
|
+
if (!isObject$1(value)) {
|
|
3571
|
+
return false;
|
|
3173
3572
|
}
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3573
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
3574
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
3575
|
+
var tag = baseGetTag(value);
|
|
3576
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
3577
|
+
}
|
|
3578
|
+
var isFunction_1 = isFunction$1;
|
|
3579
|
+
var root$1 = _root;
|
|
3580
|
+
|
|
3581
|
+
/** Used to detect overreaching core-js shims. */
|
|
3582
|
+
var coreJsData$1 = root$1['__core-js_shared__'];
|
|
3583
|
+
var _coreJsData = coreJsData$1;
|
|
3584
|
+
var coreJsData = _coreJsData;
|
|
3585
|
+
|
|
3586
|
+
/** Used to detect methods masquerading as native. */
|
|
3587
|
+
var maskSrcKey = function () {
|
|
3588
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
3589
|
+
return uid ? 'Symbol(src)_1.' + uid : '';
|
|
3590
|
+
}();
|
|
3591
|
+
|
|
3592
|
+
/**
|
|
3593
|
+
* Checks if `func` has its source masked.
|
|
3594
|
+
*
|
|
3595
|
+
* @private
|
|
3596
|
+
* @param {Function} func The function to check.
|
|
3597
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
3598
|
+
*/
|
|
3599
|
+
function isMasked$1(func) {
|
|
3600
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
3601
|
+
}
|
|
3602
|
+
var _isMasked = isMasked$1;
|
|
3603
|
+
|
|
3604
|
+
/** Used for built-in method references. */
|
|
3605
|
+
|
|
3606
|
+
var funcProto$1 = Function.prototype;
|
|
3607
|
+
|
|
3608
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3609
|
+
var funcToString$1 = funcProto$1.toString;
|
|
3610
|
+
|
|
3611
|
+
/**
|
|
3612
|
+
* Converts `func` to its source code.
|
|
3613
|
+
*
|
|
3614
|
+
* @private
|
|
3615
|
+
* @param {Function} func The function to convert.
|
|
3616
|
+
* @returns {string} Returns the source code.
|
|
3617
|
+
*/
|
|
3618
|
+
function toSource$1(func) {
|
|
3619
|
+
if (func != null) {
|
|
3620
|
+
try {
|
|
3621
|
+
return funcToString$1.call(func);
|
|
3622
|
+
} catch (e) {}
|
|
3623
|
+
try {
|
|
3624
|
+
return func + '';
|
|
3625
|
+
} catch (e) {}
|
|
3179
3626
|
}
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3627
|
+
return '';
|
|
3628
|
+
}
|
|
3629
|
+
var _toSource = toSource$1;
|
|
3630
|
+
var isFunction = isFunction_1,
|
|
3631
|
+
isMasked = _isMasked,
|
|
3632
|
+
isObject = isObject_1,
|
|
3633
|
+
toSource = _toSource;
|
|
3634
|
+
|
|
3635
|
+
/**
|
|
3636
|
+
* Used to match `RegExp`
|
|
3637
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
3638
|
+
*/
|
|
3639
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
3640
|
+
|
|
3641
|
+
/** Used to detect host constructors (Safari). */
|
|
3642
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
3643
|
+
|
|
3644
|
+
/** Used for built-in method references. */
|
|
3645
|
+
var funcProto = Function.prototype,
|
|
3646
|
+
objectProto$2 = Object.prototype;
|
|
3647
|
+
|
|
3648
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3649
|
+
var funcToString = funcProto.toString;
|
|
3650
|
+
|
|
3651
|
+
/** Used to check objects for own properties. */
|
|
3652
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
3653
|
+
|
|
3654
|
+
/** Used to detect if a method is native. */
|
|
3655
|
+
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
3656
|
+
|
|
3657
|
+
/**
|
|
3658
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
3659
|
+
*
|
|
3660
|
+
* @private
|
|
3661
|
+
* @param {*} value The value to check.
|
|
3662
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
3663
|
+
* else `false`.
|
|
3664
|
+
*/
|
|
3665
|
+
function baseIsNative$1(value) {
|
|
3666
|
+
if (!isObject(value) || isMasked(value)) {
|
|
3667
|
+
return false;
|
|
3668
|
+
}
|
|
3669
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
3670
|
+
return pattern.test(toSource(value));
|
|
3671
|
+
}
|
|
3672
|
+
var _baseIsNative = baseIsNative$1;
|
|
3673
|
+
|
|
3674
|
+
/**
|
|
3675
|
+
* Gets the value at `key` of `object`.
|
|
3676
|
+
*
|
|
3677
|
+
* @private
|
|
3678
|
+
* @param {Object} [object] The object to query.
|
|
3679
|
+
* @param {string} key The key of the property to get.
|
|
3680
|
+
* @returns {*} Returns the property value.
|
|
3681
|
+
*/
|
|
3682
|
+
|
|
3683
|
+
function getValue$1(object, key) {
|
|
3684
|
+
return object == null ? undefined : object[key];
|
|
3685
|
+
}
|
|
3686
|
+
var _getValue = getValue$1;
|
|
3687
|
+
var baseIsNative = _baseIsNative,
|
|
3688
|
+
getValue = _getValue;
|
|
3689
|
+
|
|
3690
|
+
/**
|
|
3691
|
+
* Gets the native function at `key` of `object`.
|
|
3692
|
+
*
|
|
3693
|
+
* @private
|
|
3694
|
+
* @param {Object} object The object to query.
|
|
3695
|
+
* @param {string} key The key of the method to get.
|
|
3696
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
3697
|
+
*/
|
|
3698
|
+
function getNative$2(object, key) {
|
|
3699
|
+
var value = getValue(object, key);
|
|
3700
|
+
return baseIsNative(value) ? value : undefined;
|
|
3701
|
+
}
|
|
3702
|
+
var _getNative = getNative$2;
|
|
3703
|
+
var getNative$1 = _getNative;
|
|
3704
|
+
|
|
3705
|
+
/* Built-in method references that are verified to be native. */
|
|
3706
|
+
var nativeCreate$4 = getNative$1(Object, 'create');
|
|
3707
|
+
var _nativeCreate = nativeCreate$4;
|
|
3708
|
+
var nativeCreate$3 = _nativeCreate;
|
|
3709
|
+
|
|
3710
|
+
/**
|
|
3711
|
+
* Removes all key-value entries from the hash.
|
|
3712
|
+
*
|
|
3713
|
+
* @private
|
|
3714
|
+
* @name clear
|
|
3715
|
+
* @memberOf Hash
|
|
3716
|
+
*/
|
|
3717
|
+
function hashClear$1() {
|
|
3718
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
3719
|
+
this.size = 0;
|
|
3720
|
+
}
|
|
3721
|
+
var _hashClear = hashClear$1;
|
|
3722
|
+
|
|
3723
|
+
/**
|
|
3724
|
+
* Removes `key` and its value from the hash.
|
|
3725
|
+
*
|
|
3726
|
+
* @private
|
|
3727
|
+
* @name delete
|
|
3728
|
+
* @memberOf Hash
|
|
3729
|
+
* @param {Object} hash The hash to modify.
|
|
3730
|
+
* @param {string} key The key of the value to remove.
|
|
3731
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3732
|
+
*/
|
|
3733
|
+
|
|
3734
|
+
function hashDelete$1(key) {
|
|
3735
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
3736
|
+
this.size -= result ? 1 : 0;
|
|
3737
|
+
return result;
|
|
3738
|
+
}
|
|
3739
|
+
var _hashDelete = hashDelete$1;
|
|
3740
|
+
var nativeCreate$2 = _nativeCreate;
|
|
3741
|
+
|
|
3742
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3743
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
3744
|
+
|
|
3745
|
+
/** Used for built-in method references. */
|
|
3746
|
+
var objectProto$1 = Object.prototype;
|
|
3747
|
+
|
|
3748
|
+
/** Used to check objects for own properties. */
|
|
3749
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
3750
|
+
|
|
3751
|
+
/**
|
|
3752
|
+
* Gets the hash value for `key`.
|
|
3753
|
+
*
|
|
3754
|
+
* @private
|
|
3755
|
+
* @name get
|
|
3756
|
+
* @memberOf Hash
|
|
3757
|
+
* @param {string} key The key of the value to get.
|
|
3758
|
+
* @returns {*} Returns the entry value.
|
|
3759
|
+
*/
|
|
3760
|
+
function hashGet$1(key) {
|
|
3761
|
+
var data = this.__data__;
|
|
3762
|
+
if (nativeCreate$2) {
|
|
3763
|
+
var result = data[key];
|
|
3764
|
+
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
3193
3765
|
}
|
|
3194
|
-
|
|
3195
|
-
|
|
3766
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
|
|
3767
|
+
}
|
|
3768
|
+
var _hashGet = hashGet$1;
|
|
3769
|
+
var nativeCreate$1 = _nativeCreate;
|
|
3770
|
+
|
|
3771
|
+
/** Used for built-in method references. */
|
|
3772
|
+
var objectProto = Object.prototype;
|
|
3773
|
+
|
|
3774
|
+
/** Used to check objects for own properties. */
|
|
3775
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
3776
|
+
|
|
3777
|
+
/**
|
|
3778
|
+
* Checks if a hash value for `key` exists.
|
|
3779
|
+
*
|
|
3780
|
+
* @private
|
|
3781
|
+
* @name has
|
|
3782
|
+
* @memberOf Hash
|
|
3783
|
+
* @param {string} key The key of the entry to check.
|
|
3784
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3785
|
+
*/
|
|
3786
|
+
function hashHas$1(key) {
|
|
3787
|
+
var data = this.__data__;
|
|
3788
|
+
return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|
3789
|
+
}
|
|
3790
|
+
var _hashHas = hashHas$1;
|
|
3791
|
+
var nativeCreate = _nativeCreate;
|
|
3792
|
+
|
|
3793
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3794
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
3795
|
+
|
|
3796
|
+
/**
|
|
3797
|
+
* Sets the hash `key` to `value`.
|
|
3798
|
+
*
|
|
3799
|
+
* @private
|
|
3800
|
+
* @name set
|
|
3801
|
+
* @memberOf Hash
|
|
3802
|
+
* @param {string} key The key of the value to set.
|
|
3803
|
+
* @param {*} value The value to set.
|
|
3804
|
+
* @returns {Object} Returns the hash instance.
|
|
3805
|
+
*/
|
|
3806
|
+
function hashSet$1(key, value) {
|
|
3807
|
+
var data = this.__data__;
|
|
3808
|
+
this.size += this.has(key) ? 0 : 1;
|
|
3809
|
+
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
|
|
3810
|
+
return this;
|
|
3811
|
+
}
|
|
3812
|
+
var _hashSet = hashSet$1;
|
|
3813
|
+
var hashClear = _hashClear,
|
|
3814
|
+
hashDelete = _hashDelete,
|
|
3815
|
+
hashGet = _hashGet,
|
|
3816
|
+
hashHas = _hashHas,
|
|
3817
|
+
hashSet = _hashSet;
|
|
3818
|
+
|
|
3819
|
+
/**
|
|
3820
|
+
* Creates a hash object.
|
|
3821
|
+
*
|
|
3822
|
+
* @private
|
|
3823
|
+
* @constructor
|
|
3824
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
3825
|
+
*/
|
|
3826
|
+
function Hash$1(entries) {
|
|
3827
|
+
var index = -1,
|
|
3828
|
+
length = entries == null ? 0 : entries.length;
|
|
3829
|
+
this.clear();
|
|
3830
|
+
while (++index < length) {
|
|
3831
|
+
var entry = entries[index];
|
|
3832
|
+
this.set(entry[0], entry[1]);
|
|
3196
3833
|
}
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3836
|
+
// Add methods to `Hash`.
|
|
3837
|
+
Hash$1.prototype.clear = hashClear;
|
|
3838
|
+
Hash$1.prototype['delete'] = hashDelete;
|
|
3839
|
+
Hash$1.prototype.get = hashGet;
|
|
3840
|
+
Hash$1.prototype.has = hashHas;
|
|
3841
|
+
Hash$1.prototype.set = hashSet;
|
|
3842
|
+
var _Hash = Hash$1;
|
|
3843
|
+
|
|
3844
|
+
/**
|
|
3845
|
+
* Removes all key-value entries from the list cache.
|
|
3846
|
+
*
|
|
3847
|
+
* @private
|
|
3848
|
+
* @name clear
|
|
3849
|
+
* @memberOf ListCache
|
|
3850
|
+
*/
|
|
3851
|
+
|
|
3852
|
+
function listCacheClear$1() {
|
|
3853
|
+
this.__data__ = [];
|
|
3854
|
+
this.size = 0;
|
|
3855
|
+
}
|
|
3856
|
+
var _listCacheClear = listCacheClear$1;
|
|
3857
|
+
|
|
3858
|
+
/**
|
|
3859
|
+
* Performs a
|
|
3860
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
3861
|
+
* comparison between two values to determine if they are equivalent.
|
|
3862
|
+
*
|
|
3863
|
+
* @static
|
|
3864
|
+
* @memberOf _
|
|
3865
|
+
* @since 4.0.0
|
|
3866
|
+
* @category Lang
|
|
3867
|
+
* @param {*} value The value to compare.
|
|
3868
|
+
* @param {*} other The other value to compare.
|
|
3869
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3870
|
+
* @example
|
|
3871
|
+
*
|
|
3872
|
+
* var object = { 'a': 1 };
|
|
3873
|
+
* var other = { 'a': 1 };
|
|
3874
|
+
*
|
|
3875
|
+
* _.eq(object, object);
|
|
3876
|
+
* // => true
|
|
3877
|
+
*
|
|
3878
|
+
* _.eq(object, other);
|
|
3879
|
+
* // => false
|
|
3880
|
+
*
|
|
3881
|
+
* _.eq('a', 'a');
|
|
3882
|
+
* // => true
|
|
3883
|
+
*
|
|
3884
|
+
* _.eq('a', Object('a'));
|
|
3885
|
+
* // => false
|
|
3886
|
+
*
|
|
3887
|
+
* _.eq(NaN, NaN);
|
|
3888
|
+
* // => true
|
|
3889
|
+
*/
|
|
3890
|
+
|
|
3891
|
+
function eq$1(value, other) {
|
|
3892
|
+
return value === other || value !== value && other !== other;
|
|
3893
|
+
}
|
|
3894
|
+
var eq_1 = eq$1;
|
|
3895
|
+
var eq = eq_1;
|
|
3896
|
+
|
|
3897
|
+
/**
|
|
3898
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
3899
|
+
*
|
|
3900
|
+
* @private
|
|
3901
|
+
* @param {Array} array The array to inspect.
|
|
3902
|
+
* @param {*} key The key to search for.
|
|
3903
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
3904
|
+
*/
|
|
3905
|
+
function assocIndexOf$4(array, key) {
|
|
3906
|
+
var length = array.length;
|
|
3907
|
+
while (length--) {
|
|
3908
|
+
if (eq(array[length][0], key)) {
|
|
3909
|
+
return length;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
return -1;
|
|
3913
|
+
}
|
|
3914
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
3915
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
3916
|
+
|
|
3917
|
+
/** Used for built-in method references. */
|
|
3918
|
+
var arrayProto = Array.prototype;
|
|
3919
|
+
|
|
3920
|
+
/** Built-in value references. */
|
|
3921
|
+
var splice = arrayProto.splice;
|
|
3922
|
+
|
|
3923
|
+
/**
|
|
3924
|
+
* Removes `key` and its value from the list cache.
|
|
3925
|
+
*
|
|
3926
|
+
* @private
|
|
3927
|
+
* @name delete
|
|
3928
|
+
* @memberOf ListCache
|
|
3929
|
+
* @param {string} key The key of the value to remove.
|
|
3930
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3931
|
+
*/
|
|
3932
|
+
function listCacheDelete$1(key) {
|
|
3933
|
+
var data = this.__data__,
|
|
3934
|
+
index = assocIndexOf$3(data, key);
|
|
3935
|
+
if (index < 0) {
|
|
3936
|
+
return false;
|
|
3937
|
+
}
|
|
3938
|
+
var lastIndex = data.length - 1;
|
|
3939
|
+
if (index == lastIndex) {
|
|
3940
|
+
data.pop();
|
|
3941
|
+
} else {
|
|
3942
|
+
splice.call(data, index, 1);
|
|
3943
|
+
}
|
|
3944
|
+
--this.size;
|
|
3945
|
+
return true;
|
|
3946
|
+
}
|
|
3947
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
3948
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
3949
|
+
|
|
3950
|
+
/**
|
|
3951
|
+
* Gets the list cache value for `key`.
|
|
3952
|
+
*
|
|
3953
|
+
* @private
|
|
3954
|
+
* @name get
|
|
3955
|
+
* @memberOf ListCache
|
|
3956
|
+
* @param {string} key The key of the value to get.
|
|
3957
|
+
* @returns {*} Returns the entry value.
|
|
3958
|
+
*/
|
|
3959
|
+
function listCacheGet$1(key) {
|
|
3960
|
+
var data = this.__data__,
|
|
3961
|
+
index = assocIndexOf$2(data, key);
|
|
3962
|
+
return index < 0 ? undefined : data[index][1];
|
|
3963
|
+
}
|
|
3964
|
+
var _listCacheGet = listCacheGet$1;
|
|
3965
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
3966
|
+
|
|
3967
|
+
/**
|
|
3968
|
+
* Checks if a list cache value for `key` exists.
|
|
3969
|
+
*
|
|
3970
|
+
* @private
|
|
3971
|
+
* @name has
|
|
3972
|
+
* @memberOf ListCache
|
|
3973
|
+
* @param {string} key The key of the entry to check.
|
|
3974
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3975
|
+
*/
|
|
3976
|
+
function listCacheHas$1(key) {
|
|
3977
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
3978
|
+
}
|
|
3979
|
+
var _listCacheHas = listCacheHas$1;
|
|
3980
|
+
var assocIndexOf = _assocIndexOf;
|
|
3981
|
+
|
|
3982
|
+
/**
|
|
3983
|
+
* Sets the list cache `key` to `value`.
|
|
3984
|
+
*
|
|
3985
|
+
* @private
|
|
3986
|
+
* @name set
|
|
3987
|
+
* @memberOf ListCache
|
|
3988
|
+
* @param {string} key The key of the value to set.
|
|
3989
|
+
* @param {*} value The value to set.
|
|
3990
|
+
* @returns {Object} Returns the list cache instance.
|
|
3991
|
+
*/
|
|
3992
|
+
function listCacheSet$1(key, value) {
|
|
3993
|
+
var data = this.__data__,
|
|
3994
|
+
index = assocIndexOf(data, key);
|
|
3995
|
+
if (index < 0) {
|
|
3996
|
+
++this.size;
|
|
3997
|
+
data.push([key, value]);
|
|
3998
|
+
} else {
|
|
3999
|
+
data[index][1] = value;
|
|
4000
|
+
}
|
|
4001
|
+
return this;
|
|
4002
|
+
}
|
|
4003
|
+
var _listCacheSet = listCacheSet$1;
|
|
4004
|
+
var listCacheClear = _listCacheClear,
|
|
4005
|
+
listCacheDelete = _listCacheDelete,
|
|
4006
|
+
listCacheGet = _listCacheGet,
|
|
4007
|
+
listCacheHas = _listCacheHas,
|
|
4008
|
+
listCacheSet = _listCacheSet;
|
|
4009
|
+
|
|
4010
|
+
/**
|
|
4011
|
+
* Creates an list cache object.
|
|
4012
|
+
*
|
|
4013
|
+
* @private
|
|
4014
|
+
* @constructor
|
|
4015
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4016
|
+
*/
|
|
4017
|
+
function ListCache$1(entries) {
|
|
4018
|
+
var index = -1,
|
|
4019
|
+
length = entries == null ? 0 : entries.length;
|
|
4020
|
+
this.clear();
|
|
4021
|
+
while (++index < length) {
|
|
4022
|
+
var entry = entries[index];
|
|
4023
|
+
this.set(entry[0], entry[1]);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
// Add methods to `ListCache`.
|
|
4028
|
+
ListCache$1.prototype.clear = listCacheClear;
|
|
4029
|
+
ListCache$1.prototype['delete'] = listCacheDelete;
|
|
4030
|
+
ListCache$1.prototype.get = listCacheGet;
|
|
4031
|
+
ListCache$1.prototype.has = listCacheHas;
|
|
4032
|
+
ListCache$1.prototype.set = listCacheSet;
|
|
4033
|
+
var _ListCache = ListCache$1;
|
|
4034
|
+
var getNative = _getNative,
|
|
4035
|
+
root = _root;
|
|
4036
|
+
|
|
4037
|
+
/* Built-in method references that are verified to be native. */
|
|
4038
|
+
var Map$2 = getNative(root, 'Map');
|
|
4039
|
+
var _Map = Map$2;
|
|
4040
|
+
var Hash = _Hash,
|
|
4041
|
+
ListCache = _ListCache,
|
|
4042
|
+
Map$1 = _Map;
|
|
4043
|
+
|
|
4044
|
+
/**
|
|
4045
|
+
* Removes all key-value entries from the map.
|
|
4046
|
+
*
|
|
4047
|
+
* @private
|
|
4048
|
+
* @name clear
|
|
4049
|
+
* @memberOf MapCache
|
|
4050
|
+
*/
|
|
4051
|
+
function mapCacheClear$1() {
|
|
4052
|
+
this.size = 0;
|
|
4053
|
+
this.__data__ = {
|
|
4054
|
+
'hash': new Hash(),
|
|
4055
|
+
'map': new (Map$1 || ListCache)(),
|
|
4056
|
+
'string': new Hash()
|
|
3201
4057
|
};
|
|
3202
4058
|
}
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
4059
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
4060
|
+
|
|
4061
|
+
/**
|
|
4062
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
4063
|
+
*
|
|
4064
|
+
* @private
|
|
4065
|
+
* @param {*} value The value to check.
|
|
4066
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
4067
|
+
*/
|
|
4068
|
+
|
|
4069
|
+
function isKeyable$1(value) {
|
|
4070
|
+
var type = typeof value;
|
|
4071
|
+
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
4072
|
+
}
|
|
4073
|
+
var _isKeyable = isKeyable$1;
|
|
4074
|
+
var isKeyable = _isKeyable;
|
|
4075
|
+
|
|
4076
|
+
/**
|
|
4077
|
+
* Gets the data for `map`.
|
|
4078
|
+
*
|
|
4079
|
+
* @private
|
|
4080
|
+
* @param {Object} map The map to query.
|
|
4081
|
+
* @param {string} key The reference key.
|
|
4082
|
+
* @returns {*} Returns the map data.
|
|
4083
|
+
*/
|
|
4084
|
+
function getMapData$4(map, key) {
|
|
4085
|
+
var data = map.__data__;
|
|
4086
|
+
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
4087
|
+
}
|
|
4088
|
+
var _getMapData = getMapData$4;
|
|
4089
|
+
var getMapData$3 = _getMapData;
|
|
4090
|
+
|
|
4091
|
+
/**
|
|
4092
|
+
* Removes `key` and its value from the map.
|
|
4093
|
+
*
|
|
4094
|
+
* @private
|
|
4095
|
+
* @name delete
|
|
4096
|
+
* @memberOf MapCache
|
|
4097
|
+
* @param {string} key The key of the value to remove.
|
|
4098
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
4099
|
+
*/
|
|
4100
|
+
function mapCacheDelete$1(key) {
|
|
4101
|
+
var result = getMapData$3(this, key)['delete'](key);
|
|
4102
|
+
this.size -= result ? 1 : 0;
|
|
4103
|
+
return result;
|
|
4104
|
+
}
|
|
4105
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
4106
|
+
var getMapData$2 = _getMapData;
|
|
4107
|
+
|
|
4108
|
+
/**
|
|
4109
|
+
* Gets the map value for `key`.
|
|
4110
|
+
*
|
|
4111
|
+
* @private
|
|
4112
|
+
* @name get
|
|
4113
|
+
* @memberOf MapCache
|
|
4114
|
+
* @param {string} key The key of the value to get.
|
|
4115
|
+
* @returns {*} Returns the entry value.
|
|
4116
|
+
*/
|
|
4117
|
+
function mapCacheGet$1(key) {
|
|
4118
|
+
return getMapData$2(this, key).get(key);
|
|
4119
|
+
}
|
|
4120
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
4121
|
+
var getMapData$1 = _getMapData;
|
|
4122
|
+
|
|
4123
|
+
/**
|
|
4124
|
+
* Checks if a map value for `key` exists.
|
|
4125
|
+
*
|
|
4126
|
+
* @private
|
|
4127
|
+
* @name has
|
|
4128
|
+
* @memberOf MapCache
|
|
4129
|
+
* @param {string} key The key of the entry to check.
|
|
4130
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4131
|
+
*/
|
|
4132
|
+
function mapCacheHas$1(key) {
|
|
4133
|
+
return getMapData$1(this, key).has(key);
|
|
4134
|
+
}
|
|
4135
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
4136
|
+
var getMapData = _getMapData;
|
|
4137
|
+
|
|
4138
|
+
/**
|
|
4139
|
+
* Sets the map `key` to `value`.
|
|
4140
|
+
*
|
|
4141
|
+
* @private
|
|
4142
|
+
* @name set
|
|
4143
|
+
* @memberOf MapCache
|
|
4144
|
+
* @param {string} key The key of the value to set.
|
|
4145
|
+
* @param {*} value The value to set.
|
|
4146
|
+
* @returns {Object} Returns the map cache instance.
|
|
4147
|
+
*/
|
|
4148
|
+
function mapCacheSet$1(key, value) {
|
|
4149
|
+
var data = getMapData(this, key),
|
|
4150
|
+
size = data.size;
|
|
4151
|
+
data.set(key, value);
|
|
4152
|
+
this.size += data.size == size ? 0 : 1;
|
|
4153
|
+
return this;
|
|
4154
|
+
}
|
|
4155
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
4156
|
+
var mapCacheClear = _mapCacheClear,
|
|
4157
|
+
mapCacheDelete = _mapCacheDelete,
|
|
4158
|
+
mapCacheGet = _mapCacheGet,
|
|
4159
|
+
mapCacheHas = _mapCacheHas,
|
|
4160
|
+
mapCacheSet = _mapCacheSet;
|
|
4161
|
+
|
|
4162
|
+
/**
|
|
4163
|
+
* Creates a map cache object to store key-value pairs.
|
|
4164
|
+
*
|
|
4165
|
+
* @private
|
|
4166
|
+
* @constructor
|
|
4167
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4168
|
+
*/
|
|
4169
|
+
function MapCache$1(entries) {
|
|
4170
|
+
var index = -1,
|
|
4171
|
+
length = entries == null ? 0 : entries.length;
|
|
4172
|
+
this.clear();
|
|
4173
|
+
while (++index < length) {
|
|
4174
|
+
var entry = entries[index];
|
|
4175
|
+
this.set(entry[0], entry[1]);
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4179
|
+
// Add methods to `MapCache`.
|
|
4180
|
+
MapCache$1.prototype.clear = mapCacheClear;
|
|
4181
|
+
MapCache$1.prototype['delete'] = mapCacheDelete;
|
|
4182
|
+
MapCache$1.prototype.get = mapCacheGet;
|
|
4183
|
+
MapCache$1.prototype.has = mapCacheHas;
|
|
4184
|
+
MapCache$1.prototype.set = mapCacheSet;
|
|
4185
|
+
var _MapCache = MapCache$1;
|
|
4186
|
+
var MapCache = _MapCache;
|
|
4187
|
+
|
|
4188
|
+
/** Error message constants. */
|
|
4189
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
4190
|
+
|
|
4191
|
+
/**
|
|
4192
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
4193
|
+
* provided, it determines the cache key for storing the result based on the
|
|
4194
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
4195
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
4196
|
+
* is invoked with the `this` binding of the memoized function.
|
|
4197
|
+
*
|
|
4198
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
4199
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
4200
|
+
* constructor with one whose instances implement the
|
|
4201
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
4202
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
4203
|
+
*
|
|
4204
|
+
* @static
|
|
4205
|
+
* @memberOf _
|
|
4206
|
+
* @since 0.1.0
|
|
4207
|
+
* @category Function
|
|
4208
|
+
* @param {Function} func The function to have its output memoized.
|
|
4209
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
4210
|
+
* @returns {Function} Returns the new memoized function.
|
|
4211
|
+
* @example
|
|
4212
|
+
*
|
|
4213
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
4214
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
4215
|
+
*
|
|
4216
|
+
* var values = _.memoize(_.values);
|
|
4217
|
+
* values(object);
|
|
4218
|
+
* // => [1, 2]
|
|
4219
|
+
*
|
|
4220
|
+
* values(other);
|
|
4221
|
+
* // => [3, 4]
|
|
4222
|
+
*
|
|
4223
|
+
* object.a = 2;
|
|
4224
|
+
* values(object);
|
|
4225
|
+
* // => [1, 2]
|
|
4226
|
+
*
|
|
4227
|
+
* // Modify the result cache.
|
|
4228
|
+
* values.cache.set(object, ['a', 'b']);
|
|
4229
|
+
* values(object);
|
|
4230
|
+
* // => ['a', 'b']
|
|
4231
|
+
*
|
|
4232
|
+
* // Replace `_.memoize.Cache`.
|
|
4233
|
+
* _.memoize.Cache = WeakMap;
|
|
4234
|
+
*/
|
|
4235
|
+
function memoize$1(func, resolver) {
|
|
4236
|
+
if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
|
|
4237
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
4238
|
+
}
|
|
4239
|
+
var memoized = function () {
|
|
4240
|
+
var args = arguments,
|
|
4241
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
4242
|
+
cache = memoized.cache;
|
|
4243
|
+
if (cache.has(key)) {
|
|
4244
|
+
return cache.get(key);
|
|
4245
|
+
}
|
|
4246
|
+
var result = func.apply(this, args);
|
|
4247
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
4248
|
+
return result;
|
|
4249
|
+
};
|
|
4250
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
4251
|
+
return memoized;
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
// Expose `MapCache`.
|
|
4255
|
+
memoize$1.Cache = MapCache;
|
|
4256
|
+
var memoize_1 = memoize$1;
|
|
4257
|
+
var memoize = memoize_1;
|
|
4258
|
+
|
|
4259
|
+
/** Used as the maximum memoize cache size. */
|
|
4260
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
4261
|
+
|
|
4262
|
+
/**
|
|
4263
|
+
* A specialized version of `_.memoize` which clears the memoized function's
|
|
4264
|
+
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
4265
|
+
*
|
|
4266
|
+
* @private
|
|
4267
|
+
* @param {Function} func The function to have its output memoized.
|
|
4268
|
+
* @returns {Function} Returns the new memoized function.
|
|
4269
|
+
*/
|
|
4270
|
+
function memoizeCapped$1(func) {
|
|
4271
|
+
var result = memoize(func, function (key) {
|
|
4272
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
4273
|
+
cache.clear();
|
|
4274
|
+
}
|
|
4275
|
+
return key;
|
|
4276
|
+
});
|
|
4277
|
+
var cache = result.cache;
|
|
4278
|
+
return result;
|
|
4279
|
+
}
|
|
4280
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
4281
|
+
var memoizeCapped = _memoizeCapped;
|
|
4282
|
+
|
|
4283
|
+
/** Used to match property names within property paths. */
|
|
4284
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
4285
|
+
|
|
4286
|
+
/** Used to match backslashes in property paths. */
|
|
4287
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
4288
|
+
|
|
4289
|
+
/**
|
|
4290
|
+
* Converts `string` to a property path array.
|
|
4291
|
+
*
|
|
4292
|
+
* @private
|
|
4293
|
+
* @param {string} string The string to convert.
|
|
4294
|
+
* @returns {Array} Returns the property path array.
|
|
4295
|
+
*/
|
|
4296
|
+
var stringToPath$1 = memoizeCapped(function (string) {
|
|
4297
|
+
var result = [];
|
|
4298
|
+
if (string.charCodeAt(0) === 46 /* . */) {
|
|
4299
|
+
result.push('');
|
|
4300
|
+
}
|
|
4301
|
+
string.replace(rePropName, function (match, number, quote, subString) {
|
|
4302
|
+
result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
|
|
4303
|
+
});
|
|
4304
|
+
return result;
|
|
4305
|
+
});
|
|
4306
|
+
var _stringToPath = stringToPath$1;
|
|
4307
|
+
|
|
4308
|
+
/**
|
|
4309
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
4310
|
+
* shorthands.
|
|
4311
|
+
*
|
|
4312
|
+
* @private
|
|
4313
|
+
* @param {Array} [array] The array to iterate over.
|
|
4314
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
4315
|
+
* @returns {Array} Returns the new mapped array.
|
|
4316
|
+
*/
|
|
4317
|
+
|
|
4318
|
+
function arrayMap$1(array, iteratee) {
|
|
4319
|
+
var index = -1,
|
|
4320
|
+
length = array == null ? 0 : array.length,
|
|
4321
|
+
result = Array(length);
|
|
4322
|
+
while (++index < length) {
|
|
4323
|
+
result[index] = iteratee(array[index], index, array);
|
|
4324
|
+
}
|
|
4325
|
+
return result;
|
|
4326
|
+
}
|
|
4327
|
+
var _arrayMap = arrayMap$1;
|
|
4328
|
+
var Symbol = _Symbol,
|
|
4329
|
+
arrayMap = _arrayMap,
|
|
4330
|
+
isArray$1 = isArray_1,
|
|
4331
|
+
isSymbol$1 = isSymbol_1;
|
|
4332
|
+
|
|
4333
|
+
/** Used as references for various `Number` constants. */
|
|
4334
|
+
var INFINITY$1 = 1 / 0;
|
|
4335
|
+
|
|
4336
|
+
/** Used to convert symbols to primitives and strings. */
|
|
4337
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
4338
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
4339
|
+
|
|
4340
|
+
/**
|
|
4341
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
4342
|
+
* values to empty strings.
|
|
4343
|
+
*
|
|
4344
|
+
* @private
|
|
4345
|
+
* @param {*} value The value to process.
|
|
4346
|
+
* @returns {string} Returns the string.
|
|
4347
|
+
*/
|
|
4348
|
+
function baseToString$1(value) {
|
|
4349
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
4350
|
+
if (typeof value == 'string') {
|
|
4351
|
+
return value;
|
|
4352
|
+
}
|
|
4353
|
+
if (isArray$1(value)) {
|
|
4354
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
4355
|
+
return arrayMap(value, baseToString$1) + '';
|
|
4356
|
+
}
|
|
4357
|
+
if (isSymbol$1(value)) {
|
|
4358
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
4359
|
+
}
|
|
4360
|
+
var result = value + '';
|
|
4361
|
+
return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
|
|
4362
|
+
}
|
|
4363
|
+
var _baseToString = baseToString$1;
|
|
4364
|
+
var baseToString = _baseToString;
|
|
4365
|
+
|
|
4366
|
+
/**
|
|
4367
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
4368
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
4369
|
+
*
|
|
4370
|
+
* @static
|
|
4371
|
+
* @memberOf _
|
|
4372
|
+
* @since 4.0.0
|
|
4373
|
+
* @category Lang
|
|
4374
|
+
* @param {*} value The value to convert.
|
|
4375
|
+
* @returns {string} Returns the converted string.
|
|
4376
|
+
* @example
|
|
4377
|
+
*
|
|
4378
|
+
* _.toString(null);
|
|
4379
|
+
* // => ''
|
|
4380
|
+
*
|
|
4381
|
+
* _.toString(-0);
|
|
4382
|
+
* // => '-0'
|
|
4383
|
+
*
|
|
4384
|
+
* _.toString([1, 2, 3]);
|
|
4385
|
+
* // => '1,2,3'
|
|
4386
|
+
*/
|
|
4387
|
+
function toString$1(value) {
|
|
4388
|
+
return value == null ? '' : baseToString(value);
|
|
4389
|
+
}
|
|
4390
|
+
var toString_1 = toString$1;
|
|
4391
|
+
var isArray = isArray_1,
|
|
4392
|
+
isKey = _isKey,
|
|
4393
|
+
stringToPath = _stringToPath,
|
|
4394
|
+
toString = toString_1;
|
|
4395
|
+
|
|
4396
|
+
/**
|
|
4397
|
+
* Casts `value` to a path array if it's not one.
|
|
4398
|
+
*
|
|
4399
|
+
* @private
|
|
4400
|
+
* @param {*} value The value to inspect.
|
|
4401
|
+
* @param {Object} [object] The object to query keys on.
|
|
4402
|
+
* @returns {Array} Returns the cast property path array.
|
|
4403
|
+
*/
|
|
4404
|
+
function castPath$1(value, object) {
|
|
4405
|
+
if (isArray(value)) {
|
|
4406
|
+
return value;
|
|
4407
|
+
}
|
|
4408
|
+
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
4409
|
+
}
|
|
4410
|
+
var _castPath = castPath$1;
|
|
4411
|
+
var isSymbol = isSymbol_1;
|
|
4412
|
+
|
|
4413
|
+
/** Used as references for various `Number` constants. */
|
|
4414
|
+
var INFINITY = 1 / 0;
|
|
4415
|
+
|
|
4416
|
+
/**
|
|
4417
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
4418
|
+
*
|
|
4419
|
+
* @private
|
|
4420
|
+
* @param {*} value The value to inspect.
|
|
4421
|
+
* @returns {string|symbol} Returns the key.
|
|
4422
|
+
*/
|
|
4423
|
+
function toKey$1(value) {
|
|
4424
|
+
if (typeof value == 'string' || isSymbol(value)) {
|
|
4425
|
+
return value;
|
|
4426
|
+
}
|
|
4427
|
+
var result = value + '';
|
|
4428
|
+
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
|
|
4429
|
+
}
|
|
4430
|
+
var _toKey = toKey$1;
|
|
4431
|
+
var castPath = _castPath,
|
|
4432
|
+
toKey = _toKey;
|
|
4433
|
+
|
|
4434
|
+
/**
|
|
4435
|
+
* The base implementation of `_.get` without support for default values.
|
|
4436
|
+
*
|
|
4437
|
+
* @private
|
|
4438
|
+
* @param {Object} object The object to query.
|
|
4439
|
+
* @param {Array|string} path The path of the property to get.
|
|
4440
|
+
* @returns {*} Returns the resolved value.
|
|
4441
|
+
*/
|
|
4442
|
+
function baseGet$1(object, path) {
|
|
4443
|
+
path = castPath(path, object);
|
|
4444
|
+
var index = 0,
|
|
4445
|
+
length = path.length;
|
|
4446
|
+
while (object != null && index < length) {
|
|
4447
|
+
object = object[toKey(path[index++])];
|
|
4448
|
+
}
|
|
4449
|
+
return index && index == length ? object : undefined;
|
|
4450
|
+
}
|
|
4451
|
+
var _baseGet = baseGet$1;
|
|
4452
|
+
var baseGet = _baseGet;
|
|
4453
|
+
|
|
4454
|
+
/**
|
|
4455
|
+
* Gets the value at `path` of `object`. If the resolved value is
|
|
4456
|
+
* `undefined`, the `defaultValue` is returned in its place.
|
|
4457
|
+
*
|
|
4458
|
+
* @static
|
|
4459
|
+
* @memberOf _
|
|
4460
|
+
* @since 3.7.0
|
|
4461
|
+
* @category Object
|
|
4462
|
+
* @param {Object} object The object to query.
|
|
4463
|
+
* @param {Array|string} path The path of the property to get.
|
|
4464
|
+
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
4465
|
+
* @returns {*} Returns the resolved value.
|
|
4466
|
+
* @example
|
|
4467
|
+
*
|
|
4468
|
+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
4469
|
+
*
|
|
4470
|
+
* _.get(object, 'a[0].b.c');
|
|
4471
|
+
* // => 3
|
|
4472
|
+
*
|
|
4473
|
+
* _.get(object, ['a', '0', 'b', 'c']);
|
|
4474
|
+
* // => 3
|
|
4475
|
+
*
|
|
4476
|
+
* _.get(object, 'a.b.c', 'default');
|
|
4477
|
+
* // => 'default'
|
|
4478
|
+
*/
|
|
4479
|
+
function get(object, path, defaultValue) {
|
|
4480
|
+
var result = object == null ? undefined : baseGet(object, path);
|
|
4481
|
+
return result === undefined ? defaultValue : result;
|
|
4482
|
+
}
|
|
4483
|
+
var get_1 = get;
|
|
4484
|
+
var get$1 = /*@__PURE__*/getDefaultExportFromCjs(get_1);
|
|
4485
|
+
const getLanguageParams = (select, document) => {
|
|
4486
|
+
if (!select || !document) {
|
|
4487
|
+
return {};
|
|
4488
|
+
}
|
|
4489
|
+
const selection = select || {};
|
|
4490
|
+
const selectedValue = {};
|
|
4491
|
+
for (const [key, path] of Object.entries(selection)) {
|
|
4492
|
+
let value = get$1(document, path);
|
|
4493
|
+
if (Array.isArray(value)) {
|
|
4494
|
+
value = value.filter(item => typeof item === "object" ? (item == null ? void 0 : item._type) !== "reference" || "_ref" in item : true);
|
|
4495
|
+
}
|
|
4496
|
+
selectedValue[key] = value;
|
|
4497
|
+
}
|
|
4498
|
+
return selectedValue;
|
|
4499
|
+
};
|
|
4500
|
+
const toFieldLanguagesKeyPrefix = "sanityStudio:assist:field-languages:from:";
|
|
4501
|
+
function getPreferredToFieldLanguages(fromLanguageId) {
|
|
4502
|
+
if (typeof localStorage === "undefined") {
|
|
4503
|
+
return [];
|
|
4504
|
+
}
|
|
4505
|
+
const value = localStorage.getItem("".concat(toFieldLanguagesKeyPrefix).concat(fromLanguageId));
|
|
4506
|
+
return value ? JSON.parse(value) : [];
|
|
4507
|
+
}
|
|
4508
|
+
function setPreferredToFieldLanguages(fromLanguageId, languageIds) {
|
|
4509
|
+
if (typeof localStorage === "undefined") {
|
|
4510
|
+
return;
|
|
4511
|
+
}
|
|
4512
|
+
localStorage.setItem("".concat(toFieldLanguagesKeyPrefix).concat(fromLanguageId), JSON.stringify(languageIds));
|
|
4513
|
+
}
|
|
4514
|
+
const FieldTranslationContext = createContext({
|
|
4515
|
+
openFieldTranslation: () => {},
|
|
4516
|
+
translationLoading: false
|
|
4517
|
+
});
|
|
4518
|
+
function useFieldTranslation() {
|
|
4519
|
+
return useContext(FieldTranslationContext);
|
|
4520
|
+
}
|
|
4521
|
+
function hasValuesToTranslate(fieldLanguageMaps, fromLanguage, basePath) {
|
|
4522
|
+
return fieldLanguageMaps == null ? void 0 : fieldLanguageMaps.some(map => map.inputLanguageId === (fromLanguage == null ? void 0 : fromLanguage.id) && map.inputPath && pathToString(map.inputPath).startsWith(pathToString(basePath)));
|
|
4523
|
+
}
|
|
4524
|
+
function FieldTranslationProvider(props) {
|
|
4525
|
+
var _a, _b, _c;
|
|
4526
|
+
const {
|
|
4527
|
+
config: assistConfig
|
|
4528
|
+
} = useAiAssistanceConfig();
|
|
4529
|
+
const apiClient = useApiClient(assistConfig.__customApiClient);
|
|
4530
|
+
const config = (_a = assistConfig.translate) == null ? void 0 : _a.field;
|
|
4531
|
+
const {
|
|
4532
|
+
translate: runTranslate
|
|
4533
|
+
} = useTranslate(apiClient);
|
|
4534
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
4535
|
+
const [fieldTranslationParams, setFieldTranslationParams] = useState();
|
|
4536
|
+
const [languages, setLanguages] = useState();
|
|
4537
|
+
const [fromLanguage, setFromLanguage] = useState(void 0);
|
|
4538
|
+
const [toLanguages, setToLanguages] = useState(void 0);
|
|
4539
|
+
const [fieldLanguageMaps, setFieldLanguageMaps] = useState();
|
|
4540
|
+
const close = useCallback(() => {
|
|
4541
|
+
setDialogOpen(false);
|
|
4542
|
+
setLanguages(void 0);
|
|
4543
|
+
setFieldTranslationParams(void 0);
|
|
4544
|
+
}, []);
|
|
4545
|
+
const languageClient = useClient({
|
|
4546
|
+
apiVersion: (_b = config == null ? void 0 : config.apiVersion) != null ? _b : "2022-11-27"
|
|
4547
|
+
});
|
|
4548
|
+
const documentId = (_c = fieldTranslationParams == null ? void 0 : fieldTranslationParams.document) == null ? void 0 : _c._id;
|
|
4549
|
+
const id = useId();
|
|
4550
|
+
const selectFromLanguage = useCallback((from, languages2, params) => {
|
|
4551
|
+
var _a2, _b2;
|
|
4552
|
+
const {
|
|
4553
|
+
document,
|
|
4554
|
+
documentSchema
|
|
4555
|
+
} = params != null ? params : {};
|
|
4556
|
+
setFromLanguage(from);
|
|
4557
|
+
if (!document || !documentSchema || !params || !languages2) {
|
|
4558
|
+
setFieldLanguageMaps(void 0);
|
|
4559
|
+
return;
|
|
4560
|
+
}
|
|
4561
|
+
const preferred = getPreferredToFieldLanguages(from.id);
|
|
4562
|
+
const allToLanguages = languages2.filter(l => l.id !== (from == null ? void 0 : from.id));
|
|
4563
|
+
const filteredToLanguages = allToLanguages.filter(l => !preferred.length || preferred.includes(l.id));
|
|
4564
|
+
setToLanguages(filteredToLanguages);
|
|
4565
|
+
const fromId = from == null ? void 0 : from.id;
|
|
4566
|
+
const allToIds = (_a2 = allToLanguages == null ? void 0 : allToLanguages.map(l => l.id)) != null ? _a2 : [];
|
|
4567
|
+
const docMembers = getDocumentMembersFlat(document, documentSchema);
|
|
4568
|
+
if (fromId && (allToIds == null ? void 0 : allToIds.length)) {
|
|
4569
|
+
const transMap = getFieldLanguageMap(documentSchema, docMembers, fromId, allToIds.filter(toId => fromId !== toId), (_b2 = config == null ? void 0 : config.translationOutputs) != null ? _b2 : defaultLanguageOutputs);
|
|
4570
|
+
setFieldLanguageMaps(transMap);
|
|
4571
|
+
} else {
|
|
4572
|
+
setFieldLanguageMaps(void 0);
|
|
4573
|
+
}
|
|
4574
|
+
}, [config]);
|
|
4575
|
+
const toggleToLanguage = useCallback((toggledLang, toLanguages2, languages2) => {
|
|
4576
|
+
if (!languages2 || !fromLanguage) {
|
|
4577
|
+
return;
|
|
4578
|
+
}
|
|
4579
|
+
const wasSelected = !!(toLanguages2 == null ? void 0 : toLanguages2.find(l => l.id === toggledLang.id));
|
|
4580
|
+
const newToLangs = languages2.filter(anyLang => !!(toLanguages2 == null ? void 0 : toLanguages2.find(selectedLang => toggledLang.id !== selectedLang.id && selectedLang.id === anyLang.id)) || toggledLang.id === anyLang.id && !wasSelected);
|
|
4581
|
+
setToLanguages(newToLangs);
|
|
4582
|
+
setPreferredToFieldLanguages(fromLanguage.id, newToLangs.map(l => l.id));
|
|
4583
|
+
}, [fromLanguage]);
|
|
4584
|
+
const openFieldTranslation = useCallback(async params => {
|
|
4585
|
+
setDialogOpen(true);
|
|
4586
|
+
const languageParams = getLanguageParams(config == null ? void 0 : config.selectLanguageParams, params.document);
|
|
4587
|
+
const languages2 = await (typeof (config == null ? void 0 : config.languages) === "function" ? config == null ? void 0 : config.languages(languageClient, languageParams) : Promise.resolve(config == null ? void 0 : config.languages));
|
|
4588
|
+
setLanguages(languages2);
|
|
4589
|
+
setFieldTranslationParams(params);
|
|
4590
|
+
const fromLanguage2 = languages2 == null ? void 0 : languages2[0];
|
|
4591
|
+
if (fromLanguage2) {
|
|
4592
|
+
selectFromLanguage(fromLanguage2, languages2, params);
|
|
4593
|
+
} else {
|
|
4594
|
+
console.error("No languages available for selected language params", languageParams);
|
|
4595
|
+
}
|
|
4596
|
+
}, [selectFromLanguage, config, languageClient]);
|
|
4597
|
+
const contextValue = useMemo(() => {
|
|
4598
|
+
return {
|
|
4599
|
+
openFieldTranslation,
|
|
4600
|
+
translationLoading: false
|
|
4601
|
+
};
|
|
4602
|
+
}, [openFieldTranslation]);
|
|
4603
|
+
const runDisabled = !fromLanguage || !(toLanguages == null ? void 0 : toLanguages.length) || !(fieldLanguageMaps == null ? void 0 : fieldLanguageMaps.length) || !documentId || !hasValuesToTranslate(fieldLanguageMaps, fromLanguage, fieldTranslationParams.translatePath);
|
|
4604
|
+
const onRunTranslation = useCallback(() => {
|
|
4605
|
+
const translatePath = fieldTranslationParams == null ? void 0 : fieldTranslationParams.translatePath;
|
|
4606
|
+
if (fieldLanguageMaps && documentId && translatePath) {
|
|
4607
|
+
runTranslate({
|
|
4608
|
+
documentId,
|
|
4609
|
+
translatePath,
|
|
4610
|
+
fieldLanguageMap: fieldLanguageMaps.map(map => ({
|
|
4611
|
+
...map,
|
|
4612
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
4613
|
+
outputs: map.outputs.filter(out => !!(toLanguages == null ? void 0 : toLanguages.find(l => l.id === out.id)))
|
|
4614
|
+
})),
|
|
4615
|
+
conditionalMembers: fieldTranslationParams == null ? void 0 : fieldTranslationParams.conditionalMembers
|
|
4616
|
+
});
|
|
4617
|
+
}
|
|
4618
|
+
close();
|
|
4619
|
+
}, [fieldLanguageMaps, documentId, runTranslate, close, toLanguages, fieldTranslationParams == null ? void 0 : fieldTranslationParams.translatePath, fieldTranslationParams == null ? void 0 : fieldTranslationParams.conditionalMembers]);
|
|
4620
|
+
const runButton = /* @__PURE__ */jsx(Button, {
|
|
4621
|
+
text: "Translate",
|
|
4622
|
+
tone: "primary",
|
|
4623
|
+
icon: PlayIcon,
|
|
4624
|
+
style: {
|
|
4625
|
+
width: "100%"
|
|
4626
|
+
},
|
|
4627
|
+
disabled: runDisabled,
|
|
4628
|
+
onClick: onRunTranslation
|
|
4629
|
+
});
|
|
4630
|
+
return /* @__PURE__ */jsxs(FieldTranslationContext.Provider, {
|
|
4631
|
+
value: contextValue,
|
|
4632
|
+
children: [dialogOpen ? /* @__PURE__ */jsx(Dialog, {
|
|
4633
|
+
id,
|
|
4634
|
+
width: 1,
|
|
4635
|
+
open: dialogOpen,
|
|
4636
|
+
onClose: close,
|
|
4637
|
+
header: "Translate fields",
|
|
4638
|
+
footer: /* @__PURE__ */jsx(Flex, {
|
|
4639
|
+
justify: "space-between",
|
|
4640
|
+
padding: 2,
|
|
4641
|
+
flex: 1,
|
|
4642
|
+
children: runDisabled ? /* @__PURE__ */jsx(Tooltip, {
|
|
4643
|
+
content: /* @__PURE__ */jsx(Flex, {
|
|
4644
|
+
padding: 2,
|
|
4645
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4646
|
+
children: "There is nothing to translate in the selected from-language."
|
|
4647
|
+
})
|
|
4648
|
+
}),
|
|
4649
|
+
placement: "top",
|
|
4650
|
+
children: /* @__PURE__ */jsx(Flex, {
|
|
4651
|
+
flex: 1,
|
|
4652
|
+
children: runButton
|
|
3216
4653
|
})
|
|
4654
|
+
}) : runButton
|
|
4655
|
+
}),
|
|
4656
|
+
children: languages ? /* @__PURE__ */jsxs(Flex, {
|
|
4657
|
+
padding: 4,
|
|
4658
|
+
gap: 5,
|
|
4659
|
+
align: "flex-start",
|
|
4660
|
+
justify: "center",
|
|
4661
|
+
children: [/* @__PURE__ */jsxs(Stack, {
|
|
4662
|
+
space: 2,
|
|
4663
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4664
|
+
marginBottom: 2,
|
|
4665
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4666
|
+
weight: "semibold",
|
|
4667
|
+
children: "From"
|
|
4668
|
+
})
|
|
4669
|
+
}), languages == null ? void 0 : languages.map(radioLanguage => /* @__PURE__ */jsx(FromLanguageRadio, {
|
|
4670
|
+
...{
|
|
4671
|
+
radioLanguage,
|
|
4672
|
+
fromLanguage,
|
|
4673
|
+
selectFromLanguage,
|
|
4674
|
+
languages,
|
|
4675
|
+
fieldTranslationParams
|
|
4676
|
+
}
|
|
4677
|
+
}, radioLanguage.id))]
|
|
4678
|
+
}), /* @__PURE__ */jsxs(Stack, {
|
|
4679
|
+
space: 2,
|
|
4680
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4681
|
+
marginBottom: 2,
|
|
4682
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4683
|
+
weight: "semibold",
|
|
4684
|
+
children: "To"
|
|
4685
|
+
})
|
|
4686
|
+
}), languages.map(checkboxLanguage => /* @__PURE__ */jsx(ToLanguageCheckbox, {
|
|
4687
|
+
...{
|
|
4688
|
+
checkboxLanguage,
|
|
4689
|
+
fromLanguage,
|
|
4690
|
+
toLanguages,
|
|
4691
|
+
toggleToLanguage,
|
|
4692
|
+
languages
|
|
4693
|
+
}
|
|
4694
|
+
}, checkboxLanguage.id))]
|
|
4695
|
+
})]
|
|
4696
|
+
}) : /* @__PURE__ */jsxs(Flex, {
|
|
4697
|
+
padding: 4,
|
|
4698
|
+
gap: 2,
|
|
4699
|
+
align: "flex-start",
|
|
4700
|
+
justify: "center",
|
|
4701
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4702
|
+
children: /* @__PURE__ */jsx(Spinner, {})
|
|
4703
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4704
|
+
children: "Loading languages..."
|
|
3217
4705
|
})]
|
|
3218
4706
|
})
|
|
4707
|
+
}) : null, props.children]
|
|
4708
|
+
});
|
|
4709
|
+
}
|
|
4710
|
+
function ToLanguageCheckbox(props) {
|
|
4711
|
+
var _a;
|
|
4712
|
+
const {
|
|
4713
|
+
checkboxLanguage,
|
|
4714
|
+
fromLanguage,
|
|
4715
|
+
toLanguages,
|
|
4716
|
+
toggleToLanguage,
|
|
4717
|
+
languages
|
|
4718
|
+
} = props;
|
|
4719
|
+
const langId = checkboxLanguage.id;
|
|
4720
|
+
const onChange = useCallback(() => toggleToLanguage(checkboxLanguage, toLanguages, languages), [toggleToLanguage, checkboxLanguage, toLanguages, languages]);
|
|
4721
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
4722
|
+
gap: 3,
|
|
4723
|
+
align: "center",
|
|
4724
|
+
as: "label",
|
|
4725
|
+
style: langId === (fromLanguage == null ? void 0 : fromLanguage.id) ? {
|
|
4726
|
+
opacity: 0.5
|
|
4727
|
+
} : void 0,
|
|
4728
|
+
children: [/* @__PURE__ */jsx(Checkbox, {
|
|
4729
|
+
name: "toLang",
|
|
4730
|
+
value: langId,
|
|
4731
|
+
checked: langId !== (fromLanguage == null ? void 0 : fromLanguage.id) && !!(toLanguages == null ? void 0 : toLanguages.find(tl => tl.id === langId)),
|
|
4732
|
+
onChange,
|
|
4733
|
+
disabled: langId === (fromLanguage == null ? void 0 : fromLanguage.id)
|
|
4734
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4735
|
+
muted: langId === (fromLanguage == null ? void 0 : fromLanguage.id),
|
|
4736
|
+
children: (_a = checkboxLanguage.title) != null ? _a : langId
|
|
3219
4737
|
})]
|
|
4738
|
+
}, langId);
|
|
4739
|
+
}
|
|
4740
|
+
function FromLanguageRadio(props) {
|
|
4741
|
+
var _a;
|
|
4742
|
+
const {
|
|
4743
|
+
languages,
|
|
4744
|
+
radioLanguage,
|
|
4745
|
+
selectFromLanguage,
|
|
4746
|
+
fromLanguage,
|
|
4747
|
+
fieldTranslationParams
|
|
4748
|
+
} = props;
|
|
4749
|
+
const langId = radioLanguage.id;
|
|
4750
|
+
const onChange = useCallback(() => selectFromLanguage(radioLanguage, languages, fieldTranslationParams), [selectFromLanguage, radioLanguage, languages, fieldTranslationParams]);
|
|
4751
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
4752
|
+
gap: 3,
|
|
4753
|
+
align: "center",
|
|
4754
|
+
as: "label",
|
|
4755
|
+
children: [/* @__PURE__ */jsx(Radio, {
|
|
4756
|
+
name: "fromLang",
|
|
4757
|
+
value: langId,
|
|
4758
|
+
checked: langId === (fromLanguage == null ? void 0 : fromLanguage.id),
|
|
4759
|
+
onChange
|
|
4760
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4761
|
+
children: (_a = radioLanguage.title) != null ? _a : radioLanguage.id
|
|
4762
|
+
})]
|
|
4763
|
+
}, langId);
|
|
4764
|
+
}
|
|
4765
|
+
function AssistLayout(props) {
|
|
4766
|
+
const [connectors, setConnectors] = useState([]);
|
|
4767
|
+
return /* @__PURE__ */jsx(AiAssistanceConfigProvider, {
|
|
4768
|
+
config: props.config,
|
|
4769
|
+
children: /* @__PURE__ */jsx(RunInstructionProvider, {
|
|
4770
|
+
children: /* @__PURE__ */jsx(FieldTranslationProvider, {
|
|
4771
|
+
children: /* @__PURE__ */jsxs(ConnectorsProvider, {
|
|
4772
|
+
onConnectorsChange: setConnectors,
|
|
4773
|
+
children: [props.renderDefault(props), /* @__PURE__ */jsx(ThemeProvider, {
|
|
4774
|
+
tone: "default",
|
|
4775
|
+
children: /* @__PURE__ */jsx(AssistConnectorsOverlay, {
|
|
4776
|
+
connectors
|
|
4777
|
+
})
|
|
4778
|
+
})]
|
|
4779
|
+
})
|
|
4780
|
+
})
|
|
4781
|
+
})
|
|
3220
4782
|
});
|
|
3221
4783
|
}
|
|
3222
4784
|
var __freeze$1 = Object.freeze;
|
|
@@ -3242,7 +4804,10 @@ function ErrorWrapper(props) {
|
|
|
3242
4804
|
const catchError = useCallback(params => {
|
|
3243
4805
|
setError(params.error);
|
|
3244
4806
|
}, [setError]);
|
|
3245
|
-
const unsetValue = useCallback(() =>
|
|
4807
|
+
const unsetValue = useCallback(() => {
|
|
4808
|
+
onChange(PatchEvent.from(unset()));
|
|
4809
|
+
setError(void 0);
|
|
4810
|
+
}, [onChange]);
|
|
3246
4811
|
const dismiss = useCallback(() => setError(void 0), []);
|
|
3247
4812
|
const catcher = /* @__PURE__ */jsx(ErrorBoundary, {
|
|
3248
4813
|
onCatch: catchError,
|
|
@@ -3310,6 +4875,7 @@ function AssistFormBlock(props) {
|
|
|
3310
4875
|
_key: key
|
|
3311
4876
|
}));
|
|
3312
4877
|
}, [onChange, key]);
|
|
4878
|
+
const singlePresence = presence[0];
|
|
3313
4879
|
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
3314
4880
|
onChange: localOnChange,
|
|
3315
4881
|
children: /* @__PURE__ */jsxs(Flex, {
|
|
@@ -3318,9 +4884,9 @@ function AssistFormBlock(props) {
|
|
|
3318
4884
|
children: [/* @__PURE__ */jsx(Box, {
|
|
3319
4885
|
flex: 1,
|
|
3320
4886
|
children: props.renderDefault(props)
|
|
3321
|
-
}),
|
|
3322
|
-
presence:
|
|
3323
|
-
}
|
|
4887
|
+
}), singlePresence && /* @__PURE__ */jsx(AiFieldPresence, {
|
|
4888
|
+
presence: singlePresence
|
|
4889
|
+
})]
|
|
3324
4890
|
})
|
|
3325
4891
|
});
|
|
3326
4892
|
}
|
|
@@ -3364,16 +4930,24 @@ function InstructionInput(props) {
|
|
|
3364
4930
|
...props
|
|
3365
4931
|
}), /* @__PURE__ */jsx(ShareField, {
|
|
3366
4932
|
...props
|
|
3367
|
-
}), /* @__PURE__ */jsx(
|
|
4933
|
+
}), /* @__PURE__ */jsx(ObjectMember, {
|
|
4934
|
+
fieldName: "prompt",
|
|
4935
|
+
...props
|
|
4936
|
+
}), /* @__PURE__ */jsx(ObjectMember, {
|
|
4937
|
+
fieldName: "output",
|
|
3368
4938
|
...props
|
|
3369
4939
|
})]
|
|
3370
4940
|
});
|
|
3371
4941
|
}
|
|
3372
|
-
function
|
|
3373
|
-
|
|
3374
|
-
|
|
4942
|
+
function ObjectMember(_ref13) {
|
|
4943
|
+
let {
|
|
4944
|
+
fieldName,
|
|
4945
|
+
...props
|
|
4946
|
+
} = _ref13;
|
|
4947
|
+
const member = findFieldMember(props.members, fieldName);
|
|
4948
|
+
return member ? /* @__PURE__ */jsx(ObjectInputMember, {
|
|
3375
4949
|
...props,
|
|
3376
|
-
member
|
|
4950
|
+
member
|
|
3377
4951
|
}) : null;
|
|
3378
4952
|
}
|
|
3379
4953
|
const NONE = [];
|
|
@@ -3508,8 +5082,8 @@ function IconInput(props) {
|
|
|
3508
5082
|
onChange
|
|
3509
5083
|
} = props;
|
|
3510
5084
|
const id = useId();
|
|
3511
|
-
const items = useMemo(() => Object.entries(icons).map(
|
|
3512
|
-
let [key, icon] =
|
|
5085
|
+
const items = useMemo(() => Object.entries(icons).map(_ref14 => {
|
|
5086
|
+
let [key, icon] = _ref14;
|
|
3513
5087
|
return /* @__PURE__ */jsx(IconItem, {
|
|
3514
5088
|
iconKey: key,
|
|
3515
5089
|
icon,
|
|
@@ -3537,12 +5111,12 @@ function IconInput(props) {
|
|
|
3537
5111
|
}
|
|
3538
5112
|
});
|
|
3539
5113
|
}
|
|
3540
|
-
function IconItem(
|
|
5114
|
+
function IconItem(_ref15) {
|
|
3541
5115
|
let {
|
|
3542
5116
|
icon,
|
|
3543
5117
|
iconKey: key,
|
|
3544
5118
|
onChange
|
|
3545
|
-
} =
|
|
5119
|
+
} = _ref15;
|
|
3546
5120
|
const onClick = useCallback(() => onChange(set(key)), [onChange, key]);
|
|
3547
5121
|
return /* @__PURE__ */jsx(MenuItem, {
|
|
3548
5122
|
icon,
|
|
@@ -3553,8 +5127,8 @@ function IconItem(_ref11) {
|
|
|
3553
5127
|
}
|
|
3554
5128
|
function getIcon(iconName) {
|
|
3555
5129
|
var _a, _b;
|
|
3556
|
-
return (_b = (_a = Object.entries(icons).find(
|
|
3557
|
-
let [key] =
|
|
5130
|
+
return (_b = (_a = Object.entries(icons).find(_ref16 => {
|
|
5131
|
+
let [key] = _ref16;
|
|
3558
5132
|
return key === iconName;
|
|
3559
5133
|
})) == null ? void 0 : _a[1]) != null ? _b : icons.sparkles;
|
|
3560
5134
|
}
|
|
@@ -3713,11 +5287,11 @@ const contextDocumentSchema = defineType({
|
|
|
3713
5287
|
title: "title",
|
|
3714
5288
|
context: "context"
|
|
3715
5289
|
},
|
|
3716
|
-
prepare(
|
|
5290
|
+
prepare(_ref17) {
|
|
3717
5291
|
let {
|
|
3718
5292
|
title,
|
|
3719
5293
|
context
|
|
3720
|
-
} =
|
|
5294
|
+
} = _ref17;
|
|
3721
5295
|
var _a;
|
|
3722
5296
|
const text = context == null ? void 0 : context.flatMap(block => block == null ? void 0 : block.children).flatMap(child => {
|
|
3723
5297
|
var _a2;
|
|
@@ -3744,7 +5318,7 @@ function whatwgRNG() {
|
|
|
3744
5318
|
getRandomValues(rnds8);
|
|
3745
5319
|
return rnds8;
|
|
3746
5320
|
}
|
|
3747
|
-
const getByteHexTable =
|
|
5321
|
+
const getByteHexTable = (() => {
|
|
3748
5322
|
let table;
|
|
3749
5323
|
return () => {
|
|
3750
5324
|
if (table) {
|
|
@@ -3803,10 +5377,204 @@ function InstructionsArrayField(props) {
|
|
|
3803
5377
|
title: " "
|
|
3804
5378
|
});
|
|
3805
5379
|
}
|
|
5380
|
+
function InstructionOutputField(props) {
|
|
5381
|
+
var _a;
|
|
5382
|
+
const {
|
|
5383
|
+
fieldSchema
|
|
5384
|
+
} = (_a = useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5385
|
+
if (!fieldSchema || !(isObjectSchemaType(fieldSchema) || isArrayOfObjectsSchemaType(fieldSchema))) {
|
|
5386
|
+
return null;
|
|
5387
|
+
}
|
|
5388
|
+
return /* @__PURE__ */jsx(EnabledOutputField, {
|
|
5389
|
+
...props,
|
|
5390
|
+
fieldSchema,
|
|
5391
|
+
children: props.children
|
|
5392
|
+
});
|
|
5393
|
+
}
|
|
5394
|
+
function EnabledOutputField(_ref18) {
|
|
5395
|
+
let {
|
|
5396
|
+
fieldSchema,
|
|
5397
|
+
...props
|
|
5398
|
+
} = _ref18;
|
|
5399
|
+
var _a;
|
|
5400
|
+
const [open, setOpen] = useState(!!((_a = props.value) == null ? void 0 : _a.length));
|
|
5401
|
+
const onExpand = useCallback(() => setOpen(true), []);
|
|
5402
|
+
const onCollapse = useCallback(() => setOpen(false), []);
|
|
5403
|
+
return props.renderDefault({
|
|
5404
|
+
...props,
|
|
5405
|
+
collapsible: true,
|
|
5406
|
+
onExpand,
|
|
5407
|
+
onCollapse,
|
|
5408
|
+
collapsed: !open,
|
|
5409
|
+
level: 1,
|
|
5410
|
+
title: isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
function InstructionOutputInput(props) {
|
|
5414
|
+
var _a;
|
|
5415
|
+
const {
|
|
5416
|
+
fieldSchema
|
|
5417
|
+
} = (_a = useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5418
|
+
if (!fieldSchema) {
|
|
5419
|
+
return null;
|
|
5420
|
+
}
|
|
5421
|
+
if (isObjectSchemaType(fieldSchema)) {
|
|
5422
|
+
return /* @__PURE__ */jsx(ObjectOutputInput, {
|
|
5423
|
+
...props,
|
|
5424
|
+
fieldSchema
|
|
5425
|
+
});
|
|
5426
|
+
}
|
|
5427
|
+
if (isArrayOfObjectsSchemaType(fieldSchema)) {
|
|
5428
|
+
return /* @__PURE__ */jsx(ArrayOutputInput, {
|
|
5429
|
+
...props,
|
|
5430
|
+
fieldSchema
|
|
5431
|
+
});
|
|
5432
|
+
}
|
|
5433
|
+
return null;
|
|
5434
|
+
}
|
|
5435
|
+
function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
5436
|
+
useEffect(() => {
|
|
5437
|
+
var _a, _b;
|
|
5438
|
+
const validValues = value == null ? void 0 : value.filter(v => allowedValues.find(f => f.name === (v._type === outputFieldTypeName ? v.relativePath : v.type)));
|
|
5439
|
+
const valueLength = (_a = value == null ? void 0 : value.length) != null ? _a : 0;
|
|
5440
|
+
const validLength = (_b = validValues == null ? void 0 : validValues.length) != null ? _b : 0;
|
|
5441
|
+
if (!validLength && valueLength || validLength >= allowedValues.length) {
|
|
5442
|
+
onChange(PatchEvent.from([unset()]));
|
|
5443
|
+
}
|
|
5444
|
+
}, [allowedValues, value, onChange]);
|
|
5445
|
+
}
|
|
5446
|
+
function ObjectOutputInput(_ref19) {
|
|
5447
|
+
let {
|
|
5448
|
+
fieldSchema,
|
|
5449
|
+
...props
|
|
5450
|
+
} = _ref19;
|
|
5451
|
+
const {
|
|
5452
|
+
value,
|
|
5453
|
+
onChange
|
|
5454
|
+
} = props;
|
|
5455
|
+
const fields = useMemo(() => fieldSchema.fields.filter(field => isAssistSupported(field.type)), [fieldSchema.fields]);
|
|
5456
|
+
useEmptySelectAllValue(value, fields, onChange);
|
|
5457
|
+
const onSelectChange = useCallback((checked, selectedValue) => {
|
|
5458
|
+
if (checked) {
|
|
5459
|
+
if (value == null ? void 0 : value.length) {
|
|
5460
|
+
onChange(PatchEvent.from(unset([{
|
|
5461
|
+
_key: selectedValue
|
|
5462
|
+
}])));
|
|
5463
|
+
} else {
|
|
5464
|
+
const items = fields.filter(f => f.name !== selectedValue).map(field => typed({
|
|
5465
|
+
_key: field.name,
|
|
5466
|
+
_type: "sanity.assist.output.field",
|
|
5467
|
+
relativePath: field.name
|
|
5468
|
+
}));
|
|
5469
|
+
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
5470
|
+
}
|
|
5471
|
+
} else {
|
|
5472
|
+
const patchValue = {
|
|
5473
|
+
_key: selectedValue,
|
|
5474
|
+
_type: "sanity.assist.output.field",
|
|
5475
|
+
relativePath: selectedValue
|
|
5476
|
+
};
|
|
5477
|
+
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
5478
|
+
}
|
|
5479
|
+
}, [onChange, value, fields]);
|
|
5480
|
+
return /* @__PURE__ */jsx(Stack, {
|
|
5481
|
+
space: 2,
|
|
5482
|
+
children: fields.map(field => {
|
|
5483
|
+
var _a;
|
|
5484
|
+
return /* @__PURE__ */jsx(Flex, {
|
|
5485
|
+
align: "center",
|
|
5486
|
+
gap: 2,
|
|
5487
|
+
children: /* @__PURE__ */jsx(Selectable, {
|
|
5488
|
+
value: field.name,
|
|
5489
|
+
title: (_a = field.type.title) != null ? _a : field.name,
|
|
5490
|
+
arrayValue: value,
|
|
5491
|
+
onChange: onSelectChange
|
|
5492
|
+
})
|
|
5493
|
+
}, field.name);
|
|
5494
|
+
})
|
|
5495
|
+
});
|
|
5496
|
+
}
|
|
5497
|
+
function ArrayOutputInput(_ref20) {
|
|
5498
|
+
let {
|
|
5499
|
+
fieldSchema,
|
|
5500
|
+
...props
|
|
5501
|
+
} = _ref20;
|
|
5502
|
+
const {
|
|
5503
|
+
value,
|
|
5504
|
+
onChange
|
|
5505
|
+
} = props;
|
|
5506
|
+
const ofItems = useMemo(() => fieldSchema.of.filter(itemType => isAssistSupported(itemType)), [fieldSchema.of]);
|
|
5507
|
+
useEmptySelectAllValue(value, ofItems, onChange);
|
|
5508
|
+
const onSelectChange = useCallback((checked, selectedValue) => {
|
|
5509
|
+
if (checked) {
|
|
5510
|
+
if (value == null ? void 0 : value.length) {
|
|
5511
|
+
onChange(PatchEvent.from(unset([{
|
|
5512
|
+
_key: selectedValue
|
|
5513
|
+
}])));
|
|
5514
|
+
} else {
|
|
5515
|
+
const items = ofItems.filter(f => f.name !== selectedValue).map(field => typed({
|
|
5516
|
+
_key: field.name,
|
|
5517
|
+
_type: "sanity.assist.output.type",
|
|
5518
|
+
type: field.name
|
|
5519
|
+
}));
|
|
5520
|
+
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
5521
|
+
}
|
|
5522
|
+
} else {
|
|
5523
|
+
const patchValue = {
|
|
5524
|
+
_key: selectedValue,
|
|
5525
|
+
_type: "sanity.assist.output.type",
|
|
5526
|
+
type: selectedValue
|
|
5527
|
+
};
|
|
5528
|
+
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
5529
|
+
}
|
|
5530
|
+
}, [onChange, value, ofItems]);
|
|
5531
|
+
return /* @__PURE__ */jsx(Stack, {
|
|
5532
|
+
space: 2,
|
|
5533
|
+
children: ofItems.map(itemType => {
|
|
5534
|
+
var _a;
|
|
5535
|
+
return /* @__PURE__ */jsx(Flex, {
|
|
5536
|
+
children: /* @__PURE__ */jsx(Selectable, {
|
|
5537
|
+
value: itemType.name,
|
|
5538
|
+
title: isType(itemType, "block") ? "Text" : (_a = itemType.title) != null ? _a : itemType.name,
|
|
5539
|
+
arrayValue: value,
|
|
5540
|
+
onChange: onSelectChange
|
|
5541
|
+
})
|
|
5542
|
+
}, itemType.name);
|
|
5543
|
+
})
|
|
5544
|
+
});
|
|
5545
|
+
}
|
|
5546
|
+
function Selectable(_ref21) {
|
|
5547
|
+
let {
|
|
5548
|
+
title,
|
|
5549
|
+
arrayValue,
|
|
5550
|
+
value,
|
|
5551
|
+
onChange
|
|
5552
|
+
} = _ref21;
|
|
5553
|
+
const checked = !(arrayValue == null ? void 0 : arrayValue.length) || !!(arrayValue == null ? void 0 : arrayValue.find(v => v._key === value));
|
|
5554
|
+
const handleChange = useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
5555
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
5556
|
+
gap: 2,
|
|
5557
|
+
align: "flex-start",
|
|
5558
|
+
children: [/* @__PURE__ */jsx(Checkbox, {
|
|
5559
|
+
checked,
|
|
5560
|
+
onChange: handleChange
|
|
5561
|
+
}), /* @__PURE__ */jsx(Card, {
|
|
5562
|
+
marginTop: 1,
|
|
5563
|
+
onClick: handleChange,
|
|
5564
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5565
|
+
style: {
|
|
5566
|
+
cursor: "default"
|
|
5567
|
+
},
|
|
5568
|
+
size: 1,
|
|
5569
|
+
children: title
|
|
5570
|
+
})
|
|
5571
|
+
})]
|
|
5572
|
+
});
|
|
5573
|
+
}
|
|
3806
5574
|
const fieldReference = defineType({
|
|
3807
5575
|
type: "object",
|
|
3808
5576
|
name: fieldReferenceTypeName,
|
|
3809
|
-
title: "
|
|
5577
|
+
title: "Field",
|
|
3810
5578
|
icon: ThListIcon,
|
|
3811
5579
|
fields: [defineField({
|
|
3812
5580
|
type: "string",
|
|
@@ -3846,10 +5614,10 @@ const fieldReference = defineType({
|
|
|
3846
5614
|
select: {
|
|
3847
5615
|
path: "path"
|
|
3848
5616
|
},
|
|
3849
|
-
prepare(
|
|
5617
|
+
prepare(_ref22) {
|
|
3850
5618
|
let {
|
|
3851
5619
|
path
|
|
3852
|
-
} =
|
|
5620
|
+
} = _ref22;
|
|
3853
5621
|
return {
|
|
3854
5622
|
title: path,
|
|
3855
5623
|
path,
|
|
@@ -3994,12 +5762,12 @@ const instruction = defineType({
|
|
|
3994
5762
|
title: "title",
|
|
3995
5763
|
userId: "userId"
|
|
3996
5764
|
},
|
|
3997
|
-
prepare:
|
|
5765
|
+
prepare: _ref23 => {
|
|
3998
5766
|
let {
|
|
3999
5767
|
icon,
|
|
4000
5768
|
title,
|
|
4001
5769
|
userId
|
|
4002
|
-
} =
|
|
5770
|
+
} = _ref23;
|
|
4003
5771
|
return {
|
|
4004
5772
|
title,
|
|
4005
5773
|
icon: icon ? icons[icon] : SparklesIcon,
|
|
@@ -4104,6 +5872,33 @@ const instruction = defineType({
|
|
|
4104
5872
|
var _a, _b;
|
|
4105
5873
|
return (_b = (_a = context.currentUser) == null ? void 0 : _a.id) != null ? _b : "";
|
|
4106
5874
|
}
|
|
5875
|
+
}), defineField({
|
|
5876
|
+
type: "array",
|
|
5877
|
+
name: "output",
|
|
5878
|
+
title: "Output filter",
|
|
5879
|
+
components: {
|
|
5880
|
+
input: InstructionOutputInput,
|
|
5881
|
+
field: InstructionOutputField
|
|
5882
|
+
},
|
|
5883
|
+
of: [defineArrayMember({
|
|
5884
|
+
type: "object",
|
|
5885
|
+
name: outputFieldTypeName,
|
|
5886
|
+
title: "Output field",
|
|
5887
|
+
fields: [{
|
|
5888
|
+
type: "string",
|
|
5889
|
+
name: "path",
|
|
5890
|
+
title: "Path"
|
|
5891
|
+
}]
|
|
5892
|
+
}), defineArrayMember({
|
|
5893
|
+
type: "object",
|
|
5894
|
+
name: outputTypeTypeName,
|
|
5895
|
+
title: "Output type",
|
|
5896
|
+
fields: [{
|
|
5897
|
+
type: "string",
|
|
5898
|
+
name: "type",
|
|
5899
|
+
title: "Type"
|
|
5900
|
+
}]
|
|
5901
|
+
})]
|
|
4107
5902
|
})]
|
|
4108
5903
|
});
|
|
4109
5904
|
const fieldInstructions = defineType({
|
|
@@ -4320,7 +6115,7 @@ function PrivateIcon() {
|
|
|
4320
6115
|
children: /* @__PURE__ */jsx(LockIcon, {})
|
|
4321
6116
|
});
|
|
4322
6117
|
}
|
|
4323
|
-
const ImageContext = createContext(
|
|
6118
|
+
const ImageContext = createContext({});
|
|
4324
6119
|
function ImageContextProvider(props) {
|
|
4325
6120
|
var _a;
|
|
4326
6121
|
const {
|
|
@@ -4345,28 +6140,30 @@ function ImageContextProvider(props) {
|
|
|
4345
6140
|
isSyncing
|
|
4346
6141
|
} = useSyncState(publicId(documentId), documentSchemaType.name);
|
|
4347
6142
|
useEffect(() => {
|
|
4348
|
-
const
|
|
4349
|
-
if (assetRef && documentId &&
|
|
6143
|
+
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6144
|
+
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
|
|
4350
6145
|
setAssetRefState(assetRef);
|
|
4351
6146
|
generateCaption({
|
|
4352
|
-
path: pathToString([...path,
|
|
6147
|
+
path: pathToString([...path, descriptionField]),
|
|
4353
6148
|
documentId
|
|
4354
6149
|
});
|
|
4355
6150
|
}
|
|
4356
6151
|
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing]);
|
|
4357
6152
|
const context = useMemo(() => {
|
|
4358
|
-
const
|
|
4359
|
-
|
|
4360
|
-
|
|
6153
|
+
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6154
|
+
const imageInstructionField = getImageInstructionFieldOption(schemaType);
|
|
6155
|
+
return {
|
|
6156
|
+
imageDescriptionPath: descriptionField ? pathToString([...path, descriptionField]) : void 0,
|
|
6157
|
+
imageInstructionPath: imageInstructionField ? pathToString([...path, imageInstructionField]) : void 0,
|
|
4361
6158
|
assetRef
|
|
4362
|
-
}
|
|
6159
|
+
};
|
|
4363
6160
|
}, [schemaType, path, assetRef]);
|
|
4364
6161
|
return /* @__PURE__ */jsx(ImageContext.Provider, {
|
|
4365
6162
|
value: context,
|
|
4366
6163
|
children: props.renderDefault(props)
|
|
4367
6164
|
});
|
|
4368
6165
|
}
|
|
4369
|
-
function node$
|
|
6166
|
+
function node$3(node2) {
|
|
4370
6167
|
return node2;
|
|
4371
6168
|
}
|
|
4372
6169
|
const generateCaptionsActions = {
|
|
@@ -4382,12 +6179,12 @@ const generateCaptionsActions = {
|
|
|
4382
6179
|
loading
|
|
4383
6180
|
} = useGenerateCaption(apiClient);
|
|
4384
6181
|
const imageContext = useContext(ImageContext);
|
|
4385
|
-
if (imageContext && pathKey === (imageContext == null ? void 0 : imageContext.
|
|
6182
|
+
if (imageContext && pathKey === (imageContext == null ? void 0 : imageContext.imageDescriptionPath)) {
|
|
4386
6183
|
const {
|
|
4387
6184
|
documentId
|
|
4388
6185
|
} = useAssistDocumentContext();
|
|
4389
6186
|
return useMemo(() => {
|
|
4390
|
-
return node$
|
|
6187
|
+
return node$3({
|
|
4391
6188
|
type: "action",
|
|
4392
6189
|
icon: loading ? () => /* @__PURE__ */jsx(Box, {
|
|
4393
6190
|
style: {
|
|
@@ -4399,7 +6196,7 @@ const generateCaptionsActions = {
|
|
|
4399
6196
|
}
|
|
4400
6197
|
})
|
|
4401
6198
|
}) : ImageIcon,
|
|
4402
|
-
title: "Generate
|
|
6199
|
+
title: "Generate image description",
|
|
4403
6200
|
onAction: () => {
|
|
4404
6201
|
if (loading) {
|
|
4405
6202
|
return;
|
|
@@ -4418,6 +6215,185 @@ const generateCaptionsActions = {
|
|
|
4418
6215
|
return void 0;
|
|
4419
6216
|
}
|
|
4420
6217
|
};
|
|
6218
|
+
function node$2(node2) {
|
|
6219
|
+
return node2;
|
|
6220
|
+
}
|
|
6221
|
+
const translateActions = {
|
|
6222
|
+
name: "sanity-assist-translate",
|
|
6223
|
+
useAction(props) {
|
|
6224
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6225
|
+
const {
|
|
6226
|
+
config,
|
|
6227
|
+
status
|
|
6228
|
+
} = useAiAssistanceConfig();
|
|
6229
|
+
const apiClient = useApiClient(config == null ? void 0 : config.__customApiClient);
|
|
6230
|
+
const {
|
|
6231
|
+
schemaType: fieldSchemaType,
|
|
6232
|
+
path,
|
|
6233
|
+
documentId,
|
|
6234
|
+
documentSchemaType,
|
|
6235
|
+
documentIsAssistable
|
|
6236
|
+
} = props;
|
|
6237
|
+
const isDocumentLevel = path.length === 0;
|
|
6238
|
+
const readOnly = fieldSchemaType.readOnly === true;
|
|
6239
|
+
const docTransTypes = (_b = (_a = config.translate) == null ? void 0 : _a.document) == null ? void 0 : _b.documentTypes;
|
|
6240
|
+
const options = fieldSchemaType == null ? void 0 : fieldSchemaType.options;
|
|
6241
|
+
const addFieldAction = isDocumentLevel || ((_c = options == null ? void 0 : options.aiAssist) == null ? void 0 : _c.translateAction);
|
|
6242
|
+
const fieldTransEnabled = addFieldAction && documentSchemaType && ((_f = (_e = (_d = config.translate) == null ? void 0 : _d.field) == null ? void 0 : _e.documentTypes) == null ? void 0 : _f.includes(documentSchemaType.name));
|
|
6243
|
+
const documentTranslationEnabled = addFieldAction && documentSchemaType && (!docTransTypes && isAssistSupported(fieldSchemaType) || (docTransTypes == null ? void 0 : docTransTypes.includes(documentSchemaType.name)));
|
|
6244
|
+
if (documentSchemaType && (documentTranslationEnabled || fieldTransEnabled)) {
|
|
6245
|
+
const {
|
|
6246
|
+
value: documentValue,
|
|
6247
|
+
onChange: documentOnChange,
|
|
6248
|
+
formState
|
|
6249
|
+
} = useDocumentPane();
|
|
6250
|
+
const docRef = useRef(documentValue);
|
|
6251
|
+
docRef.current = documentValue;
|
|
6252
|
+
const formStateRef = useRef(formState);
|
|
6253
|
+
formStateRef.current = formState;
|
|
6254
|
+
const translationApi = useTranslate(apiClient);
|
|
6255
|
+
const translate = useDraftDelayedTask({
|
|
6256
|
+
documentOnChange,
|
|
6257
|
+
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false,
|
|
6258
|
+
task: translationApi.translate
|
|
6259
|
+
});
|
|
6260
|
+
const languagePath = (_h = (_g = config.translate) == null ? void 0 : _g.document) == null ? void 0 : _h.languageField;
|
|
6261
|
+
const translateDocumentAction = useMemo(() => {
|
|
6262
|
+
if (!languagePath || !documentTranslationEnabled) {
|
|
6263
|
+
return void 0;
|
|
6264
|
+
}
|
|
6265
|
+
const title = path.length ? "Translate" : "Translate document";
|
|
6266
|
+
return node$2({
|
|
6267
|
+
type: "action",
|
|
6268
|
+
icon: translationApi.loading ? () => /* @__PURE__ */jsx(Box, {
|
|
6269
|
+
style: {
|
|
6270
|
+
height: 17
|
|
6271
|
+
},
|
|
6272
|
+
children: /* @__PURE__ */jsx(Spinner, {
|
|
6273
|
+
style: {
|
|
6274
|
+
transform: "translateY(6px)"
|
|
6275
|
+
}
|
|
6276
|
+
})
|
|
6277
|
+
}) : TranslateIcon,
|
|
6278
|
+
title,
|
|
6279
|
+
onAction: () => {
|
|
6280
|
+
if (translationApi.loading || !languagePath || !documentId) {
|
|
6281
|
+
return;
|
|
6282
|
+
}
|
|
6283
|
+
translate({
|
|
6284
|
+
languagePath,
|
|
6285
|
+
translatePath: path,
|
|
6286
|
+
documentId: documentId != null ? documentId : "",
|
|
6287
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
6288
|
+
});
|
|
6289
|
+
},
|
|
6290
|
+
renderAsButton: true,
|
|
6291
|
+
disabled: translationApi.loading || readOnly
|
|
6292
|
+
});
|
|
6293
|
+
}, [languagePath, translate, documentId, translationApi.loading, documentTranslationEnabled, path, readOnly]);
|
|
6294
|
+
const fieldTranslate = useFieldTranslation();
|
|
6295
|
+
const openFieldTranslation = useDraftDelayedTask({
|
|
6296
|
+
documentOnChange,
|
|
6297
|
+
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false,
|
|
6298
|
+
task: fieldTranslate.openFieldTranslation
|
|
6299
|
+
});
|
|
6300
|
+
const translateFieldsAction = useMemo(() => fieldTransEnabled ? node$2({
|
|
6301
|
+
type: "action",
|
|
6302
|
+
icon: fieldTranslate.translationLoading ? () => /* @__PURE__ */jsx(Box, {
|
|
6303
|
+
style: {
|
|
6304
|
+
height: 17
|
|
6305
|
+
},
|
|
6306
|
+
children: /* @__PURE__ */jsx(Spinner, {
|
|
6307
|
+
style: {
|
|
6308
|
+
transform: "translateY(6px)"
|
|
6309
|
+
}
|
|
6310
|
+
})
|
|
6311
|
+
}) : TranslateIcon,
|
|
6312
|
+
title: "Translate fields...",
|
|
6313
|
+
onAction: () => {
|
|
6314
|
+
if (fieldTranslate.translationLoading || !documentId) {
|
|
6315
|
+
return;
|
|
6316
|
+
}
|
|
6317
|
+
if (formStateRef.current) {
|
|
6318
|
+
getConditionalMembers(formStateRef.current);
|
|
6319
|
+
}
|
|
6320
|
+
openFieldTranslation({
|
|
6321
|
+
document: docRef.current,
|
|
6322
|
+
documentSchema: documentSchemaType,
|
|
6323
|
+
translatePath: path,
|
|
6324
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
6325
|
+
});
|
|
6326
|
+
},
|
|
6327
|
+
renderAsButton: true,
|
|
6328
|
+
disabled: fieldTranslate.translationLoading || readOnly
|
|
6329
|
+
}) : void 0, [openFieldTranslation, documentSchemaType, documentId, fieldTranslate.translationLoading, fieldTransEnabled, path, readOnly]);
|
|
6330
|
+
return useMemo(() => {
|
|
6331
|
+
if (!(status == null ? void 0 : status.initialized)) {
|
|
6332
|
+
return void 0;
|
|
6333
|
+
}
|
|
6334
|
+
return node$2({
|
|
6335
|
+
type: "group",
|
|
6336
|
+
icon: () => null,
|
|
6337
|
+
title: "Translation",
|
|
6338
|
+
children: [translateDocumentAction, translateFieldsAction].filter(c => !!c),
|
|
6339
|
+
expanded: true
|
|
6340
|
+
});
|
|
6341
|
+
}, [translateDocumentAction, translateFieldsAction, status]);
|
|
6342
|
+
}
|
|
6343
|
+
return void 0;
|
|
6344
|
+
}
|
|
6345
|
+
};
|
|
6346
|
+
function node$1(node2) {
|
|
6347
|
+
return node2;
|
|
6348
|
+
}
|
|
6349
|
+
const generateImagActions = {
|
|
6350
|
+
name: "sanity-assist-generate-image",
|
|
6351
|
+
useAction(props) {
|
|
6352
|
+
const pathKey = usePathKey(props.path);
|
|
6353
|
+
const {
|
|
6354
|
+
config
|
|
6355
|
+
} = useAiAssistanceConfig();
|
|
6356
|
+
const apiClient = useApiClient(config == null ? void 0 : config.__customApiClient);
|
|
6357
|
+
const {
|
|
6358
|
+
generateImage,
|
|
6359
|
+
loading
|
|
6360
|
+
} = useGenerateImage(apiClient);
|
|
6361
|
+
const imageContext = useContext(ImageContext);
|
|
6362
|
+
if (imageContext && pathKey === (imageContext == null ? void 0 : imageContext.imageInstructionPath)) {
|
|
6363
|
+
const {
|
|
6364
|
+
documentId
|
|
6365
|
+
} = useAssistDocumentContext();
|
|
6366
|
+
return useMemo(() => {
|
|
6367
|
+
return node$1({
|
|
6368
|
+
type: "action",
|
|
6369
|
+
icon: loading ? () => /* @__PURE__ */jsx(Box, {
|
|
6370
|
+
style: {
|
|
6371
|
+
height: 17
|
|
6372
|
+
},
|
|
6373
|
+
children: /* @__PURE__ */jsx(Spinner, {
|
|
6374
|
+
style: {
|
|
6375
|
+
transform: "translateY(6px)"
|
|
6376
|
+
}
|
|
6377
|
+
})
|
|
6378
|
+
}) : ImageIcon,
|
|
6379
|
+
title: "Generate image from prompt",
|
|
6380
|
+
onAction: () => {
|
|
6381
|
+
if (loading) {
|
|
6382
|
+
return;
|
|
6383
|
+
}
|
|
6384
|
+
generateImage({
|
|
6385
|
+
path: pathKey,
|
|
6386
|
+
documentId: documentId != null ? documentId : ""
|
|
6387
|
+
});
|
|
6388
|
+
},
|
|
6389
|
+
renderAsButton: true,
|
|
6390
|
+
disabled: loading
|
|
6391
|
+
});
|
|
6392
|
+
}, [generateImage, pathKey, documentId, loading]);
|
|
6393
|
+
}
|
|
6394
|
+
return void 0;
|
|
6395
|
+
}
|
|
6396
|
+
};
|
|
4421
6397
|
function node(node2) {
|
|
4422
6398
|
return node2;
|
|
4423
6399
|
}
|
|
@@ -4438,7 +6414,8 @@ const assistFieldActions = {
|
|
|
4438
6414
|
documentOnChange,
|
|
4439
6415
|
documentSchemaType,
|
|
4440
6416
|
documentId,
|
|
4441
|
-
selectedPath
|
|
6417
|
+
selectedPath,
|
|
6418
|
+
assistableDocumentId
|
|
4442
6419
|
} =
|
|
4443
6420
|
// document field actions do not have access to the document context
|
|
4444
6421
|
// conditional hook _should_ be safe here since the logical path will be stable
|
|
@@ -4448,8 +6425,11 @@ const assistFieldActions = {
|
|
|
4448
6425
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
4449
6426
|
useAssistDocumentContext();
|
|
4450
6427
|
const {
|
|
4451
|
-
value: docValue
|
|
6428
|
+
value: docValue,
|
|
6429
|
+
formState
|
|
4452
6430
|
} = useDocumentPane();
|
|
6431
|
+
const formStateRef = useRef(formState);
|
|
6432
|
+
formStateRef.current = formState;
|
|
4453
6433
|
const currentUser = useCurrentUser();
|
|
4454
6434
|
const isHidden = !assistDocument;
|
|
4455
6435
|
const pathKey = usePathKey(props.path);
|
|
@@ -4463,7 +6443,7 @@ const assistFieldActions = {
|
|
|
4463
6443
|
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false
|
|
4464
6444
|
});
|
|
4465
6445
|
const isSelectable = !!useSelectedField(documentSchemaType, typePath);
|
|
4466
|
-
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType);
|
|
6446
|
+
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== true;
|
|
4467
6447
|
const fieldAssist = useMemo(() => {
|
|
4468
6448
|
var _a;
|
|
4469
6449
|
return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path === typePath || pathKey === documentRootKey && f.path === pathKey);
|
|
@@ -4473,6 +6453,13 @@ const assistFieldActions = {
|
|
|
4473
6453
|
const isPathSelected = pathKey === selectedPath;
|
|
4474
6454
|
const isSelected = isInspectorOpen && isPathSelected;
|
|
4475
6455
|
const imageCaptionAction = generateCaptionsActions.useAction(props);
|
|
6456
|
+
const imageGenAction = generateImagActions.useAction(props);
|
|
6457
|
+
const translateAction = translateActions.useAction(typed({
|
|
6458
|
+
...props,
|
|
6459
|
+
documentId: assistableDocumentId,
|
|
6460
|
+
documentIsAssistable,
|
|
6461
|
+
documentSchemaType
|
|
6462
|
+
}));
|
|
4476
6463
|
const manageInstructions = useCallback(() => isSelected ? closeInspector(aiInspectorId) : openInspector(aiInspectorId, {
|
|
4477
6464
|
[fieldPathParam]: pathKey,
|
|
4478
6465
|
[instructionParam]: void 0
|
|
@@ -4486,7 +6473,8 @@ const assistFieldActions = {
|
|
|
4486
6473
|
assistDocumentId,
|
|
4487
6474
|
path: pathKey,
|
|
4488
6475
|
typePath,
|
|
4489
|
-
instruction
|
|
6476
|
+
instruction,
|
|
6477
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
4490
6478
|
});
|
|
4491
6479
|
}, [requestRunInstruction, assistableDocId, pathKey, typePath, assistDocumentId, fieldAssistKey]);
|
|
4492
6480
|
const privateInstructions = useMemo(() => {
|
|
@@ -4499,7 +6487,7 @@ const assistFieldActions = {
|
|
|
4499
6487
|
}, [fieldAssist == null ? void 0 : fieldAssist.instructions]);
|
|
4500
6488
|
const instructions = useMemo(() => [...privateInstructions, ...sharedInstructions], [privateInstructions, sharedInstructions]);
|
|
4501
6489
|
const runInstructionsGroup = useMemo(() => {
|
|
4502
|
-
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction ? node({
|
|
6490
|
+
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction || translateAction || imageGenAction ? node({
|
|
4503
6491
|
type: "group",
|
|
4504
6492
|
icon: () => null,
|
|
4505
6493
|
title: "Run instructions",
|
|
@@ -4510,10 +6498,10 @@ const assistFieldActions = {
|
|
|
4510
6498
|
hidden: isHidden,
|
|
4511
6499
|
documentIsNew: !!documentIsNew,
|
|
4512
6500
|
assistSupported
|
|
4513
|
-
}))), imageCaptionAction].filter(
|
|
6501
|
+
}))), imageCaptionAction, imageGenAction].filter(a => !!a),
|
|
4514
6502
|
expanded: true
|
|
4515
6503
|
}) : void 0;
|
|
4516
|
-
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction]);
|
|
6504
|
+
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction, translateAction, imageGenAction]);
|
|
4517
6505
|
const instructionsLength = (instructions == null ? void 0 : instructions.length) || 0;
|
|
4518
6506
|
const manageInstructionsItem = useMemo(() => node({
|
|
4519
6507
|
type: "action",
|
|
@@ -4526,13 +6514,13 @@ const assistFieldActions = {
|
|
|
4526
6514
|
type: "group",
|
|
4527
6515
|
icon: SparklesIcon,
|
|
4528
6516
|
title: pluginTitleShort,
|
|
4529
|
-
children: [runInstructionsGroup, assistSupported && manageInstructionsItem].filter(c => !!c),
|
|
6517
|
+
children: [runInstructionsGroup, translateAction, assistSupported && manageInstructionsItem].filter(c => !!c).filter(c => c.type === "group" ? c.children.length : true),
|
|
4530
6518
|
expanded: false,
|
|
4531
6519
|
renderAsButton: true,
|
|
4532
|
-
hidden: !assistSupported && !imageCaptionAction
|
|
6520
|
+
hidden: !assistSupported && !imageCaptionAction && !translateAction && !imageGenAction
|
|
4533
6521
|
}), [
|
|
4534
6522
|
//documentIsNew,
|
|
4535
|
-
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction]);
|
|
6523
|
+
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction, translateAction, imageGenAction]);
|
|
4536
6524
|
const emptyAction = useMemo(() => node({
|
|
4537
6525
|
type: "action",
|
|
4538
6526
|
hidden: !assistSupported,
|
|
@@ -4542,7 +6530,7 @@ const assistFieldActions = {
|
|
|
4542
6530
|
title: pluginTitleShort,
|
|
4543
6531
|
selected: isSelected
|
|
4544
6532
|
}), [assistSupported, manageInstructions, isSelected]);
|
|
4545
|
-
if (instructionsLength === 0 && !imageCaptionAction) {
|
|
6533
|
+
if (instructionsLength === 0 && !imageCaptionAction && !translateAction && !imageGenAction) {
|
|
4546
6534
|
return emptyAction;
|
|
4547
6535
|
}
|
|
4548
6536
|
return group;
|
|
@@ -4562,9 +6550,7 @@ function instructionItem(props) {
|
|
|
4562
6550
|
iconRight: isPrivate ? PrivateIcon : void 0,
|
|
4563
6551
|
title: getInstructionTitle(instruction),
|
|
4564
6552
|
onAction: () => onInstructionAction(instruction),
|
|
4565
|
-
disabled: assistSupported
|
|
4566
|
-
reason: "".concat(pluginTitle, " is not supported for this field")
|
|
4567
|
-
},
|
|
6553
|
+
disabled: !assistSupported,
|
|
4568
6554
|
hidden
|
|
4569
6555
|
});
|
|
4570
6556
|
}
|
|
@@ -4641,7 +6627,7 @@ function useInstructionToaster(documentId, documentSchemaType) {
|
|
|
4641
6627
|
}
|
|
4642
6628
|
function AssistDocumentInputWrapper(props) {
|
|
4643
6629
|
var _a;
|
|
4644
|
-
if (!isType(props.schemaType, "document") && props.id !== "root") {
|
|
6630
|
+
if (!isType(props.schemaType, "document") && props.id !== "root" && props.id !== assistFormId) {
|
|
4645
6631
|
return /* @__PURE__ */jsx(AssistInput, {
|
|
4646
6632
|
...props
|
|
4647
6633
|
});
|
|
@@ -4655,18 +6641,34 @@ function AssistDocumentInputWrapper(props) {
|
|
|
4655
6641
|
documentId
|
|
4656
6642
|
});
|
|
4657
6643
|
}
|
|
4658
|
-
function AssistDocumentInput(
|
|
6644
|
+
function AssistDocumentInput(_ref24) {
|
|
4659
6645
|
let {
|
|
4660
6646
|
documentId,
|
|
4661
6647
|
...props
|
|
4662
|
-
} =
|
|
6648
|
+
} = _ref24;
|
|
4663
6649
|
useInstructionToaster(documentId, props.schemaType);
|
|
6650
|
+
const schemaType = useMemo(() => {
|
|
6651
|
+
if (props.schemaType.name !== assistDocumentTypeName) {
|
|
6652
|
+
return props.schemaType;
|
|
6653
|
+
}
|
|
6654
|
+
return {
|
|
6655
|
+
...props.schemaType,
|
|
6656
|
+
type: {
|
|
6657
|
+
...props.schemaType.type,
|
|
6658
|
+
// compatability with i18nArrays plugin that requires this to be document
|
|
6659
|
+
name: "document"
|
|
6660
|
+
}
|
|
6661
|
+
};
|
|
6662
|
+
}, [props.schemaType]);
|
|
4664
6663
|
return /* @__PURE__ */jsx(FirstAssistedPathProvider, {
|
|
4665
6664
|
members: props.members,
|
|
4666
6665
|
children: /* @__PURE__ */jsx(AssistDocumentContextProvider, {
|
|
4667
|
-
schemaType
|
|
6666
|
+
schemaType,
|
|
4668
6667
|
documentId,
|
|
4669
|
-
children: props.renderDefault(
|
|
6668
|
+
children: props.renderDefault({
|
|
6669
|
+
...props,
|
|
6670
|
+
schemaType
|
|
6671
|
+
})
|
|
4670
6672
|
})
|
|
4671
6673
|
});
|
|
4672
6674
|
}
|
|
@@ -4737,31 +6739,41 @@ const assist = definePlugin(config => {
|
|
|
4737
6739
|
schema: {
|
|
4738
6740
|
types: schemaTypes
|
|
4739
6741
|
},
|
|
6742
|
+
i18n: {
|
|
6743
|
+
bundles: [{}]
|
|
6744
|
+
},
|
|
4740
6745
|
document: {
|
|
4741
6746
|
inspectors: (prev, context) => {
|
|
4742
|
-
const
|
|
6747
|
+
const documentType = context.documentType;
|
|
6748
|
+
const docSchema = context.schema.get(documentType);
|
|
4743
6749
|
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
4744
6750
|
return [...prev, assistInspector];
|
|
4745
6751
|
}
|
|
4746
6752
|
return prev;
|
|
4747
6753
|
},
|
|
4748
|
-
unstable_fieldActions: (prev,
|
|
6754
|
+
unstable_fieldActions: (prev, _ref25) => {
|
|
4749
6755
|
let {
|
|
4750
6756
|
documentType,
|
|
4751
6757
|
schema
|
|
4752
|
-
} =
|
|
6758
|
+
} = _ref25;
|
|
6759
|
+
if (documentType === assistDocumentTypeName) {
|
|
6760
|
+
return [];
|
|
6761
|
+
}
|
|
4753
6762
|
const docSchema = schema.get(documentType);
|
|
4754
6763
|
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
4755
6764
|
return [...prev, assistFieldActions];
|
|
4756
6765
|
}
|
|
4757
6766
|
return prev;
|
|
4758
6767
|
},
|
|
4759
|
-
unstable_languageFilter: (prev,
|
|
6768
|
+
unstable_languageFilter: (prev, _ref26) => {
|
|
4760
6769
|
let {
|
|
4761
6770
|
documentId,
|
|
4762
6771
|
schema,
|
|
4763
6772
|
schemaType
|
|
4764
|
-
} =
|
|
6773
|
+
} = _ref26;
|
|
6774
|
+
if (schemaType === assistDocumentTypeName) {
|
|
6775
|
+
return [];
|
|
6776
|
+
}
|
|
4765
6777
|
const docSchema = schema.get(schemaType);
|
|
4766
6778
|
if (docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
|
|
4767
6779
|
return [...prev, createAssistDocumentPresence(documentId, docSchema)];
|
|
@@ -4815,5 +6827,5 @@ const assist = definePlugin(config => {
|
|
|
4815
6827
|
})()]
|
|
4816
6828
|
};
|
|
4817
6829
|
});
|
|
4818
|
-
export { SchemaTypeTool, assist, contextDocumentTypeName };
|
|
6830
|
+
export { SchemaTypeTool, assist, contextDocumentTypeName, defaultLanguageOutputs };
|
|
4819
6831
|
//# sourceMappingURL=index.esm.js.map
|