@sanity/assist 1.2.13 → 1.2.15-lang.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +392 -6
- package/dist/index.d.ts +170 -3
- package/dist/index.esm.js +1986 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1980 -105
- package/dist/index.js.map +1 -1
- package/package.json +15 -14
- package/src/_lib/form/DocumentForm.tsx +1 -1
- 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 +5 -4
- package/src/assistFormComponents/AssistFormBlock.tsx +2 -3
- package/src/assistFormComponents/validation/listItem.tsx +2 -2
- package/src/assistInspector/FieldAutocomplete.tsx +1 -0
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +2 -3
- package/src/assistInspector/helpers.ts +7 -9
- package/src/assistLayout/AssistLayout.tsx +9 -6
- package/src/fieldActions/assistFieldActions.tsx +14 -8
- package/src/fieldActions/translateActions.tsx +118 -0
- package/src/helpers/assistSupported.ts +1 -1
- package/src/node_modules/.vitest/results.json +1 -0
- package/src/plugin.tsx +12 -2
- package/src/presence/AssistAvatar.tsx +1 -1
- package/src/schemas/assistDocumentSchema.tsx +39 -0
- package/src/schemas/serialize/serializeSchema.test.ts +15 -2
- package/src/schemas/serialize/serializeSchema.ts +8 -7
- package/src/schemas/typeDefExtensions.ts +12 -1
- package/src/translate/FieldTranslationProvider.tsx +254 -0
- package/src/translate/getLanguageParams.ts +26 -0
- package/src/translate/paths.test.ts +87 -0
- package/src/translate/paths.ts +151 -0
- package/src/translate/types.ts +159 -0
- package/src/types.ts +21 -2
- package/src/useApiClient.ts +63 -0
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@ const instructionTaskTypeName = "sanity.assist.instructionTask";
|
|
|
41
41
|
const fieldPresenceTypeName = "sanity.assist.instructionTask.presence";
|
|
42
42
|
const assistSerializedTypeName = "sanity.assist.serialized.type";
|
|
43
43
|
const assistSerializedFieldTypeName = "sanity.assist.serialized.field";
|
|
44
|
+
const outputFieldTypeName = "sanity.assist.output.field";
|
|
45
|
+
const outputTypeTypeName = "sanity.assist.output.type";
|
|
44
46
|
const fieldPathParam = "pathKey";
|
|
45
47
|
const instructionParam = "instruction";
|
|
46
48
|
const documentRootKey = "<document>";
|
|
@@ -175,11 +177,12 @@ function isDisabled(type, allowReadonlyHidden) {
|
|
|
175
177
|
return !isSchemaAssistEnabled(type) || isUnsupportedType(type) || !allowReadonlyHidden && readonlyHidden;
|
|
176
178
|
}
|
|
177
179
|
function isUnsupportedType(type) {
|
|
178
|
-
|
|
180
|
+
var _a, _b;
|
|
181
|
+
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.aiWritingAssistance) == null ? void 0 : _b.embeddingsIndex) || isType(type, "crossDatasetReference") || isType(type, "slug") || isType(type, "url") || isType(type, "date") || isType(type, "datetime") || isType(type, "file");
|
|
179
182
|
}
|
|
180
183
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
181
184
|
function serializeSchema(schema, options) {
|
|
182
|
-
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t =>
|
|
185
|
+
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
|
|
183
186
|
if ("to" in t && t.to && !t.to.length) {
|
|
184
187
|
return false;
|
|
185
188
|
}
|
|
@@ -217,13 +220,14 @@ function getSchemaStub(schemaType, schema, options) {
|
|
|
217
220
|
return removeUndef(baseSchema);
|
|
218
221
|
}
|
|
219
222
|
function getBaseFields(schema, type, typeName, options) {
|
|
220
|
-
var _a, _b, _c;
|
|
221
|
-
const
|
|
223
|
+
var _a, _b, _c, _d, _e;
|
|
224
|
+
const schemaOptions = removeUndef({
|
|
225
|
+
imagePromptField: (_a = type.options) == null ? void 0 : _a.imagePromptField,
|
|
226
|
+
embeddingsIndex: (_c = (_b = type.options) == null ? void 0 : _b.aiWritingAssistance) == null ? void 0 : _c.embeddingsIndex
|
|
227
|
+
});
|
|
222
228
|
return removeUndef({
|
|
223
|
-
options:
|
|
224
|
-
|
|
225
|
-
} : void 0,
|
|
226
|
-
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 => {
|
|
229
|
+
options: Object.keys(schemaOptions).length ? schemaOptions : void 0,
|
|
230
|
+
values: Array.isArray((_d = type == null ? void 0 : type.options) == null ? void 0 : _d.list) ? (_e = type == null ? void 0 : type.options) == null ? void 0 : _e.list.map(v => {
|
|
227
231
|
var _a2;
|
|
228
232
|
return typeof v === "string" ? v : (_a2 = v.value) != null ? _a2 : "".concat(v.title);
|
|
229
233
|
}) : void 0,
|
|
@@ -680,7 +684,6 @@ function useStudioAssistDocument(_ref2) {
|
|
|
680
684
|
} = _ref2;
|
|
681
685
|
const documentTypeName = schemaType.name;
|
|
682
686
|
const currentUser = sanity.useCurrentUser();
|
|
683
|
-
const validation = sanity.useValidationStatus(publicId(documentId), schemaType.name).validation;
|
|
684
687
|
const assistDocument = useDocumentState(assistDocumentId(documentTypeName), assistDocumentTypeName);
|
|
685
688
|
const assistTasksStatus = useDocumentState(assistTasksStatusId(documentId != null ? documentId : ""), assistTasksStatusTypeName);
|
|
686
689
|
const client = sanity.useClient({
|
|
@@ -705,7 +708,7 @@ function useStudioAssistDocument(_ref2) {
|
|
|
705
708
|
return {
|
|
706
709
|
...assistField,
|
|
707
710
|
tasks: tasks.filter(task => task.path === assistField.path),
|
|
708
|
-
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
|
|
711
|
+
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))
|
|
709
712
|
};
|
|
710
713
|
});
|
|
711
714
|
return sanity.typed({
|
|
@@ -720,21 +723,12 @@ function useStudioAssistDocument(_ref2) {
|
|
|
720
723
|
}),
|
|
721
724
|
fields
|
|
722
725
|
});
|
|
723
|
-
}, [assistDocument, assistTasksStatus, currentUser
|
|
726
|
+
}, [assistDocument, assistTasksStatus, currentUser]);
|
|
724
727
|
}
|
|
725
|
-
function asStudioInstruction(instruction, run
|
|
726
|
-
var _a;
|
|
727
|
-
const errors = validation.filter(marker => marker.level === "error");
|
|
728
|
-
const fieldRefs = ((_a = instruction == null ? void 0 : instruction.prompt) != null ? _a : []).flatMap(block => {
|
|
729
|
-
if (block._type === "block") {
|
|
730
|
-
return block.children.filter(c => c._type === fieldReferenceTypeName);
|
|
731
|
-
}
|
|
732
|
-
return [];
|
|
733
|
-
});
|
|
728
|
+
function asStudioInstruction(instruction, run) {
|
|
734
729
|
return {
|
|
735
730
|
...instruction,
|
|
736
|
-
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && /* @__PURE__ */new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
737
|
-
validation: errors.filter(marker => fieldRefs.map(r => r.path).filter(p => !!p).find(path => sanity.pathToString(marker.path) === path))
|
|
731
|
+
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
738
732
|
};
|
|
739
733
|
}
|
|
740
734
|
function useInterval(ms) {
|
|
@@ -815,13 +809,13 @@ function InstructionTaskHistoryButton(props) {
|
|
|
815
809
|
const statusDocId = assistTasksStatusId(documentId);
|
|
816
810
|
const basePath = "".concat(sanity.typed("tasks"), '[_key=="').concat(taskKey, '"]');
|
|
817
811
|
client.patch(statusDocId).set({
|
|
818
|
-
["".concat(basePath, ".").concat(sanity.typed("ended"))]: /* @__PURE__ */new Date().toISOString(),
|
|
812
|
+
["".concat(basePath, ".").concat(sanity.typed("ended"))]: ( /* @__PURE__ */new Date()).toISOString(),
|
|
819
813
|
["".concat(basePath, ".").concat(sanity.typed("reason"))]: sanity.typed("aborted")
|
|
820
814
|
}).commit().catch(console.error);
|
|
821
815
|
}, [client, documentId]);
|
|
822
816
|
const titledTasks = react.useMemo(() => {
|
|
823
817
|
var _a2;
|
|
824
|
-
const t = (_a2 = tasks == null ? void 0 : tasks.filter(task => task.started && /* @__PURE__ */new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs).map(task => {
|
|
818
|
+
const t = (_a2 = tasks == null ? void 0 : tasks.filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs).map(task => {
|
|
825
819
|
var _a3;
|
|
826
820
|
const instruction = instructions == null ? void 0 : instructions.find(i => i._key === task.instructionKey);
|
|
827
821
|
return {
|
|
@@ -888,11 +882,10 @@ const TaskStatusButton = react.forwardRef(function TaskStatusButton2(props, ref)
|
|
|
888
882
|
mode: "bleed",
|
|
889
883
|
onClick,
|
|
890
884
|
tone: hasErrors ? "critical" : void 0,
|
|
891
|
-
fontSize: 1,
|
|
892
885
|
disabled,
|
|
893
886
|
ref,
|
|
894
887
|
selected,
|
|
895
|
-
|
|
888
|
+
tooltipProps: TASK_STATUS_BUTTON_TOOLTIP_PROPS
|
|
896
889
|
});
|
|
897
890
|
});
|
|
898
891
|
function TaskList(props) {
|
|
@@ -979,6 +972,50 @@ function useApiClient(customApiClient) {
|
|
|
979
972
|
});
|
|
980
973
|
return react.useMemo(() => customApiClient ? customApiClient(client) : client, [client, customApiClient]);
|
|
981
974
|
}
|
|
975
|
+
function useTranslate(apiClient) {
|
|
976
|
+
const [loading, setLoading] = react.useState(false);
|
|
977
|
+
const user = sanity.useCurrentUser();
|
|
978
|
+
const schema = sanity.useSchema();
|
|
979
|
+
const types = react.useMemo(() => serializeSchema(schema, {
|
|
980
|
+
leanFormat: true
|
|
981
|
+
}), [schema]);
|
|
982
|
+
const toast = ui.useToast();
|
|
983
|
+
const translate = react.useCallback(_ref4 => {
|
|
984
|
+
let {
|
|
985
|
+
documentId,
|
|
986
|
+
languagePath,
|
|
987
|
+
fieldLanguageMap
|
|
988
|
+
} = _ref4;
|
|
989
|
+
setLoading(true);
|
|
990
|
+
return apiClient.request({
|
|
991
|
+
method: "POST",
|
|
992
|
+
url: "/assist/tasks/translate/".concat(apiClient.config().dataset, "?projectId=").concat(apiClient.config().projectId),
|
|
993
|
+
body: {
|
|
994
|
+
documentId,
|
|
995
|
+
types,
|
|
996
|
+
languagePath,
|
|
997
|
+
fieldLanguageMap,
|
|
998
|
+
userId: user == null ? void 0 : user.id
|
|
999
|
+
}
|
|
1000
|
+
}).catch(e => {
|
|
1001
|
+
toast.push({
|
|
1002
|
+
status: "error",
|
|
1003
|
+
title: "Translate failed",
|
|
1004
|
+
description: e.message
|
|
1005
|
+
});
|
|
1006
|
+
setLoading(false);
|
|
1007
|
+
throw e;
|
|
1008
|
+
}).finally(() => {
|
|
1009
|
+
setTimeout(() => {
|
|
1010
|
+
setLoading(false);
|
|
1011
|
+
}, 2e3);
|
|
1012
|
+
});
|
|
1013
|
+
}, [setLoading, apiClient, toast, user, types]);
|
|
1014
|
+
return react.useMemo(() => ({
|
|
1015
|
+
translate,
|
|
1016
|
+
loading
|
|
1017
|
+
}), [translate, loading]);
|
|
1018
|
+
}
|
|
982
1019
|
function useGenerateCaption(apiClient) {
|
|
983
1020
|
const [loading, setLoading] = react.useState(false);
|
|
984
1021
|
const user = sanity.useCurrentUser();
|
|
@@ -987,11 +1024,11 @@ function useGenerateCaption(apiClient) {
|
|
|
987
1024
|
leanFormat: true
|
|
988
1025
|
}), [schema]);
|
|
989
1026
|
const toast = ui.useToast();
|
|
990
|
-
const generateCaption = react.useCallback(
|
|
1027
|
+
const generateCaption = react.useCallback(_ref5 => {
|
|
991
1028
|
let {
|
|
992
1029
|
path,
|
|
993
1030
|
documentId
|
|
994
|
-
} =
|
|
1031
|
+
} = _ref5;
|
|
995
1032
|
setLoading(true);
|
|
996
1033
|
return apiClient.request({
|
|
997
1034
|
method: "POST",
|
|
@@ -1210,8 +1247,8 @@ function RunInstructionProvider(props) {
|
|
|
1210
1247
|
runInstructionRequest({
|
|
1211
1248
|
...request,
|
|
1212
1249
|
instructionKey: instruction._key,
|
|
1213
|
-
userTexts: Object.entries(inputs).map(
|
|
1214
|
-
let [key, value] =
|
|
1250
|
+
userTexts: Object.entries(inputs).map(_ref6 => {
|
|
1251
|
+
let [key, value] = _ref6;
|
|
1215
1252
|
return {
|
|
1216
1253
|
blockKey: key,
|
|
1217
1254
|
userInput: value
|
|
@@ -1224,8 +1261,8 @@ function RunInstructionProvider(props) {
|
|
|
1224
1261
|
const open = !!runRequest;
|
|
1225
1262
|
const runDisabled = react.useMemo(() => {
|
|
1226
1263
|
var _a2, _b;
|
|
1227
|
-
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(
|
|
1228
|
-
let [, value] =
|
|
1264
|
+
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(_ref7 => {
|
|
1265
|
+
let [, value] = _ref7;
|
|
1229
1266
|
return !!value;
|
|
1230
1267
|
}).length;
|
|
1231
1268
|
}, [runRequest == null ? void 0 : runRequest.userInputBlocks, inputs]);
|
|
@@ -1609,13 +1646,13 @@ function useSelectedSchema(fieldPath, documentSchema) {
|
|
|
1609
1646
|
return currentSchema;
|
|
1610
1647
|
}, [documentSchema, fieldPath]);
|
|
1611
1648
|
}
|
|
1612
|
-
function FieldsInitializer(
|
|
1649
|
+
function FieldsInitializer(_ref8) {
|
|
1613
1650
|
let {
|
|
1614
1651
|
pathKey,
|
|
1615
1652
|
activePath,
|
|
1616
1653
|
fieldExists,
|
|
1617
1654
|
onChange
|
|
1618
|
-
} =
|
|
1655
|
+
} = _ref8;
|
|
1619
1656
|
const initialized = react.useRef(false);
|
|
1620
1657
|
react.useEffect(() => {
|
|
1621
1658
|
if (initialized.current || fieldExists || activePath || !pathKey) {
|
|
@@ -1646,7 +1683,7 @@ function FieldAutocomplete(props) {
|
|
|
1646
1683
|
return getFieldRefs(schemaType);
|
|
1647
1684
|
}, [schemaType, includeDocument]);
|
|
1648
1685
|
const currentField = react.useMemo(() => fieldRefs.find(f => f.key === fieldPath), [fieldPath, fieldRefs]);
|
|
1649
|
-
const autocompleteOptions = react.useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).map(field => ({
|
|
1686
|
+
const autocompleteOptions = react.useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).filter(f => !isType(f.schemaType, "reference")).map(field => ({
|
|
1650
1687
|
value: field.key,
|
|
1651
1688
|
field
|
|
1652
1689
|
})), [fieldRefs, filter]);
|
|
@@ -2143,10 +2180,10 @@ const assistInspector = {
|
|
|
2143
2180
|
showAsAction: false
|
|
2144
2181
|
}),
|
|
2145
2182
|
component: AssistInspectorWrapper,
|
|
2146
|
-
onClose(
|
|
2183
|
+
onClose(_ref9) {
|
|
2147
2184
|
let {
|
|
2148
2185
|
params
|
|
2149
|
-
} =
|
|
2186
|
+
} = _ref9;
|
|
2150
2187
|
return {
|
|
2151
2188
|
params: sanity.typed({
|
|
2152
2189
|
...params,
|
|
@@ -2174,7 +2211,7 @@ function useAssistPresence(path, showFocusWithin) {
|
|
|
2174
2211
|
const activePresence = (_b = (_a = tasks == null ? void 0 : tasks.filter(task => !task.ended)) == null ? void 0 : _a.flatMap(task => {
|
|
2175
2212
|
var _a2;
|
|
2176
2213
|
return (_a2 = task.presence) != null ? _a2 : [];
|
|
2177
|
-
})) == null ? void 0 : _b.filter(p => p.started && /* @__PURE__ */new Date().getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs).filter(presence => {
|
|
2214
|
+
})) == null ? void 0 : _b.filter(p => p.started && ( /* @__PURE__ */new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs).filter(presence => {
|
|
2178
2215
|
if (!presence.path || !path.length) {
|
|
2179
2216
|
return false;
|
|
2180
2217
|
}
|
|
@@ -2208,7 +2245,7 @@ function aiPresence(presence, path, title) {
|
|
|
2208
2245
|
},
|
|
2209
2246
|
path,
|
|
2210
2247
|
sessionId: "not-available",
|
|
2211
|
-
lastActiveAt: (_a = presence == null ? void 0 : presence.started) != null ? _a : /* @__PURE__ */new Date().toISOString()
|
|
2248
|
+
lastActiveAt: (_a = presence == null ? void 0 : presence.started) != null ? _a : ( /* @__PURE__ */new Date()).toISOString()
|
|
2212
2249
|
};
|
|
2213
2250
|
}
|
|
2214
2251
|
var __freeze$3 = Object.freeze;
|
|
@@ -2219,11 +2256,11 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$3(cooked, "raw", {
|
|
|
2219
2256
|
var _a$3, _b$1;
|
|
2220
2257
|
const fadeIn = styled.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"])));
|
|
2221
2258
|
const FadeInDiv = styled__default.default.div(_b$1 || (_b$1 = __template$3(["\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n"])), fadeIn);
|
|
2222
|
-
const FadeInContent = react.forwardRef(function FadeInContent2(
|
|
2259
|
+
const FadeInContent = react.forwardRef(function FadeInContent2(_ref10, ref) {
|
|
2223
2260
|
let {
|
|
2224
2261
|
children,
|
|
2225
2262
|
durationMs = 250
|
|
2226
|
-
} =
|
|
2263
|
+
} = _ref10;
|
|
2227
2264
|
return /* @__PURE__ */jsxRuntime.jsx(FadeInDiv, {
|
|
2228
2265
|
ref,
|
|
2229
2266
|
style: {
|
|
@@ -2235,47 +2272,47 @@ const FadeInContent = react.forwardRef(function FadeInContent2(_ref9, ref) {
|
|
|
2235
2272
|
const purple = {
|
|
2236
2273
|
"50": {
|
|
2237
2274
|
title: "Purple 50",
|
|
2238
|
-
hex: "#
|
|
2275
|
+
hex: "#f8f5ff"
|
|
2239
2276
|
},
|
|
2240
2277
|
"100": {
|
|
2241
2278
|
title: "Purple 100",
|
|
2242
|
-
hex: "#
|
|
2279
|
+
hex: "#f1ebff"
|
|
2243
2280
|
},
|
|
2244
2281
|
"200": {
|
|
2245
2282
|
title: "Purple 200",
|
|
2246
|
-
hex: "#
|
|
2283
|
+
hex: "#ece1fe"
|
|
2247
2284
|
},
|
|
2248
2285
|
"300": {
|
|
2249
2286
|
title: "Purple 300",
|
|
2250
|
-
hex: "#
|
|
2287
|
+
hex: "#ccb1fc"
|
|
2251
2288
|
},
|
|
2252
2289
|
"400": {
|
|
2253
2290
|
title: "Purple 400",
|
|
2254
|
-
hex: "#
|
|
2291
|
+
hex: "#b087f7"
|
|
2255
2292
|
},
|
|
2256
2293
|
"500": {
|
|
2257
2294
|
title: "Purple 500",
|
|
2258
|
-
hex: "#
|
|
2295
|
+
hex: "#8f57ef"
|
|
2259
2296
|
},
|
|
2260
2297
|
"600": {
|
|
2261
2298
|
title: "Purple 600",
|
|
2262
|
-
hex: "#
|
|
2299
|
+
hex: "#721fe5"
|
|
2263
2300
|
},
|
|
2264
2301
|
"700": {
|
|
2265
2302
|
title: "Purple 700",
|
|
2266
|
-
hex: "#
|
|
2303
|
+
hex: "#4c1a9e"
|
|
2267
2304
|
},
|
|
2268
2305
|
"800": {
|
|
2269
2306
|
title: "Purple 800",
|
|
2270
|
-
hex: "#
|
|
2307
|
+
hex: "#2f1862"
|
|
2271
2308
|
},
|
|
2272
2309
|
"900": {
|
|
2273
2310
|
title: "Purple 900",
|
|
2274
|
-
hex: "#
|
|
2311
|
+
hex: "#23173f"
|
|
2275
2312
|
},
|
|
2276
2313
|
"950": {
|
|
2277
2314
|
title: "Purple 950",
|
|
2278
|
-
hex: "#
|
|
2315
|
+
hex: "#181128"
|
|
2279
2316
|
}
|
|
2280
2317
|
};
|
|
2281
2318
|
var __freeze$2 = Object.freeze;
|
|
@@ -2326,7 +2363,11 @@ function AssistAvatar(props) {
|
|
|
2326
2363
|
style: {
|
|
2327
2364
|
color: "inherit"
|
|
2328
2365
|
},
|
|
2329
|
-
children: /* @__PURE__ */jsxRuntime.jsx(icons.SparklesIcon, {
|
|
2366
|
+
children: /* @__PURE__ */jsxRuntime.jsx(icons.SparklesIcon, {
|
|
2367
|
+
style: {
|
|
2368
|
+
color: "inherit"
|
|
2369
|
+
}
|
|
2370
|
+
})
|
|
2330
2371
|
})
|
|
2331
2372
|
})]
|
|
2332
2373
|
});
|
|
@@ -2492,15 +2533,16 @@ function AssistField(props) {
|
|
|
2492
2533
|
showOnboarding,
|
|
2493
2534
|
dismissOnboarding
|
|
2494
2535
|
} = useOnboardingFeature(fieldOnboardingKey);
|
|
2536
|
+
const singlePresence = presence[0];
|
|
2495
2537
|
const actions = /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2496
2538
|
gap: 2,
|
|
2497
2539
|
align: "center",
|
|
2498
2540
|
justify: "space-between",
|
|
2499
|
-
children: [
|
|
2541
|
+
children: [singlePresence && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2500
2542
|
children: /* @__PURE__ */jsxRuntime.jsx(AiFieldPresence, {
|
|
2501
|
-
presence:
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2543
|
+
presence: singlePresence
|
|
2544
|
+
})
|
|
2545
|
+
}), isFirstAssisted && showOnboarding && /* @__PURE__ */jsxRuntime.jsx(AssistOnboardingPopover, {
|
|
2504
2546
|
dismiss: dismissOnboarding
|
|
2505
2547
|
})]
|
|
2506
2548
|
});
|
|
@@ -2972,7 +3014,6 @@ function AssistConnectorsOverlay(props) {
|
|
|
2972
3014
|
zIndex: 150
|
|
2973
3015
|
// zIndex,
|
|
2974
3016
|
},
|
|
2975
|
-
|
|
2976
3017
|
children: connectors.map(connector => /* @__PURE__ */jsxRuntime.jsx(ConnectorPath, {
|
|
2977
3018
|
from: connector.from,
|
|
2978
3019
|
options,
|
|
@@ -3211,6 +3252,1502 @@ function mapBlock(block, migratedContexts) {
|
|
|
3211
3252
|
children: ((_d = textBlock.children) != null ? _d : []).map(child => mapBlock(child, migratedContexts))
|
|
3212
3253
|
};
|
|
3213
3254
|
}
|
|
3255
|
+
const MAX_DEPTH = 6;
|
|
3256
|
+
function getDocumentMembersFlat(doc, schemaType) {
|
|
3257
|
+
if (!sanity.isDocumentSchemaType(schemaType)) {
|
|
3258
|
+
console.error("Schema type is not a document");
|
|
3259
|
+
return [];
|
|
3260
|
+
}
|
|
3261
|
+
return extractPaths(doc, schemaType, [], MAX_DEPTH);
|
|
3262
|
+
}
|
|
3263
|
+
function extractPaths(doc, schemaType, path, maxDepth) {
|
|
3264
|
+
if (path.length >= maxDepth) {
|
|
3265
|
+
return [];
|
|
3266
|
+
}
|
|
3267
|
+
return schemaType.fields.reduce((acc, field) => {
|
|
3268
|
+
var _a;
|
|
3269
|
+
const fieldPath = [...path, field.name];
|
|
3270
|
+
const fieldSchema = field.type;
|
|
3271
|
+
const thisFieldWithPath = {
|
|
3272
|
+
path: fieldPath,
|
|
3273
|
+
name: field.name,
|
|
3274
|
+
schemaType: fieldSchema
|
|
3275
|
+
};
|
|
3276
|
+
if (fieldSchema.jsonType === "object") {
|
|
3277
|
+
const innerFields = extractPaths(doc, fieldSchema, fieldPath, maxDepth);
|
|
3278
|
+
return [...acc, thisFieldWithPath, ...innerFields];
|
|
3279
|
+
} else if (fieldSchema.jsonType === "array" && fieldSchema.of.length && fieldSchema.of.some(item => "fields" in item)) {
|
|
3280
|
+
const {
|
|
3281
|
+
value: arrayValue
|
|
3282
|
+
} = (_a = mutator.extractWithPath(sanity.pathToString(fieldPath), doc)[0]) != null ? _a : {};
|
|
3283
|
+
let arrayPaths = [];
|
|
3284
|
+
if (arrayValue == null ? void 0 : arrayValue.length) {
|
|
3285
|
+
for (const item of arrayValue) {
|
|
3286
|
+
const arrayItemSchema = fieldSchema.of.find(t => t.name === item._type);
|
|
3287
|
+
if (item._key && arrayItemSchema) {
|
|
3288
|
+
const itemPath = [...fieldPath, {
|
|
3289
|
+
_key: item._key
|
|
3290
|
+
}];
|
|
3291
|
+
const innerFields = extractPaths(doc, arrayItemSchema, itemPath, maxDepth);
|
|
3292
|
+
arrayPaths = [...arrayPaths, {
|
|
3293
|
+
path: itemPath,
|
|
3294
|
+
name: item._key,
|
|
3295
|
+
schemaType: arrayItemSchema
|
|
3296
|
+
}, ...innerFields];
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
return [...acc, thisFieldWithPath, ...arrayPaths];
|
|
3301
|
+
}
|
|
3302
|
+
return [...acc, thisFieldWithPath];
|
|
3303
|
+
}, []);
|
|
3304
|
+
}
|
|
3305
|
+
const defaultLanguageOutputs = function (member, enclosingType, translateFromLanguageId, translateToLanguageIds) {
|
|
3306
|
+
if (member.schemaType.jsonType === "object" && member.schemaType.name.startsWith("internationalizedArray")) {
|
|
3307
|
+
const pathEnd = member.path.slice(-1);
|
|
3308
|
+
const language = sanity.isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null;
|
|
3309
|
+
return language === translateFromLanguageId ? translateToLanguageIds.map(translateToId => ({
|
|
3310
|
+
id: translateToId,
|
|
3311
|
+
outputPath: [...member.path.slice(0, -1), {
|
|
3312
|
+
_key: translateToId
|
|
3313
|
+
}]
|
|
3314
|
+
})) : void 0;
|
|
3315
|
+
}
|
|
3316
|
+
if (enclosingType.jsonType === "object" && enclosingType.name.startsWith("locale")) {
|
|
3317
|
+
return translateFromLanguageId === member.name ? translateToLanguageIds.map(translateToId => ({
|
|
3318
|
+
id: translateToId,
|
|
3319
|
+
outputPath: [...member.path.slice(0, -1), translateToId]
|
|
3320
|
+
})) : void 0;
|
|
3321
|
+
}
|
|
3322
|
+
return void 0;
|
|
3323
|
+
};
|
|
3324
|
+
function getTranslationMap(documentSchema, documentMembers, translateFromLanguageId, outputLanguageIds, langFn) {
|
|
3325
|
+
var _a, _b, _c;
|
|
3326
|
+
const translationMaps = [];
|
|
3327
|
+
for (const member of documentMembers) {
|
|
3328
|
+
const parentPath = member.path.slice(0, -1);
|
|
3329
|
+
const enclosingType = (_b = (_a = documentMembers.find(m => sanity.pathToString(m.path) === sanity.pathToString(parentPath))) == null ? void 0 : _a.schemaType) != null ? _b : documentSchema;
|
|
3330
|
+
const translations = (_c = langFn(member, enclosingType, translateFromLanguageId, outputLanguageIds)) == null ? void 0 : _c.filter(translation => translation.id !== translateFromLanguageId);
|
|
3331
|
+
if (translations) {
|
|
3332
|
+
translationMaps.push({
|
|
3333
|
+
inputLanguageId: translateFromLanguageId,
|
|
3334
|
+
inputPath: member.path,
|
|
3335
|
+
outputs: translations
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
return translationMaps;
|
|
3340
|
+
}
|
|
3341
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3342
|
+
function getDefaultExportFromCjs(x) {
|
|
3343
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
/**
|
|
3347
|
+
* Checks if `value` is classified as an `Array` object.
|
|
3348
|
+
*
|
|
3349
|
+
* @static
|
|
3350
|
+
* @memberOf _
|
|
3351
|
+
* @since 0.1.0
|
|
3352
|
+
* @category Lang
|
|
3353
|
+
* @param {*} value The value to check.
|
|
3354
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
3355
|
+
* @example
|
|
3356
|
+
*
|
|
3357
|
+
* _.isArray([1, 2, 3]);
|
|
3358
|
+
* // => true
|
|
3359
|
+
*
|
|
3360
|
+
* _.isArray(document.body.children);
|
|
3361
|
+
* // => false
|
|
3362
|
+
*
|
|
3363
|
+
* _.isArray('abc');
|
|
3364
|
+
* // => false
|
|
3365
|
+
*
|
|
3366
|
+
* _.isArray(_.noop);
|
|
3367
|
+
* // => false
|
|
3368
|
+
*/
|
|
3369
|
+
|
|
3370
|
+
var isArray$3 = Array.isArray;
|
|
3371
|
+
var isArray_1 = isArray$3;
|
|
3372
|
+
|
|
3373
|
+
/** Detect free variable `global` from Node.js. */
|
|
3374
|
+
|
|
3375
|
+
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
3376
|
+
var _freeGlobal = freeGlobal$1;
|
|
3377
|
+
var freeGlobal = _freeGlobal;
|
|
3378
|
+
|
|
3379
|
+
/** Detect free variable `self`. */
|
|
3380
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
3381
|
+
|
|
3382
|
+
/** Used as a reference to the global object. */
|
|
3383
|
+
var root$3 = freeGlobal || freeSelf || Function('return this')();
|
|
3384
|
+
var _root = root$3;
|
|
3385
|
+
var root$2 = _root;
|
|
3386
|
+
|
|
3387
|
+
/** Built-in value references. */
|
|
3388
|
+
var Symbol$3 = root$2.Symbol;
|
|
3389
|
+
var _Symbol = Symbol$3;
|
|
3390
|
+
var Symbol$2 = _Symbol;
|
|
3391
|
+
|
|
3392
|
+
/** Used for built-in method references. */
|
|
3393
|
+
var objectProto$4 = Object.prototype;
|
|
3394
|
+
|
|
3395
|
+
/** Used to check objects for own properties. */
|
|
3396
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
3397
|
+
|
|
3398
|
+
/**
|
|
3399
|
+
* Used to resolve the
|
|
3400
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3401
|
+
* of values.
|
|
3402
|
+
*/
|
|
3403
|
+
var nativeObjectToString$1 = objectProto$4.toString;
|
|
3404
|
+
|
|
3405
|
+
/** Built-in value references. */
|
|
3406
|
+
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
3407
|
+
|
|
3408
|
+
/**
|
|
3409
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
3410
|
+
*
|
|
3411
|
+
* @private
|
|
3412
|
+
* @param {*} value The value to query.
|
|
3413
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
3414
|
+
*/
|
|
3415
|
+
function getRawTag$1(value) {
|
|
3416
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
|
|
3417
|
+
tag = value[symToStringTag$1];
|
|
3418
|
+
try {
|
|
3419
|
+
value[symToStringTag$1] = undefined;
|
|
3420
|
+
var unmasked = true;
|
|
3421
|
+
} catch (e) {}
|
|
3422
|
+
var result = nativeObjectToString$1.call(value);
|
|
3423
|
+
if (unmasked) {
|
|
3424
|
+
if (isOwn) {
|
|
3425
|
+
value[symToStringTag$1] = tag;
|
|
3426
|
+
} else {
|
|
3427
|
+
delete value[symToStringTag$1];
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
return result;
|
|
3431
|
+
}
|
|
3432
|
+
var _getRawTag = getRawTag$1;
|
|
3433
|
+
|
|
3434
|
+
/** Used for built-in method references. */
|
|
3435
|
+
|
|
3436
|
+
var objectProto$3 = Object.prototype;
|
|
3437
|
+
|
|
3438
|
+
/**
|
|
3439
|
+
* Used to resolve the
|
|
3440
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3441
|
+
* of values.
|
|
3442
|
+
*/
|
|
3443
|
+
var nativeObjectToString = objectProto$3.toString;
|
|
3444
|
+
|
|
3445
|
+
/**
|
|
3446
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
3447
|
+
*
|
|
3448
|
+
* @private
|
|
3449
|
+
* @param {*} value The value to convert.
|
|
3450
|
+
* @returns {string} Returns the converted string.
|
|
3451
|
+
*/
|
|
3452
|
+
function objectToString$1(value) {
|
|
3453
|
+
return nativeObjectToString.call(value);
|
|
3454
|
+
}
|
|
3455
|
+
var _objectToString = objectToString$1;
|
|
3456
|
+
var Symbol$1 = _Symbol,
|
|
3457
|
+
getRawTag = _getRawTag,
|
|
3458
|
+
objectToString = _objectToString;
|
|
3459
|
+
|
|
3460
|
+
/** `Object#toString` result references. */
|
|
3461
|
+
var nullTag = '[object Null]',
|
|
3462
|
+
undefinedTag = '[object Undefined]';
|
|
3463
|
+
|
|
3464
|
+
/** Built-in value references. */
|
|
3465
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
3466
|
+
|
|
3467
|
+
/**
|
|
3468
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
3469
|
+
*
|
|
3470
|
+
* @private
|
|
3471
|
+
* @param {*} value The value to query.
|
|
3472
|
+
* @returns {string} Returns the `toStringTag`.
|
|
3473
|
+
*/
|
|
3474
|
+
function baseGetTag$2(value) {
|
|
3475
|
+
if (value == null) {
|
|
3476
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
3477
|
+
}
|
|
3478
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
3479
|
+
}
|
|
3480
|
+
var _baseGetTag = baseGetTag$2;
|
|
3481
|
+
|
|
3482
|
+
/**
|
|
3483
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
3484
|
+
* and has a `typeof` result of "object".
|
|
3485
|
+
*
|
|
3486
|
+
* @static
|
|
3487
|
+
* @memberOf _
|
|
3488
|
+
* @since 4.0.0
|
|
3489
|
+
* @category Lang
|
|
3490
|
+
* @param {*} value The value to check.
|
|
3491
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
3492
|
+
* @example
|
|
3493
|
+
*
|
|
3494
|
+
* _.isObjectLike({});
|
|
3495
|
+
* // => true
|
|
3496
|
+
*
|
|
3497
|
+
* _.isObjectLike([1, 2, 3]);
|
|
3498
|
+
* // => true
|
|
3499
|
+
*
|
|
3500
|
+
* _.isObjectLike(_.noop);
|
|
3501
|
+
* // => false
|
|
3502
|
+
*
|
|
3503
|
+
* _.isObjectLike(null);
|
|
3504
|
+
* // => false
|
|
3505
|
+
*/
|
|
3506
|
+
|
|
3507
|
+
function isObjectLike$1(value) {
|
|
3508
|
+
return value != null && typeof value == 'object';
|
|
3509
|
+
}
|
|
3510
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
3511
|
+
var baseGetTag$1 = _baseGetTag,
|
|
3512
|
+
isObjectLike = isObjectLike_1;
|
|
3513
|
+
|
|
3514
|
+
/** `Object#toString` result references. */
|
|
3515
|
+
var symbolTag = '[object Symbol]';
|
|
3516
|
+
|
|
3517
|
+
/**
|
|
3518
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
3519
|
+
*
|
|
3520
|
+
* @static
|
|
3521
|
+
* @memberOf _
|
|
3522
|
+
* @since 4.0.0
|
|
3523
|
+
* @category Lang
|
|
3524
|
+
* @param {*} value The value to check.
|
|
3525
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
3526
|
+
* @example
|
|
3527
|
+
*
|
|
3528
|
+
* _.isSymbol(Symbol.iterator);
|
|
3529
|
+
* // => true
|
|
3530
|
+
*
|
|
3531
|
+
* _.isSymbol('abc');
|
|
3532
|
+
* // => false
|
|
3533
|
+
*/
|
|
3534
|
+
function isSymbol$3(value) {
|
|
3535
|
+
return typeof value == 'symbol' || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
3536
|
+
}
|
|
3537
|
+
var isSymbol_1 = isSymbol$3;
|
|
3538
|
+
var isArray$2 = isArray_1,
|
|
3539
|
+
isSymbol$2 = isSymbol_1;
|
|
3540
|
+
|
|
3541
|
+
/** Used to match property names within property paths. */
|
|
3542
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
3543
|
+
reIsPlainProp = /^\w*$/;
|
|
3544
|
+
|
|
3545
|
+
/**
|
|
3546
|
+
* Checks if `value` is a property name and not a property path.
|
|
3547
|
+
*
|
|
3548
|
+
* @private
|
|
3549
|
+
* @param {*} value The value to check.
|
|
3550
|
+
* @param {Object} [object] The object to query keys on.
|
|
3551
|
+
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
3552
|
+
*/
|
|
3553
|
+
function isKey$1(value, object) {
|
|
3554
|
+
if (isArray$2(value)) {
|
|
3555
|
+
return false;
|
|
3556
|
+
}
|
|
3557
|
+
var type = typeof value;
|
|
3558
|
+
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
|
|
3559
|
+
return true;
|
|
3560
|
+
}
|
|
3561
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
3562
|
+
}
|
|
3563
|
+
var _isKey = isKey$1;
|
|
3564
|
+
|
|
3565
|
+
/**
|
|
3566
|
+
* Checks if `value` is the
|
|
3567
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
3568
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
3569
|
+
*
|
|
3570
|
+
* @static
|
|
3571
|
+
* @memberOf _
|
|
3572
|
+
* @since 0.1.0
|
|
3573
|
+
* @category Lang
|
|
3574
|
+
* @param {*} value The value to check.
|
|
3575
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
3576
|
+
* @example
|
|
3577
|
+
*
|
|
3578
|
+
* _.isObject({});
|
|
3579
|
+
* // => true
|
|
3580
|
+
*
|
|
3581
|
+
* _.isObject([1, 2, 3]);
|
|
3582
|
+
* // => true
|
|
3583
|
+
*
|
|
3584
|
+
* _.isObject(_.noop);
|
|
3585
|
+
* // => true
|
|
3586
|
+
*
|
|
3587
|
+
* _.isObject(null);
|
|
3588
|
+
* // => false
|
|
3589
|
+
*/
|
|
3590
|
+
|
|
3591
|
+
function isObject$2(value) {
|
|
3592
|
+
var type = typeof value;
|
|
3593
|
+
return value != null && (type == 'object' || type == 'function');
|
|
3594
|
+
}
|
|
3595
|
+
var isObject_1 = isObject$2;
|
|
3596
|
+
var baseGetTag = _baseGetTag,
|
|
3597
|
+
isObject$1 = isObject_1;
|
|
3598
|
+
|
|
3599
|
+
/** `Object#toString` result references. */
|
|
3600
|
+
var asyncTag = '[object AsyncFunction]',
|
|
3601
|
+
funcTag = '[object Function]',
|
|
3602
|
+
genTag = '[object GeneratorFunction]',
|
|
3603
|
+
proxyTag = '[object Proxy]';
|
|
3604
|
+
|
|
3605
|
+
/**
|
|
3606
|
+
* Checks if `value` is classified as a `Function` object.
|
|
3607
|
+
*
|
|
3608
|
+
* @static
|
|
3609
|
+
* @memberOf _
|
|
3610
|
+
* @since 0.1.0
|
|
3611
|
+
* @category Lang
|
|
3612
|
+
* @param {*} value The value to check.
|
|
3613
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
3614
|
+
* @example
|
|
3615
|
+
*
|
|
3616
|
+
* _.isFunction(_);
|
|
3617
|
+
* // => true
|
|
3618
|
+
*
|
|
3619
|
+
* _.isFunction(/abc/);
|
|
3620
|
+
* // => false
|
|
3621
|
+
*/
|
|
3622
|
+
function isFunction$1(value) {
|
|
3623
|
+
if (!isObject$1(value)) {
|
|
3624
|
+
return false;
|
|
3625
|
+
}
|
|
3626
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
3627
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
3628
|
+
var tag = baseGetTag(value);
|
|
3629
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
3630
|
+
}
|
|
3631
|
+
var isFunction_1 = isFunction$1;
|
|
3632
|
+
var root$1 = _root;
|
|
3633
|
+
|
|
3634
|
+
/** Used to detect overreaching core-js shims. */
|
|
3635
|
+
var coreJsData$1 = root$1['__core-js_shared__'];
|
|
3636
|
+
var _coreJsData = coreJsData$1;
|
|
3637
|
+
var coreJsData = _coreJsData;
|
|
3638
|
+
|
|
3639
|
+
/** Used to detect methods masquerading as native. */
|
|
3640
|
+
var maskSrcKey = function () {
|
|
3641
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
3642
|
+
return uid ? 'Symbol(src)_1.' + uid : '';
|
|
3643
|
+
}();
|
|
3644
|
+
|
|
3645
|
+
/**
|
|
3646
|
+
* Checks if `func` has its source masked.
|
|
3647
|
+
*
|
|
3648
|
+
* @private
|
|
3649
|
+
* @param {Function} func The function to check.
|
|
3650
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
3651
|
+
*/
|
|
3652
|
+
function isMasked$1(func) {
|
|
3653
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
3654
|
+
}
|
|
3655
|
+
var _isMasked = isMasked$1;
|
|
3656
|
+
|
|
3657
|
+
/** Used for built-in method references. */
|
|
3658
|
+
|
|
3659
|
+
var funcProto$1 = Function.prototype;
|
|
3660
|
+
|
|
3661
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3662
|
+
var funcToString$1 = funcProto$1.toString;
|
|
3663
|
+
|
|
3664
|
+
/**
|
|
3665
|
+
* Converts `func` to its source code.
|
|
3666
|
+
*
|
|
3667
|
+
* @private
|
|
3668
|
+
* @param {Function} func The function to convert.
|
|
3669
|
+
* @returns {string} Returns the source code.
|
|
3670
|
+
*/
|
|
3671
|
+
function toSource$1(func) {
|
|
3672
|
+
if (func != null) {
|
|
3673
|
+
try {
|
|
3674
|
+
return funcToString$1.call(func);
|
|
3675
|
+
} catch (e) {}
|
|
3676
|
+
try {
|
|
3677
|
+
return func + '';
|
|
3678
|
+
} catch (e) {}
|
|
3679
|
+
}
|
|
3680
|
+
return '';
|
|
3681
|
+
}
|
|
3682
|
+
var _toSource = toSource$1;
|
|
3683
|
+
var isFunction = isFunction_1,
|
|
3684
|
+
isMasked = _isMasked,
|
|
3685
|
+
isObject = isObject_1,
|
|
3686
|
+
toSource = _toSource;
|
|
3687
|
+
|
|
3688
|
+
/**
|
|
3689
|
+
* Used to match `RegExp`
|
|
3690
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
3691
|
+
*/
|
|
3692
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
3693
|
+
|
|
3694
|
+
/** Used to detect host constructors (Safari). */
|
|
3695
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
3696
|
+
|
|
3697
|
+
/** Used for built-in method references. */
|
|
3698
|
+
var funcProto = Function.prototype,
|
|
3699
|
+
objectProto$2 = Object.prototype;
|
|
3700
|
+
|
|
3701
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3702
|
+
var funcToString = funcProto.toString;
|
|
3703
|
+
|
|
3704
|
+
/** Used to check objects for own properties. */
|
|
3705
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
3706
|
+
|
|
3707
|
+
/** Used to detect if a method is native. */
|
|
3708
|
+
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
3709
|
+
|
|
3710
|
+
/**
|
|
3711
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
3712
|
+
*
|
|
3713
|
+
* @private
|
|
3714
|
+
* @param {*} value The value to check.
|
|
3715
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
3716
|
+
* else `false`.
|
|
3717
|
+
*/
|
|
3718
|
+
function baseIsNative$1(value) {
|
|
3719
|
+
if (!isObject(value) || isMasked(value)) {
|
|
3720
|
+
return false;
|
|
3721
|
+
}
|
|
3722
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
3723
|
+
return pattern.test(toSource(value));
|
|
3724
|
+
}
|
|
3725
|
+
var _baseIsNative = baseIsNative$1;
|
|
3726
|
+
|
|
3727
|
+
/**
|
|
3728
|
+
* Gets the value at `key` of `object`.
|
|
3729
|
+
*
|
|
3730
|
+
* @private
|
|
3731
|
+
* @param {Object} [object] The object to query.
|
|
3732
|
+
* @param {string} key The key of the property to get.
|
|
3733
|
+
* @returns {*} Returns the property value.
|
|
3734
|
+
*/
|
|
3735
|
+
|
|
3736
|
+
function getValue$1(object, key) {
|
|
3737
|
+
return object == null ? undefined : object[key];
|
|
3738
|
+
}
|
|
3739
|
+
var _getValue = getValue$1;
|
|
3740
|
+
var baseIsNative = _baseIsNative,
|
|
3741
|
+
getValue = _getValue;
|
|
3742
|
+
|
|
3743
|
+
/**
|
|
3744
|
+
* Gets the native function at `key` of `object`.
|
|
3745
|
+
*
|
|
3746
|
+
* @private
|
|
3747
|
+
* @param {Object} object The object to query.
|
|
3748
|
+
* @param {string} key The key of the method to get.
|
|
3749
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
3750
|
+
*/
|
|
3751
|
+
function getNative$2(object, key) {
|
|
3752
|
+
var value = getValue(object, key);
|
|
3753
|
+
return baseIsNative(value) ? value : undefined;
|
|
3754
|
+
}
|
|
3755
|
+
var _getNative = getNative$2;
|
|
3756
|
+
var getNative$1 = _getNative;
|
|
3757
|
+
|
|
3758
|
+
/* Built-in method references that are verified to be native. */
|
|
3759
|
+
var nativeCreate$4 = getNative$1(Object, 'create');
|
|
3760
|
+
var _nativeCreate = nativeCreate$4;
|
|
3761
|
+
var nativeCreate$3 = _nativeCreate;
|
|
3762
|
+
|
|
3763
|
+
/**
|
|
3764
|
+
* Removes all key-value entries from the hash.
|
|
3765
|
+
*
|
|
3766
|
+
* @private
|
|
3767
|
+
* @name clear
|
|
3768
|
+
* @memberOf Hash
|
|
3769
|
+
*/
|
|
3770
|
+
function hashClear$1() {
|
|
3771
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
3772
|
+
this.size = 0;
|
|
3773
|
+
}
|
|
3774
|
+
var _hashClear = hashClear$1;
|
|
3775
|
+
|
|
3776
|
+
/**
|
|
3777
|
+
* Removes `key` and its value from the hash.
|
|
3778
|
+
*
|
|
3779
|
+
* @private
|
|
3780
|
+
* @name delete
|
|
3781
|
+
* @memberOf Hash
|
|
3782
|
+
* @param {Object} hash The hash to modify.
|
|
3783
|
+
* @param {string} key The key of the value to remove.
|
|
3784
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3785
|
+
*/
|
|
3786
|
+
|
|
3787
|
+
function hashDelete$1(key) {
|
|
3788
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
3789
|
+
this.size -= result ? 1 : 0;
|
|
3790
|
+
return result;
|
|
3791
|
+
}
|
|
3792
|
+
var _hashDelete = hashDelete$1;
|
|
3793
|
+
var nativeCreate$2 = _nativeCreate;
|
|
3794
|
+
|
|
3795
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3796
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
3797
|
+
|
|
3798
|
+
/** Used for built-in method references. */
|
|
3799
|
+
var objectProto$1 = Object.prototype;
|
|
3800
|
+
|
|
3801
|
+
/** Used to check objects for own properties. */
|
|
3802
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
3803
|
+
|
|
3804
|
+
/**
|
|
3805
|
+
* Gets the hash value for `key`.
|
|
3806
|
+
*
|
|
3807
|
+
* @private
|
|
3808
|
+
* @name get
|
|
3809
|
+
* @memberOf Hash
|
|
3810
|
+
* @param {string} key The key of the value to get.
|
|
3811
|
+
* @returns {*} Returns the entry value.
|
|
3812
|
+
*/
|
|
3813
|
+
function hashGet$1(key) {
|
|
3814
|
+
var data = this.__data__;
|
|
3815
|
+
if (nativeCreate$2) {
|
|
3816
|
+
var result = data[key];
|
|
3817
|
+
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
3818
|
+
}
|
|
3819
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
|
|
3820
|
+
}
|
|
3821
|
+
var _hashGet = hashGet$1;
|
|
3822
|
+
var nativeCreate$1 = _nativeCreate;
|
|
3823
|
+
|
|
3824
|
+
/** Used for built-in method references. */
|
|
3825
|
+
var objectProto = Object.prototype;
|
|
3826
|
+
|
|
3827
|
+
/** Used to check objects for own properties. */
|
|
3828
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
3829
|
+
|
|
3830
|
+
/**
|
|
3831
|
+
* Checks if a hash value for `key` exists.
|
|
3832
|
+
*
|
|
3833
|
+
* @private
|
|
3834
|
+
* @name has
|
|
3835
|
+
* @memberOf Hash
|
|
3836
|
+
* @param {string} key The key of the entry to check.
|
|
3837
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3838
|
+
*/
|
|
3839
|
+
function hashHas$1(key) {
|
|
3840
|
+
var data = this.__data__;
|
|
3841
|
+
return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|
3842
|
+
}
|
|
3843
|
+
var _hashHas = hashHas$1;
|
|
3844
|
+
var nativeCreate = _nativeCreate;
|
|
3845
|
+
|
|
3846
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3847
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
3848
|
+
|
|
3849
|
+
/**
|
|
3850
|
+
* Sets the hash `key` to `value`.
|
|
3851
|
+
*
|
|
3852
|
+
* @private
|
|
3853
|
+
* @name set
|
|
3854
|
+
* @memberOf Hash
|
|
3855
|
+
* @param {string} key The key of the value to set.
|
|
3856
|
+
* @param {*} value The value to set.
|
|
3857
|
+
* @returns {Object} Returns the hash instance.
|
|
3858
|
+
*/
|
|
3859
|
+
function hashSet$1(key, value) {
|
|
3860
|
+
var data = this.__data__;
|
|
3861
|
+
this.size += this.has(key) ? 0 : 1;
|
|
3862
|
+
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
|
|
3863
|
+
return this;
|
|
3864
|
+
}
|
|
3865
|
+
var _hashSet = hashSet$1;
|
|
3866
|
+
var hashClear = _hashClear,
|
|
3867
|
+
hashDelete = _hashDelete,
|
|
3868
|
+
hashGet = _hashGet,
|
|
3869
|
+
hashHas = _hashHas,
|
|
3870
|
+
hashSet = _hashSet;
|
|
3871
|
+
|
|
3872
|
+
/**
|
|
3873
|
+
* Creates a hash object.
|
|
3874
|
+
*
|
|
3875
|
+
* @private
|
|
3876
|
+
* @constructor
|
|
3877
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
3878
|
+
*/
|
|
3879
|
+
function Hash$1(entries) {
|
|
3880
|
+
var index = -1,
|
|
3881
|
+
length = entries == null ? 0 : entries.length;
|
|
3882
|
+
this.clear();
|
|
3883
|
+
while (++index < length) {
|
|
3884
|
+
var entry = entries[index];
|
|
3885
|
+
this.set(entry[0], entry[1]);
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
// Add methods to `Hash`.
|
|
3890
|
+
Hash$1.prototype.clear = hashClear;
|
|
3891
|
+
Hash$1.prototype['delete'] = hashDelete;
|
|
3892
|
+
Hash$1.prototype.get = hashGet;
|
|
3893
|
+
Hash$1.prototype.has = hashHas;
|
|
3894
|
+
Hash$1.prototype.set = hashSet;
|
|
3895
|
+
var _Hash = Hash$1;
|
|
3896
|
+
|
|
3897
|
+
/**
|
|
3898
|
+
* Removes all key-value entries from the list cache.
|
|
3899
|
+
*
|
|
3900
|
+
* @private
|
|
3901
|
+
* @name clear
|
|
3902
|
+
* @memberOf ListCache
|
|
3903
|
+
*/
|
|
3904
|
+
|
|
3905
|
+
function listCacheClear$1() {
|
|
3906
|
+
this.__data__ = [];
|
|
3907
|
+
this.size = 0;
|
|
3908
|
+
}
|
|
3909
|
+
var _listCacheClear = listCacheClear$1;
|
|
3910
|
+
|
|
3911
|
+
/**
|
|
3912
|
+
* Performs a
|
|
3913
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
3914
|
+
* comparison between two values to determine if they are equivalent.
|
|
3915
|
+
*
|
|
3916
|
+
* @static
|
|
3917
|
+
* @memberOf _
|
|
3918
|
+
* @since 4.0.0
|
|
3919
|
+
* @category Lang
|
|
3920
|
+
* @param {*} value The value to compare.
|
|
3921
|
+
* @param {*} other The other value to compare.
|
|
3922
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3923
|
+
* @example
|
|
3924
|
+
*
|
|
3925
|
+
* var object = { 'a': 1 };
|
|
3926
|
+
* var other = { 'a': 1 };
|
|
3927
|
+
*
|
|
3928
|
+
* _.eq(object, object);
|
|
3929
|
+
* // => true
|
|
3930
|
+
*
|
|
3931
|
+
* _.eq(object, other);
|
|
3932
|
+
* // => false
|
|
3933
|
+
*
|
|
3934
|
+
* _.eq('a', 'a');
|
|
3935
|
+
* // => true
|
|
3936
|
+
*
|
|
3937
|
+
* _.eq('a', Object('a'));
|
|
3938
|
+
* // => false
|
|
3939
|
+
*
|
|
3940
|
+
* _.eq(NaN, NaN);
|
|
3941
|
+
* // => true
|
|
3942
|
+
*/
|
|
3943
|
+
|
|
3944
|
+
function eq$1(value, other) {
|
|
3945
|
+
return value === other || value !== value && other !== other;
|
|
3946
|
+
}
|
|
3947
|
+
var eq_1 = eq$1;
|
|
3948
|
+
var eq = eq_1;
|
|
3949
|
+
|
|
3950
|
+
/**
|
|
3951
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
3952
|
+
*
|
|
3953
|
+
* @private
|
|
3954
|
+
* @param {Array} array The array to inspect.
|
|
3955
|
+
* @param {*} key The key to search for.
|
|
3956
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
3957
|
+
*/
|
|
3958
|
+
function assocIndexOf$4(array, key) {
|
|
3959
|
+
var length = array.length;
|
|
3960
|
+
while (length--) {
|
|
3961
|
+
if (eq(array[length][0], key)) {
|
|
3962
|
+
return length;
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
return -1;
|
|
3966
|
+
}
|
|
3967
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
3968
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
3969
|
+
|
|
3970
|
+
/** Used for built-in method references. */
|
|
3971
|
+
var arrayProto = Array.prototype;
|
|
3972
|
+
|
|
3973
|
+
/** Built-in value references. */
|
|
3974
|
+
var splice = arrayProto.splice;
|
|
3975
|
+
|
|
3976
|
+
/**
|
|
3977
|
+
* Removes `key` and its value from the list cache.
|
|
3978
|
+
*
|
|
3979
|
+
* @private
|
|
3980
|
+
* @name delete
|
|
3981
|
+
* @memberOf ListCache
|
|
3982
|
+
* @param {string} key The key of the value to remove.
|
|
3983
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3984
|
+
*/
|
|
3985
|
+
function listCacheDelete$1(key) {
|
|
3986
|
+
var data = this.__data__,
|
|
3987
|
+
index = assocIndexOf$3(data, key);
|
|
3988
|
+
if (index < 0) {
|
|
3989
|
+
return false;
|
|
3990
|
+
}
|
|
3991
|
+
var lastIndex = data.length - 1;
|
|
3992
|
+
if (index == lastIndex) {
|
|
3993
|
+
data.pop();
|
|
3994
|
+
} else {
|
|
3995
|
+
splice.call(data, index, 1);
|
|
3996
|
+
}
|
|
3997
|
+
--this.size;
|
|
3998
|
+
return true;
|
|
3999
|
+
}
|
|
4000
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
4001
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
4002
|
+
|
|
4003
|
+
/**
|
|
4004
|
+
* Gets the list cache value for `key`.
|
|
4005
|
+
*
|
|
4006
|
+
* @private
|
|
4007
|
+
* @name get
|
|
4008
|
+
* @memberOf ListCache
|
|
4009
|
+
* @param {string} key The key of the value to get.
|
|
4010
|
+
* @returns {*} Returns the entry value.
|
|
4011
|
+
*/
|
|
4012
|
+
function listCacheGet$1(key) {
|
|
4013
|
+
var data = this.__data__,
|
|
4014
|
+
index = assocIndexOf$2(data, key);
|
|
4015
|
+
return index < 0 ? undefined : data[index][1];
|
|
4016
|
+
}
|
|
4017
|
+
var _listCacheGet = listCacheGet$1;
|
|
4018
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
4019
|
+
|
|
4020
|
+
/**
|
|
4021
|
+
* Checks if a list cache value for `key` exists.
|
|
4022
|
+
*
|
|
4023
|
+
* @private
|
|
4024
|
+
* @name has
|
|
4025
|
+
* @memberOf ListCache
|
|
4026
|
+
* @param {string} key The key of the entry to check.
|
|
4027
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4028
|
+
*/
|
|
4029
|
+
function listCacheHas$1(key) {
|
|
4030
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
4031
|
+
}
|
|
4032
|
+
var _listCacheHas = listCacheHas$1;
|
|
4033
|
+
var assocIndexOf = _assocIndexOf;
|
|
4034
|
+
|
|
4035
|
+
/**
|
|
4036
|
+
* Sets the list cache `key` to `value`.
|
|
4037
|
+
*
|
|
4038
|
+
* @private
|
|
4039
|
+
* @name set
|
|
4040
|
+
* @memberOf ListCache
|
|
4041
|
+
* @param {string} key The key of the value to set.
|
|
4042
|
+
* @param {*} value The value to set.
|
|
4043
|
+
* @returns {Object} Returns the list cache instance.
|
|
4044
|
+
*/
|
|
4045
|
+
function listCacheSet$1(key, value) {
|
|
4046
|
+
var data = this.__data__,
|
|
4047
|
+
index = assocIndexOf(data, key);
|
|
4048
|
+
if (index < 0) {
|
|
4049
|
+
++this.size;
|
|
4050
|
+
data.push([key, value]);
|
|
4051
|
+
} else {
|
|
4052
|
+
data[index][1] = value;
|
|
4053
|
+
}
|
|
4054
|
+
return this;
|
|
4055
|
+
}
|
|
4056
|
+
var _listCacheSet = listCacheSet$1;
|
|
4057
|
+
var listCacheClear = _listCacheClear,
|
|
4058
|
+
listCacheDelete = _listCacheDelete,
|
|
4059
|
+
listCacheGet = _listCacheGet,
|
|
4060
|
+
listCacheHas = _listCacheHas,
|
|
4061
|
+
listCacheSet = _listCacheSet;
|
|
4062
|
+
|
|
4063
|
+
/**
|
|
4064
|
+
* Creates an list cache object.
|
|
4065
|
+
*
|
|
4066
|
+
* @private
|
|
4067
|
+
* @constructor
|
|
4068
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4069
|
+
*/
|
|
4070
|
+
function ListCache$1(entries) {
|
|
4071
|
+
var index = -1,
|
|
4072
|
+
length = entries == null ? 0 : entries.length;
|
|
4073
|
+
this.clear();
|
|
4074
|
+
while (++index < length) {
|
|
4075
|
+
var entry = entries[index];
|
|
4076
|
+
this.set(entry[0], entry[1]);
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
// Add methods to `ListCache`.
|
|
4081
|
+
ListCache$1.prototype.clear = listCacheClear;
|
|
4082
|
+
ListCache$1.prototype['delete'] = listCacheDelete;
|
|
4083
|
+
ListCache$1.prototype.get = listCacheGet;
|
|
4084
|
+
ListCache$1.prototype.has = listCacheHas;
|
|
4085
|
+
ListCache$1.prototype.set = listCacheSet;
|
|
4086
|
+
var _ListCache = ListCache$1;
|
|
4087
|
+
var getNative = _getNative,
|
|
4088
|
+
root = _root;
|
|
4089
|
+
|
|
4090
|
+
/* Built-in method references that are verified to be native. */
|
|
4091
|
+
var Map$2 = getNative(root, 'Map');
|
|
4092
|
+
var _Map = Map$2;
|
|
4093
|
+
var Hash = _Hash,
|
|
4094
|
+
ListCache = _ListCache,
|
|
4095
|
+
Map$1 = _Map;
|
|
4096
|
+
|
|
4097
|
+
/**
|
|
4098
|
+
* Removes all key-value entries from the map.
|
|
4099
|
+
*
|
|
4100
|
+
* @private
|
|
4101
|
+
* @name clear
|
|
4102
|
+
* @memberOf MapCache
|
|
4103
|
+
*/
|
|
4104
|
+
function mapCacheClear$1() {
|
|
4105
|
+
this.size = 0;
|
|
4106
|
+
this.__data__ = {
|
|
4107
|
+
'hash': new Hash(),
|
|
4108
|
+
'map': new (Map$1 || ListCache)(),
|
|
4109
|
+
'string': new Hash()
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
4113
|
+
|
|
4114
|
+
/**
|
|
4115
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
4116
|
+
*
|
|
4117
|
+
* @private
|
|
4118
|
+
* @param {*} value The value to check.
|
|
4119
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
4120
|
+
*/
|
|
4121
|
+
|
|
4122
|
+
function isKeyable$1(value) {
|
|
4123
|
+
var type = typeof value;
|
|
4124
|
+
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
4125
|
+
}
|
|
4126
|
+
var _isKeyable = isKeyable$1;
|
|
4127
|
+
var isKeyable = _isKeyable;
|
|
4128
|
+
|
|
4129
|
+
/**
|
|
4130
|
+
* Gets the data for `map`.
|
|
4131
|
+
*
|
|
4132
|
+
* @private
|
|
4133
|
+
* @param {Object} map The map to query.
|
|
4134
|
+
* @param {string} key The reference key.
|
|
4135
|
+
* @returns {*} Returns the map data.
|
|
4136
|
+
*/
|
|
4137
|
+
function getMapData$4(map, key) {
|
|
4138
|
+
var data = map.__data__;
|
|
4139
|
+
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
4140
|
+
}
|
|
4141
|
+
var _getMapData = getMapData$4;
|
|
4142
|
+
var getMapData$3 = _getMapData;
|
|
4143
|
+
|
|
4144
|
+
/**
|
|
4145
|
+
* Removes `key` and its value from the map.
|
|
4146
|
+
*
|
|
4147
|
+
* @private
|
|
4148
|
+
* @name delete
|
|
4149
|
+
* @memberOf MapCache
|
|
4150
|
+
* @param {string} key The key of the value to remove.
|
|
4151
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
4152
|
+
*/
|
|
4153
|
+
function mapCacheDelete$1(key) {
|
|
4154
|
+
var result = getMapData$3(this, key)['delete'](key);
|
|
4155
|
+
this.size -= result ? 1 : 0;
|
|
4156
|
+
return result;
|
|
4157
|
+
}
|
|
4158
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
4159
|
+
var getMapData$2 = _getMapData;
|
|
4160
|
+
|
|
4161
|
+
/**
|
|
4162
|
+
* Gets the map value for `key`.
|
|
4163
|
+
*
|
|
4164
|
+
* @private
|
|
4165
|
+
* @name get
|
|
4166
|
+
* @memberOf MapCache
|
|
4167
|
+
* @param {string} key The key of the value to get.
|
|
4168
|
+
* @returns {*} Returns the entry value.
|
|
4169
|
+
*/
|
|
4170
|
+
function mapCacheGet$1(key) {
|
|
4171
|
+
return getMapData$2(this, key).get(key);
|
|
4172
|
+
}
|
|
4173
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
4174
|
+
var getMapData$1 = _getMapData;
|
|
4175
|
+
|
|
4176
|
+
/**
|
|
4177
|
+
* Checks if a map value for `key` exists.
|
|
4178
|
+
*
|
|
4179
|
+
* @private
|
|
4180
|
+
* @name has
|
|
4181
|
+
* @memberOf MapCache
|
|
4182
|
+
* @param {string} key The key of the entry to check.
|
|
4183
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4184
|
+
*/
|
|
4185
|
+
function mapCacheHas$1(key) {
|
|
4186
|
+
return getMapData$1(this, key).has(key);
|
|
4187
|
+
}
|
|
4188
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
4189
|
+
var getMapData = _getMapData;
|
|
4190
|
+
|
|
4191
|
+
/**
|
|
4192
|
+
* Sets the map `key` to `value`.
|
|
4193
|
+
*
|
|
4194
|
+
* @private
|
|
4195
|
+
* @name set
|
|
4196
|
+
* @memberOf MapCache
|
|
4197
|
+
* @param {string} key The key of the value to set.
|
|
4198
|
+
* @param {*} value The value to set.
|
|
4199
|
+
* @returns {Object} Returns the map cache instance.
|
|
4200
|
+
*/
|
|
4201
|
+
function mapCacheSet$1(key, value) {
|
|
4202
|
+
var data = getMapData(this, key),
|
|
4203
|
+
size = data.size;
|
|
4204
|
+
data.set(key, value);
|
|
4205
|
+
this.size += data.size == size ? 0 : 1;
|
|
4206
|
+
return this;
|
|
4207
|
+
}
|
|
4208
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
4209
|
+
var mapCacheClear = _mapCacheClear,
|
|
4210
|
+
mapCacheDelete = _mapCacheDelete,
|
|
4211
|
+
mapCacheGet = _mapCacheGet,
|
|
4212
|
+
mapCacheHas = _mapCacheHas,
|
|
4213
|
+
mapCacheSet = _mapCacheSet;
|
|
4214
|
+
|
|
4215
|
+
/**
|
|
4216
|
+
* Creates a map cache object to store key-value pairs.
|
|
4217
|
+
*
|
|
4218
|
+
* @private
|
|
4219
|
+
* @constructor
|
|
4220
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4221
|
+
*/
|
|
4222
|
+
function MapCache$1(entries) {
|
|
4223
|
+
var index = -1,
|
|
4224
|
+
length = entries == null ? 0 : entries.length;
|
|
4225
|
+
this.clear();
|
|
4226
|
+
while (++index < length) {
|
|
4227
|
+
var entry = entries[index];
|
|
4228
|
+
this.set(entry[0], entry[1]);
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
|
|
4232
|
+
// Add methods to `MapCache`.
|
|
4233
|
+
MapCache$1.prototype.clear = mapCacheClear;
|
|
4234
|
+
MapCache$1.prototype['delete'] = mapCacheDelete;
|
|
4235
|
+
MapCache$1.prototype.get = mapCacheGet;
|
|
4236
|
+
MapCache$1.prototype.has = mapCacheHas;
|
|
4237
|
+
MapCache$1.prototype.set = mapCacheSet;
|
|
4238
|
+
var _MapCache = MapCache$1;
|
|
4239
|
+
var MapCache = _MapCache;
|
|
4240
|
+
|
|
4241
|
+
/** Error message constants. */
|
|
4242
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
4243
|
+
|
|
4244
|
+
/**
|
|
4245
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
4246
|
+
* provided, it determines the cache key for storing the result based on the
|
|
4247
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
4248
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
4249
|
+
* is invoked with the `this` binding of the memoized function.
|
|
4250
|
+
*
|
|
4251
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
4252
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
4253
|
+
* constructor with one whose instances implement the
|
|
4254
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
4255
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
4256
|
+
*
|
|
4257
|
+
* @static
|
|
4258
|
+
* @memberOf _
|
|
4259
|
+
* @since 0.1.0
|
|
4260
|
+
* @category Function
|
|
4261
|
+
* @param {Function} func The function to have its output memoized.
|
|
4262
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
4263
|
+
* @returns {Function} Returns the new memoized function.
|
|
4264
|
+
* @example
|
|
4265
|
+
*
|
|
4266
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
4267
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
4268
|
+
*
|
|
4269
|
+
* var values = _.memoize(_.values);
|
|
4270
|
+
* values(object);
|
|
4271
|
+
* // => [1, 2]
|
|
4272
|
+
*
|
|
4273
|
+
* values(other);
|
|
4274
|
+
* // => [3, 4]
|
|
4275
|
+
*
|
|
4276
|
+
* object.a = 2;
|
|
4277
|
+
* values(object);
|
|
4278
|
+
* // => [1, 2]
|
|
4279
|
+
*
|
|
4280
|
+
* // Modify the result cache.
|
|
4281
|
+
* values.cache.set(object, ['a', 'b']);
|
|
4282
|
+
* values(object);
|
|
4283
|
+
* // => ['a', 'b']
|
|
4284
|
+
*
|
|
4285
|
+
* // Replace `_.memoize.Cache`.
|
|
4286
|
+
* _.memoize.Cache = WeakMap;
|
|
4287
|
+
*/
|
|
4288
|
+
function memoize$1(func, resolver) {
|
|
4289
|
+
if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
|
|
4290
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
4291
|
+
}
|
|
4292
|
+
var memoized = function () {
|
|
4293
|
+
var args = arguments,
|
|
4294
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
4295
|
+
cache = memoized.cache;
|
|
4296
|
+
if (cache.has(key)) {
|
|
4297
|
+
return cache.get(key);
|
|
4298
|
+
}
|
|
4299
|
+
var result = func.apply(this, args);
|
|
4300
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
4301
|
+
return result;
|
|
4302
|
+
};
|
|
4303
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
4304
|
+
return memoized;
|
|
4305
|
+
}
|
|
4306
|
+
|
|
4307
|
+
// Expose `MapCache`.
|
|
4308
|
+
memoize$1.Cache = MapCache;
|
|
4309
|
+
var memoize_1 = memoize$1;
|
|
4310
|
+
var memoize = memoize_1;
|
|
4311
|
+
|
|
4312
|
+
/** Used as the maximum memoize cache size. */
|
|
4313
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
4314
|
+
|
|
4315
|
+
/**
|
|
4316
|
+
* A specialized version of `_.memoize` which clears the memoized function's
|
|
4317
|
+
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
4318
|
+
*
|
|
4319
|
+
* @private
|
|
4320
|
+
* @param {Function} func The function to have its output memoized.
|
|
4321
|
+
* @returns {Function} Returns the new memoized function.
|
|
4322
|
+
*/
|
|
4323
|
+
function memoizeCapped$1(func) {
|
|
4324
|
+
var result = memoize(func, function (key) {
|
|
4325
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
4326
|
+
cache.clear();
|
|
4327
|
+
}
|
|
4328
|
+
return key;
|
|
4329
|
+
});
|
|
4330
|
+
var cache = result.cache;
|
|
4331
|
+
return result;
|
|
4332
|
+
}
|
|
4333
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
4334
|
+
var memoizeCapped = _memoizeCapped;
|
|
4335
|
+
|
|
4336
|
+
/** Used to match property names within property paths. */
|
|
4337
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
4338
|
+
|
|
4339
|
+
/** Used to match backslashes in property paths. */
|
|
4340
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
4341
|
+
|
|
4342
|
+
/**
|
|
4343
|
+
* Converts `string` to a property path array.
|
|
4344
|
+
*
|
|
4345
|
+
* @private
|
|
4346
|
+
* @param {string} string The string to convert.
|
|
4347
|
+
* @returns {Array} Returns the property path array.
|
|
4348
|
+
*/
|
|
4349
|
+
var stringToPath$1 = memoizeCapped(function (string) {
|
|
4350
|
+
var result = [];
|
|
4351
|
+
if (string.charCodeAt(0) === 46 /* . */) {
|
|
4352
|
+
result.push('');
|
|
4353
|
+
}
|
|
4354
|
+
string.replace(rePropName, function (match, number, quote, subString) {
|
|
4355
|
+
result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
|
|
4356
|
+
});
|
|
4357
|
+
return result;
|
|
4358
|
+
});
|
|
4359
|
+
var _stringToPath = stringToPath$1;
|
|
4360
|
+
|
|
4361
|
+
/**
|
|
4362
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
4363
|
+
* shorthands.
|
|
4364
|
+
*
|
|
4365
|
+
* @private
|
|
4366
|
+
* @param {Array} [array] The array to iterate over.
|
|
4367
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
4368
|
+
* @returns {Array} Returns the new mapped array.
|
|
4369
|
+
*/
|
|
4370
|
+
|
|
4371
|
+
function arrayMap$1(array, iteratee) {
|
|
4372
|
+
var index = -1,
|
|
4373
|
+
length = array == null ? 0 : array.length,
|
|
4374
|
+
result = Array(length);
|
|
4375
|
+
while (++index < length) {
|
|
4376
|
+
result[index] = iteratee(array[index], index, array);
|
|
4377
|
+
}
|
|
4378
|
+
return result;
|
|
4379
|
+
}
|
|
4380
|
+
var _arrayMap = arrayMap$1;
|
|
4381
|
+
var Symbol = _Symbol,
|
|
4382
|
+
arrayMap = _arrayMap,
|
|
4383
|
+
isArray$1 = isArray_1,
|
|
4384
|
+
isSymbol$1 = isSymbol_1;
|
|
4385
|
+
|
|
4386
|
+
/** Used as references for various `Number` constants. */
|
|
4387
|
+
var INFINITY$1 = 1 / 0;
|
|
4388
|
+
|
|
4389
|
+
/** Used to convert symbols to primitives and strings. */
|
|
4390
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
4391
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
4392
|
+
|
|
4393
|
+
/**
|
|
4394
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
4395
|
+
* values to empty strings.
|
|
4396
|
+
*
|
|
4397
|
+
* @private
|
|
4398
|
+
* @param {*} value The value to process.
|
|
4399
|
+
* @returns {string} Returns the string.
|
|
4400
|
+
*/
|
|
4401
|
+
function baseToString$1(value) {
|
|
4402
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
4403
|
+
if (typeof value == 'string') {
|
|
4404
|
+
return value;
|
|
4405
|
+
}
|
|
4406
|
+
if (isArray$1(value)) {
|
|
4407
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
4408
|
+
return arrayMap(value, baseToString$1) + '';
|
|
4409
|
+
}
|
|
4410
|
+
if (isSymbol$1(value)) {
|
|
4411
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
4412
|
+
}
|
|
4413
|
+
var result = value + '';
|
|
4414
|
+
return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
|
|
4415
|
+
}
|
|
4416
|
+
var _baseToString = baseToString$1;
|
|
4417
|
+
var baseToString = _baseToString;
|
|
4418
|
+
|
|
4419
|
+
/**
|
|
4420
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
4421
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
4422
|
+
*
|
|
4423
|
+
* @static
|
|
4424
|
+
* @memberOf _
|
|
4425
|
+
* @since 4.0.0
|
|
4426
|
+
* @category Lang
|
|
4427
|
+
* @param {*} value The value to convert.
|
|
4428
|
+
* @returns {string} Returns the converted string.
|
|
4429
|
+
* @example
|
|
4430
|
+
*
|
|
4431
|
+
* _.toString(null);
|
|
4432
|
+
* // => ''
|
|
4433
|
+
*
|
|
4434
|
+
* _.toString(-0);
|
|
4435
|
+
* // => '-0'
|
|
4436
|
+
*
|
|
4437
|
+
* _.toString([1, 2, 3]);
|
|
4438
|
+
* // => '1,2,3'
|
|
4439
|
+
*/
|
|
4440
|
+
function toString$1(value) {
|
|
4441
|
+
return value == null ? '' : baseToString(value);
|
|
4442
|
+
}
|
|
4443
|
+
var toString_1 = toString$1;
|
|
4444
|
+
var isArray = isArray_1,
|
|
4445
|
+
isKey = _isKey,
|
|
4446
|
+
stringToPath = _stringToPath,
|
|
4447
|
+
toString = toString_1;
|
|
4448
|
+
|
|
4449
|
+
/**
|
|
4450
|
+
* Casts `value` to a path array if it's not one.
|
|
4451
|
+
*
|
|
4452
|
+
* @private
|
|
4453
|
+
* @param {*} value The value to inspect.
|
|
4454
|
+
* @param {Object} [object] The object to query keys on.
|
|
4455
|
+
* @returns {Array} Returns the cast property path array.
|
|
4456
|
+
*/
|
|
4457
|
+
function castPath$1(value, object) {
|
|
4458
|
+
if (isArray(value)) {
|
|
4459
|
+
return value;
|
|
4460
|
+
}
|
|
4461
|
+
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
4462
|
+
}
|
|
4463
|
+
var _castPath = castPath$1;
|
|
4464
|
+
var isSymbol = isSymbol_1;
|
|
4465
|
+
|
|
4466
|
+
/** Used as references for various `Number` constants. */
|
|
4467
|
+
var INFINITY = 1 / 0;
|
|
4468
|
+
|
|
4469
|
+
/**
|
|
4470
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
4471
|
+
*
|
|
4472
|
+
* @private
|
|
4473
|
+
* @param {*} value The value to inspect.
|
|
4474
|
+
* @returns {string|symbol} Returns the key.
|
|
4475
|
+
*/
|
|
4476
|
+
function toKey$1(value) {
|
|
4477
|
+
if (typeof value == 'string' || isSymbol(value)) {
|
|
4478
|
+
return value;
|
|
4479
|
+
}
|
|
4480
|
+
var result = value + '';
|
|
4481
|
+
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
|
|
4482
|
+
}
|
|
4483
|
+
var _toKey = toKey$1;
|
|
4484
|
+
var castPath = _castPath,
|
|
4485
|
+
toKey = _toKey;
|
|
4486
|
+
|
|
4487
|
+
/**
|
|
4488
|
+
* The base implementation of `_.get` without support for default values.
|
|
4489
|
+
*
|
|
4490
|
+
* @private
|
|
4491
|
+
* @param {Object} object The object to query.
|
|
4492
|
+
* @param {Array|string} path The path of the property to get.
|
|
4493
|
+
* @returns {*} Returns the resolved value.
|
|
4494
|
+
*/
|
|
4495
|
+
function baseGet$1(object, path) {
|
|
4496
|
+
path = castPath(path, object);
|
|
4497
|
+
var index = 0,
|
|
4498
|
+
length = path.length;
|
|
4499
|
+
while (object != null && index < length) {
|
|
4500
|
+
object = object[toKey(path[index++])];
|
|
4501
|
+
}
|
|
4502
|
+
return index && index == length ? object : undefined;
|
|
4503
|
+
}
|
|
4504
|
+
var _baseGet = baseGet$1;
|
|
4505
|
+
var baseGet = _baseGet;
|
|
4506
|
+
|
|
4507
|
+
/**
|
|
4508
|
+
* Gets the value at `path` of `object`. If the resolved value is
|
|
4509
|
+
* `undefined`, the `defaultValue` is returned in its place.
|
|
4510
|
+
*
|
|
4511
|
+
* @static
|
|
4512
|
+
* @memberOf _
|
|
4513
|
+
* @since 3.7.0
|
|
4514
|
+
* @category Object
|
|
4515
|
+
* @param {Object} object The object to query.
|
|
4516
|
+
* @param {Array|string} path The path of the property to get.
|
|
4517
|
+
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
4518
|
+
* @returns {*} Returns the resolved value.
|
|
4519
|
+
* @example
|
|
4520
|
+
*
|
|
4521
|
+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
4522
|
+
*
|
|
4523
|
+
* _.get(object, 'a[0].b.c');
|
|
4524
|
+
* // => 3
|
|
4525
|
+
*
|
|
4526
|
+
* _.get(object, ['a', '0', 'b', 'c']);
|
|
4527
|
+
* // => 3
|
|
4528
|
+
*
|
|
4529
|
+
* _.get(object, 'a.b.c', 'default');
|
|
4530
|
+
* // => 'default'
|
|
4531
|
+
*/
|
|
4532
|
+
function get(object, path, defaultValue) {
|
|
4533
|
+
var result = object == null ? undefined : baseGet(object, path);
|
|
4534
|
+
return result === undefined ? defaultValue : result;
|
|
4535
|
+
}
|
|
4536
|
+
var get_1 = get;
|
|
4537
|
+
var get$1 = /*@__PURE__*/getDefaultExportFromCjs(get_1);
|
|
4538
|
+
const getLanguageParams = (select, document) => {
|
|
4539
|
+
if (!select || !document) {
|
|
4540
|
+
return {};
|
|
4541
|
+
}
|
|
4542
|
+
const selection = select || {};
|
|
4543
|
+
const selectedValue = {};
|
|
4544
|
+
for (const [key, path] of Object.entries(selection)) {
|
|
4545
|
+
let value = get$1(document, path);
|
|
4546
|
+
if (Array.isArray(value)) {
|
|
4547
|
+
value = value.filter(item => typeof item === "object" ? (item == null ? void 0 : item._type) !== "reference" || "_ref" in item : true);
|
|
4548
|
+
}
|
|
4549
|
+
selectedValue[key] = value;
|
|
4550
|
+
}
|
|
4551
|
+
return selectedValue;
|
|
4552
|
+
};
|
|
4553
|
+
const FieldTranslationContext = react.createContext({
|
|
4554
|
+
openFieldTranslation: () => {},
|
|
4555
|
+
translationLoading: false
|
|
4556
|
+
});
|
|
4557
|
+
function useFieldTranslation() {
|
|
4558
|
+
return react.useContext(FieldTranslationContext);
|
|
4559
|
+
}
|
|
4560
|
+
function FieldTranslationProvider(props) {
|
|
4561
|
+
var _a, _b;
|
|
4562
|
+
const {
|
|
4563
|
+
config: assistConfig
|
|
4564
|
+
} = useAiAssistanceConfig();
|
|
4565
|
+
const apiClient = useApiClient(assistConfig.__customApiClient);
|
|
4566
|
+
const config = (_a = assistConfig.translate) == null ? void 0 : _a.field;
|
|
4567
|
+
const {
|
|
4568
|
+
translate: runTranslate
|
|
4569
|
+
} = useTranslate(apiClient);
|
|
4570
|
+
const [dialogOpen, setDialogOpen] = react.useState(false);
|
|
4571
|
+
const [document, setDocument] = react.useState();
|
|
4572
|
+
const [documentSchema, setDocumentSchema] = react.useState();
|
|
4573
|
+
const [languages, setLanguages] = react.useState();
|
|
4574
|
+
const [fromLanguage, setFromLanguage] = react.useState(void 0);
|
|
4575
|
+
const [toLanguages, setToLanguages] = react.useState(void 0);
|
|
4576
|
+
const [translationMap, setTranslationMap] = react.useState();
|
|
4577
|
+
const close = react.useCallback(() => {
|
|
4578
|
+
setDialogOpen(false);
|
|
4579
|
+
setLanguages(void 0);
|
|
4580
|
+
setDocument(void 0);
|
|
4581
|
+
setDocument(void 0);
|
|
4582
|
+
}, []);
|
|
4583
|
+
const languageClient = sanity.useClient({
|
|
4584
|
+
apiVersion: (_b = config == null ? void 0 : config.apiVersion) != null ? _b : "2022-11-27"
|
|
4585
|
+
});
|
|
4586
|
+
const documentId = document == null ? void 0 : document._id;
|
|
4587
|
+
const id = react.useId();
|
|
4588
|
+
const selectFromLanguage = react.useCallback((from, languages2, document2, documentSchema2) => {
|
|
4589
|
+
var _a2, _b2;
|
|
4590
|
+
setFromLanguage(from);
|
|
4591
|
+
if (!document2 || !documentSchema2 || !languages2) {
|
|
4592
|
+
setTranslationMap(void 0);
|
|
4593
|
+
return;
|
|
4594
|
+
}
|
|
4595
|
+
const to = languages2.filter(l => l.id !== (from == null ? void 0 : from.id));
|
|
4596
|
+
setToLanguages(to);
|
|
4597
|
+
const fromId = from == null ? void 0 : from.id;
|
|
4598
|
+
const toIds = (_a2 = to == null ? void 0 : to.map(l => l.id)) != null ? _a2 : [];
|
|
4599
|
+
const docMembers = getDocumentMembersFlat(document2, documentSchema2);
|
|
4600
|
+
if (fromId && (toIds == null ? void 0 : toIds.length)) {
|
|
4601
|
+
const transMap = getTranslationMap(documentSchema2, docMembers, fromId, toIds, (_b2 = config == null ? void 0 : config.translationOutputs) != null ? _b2 : defaultLanguageOutputs);
|
|
4602
|
+
setTranslationMap(transMap);
|
|
4603
|
+
} else {
|
|
4604
|
+
setTranslationMap(void 0);
|
|
4605
|
+
}
|
|
4606
|
+
}, [config]);
|
|
4607
|
+
const toggleToLanguage = react.useCallback((toggledLang, toLanguages2, languages2) => {
|
|
4608
|
+
if (!languages2) {
|
|
4609
|
+
return;
|
|
4610
|
+
}
|
|
4611
|
+
const wasSelected = !!(toLanguages2 == null ? void 0 : toLanguages2.find(l => l.id === toggledLang.id));
|
|
4612
|
+
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);
|
|
4613
|
+
setToLanguages(newToLangs);
|
|
4614
|
+
}, []);
|
|
4615
|
+
const contextValue = react.useMemo(() => {
|
|
4616
|
+
return {
|
|
4617
|
+
openFieldTranslation: async (document2, documentSchema2) => {
|
|
4618
|
+
setDialogOpen(true);
|
|
4619
|
+
const languageParams = getLanguageParams(config == null ? void 0 : config.selectLanguageParams, document2);
|
|
4620
|
+
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));
|
|
4621
|
+
setLanguages(languages2);
|
|
4622
|
+
setDocument(document2);
|
|
4623
|
+
setDocumentSchema(documentSchema2);
|
|
4624
|
+
const fromLanguage2 = languages2 == null ? void 0 : languages2[0];
|
|
4625
|
+
if (fromLanguage2) {
|
|
4626
|
+
selectFromLanguage(fromLanguage2, languages2, document2, documentSchema2);
|
|
4627
|
+
} else {
|
|
4628
|
+
console.error("No languages available for selected language params", languageParams);
|
|
4629
|
+
}
|
|
4630
|
+
},
|
|
4631
|
+
translationLoading: false
|
|
4632
|
+
};
|
|
4633
|
+
}, [selectFromLanguage, config, languageClient]);
|
|
4634
|
+
const runDisabled = !fromLanguage || !(toLanguages == null ? void 0 : toLanguages.length) || !(translationMap == null ? void 0 : translationMap.length) || !documentId;
|
|
4635
|
+
const onRunTranslation = react.useCallback(() => {
|
|
4636
|
+
if (translationMap && documentId) {
|
|
4637
|
+
runTranslate({
|
|
4638
|
+
documentId,
|
|
4639
|
+
fieldLanguageMap: translationMap.map(map => ({
|
|
4640
|
+
...map,
|
|
4641
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
4642
|
+
outputs: map.outputs.filter(out => !!(toLanguages == null ? void 0 : toLanguages.find(l => l.id === out.id)))
|
|
4643
|
+
}))
|
|
4644
|
+
});
|
|
4645
|
+
}
|
|
4646
|
+
close();
|
|
4647
|
+
}, [translationMap, documentId, runTranslate, close, toLanguages]);
|
|
4648
|
+
const runButton = /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
4649
|
+
text: "Translate",
|
|
4650
|
+
tone: "primary",
|
|
4651
|
+
icon: icons.PlayIcon,
|
|
4652
|
+
style: {
|
|
4653
|
+
width: "100%"
|
|
4654
|
+
},
|
|
4655
|
+
disabled: runDisabled,
|
|
4656
|
+
onClick: onRunTranslation
|
|
4657
|
+
});
|
|
4658
|
+
return /* @__PURE__ */jsxRuntime.jsxs(FieldTranslationContext.Provider, {
|
|
4659
|
+
value: contextValue,
|
|
4660
|
+
children: [dialogOpen ? /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
4661
|
+
id,
|
|
4662
|
+
width: 1,
|
|
4663
|
+
open: dialogOpen,
|
|
4664
|
+
onClose: close,
|
|
4665
|
+
header: "Translate fields",
|
|
4666
|
+
footer: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
4667
|
+
justify: "space-between",
|
|
4668
|
+
padding: 2,
|
|
4669
|
+
flex: 1,
|
|
4670
|
+
children: runDisabled ? /* @__PURE__ */jsxRuntime.jsx(ui.Tooltip, {
|
|
4671
|
+
content: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
4672
|
+
padding: 2,
|
|
4673
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4674
|
+
children: "Nothing to translate."
|
|
4675
|
+
})
|
|
4676
|
+
}),
|
|
4677
|
+
placement: "top",
|
|
4678
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
4679
|
+
flex: 1,
|
|
4680
|
+
children: runButton
|
|
4681
|
+
})
|
|
4682
|
+
}) : runButton
|
|
4683
|
+
}),
|
|
4684
|
+
children: languages ? /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
4685
|
+
padding: 4,
|
|
4686
|
+
gap: 5,
|
|
4687
|
+
align: "flex-start",
|
|
4688
|
+
justify: "center",
|
|
4689
|
+
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
4690
|
+
space: 2,
|
|
4691
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
4692
|
+
marginBottom: 2,
|
|
4693
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4694
|
+
weight: "semibold",
|
|
4695
|
+
children: "From"
|
|
4696
|
+
})
|
|
4697
|
+
}), languages == null ? void 0 : languages.map(l => {
|
|
4698
|
+
var _a2;
|
|
4699
|
+
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
4700
|
+
gap: 3,
|
|
4701
|
+
align: "center",
|
|
4702
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Radio, {
|
|
4703
|
+
name: "fromLang",
|
|
4704
|
+
value: l.id,
|
|
4705
|
+
checked: l.id === (fromLanguage == null ? void 0 : fromLanguage.id),
|
|
4706
|
+
onClick: () => selectFromLanguage(l, languages, document, documentSchema)
|
|
4707
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4708
|
+
children: (_a2 = l.title) != null ? _a2 : l.id
|
|
4709
|
+
})]
|
|
4710
|
+
}, l.id);
|
|
4711
|
+
})]
|
|
4712
|
+
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
4713
|
+
space: 2,
|
|
4714
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
4715
|
+
marginBottom: 2,
|
|
4716
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4717
|
+
weight: "semibold",
|
|
4718
|
+
children: "To"
|
|
4719
|
+
})
|
|
4720
|
+
}), languages == null ? void 0 : languages.filter(l => l.id !== (fromLanguage == null ? void 0 : fromLanguage.id)).map(l => {
|
|
4721
|
+
var _a2;
|
|
4722
|
+
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
4723
|
+
gap: 3,
|
|
4724
|
+
align: "center",
|
|
4725
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
|
|
4726
|
+
name: "toLang",
|
|
4727
|
+
value: l.id,
|
|
4728
|
+
checked: !!(toLanguages == null ? void 0 : toLanguages.find(tl => tl.id === l.id)),
|
|
4729
|
+
onClick: () => toggleToLanguage(l, toLanguages, languages),
|
|
4730
|
+
disabled: !(translationMap == null ? void 0 : translationMap.find(tm => tm.outputs.find(o => o.id === l.id)))
|
|
4731
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4732
|
+
children: (_a2 = l.title) != null ? _a2 : l.id
|
|
4733
|
+
})]
|
|
4734
|
+
}, l.id);
|
|
4735
|
+
})]
|
|
4736
|
+
})]
|
|
4737
|
+
}) : /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
4738
|
+
padding: 4,
|
|
4739
|
+
gap: 2,
|
|
4740
|
+
align: "flex-start",
|
|
4741
|
+
justify: "center",
|
|
4742
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
4743
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
|
|
4744
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
4745
|
+
children: "Loading languages..."
|
|
4746
|
+
})]
|
|
4747
|
+
})
|
|
4748
|
+
}) : null, props.children]
|
|
4749
|
+
});
|
|
4750
|
+
}
|
|
3214
4751
|
function AssistLayout(props) {
|
|
3215
4752
|
var _a;
|
|
3216
4753
|
const [connectors, setConnectors] = react.useState([]);
|
|
@@ -3218,14 +4755,16 @@ function AssistLayout(props) {
|
|
|
3218
4755
|
return /* @__PURE__ */jsxRuntime.jsxs(AiAssistanceConfigProvider, {
|
|
3219
4756
|
config: props.config,
|
|
3220
4757
|
children: [migrate ? /* @__PURE__ */jsxRuntime.jsx(AlphaMigration, {}) : null, /* @__PURE__ */jsxRuntime.jsx(RunInstructionProvider, {
|
|
3221
|
-
children: /* @__PURE__ */jsxRuntime.
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
4758
|
+
children: /* @__PURE__ */jsxRuntime.jsx(FieldTranslationProvider, {
|
|
4759
|
+
children: /* @__PURE__ */jsxRuntime.jsxs(ConnectorsProvider, {
|
|
4760
|
+
onConnectorsChange: setConnectors,
|
|
4761
|
+
children: [props.renderDefault(props), /* @__PURE__ */jsxRuntime.jsx(ui.ThemeProvider, {
|
|
4762
|
+
tone: "default",
|
|
4763
|
+
children: /* @__PURE__ */jsxRuntime.jsx(AssistConnectorsOverlay, {
|
|
4764
|
+
connectors
|
|
4765
|
+
})
|
|
4766
|
+
})]
|
|
4767
|
+
})
|
|
3229
4768
|
})
|
|
3230
4769
|
})]
|
|
3231
4770
|
});
|
|
@@ -3321,6 +4860,7 @@ function AssistFormBlock(props) {
|
|
|
3321
4860
|
_key: key
|
|
3322
4861
|
}));
|
|
3323
4862
|
}, [onChange, key]);
|
|
4863
|
+
const singlePresence = presence[0];
|
|
3324
4864
|
return /* @__PURE__ */jsxRuntime.jsx(ErrorWrapper, {
|
|
3325
4865
|
onChange: localOnChange,
|
|
3326
4866
|
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
@@ -3329,9 +4869,9 @@ function AssistFormBlock(props) {
|
|
|
3329
4869
|
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
3330
4870
|
flex: 1,
|
|
3331
4871
|
children: props.renderDefault(props)
|
|
3332
|
-
}),
|
|
3333
|
-
presence:
|
|
3334
|
-
}
|
|
4872
|
+
}), singlePresence && /* @__PURE__ */jsxRuntime.jsx(AiFieldPresence, {
|
|
4873
|
+
presence: singlePresence
|
|
4874
|
+
})]
|
|
3335
4875
|
})
|
|
3336
4876
|
});
|
|
3337
4877
|
}
|
|
@@ -3375,16 +4915,24 @@ function InstructionInput(props) {
|
|
|
3375
4915
|
...props
|
|
3376
4916
|
}), /* @__PURE__ */jsxRuntime.jsx(ShareField, {
|
|
3377
4917
|
...props
|
|
3378
|
-
}), /* @__PURE__ */jsxRuntime.jsx(
|
|
4918
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ObjectMember, {
|
|
4919
|
+
fieldName: "prompt",
|
|
4920
|
+
...props
|
|
4921
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ObjectMember, {
|
|
4922
|
+
fieldName: "output",
|
|
3379
4923
|
...props
|
|
3380
4924
|
})]
|
|
3381
4925
|
});
|
|
3382
4926
|
}
|
|
3383
|
-
function
|
|
3384
|
-
|
|
3385
|
-
|
|
4927
|
+
function ObjectMember(_ref11) {
|
|
4928
|
+
let {
|
|
4929
|
+
fieldName,
|
|
4930
|
+
...props
|
|
4931
|
+
} = _ref11;
|
|
4932
|
+
const member = findFieldMember(props.members, fieldName);
|
|
4933
|
+
return member ? /* @__PURE__ */jsxRuntime.jsx(sanity.ObjectInputMember, {
|
|
3386
4934
|
...props,
|
|
3387
|
-
member
|
|
4935
|
+
member
|
|
3388
4936
|
}) : null;
|
|
3389
4937
|
}
|
|
3390
4938
|
const NONE = [];
|
|
@@ -3519,8 +5067,8 @@ function IconInput(props) {
|
|
|
3519
5067
|
onChange
|
|
3520
5068
|
} = props;
|
|
3521
5069
|
const id = react.useId();
|
|
3522
|
-
const items = react.useMemo(() => Object.entries(icons.icons).map(
|
|
3523
|
-
let [key, icon] =
|
|
5070
|
+
const items = react.useMemo(() => Object.entries(icons.icons).map(_ref12 => {
|
|
5071
|
+
let [key, icon] = _ref12;
|
|
3524
5072
|
return /* @__PURE__ */jsxRuntime.jsx(IconItem, {
|
|
3525
5073
|
iconKey: key,
|
|
3526
5074
|
icon,
|
|
@@ -3548,12 +5096,12 @@ function IconInput(props) {
|
|
|
3548
5096
|
}
|
|
3549
5097
|
});
|
|
3550
5098
|
}
|
|
3551
|
-
function IconItem(
|
|
5099
|
+
function IconItem(_ref13) {
|
|
3552
5100
|
let {
|
|
3553
5101
|
icon,
|
|
3554
5102
|
iconKey: key,
|
|
3555
5103
|
onChange
|
|
3556
|
-
} =
|
|
5104
|
+
} = _ref13;
|
|
3557
5105
|
const onClick = react.useCallback(() => onChange(sanity.set(key)), [onChange, key]);
|
|
3558
5106
|
return /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
3559
5107
|
icon,
|
|
@@ -3564,8 +5112,8 @@ function IconItem(_ref11) {
|
|
|
3564
5112
|
}
|
|
3565
5113
|
function getIcon(iconName) {
|
|
3566
5114
|
var _a, _b;
|
|
3567
|
-
return (_b = (_a = Object.entries(icons.icons).find(
|
|
3568
|
-
let [key] =
|
|
5115
|
+
return (_b = (_a = Object.entries(icons.icons).find(_ref14 => {
|
|
5116
|
+
let [key] = _ref14;
|
|
3569
5117
|
return key === iconName;
|
|
3570
5118
|
})) == null ? void 0 : _a[1]) != null ? _b : icons.icons.sparkles;
|
|
3571
5119
|
}
|
|
@@ -3724,11 +5272,11 @@ const contextDocumentSchema = sanity.defineType({
|
|
|
3724
5272
|
title: "title",
|
|
3725
5273
|
context: "context"
|
|
3726
5274
|
},
|
|
3727
|
-
prepare(
|
|
5275
|
+
prepare(_ref15) {
|
|
3728
5276
|
let {
|
|
3729
5277
|
title,
|
|
3730
5278
|
context
|
|
3731
|
-
} =
|
|
5279
|
+
} = _ref15;
|
|
3732
5280
|
var _a;
|
|
3733
5281
|
const text = context == null ? void 0 : context.flatMap(block => block == null ? void 0 : block.children).flatMap(child => {
|
|
3734
5282
|
var _a2;
|
|
@@ -3814,6 +5362,200 @@ function InstructionsArrayField(props) {
|
|
|
3814
5362
|
title: " "
|
|
3815
5363
|
});
|
|
3816
5364
|
}
|
|
5365
|
+
function InstructionOutputField(props) {
|
|
5366
|
+
var _a;
|
|
5367
|
+
const {
|
|
5368
|
+
fieldSchema
|
|
5369
|
+
} = (_a = react.useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5370
|
+
if (!fieldSchema || !(sanity.isObjectSchemaType(fieldSchema) || sanity.isArrayOfObjectsSchemaType(fieldSchema))) {
|
|
5371
|
+
return null;
|
|
5372
|
+
}
|
|
5373
|
+
return /* @__PURE__ */jsxRuntime.jsx(EnabledOutputField, {
|
|
5374
|
+
...props,
|
|
5375
|
+
fieldSchema,
|
|
5376
|
+
children: props.children
|
|
5377
|
+
});
|
|
5378
|
+
}
|
|
5379
|
+
function EnabledOutputField(_ref16) {
|
|
5380
|
+
let {
|
|
5381
|
+
fieldSchema,
|
|
5382
|
+
...props
|
|
5383
|
+
} = _ref16;
|
|
5384
|
+
var _a;
|
|
5385
|
+
const [open, setOpen] = react.useState(!!((_a = props.value) == null ? void 0 : _a.length));
|
|
5386
|
+
const onExpand = react.useCallback(() => setOpen(true), []);
|
|
5387
|
+
const onCollapse = react.useCallback(() => setOpen(false), []);
|
|
5388
|
+
return props.renderDefault({
|
|
5389
|
+
...props,
|
|
5390
|
+
collapsible: true,
|
|
5391
|
+
onExpand,
|
|
5392
|
+
onCollapse,
|
|
5393
|
+
collapsed: !open,
|
|
5394
|
+
level: 1,
|
|
5395
|
+
title: sanity.isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
function InstructionOutputInput(props) {
|
|
5399
|
+
var _a;
|
|
5400
|
+
const {
|
|
5401
|
+
fieldSchema
|
|
5402
|
+
} = (_a = react.useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5403
|
+
if (!fieldSchema) {
|
|
5404
|
+
return null;
|
|
5405
|
+
}
|
|
5406
|
+
if (sanity.isObjectSchemaType(fieldSchema)) {
|
|
5407
|
+
return /* @__PURE__ */jsxRuntime.jsx(ObjectOutputInput, {
|
|
5408
|
+
...props,
|
|
5409
|
+
fieldSchema
|
|
5410
|
+
});
|
|
5411
|
+
}
|
|
5412
|
+
if (sanity.isArrayOfObjectsSchemaType(fieldSchema)) {
|
|
5413
|
+
return /* @__PURE__ */jsxRuntime.jsx(ArrayOutputInput, {
|
|
5414
|
+
...props,
|
|
5415
|
+
fieldSchema
|
|
5416
|
+
});
|
|
5417
|
+
}
|
|
5418
|
+
return null;
|
|
5419
|
+
}
|
|
5420
|
+
function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
5421
|
+
react.useEffect(() => {
|
|
5422
|
+
var _a, _b;
|
|
5423
|
+
const validValues = value == null ? void 0 : value.filter(v => allowedValues.find(f => f.name === (v._type === outputFieldTypeName ? v.relativePath : v.type)));
|
|
5424
|
+
const valueLength = (_a = value == null ? void 0 : value.length) != null ? _a : 0;
|
|
5425
|
+
const validLength = (_b = validValues == null ? void 0 : validValues.length) != null ? _b : 0;
|
|
5426
|
+
if (!validLength && valueLength || validLength >= allowedValues.length) {
|
|
5427
|
+
onChange(sanity.PatchEvent.from([sanity.unset()]));
|
|
5428
|
+
}
|
|
5429
|
+
}, [allowedValues, value, onChange]);
|
|
5430
|
+
}
|
|
5431
|
+
function ObjectOutputInput(_ref17) {
|
|
5432
|
+
let {
|
|
5433
|
+
fieldSchema,
|
|
5434
|
+
...props
|
|
5435
|
+
} = _ref17;
|
|
5436
|
+
const {
|
|
5437
|
+
value,
|
|
5438
|
+
onChange
|
|
5439
|
+
} = props;
|
|
5440
|
+
const fields = react.useMemo(() => fieldSchema.fields.filter(field => isAssistSupported(field.type)), [fieldSchema.fields]);
|
|
5441
|
+
useEmptySelectAllValue(value, fields, onChange);
|
|
5442
|
+
const onSelectChange = react.useCallback((checked, selectedValue) => {
|
|
5443
|
+
if (checked) {
|
|
5444
|
+
if (value == null ? void 0 : value.length) {
|
|
5445
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{
|
|
5446
|
+
_key: selectedValue
|
|
5447
|
+
}])));
|
|
5448
|
+
} else {
|
|
5449
|
+
const items = fields.filter(f => f.name !== selectedValue).map(field => sanity.typed({
|
|
5450
|
+
_key: field.name,
|
|
5451
|
+
_type: "sanity.assist.output.field",
|
|
5452
|
+
relativePath: field.name
|
|
5453
|
+
}));
|
|
5454
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
5455
|
+
}
|
|
5456
|
+
} else {
|
|
5457
|
+
const patchValue = {
|
|
5458
|
+
_key: selectedValue,
|
|
5459
|
+
_type: "sanity.assist.output.field",
|
|
5460
|
+
relativePath: selectedValue
|
|
5461
|
+
};
|
|
5462
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
5463
|
+
}
|
|
5464
|
+
}, [onChange, value, fields]);
|
|
5465
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
5466
|
+
space: 2,
|
|
5467
|
+
children: fields.map(field => {
|
|
5468
|
+
var _a;
|
|
5469
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
5470
|
+
align: "center",
|
|
5471
|
+
gap: 2,
|
|
5472
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Selectable, {
|
|
5473
|
+
value: field.name,
|
|
5474
|
+
title: (_a = field.type.title) != null ? _a : field.name,
|
|
5475
|
+
arrayValue: value,
|
|
5476
|
+
onChange: onSelectChange
|
|
5477
|
+
})
|
|
5478
|
+
}, field.name);
|
|
5479
|
+
})
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
function ArrayOutputInput(_ref18) {
|
|
5483
|
+
let {
|
|
5484
|
+
fieldSchema,
|
|
5485
|
+
...props
|
|
5486
|
+
} = _ref18;
|
|
5487
|
+
const {
|
|
5488
|
+
value,
|
|
5489
|
+
onChange
|
|
5490
|
+
} = props;
|
|
5491
|
+
const ofItems = react.useMemo(() => fieldSchema.of.filter(itemType => isAssistSupported(itemType)), [fieldSchema.of]);
|
|
5492
|
+
useEmptySelectAllValue(value, ofItems, onChange);
|
|
5493
|
+
const onSelectChange = react.useCallback((checked, selectedValue) => {
|
|
5494
|
+
if (checked) {
|
|
5495
|
+
if (value == null ? void 0 : value.length) {
|
|
5496
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{
|
|
5497
|
+
_key: selectedValue
|
|
5498
|
+
}])));
|
|
5499
|
+
} else {
|
|
5500
|
+
const items = ofItems.filter(f => f.name !== selectedValue).map(field => sanity.typed({
|
|
5501
|
+
_key: field.name,
|
|
5502
|
+
_type: "sanity.assist.output.type",
|
|
5503
|
+
type: field.name
|
|
5504
|
+
}));
|
|
5505
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
5506
|
+
}
|
|
5507
|
+
} else {
|
|
5508
|
+
const patchValue = {
|
|
5509
|
+
_key: selectedValue,
|
|
5510
|
+
_type: "sanity.assist.output.type",
|
|
5511
|
+
type: selectedValue
|
|
5512
|
+
};
|
|
5513
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
5514
|
+
}
|
|
5515
|
+
}, [onChange, value, ofItems]);
|
|
5516
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
5517
|
+
space: 2,
|
|
5518
|
+
children: ofItems.map(itemType => {
|
|
5519
|
+
var _a;
|
|
5520
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
5521
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Selectable, {
|
|
5522
|
+
value: itemType.name,
|
|
5523
|
+
title: isType(itemType, "block") ? "Text" : (_a = itemType.title) != null ? _a : itemType.name,
|
|
5524
|
+
arrayValue: value,
|
|
5525
|
+
onChange: onSelectChange
|
|
5526
|
+
})
|
|
5527
|
+
}, itemType.name);
|
|
5528
|
+
})
|
|
5529
|
+
});
|
|
5530
|
+
}
|
|
5531
|
+
function Selectable(_ref19) {
|
|
5532
|
+
let {
|
|
5533
|
+
title,
|
|
5534
|
+
arrayValue,
|
|
5535
|
+
value,
|
|
5536
|
+
onChange
|
|
5537
|
+
} = _ref19;
|
|
5538
|
+
const checked = !(arrayValue == null ? void 0 : arrayValue.length) || !!(arrayValue == null ? void 0 : arrayValue.find(v => v._key === value));
|
|
5539
|
+
const handleChange = react.useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
5540
|
+
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
5541
|
+
gap: 2,
|
|
5542
|
+
align: "flex-start",
|
|
5543
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
|
|
5544
|
+
checked,
|
|
5545
|
+
onChange: handleChange
|
|
5546
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
5547
|
+
marginTop: 1,
|
|
5548
|
+
onClick: () => handleChange,
|
|
5549
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
5550
|
+
style: {
|
|
5551
|
+
cursor: "default"
|
|
5552
|
+
},
|
|
5553
|
+
size: 1,
|
|
5554
|
+
children: title
|
|
5555
|
+
})
|
|
5556
|
+
})]
|
|
5557
|
+
});
|
|
5558
|
+
}
|
|
3817
5559
|
const fieldReference = sanity.defineType({
|
|
3818
5560
|
type: "object",
|
|
3819
5561
|
name: fieldReferenceTypeName,
|
|
@@ -3857,10 +5599,10 @@ const fieldReference = sanity.defineType({
|
|
|
3857
5599
|
select: {
|
|
3858
5600
|
path: "path"
|
|
3859
5601
|
},
|
|
3860
|
-
prepare(
|
|
5602
|
+
prepare(_ref20) {
|
|
3861
5603
|
let {
|
|
3862
5604
|
path
|
|
3863
|
-
} =
|
|
5605
|
+
} = _ref20;
|
|
3864
5606
|
return {
|
|
3865
5607
|
title: path,
|
|
3866
5608
|
path,
|
|
@@ -3987,7 +5729,6 @@ const prompt = sanity.defineType({
|
|
|
3987
5729
|
type: userInput.name,
|
|
3988
5730
|
}),*/]
|
|
3989
5731
|
});
|
|
3990
|
-
|
|
3991
5732
|
const instruction = sanity.defineType({
|
|
3992
5733
|
type: "object",
|
|
3993
5734
|
name: instructionTypeName,
|
|
@@ -4006,12 +5747,12 @@ const instruction = sanity.defineType({
|
|
|
4006
5747
|
title: "title",
|
|
4007
5748
|
userId: "userId"
|
|
4008
5749
|
},
|
|
4009
|
-
prepare:
|
|
5750
|
+
prepare: _ref21 => {
|
|
4010
5751
|
let {
|
|
4011
5752
|
icon,
|
|
4012
5753
|
title,
|
|
4013
5754
|
userId
|
|
4014
|
-
} =
|
|
5755
|
+
} = _ref21;
|
|
4015
5756
|
return {
|
|
4016
5757
|
title,
|
|
4017
5758
|
icon: icon ? icons.icons[icon] : icons.SparklesIcon,
|
|
@@ -4116,6 +5857,33 @@ const instruction = sanity.defineType({
|
|
|
4116
5857
|
var _a, _b;
|
|
4117
5858
|
return (_b = (_a = context.currentUser) == null ? void 0 : _a.id) != null ? _b : "";
|
|
4118
5859
|
}
|
|
5860
|
+
}), sanity.defineField({
|
|
5861
|
+
type: "array",
|
|
5862
|
+
name: "output",
|
|
5863
|
+
title: "Output filter",
|
|
5864
|
+
components: {
|
|
5865
|
+
input: InstructionOutputInput,
|
|
5866
|
+
field: InstructionOutputField
|
|
5867
|
+
},
|
|
5868
|
+
of: [sanity.defineArrayMember({
|
|
5869
|
+
type: "object",
|
|
5870
|
+
name: outputFieldTypeName,
|
|
5871
|
+
title: "Output field",
|
|
5872
|
+
fields: [{
|
|
5873
|
+
type: "string",
|
|
5874
|
+
name: "path",
|
|
5875
|
+
title: "Path"
|
|
5876
|
+
}]
|
|
5877
|
+
}), sanity.defineArrayMember({
|
|
5878
|
+
type: "object",
|
|
5879
|
+
name: outputTypeTypeName,
|
|
5880
|
+
title: "Output type",
|
|
5881
|
+
fields: [{
|
|
5882
|
+
type: "string",
|
|
5883
|
+
name: "type",
|
|
5884
|
+
title: "Type"
|
|
5885
|
+
}]
|
|
5886
|
+
})]
|
|
4119
5887
|
})]
|
|
4120
5888
|
});
|
|
4121
5889
|
const fieldInstructions = sanity.defineType({
|
|
@@ -4378,7 +6146,7 @@ function ImageContextProvider(props) {
|
|
|
4378
6146
|
children: props.renderDefault(props)
|
|
4379
6147
|
});
|
|
4380
6148
|
}
|
|
4381
|
-
function node$
|
|
6149
|
+
function node$2(node2) {
|
|
4382
6150
|
return node2;
|
|
4383
6151
|
}
|
|
4384
6152
|
const generateCaptionsActions = {
|
|
@@ -4399,7 +6167,7 @@ const generateCaptionsActions = {
|
|
|
4399
6167
|
documentId
|
|
4400
6168
|
} = useAssistDocumentContext();
|
|
4401
6169
|
return react.useMemo(() => {
|
|
4402
|
-
return node$
|
|
6170
|
+
return node$2({
|
|
4403
6171
|
type: "action",
|
|
4404
6172
|
icon: loading ? () => /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
4405
6173
|
style: {
|
|
@@ -4430,6 +6198,97 @@ const generateCaptionsActions = {
|
|
|
4430
6198
|
return void 0;
|
|
4431
6199
|
}
|
|
4432
6200
|
};
|
|
6201
|
+
function node$1(node2) {
|
|
6202
|
+
return node2;
|
|
6203
|
+
}
|
|
6204
|
+
const translateActions = {
|
|
6205
|
+
name: "sanity-assist-translate",
|
|
6206
|
+
useAction(props) {
|
|
6207
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6208
|
+
const {
|
|
6209
|
+
config
|
|
6210
|
+
} = useAiAssistanceConfig();
|
|
6211
|
+
const apiClient = useApiClient(config == null ? void 0 : config.__customApiClient);
|
|
6212
|
+
const {
|
|
6213
|
+
translate,
|
|
6214
|
+
loading
|
|
6215
|
+
} = useTranslate(apiClient);
|
|
6216
|
+
const isDocumentLevel = props.path.length === 0;
|
|
6217
|
+
const {
|
|
6218
|
+
schemaType,
|
|
6219
|
+
documentId
|
|
6220
|
+
} = props;
|
|
6221
|
+
if (isDocumentLevel) {
|
|
6222
|
+
const {
|
|
6223
|
+
value: documentValue
|
|
6224
|
+
} = desk.useDocumentPane();
|
|
6225
|
+
const docRef = react.useRef(documentValue);
|
|
6226
|
+
docRef.current = documentValue;
|
|
6227
|
+
const docTransTypes = (_b = (_a = config.translate) == null ? void 0 : _a.document) == null ? void 0 : _b.documentTypes;
|
|
6228
|
+
const documentTranslation = !docTransTypes && isAssistSupported(schemaType) || (docTransTypes == null ? void 0 : docTransTypes.includes(schemaType.name));
|
|
6229
|
+
const languagePath = (_d = (_c = config.translate) == null ? void 0 : _c.document) == null ? void 0 : _d.languageField;
|
|
6230
|
+
const translateDocumentAction = react.useMemo(() => languagePath && documentTranslation ? node$1({
|
|
6231
|
+
type: "action",
|
|
6232
|
+
icon: loading ? () => /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
6233
|
+
style: {
|
|
6234
|
+
height: 17
|
|
6235
|
+
},
|
|
6236
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
6237
|
+
style: {
|
|
6238
|
+
transform: "translateY(6px)"
|
|
6239
|
+
}
|
|
6240
|
+
})
|
|
6241
|
+
}) : icons.TranslateIcon,
|
|
6242
|
+
title: "Translate document",
|
|
6243
|
+
onAction: () => {
|
|
6244
|
+
if (loading || !languagePath || !documentId) {
|
|
6245
|
+
return;
|
|
6246
|
+
}
|
|
6247
|
+
translate({
|
|
6248
|
+
languagePath,
|
|
6249
|
+
documentId: documentId != null ? documentId : ""
|
|
6250
|
+
});
|
|
6251
|
+
},
|
|
6252
|
+
renderAsButton: true,
|
|
6253
|
+
disabled: loading
|
|
6254
|
+
}) : void 0, [languagePath, translate, documentId, loading, documentTranslation]);
|
|
6255
|
+
const fieldTranslate = useFieldTranslation();
|
|
6256
|
+
const fieldTransEnabled = (_g = (_f = (_e = config.translate) == null ? void 0 : _e.field) == null ? void 0 : _f.documentTypes) == null ? void 0 : _g.includes(schemaType.name);
|
|
6257
|
+
const translateFieldsAction = react.useMemo(() => fieldTransEnabled ? node$1({
|
|
6258
|
+
type: "action",
|
|
6259
|
+
icon: loading ? () => /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
6260
|
+
style: {
|
|
6261
|
+
height: 17
|
|
6262
|
+
},
|
|
6263
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
6264
|
+
style: {
|
|
6265
|
+
transform: "translateY(6px)"
|
|
6266
|
+
}
|
|
6267
|
+
})
|
|
6268
|
+
}) : icons.TranslateIcon,
|
|
6269
|
+
title: "Translate fields",
|
|
6270
|
+
onAction: () => {
|
|
6271
|
+
if (loading || !documentId) {
|
|
6272
|
+
return;
|
|
6273
|
+
}
|
|
6274
|
+
fieldTranslate.openFieldTranslation(docRef.current, schemaType);
|
|
6275
|
+
},
|
|
6276
|
+
renderAsButton: true,
|
|
6277
|
+
disabled: loading
|
|
6278
|
+
}) : void 0, [fieldTranslate, schemaType, documentId, loading, fieldTransEnabled]);
|
|
6279
|
+
return react.useMemo(() => {
|
|
6280
|
+
return node$1({
|
|
6281
|
+
type: "group",
|
|
6282
|
+
icon: () => null,
|
|
6283
|
+
title: "Translate",
|
|
6284
|
+
children: [translateDocumentAction, translateFieldsAction].filter(c => !!c),
|
|
6285
|
+
expanded: true
|
|
6286
|
+
});
|
|
6287
|
+
}, [translateDocumentAction, translateFieldsAction]);
|
|
6288
|
+
}
|
|
6289
|
+
return void 0;
|
|
6290
|
+
}
|
|
6291
|
+
};
|
|
4433
6292
|
function node(node2) {
|
|
4434
6293
|
return node2;
|
|
4435
6294
|
}
|
|
@@ -4450,7 +6309,8 @@ const assistFieldActions = {
|
|
|
4450
6309
|
documentOnChange,
|
|
4451
6310
|
documentSchemaType,
|
|
4452
6311
|
documentId,
|
|
4453
|
-
selectedPath
|
|
6312
|
+
selectedPath,
|
|
6313
|
+
assistableDocumentId
|
|
4454
6314
|
} =
|
|
4455
6315
|
// document field actions do not have access to the document context
|
|
4456
6316
|
// conditional hook _should_ be safe here since the logical path will be stable
|
|
@@ -4485,6 +6345,10 @@ const assistFieldActions = {
|
|
|
4485
6345
|
const isPathSelected = pathKey === selectedPath;
|
|
4486
6346
|
const isSelected = isInspectorOpen && isPathSelected;
|
|
4487
6347
|
const imageCaptionAction = generateCaptionsActions.useAction(props);
|
|
6348
|
+
const translateAction = translateActions.useAction({
|
|
6349
|
+
...props,
|
|
6350
|
+
documentId: assistableDocumentId
|
|
6351
|
+
});
|
|
4488
6352
|
const manageInstructions = react.useCallback(() => isSelected ? closeInspector(aiInspectorId) : openInspector(aiInspectorId, {
|
|
4489
6353
|
[fieldPathParam]: pathKey,
|
|
4490
6354
|
[instructionParam]: void 0
|
|
@@ -4511,7 +6375,7 @@ const assistFieldActions = {
|
|
|
4511
6375
|
}, [fieldAssist == null ? void 0 : fieldAssist.instructions]);
|
|
4512
6376
|
const instructions = react.useMemo(() => [...privateInstructions, ...sharedInstructions], [privateInstructions, sharedInstructions]);
|
|
4513
6377
|
const runInstructionsGroup = react.useMemo(() => {
|
|
4514
|
-
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction ? node({
|
|
6378
|
+
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction || translateAction ? node({
|
|
4515
6379
|
type: "group",
|
|
4516
6380
|
icon: () => null,
|
|
4517
6381
|
title: "Run instructions",
|
|
@@ -4522,10 +6386,10 @@ const assistFieldActions = {
|
|
|
4522
6386
|
hidden: isHidden,
|
|
4523
6387
|
documentIsNew: !!documentIsNew,
|
|
4524
6388
|
assistSupported
|
|
4525
|
-
}))), imageCaptionAction].filter(
|
|
6389
|
+
}))), imageCaptionAction].filter(a => !!a),
|
|
4526
6390
|
expanded: true
|
|
4527
6391
|
}) : void 0;
|
|
4528
|
-
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction]);
|
|
6392
|
+
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction, translateAction]);
|
|
4529
6393
|
const instructionsLength = (instructions == null ? void 0 : instructions.length) || 0;
|
|
4530
6394
|
const manageInstructionsItem = react.useMemo(() => node({
|
|
4531
6395
|
type: "action",
|
|
@@ -4538,13 +6402,13 @@ const assistFieldActions = {
|
|
|
4538
6402
|
type: "group",
|
|
4539
6403
|
icon: icons.SparklesIcon,
|
|
4540
6404
|
title: pluginTitleShort,
|
|
4541
|
-
children: [runInstructionsGroup, assistSupported && manageInstructionsItem].filter(c => !!c),
|
|
6405
|
+
children: [runInstructionsGroup, translateAction, assistSupported && manageInstructionsItem].filter(c => !!c),
|
|
4542
6406
|
expanded: false,
|
|
4543
6407
|
renderAsButton: true,
|
|
4544
|
-
hidden: !assistSupported && !imageCaptionAction
|
|
6408
|
+
hidden: !assistSupported && !imageCaptionAction && !translateAction
|
|
4545
6409
|
}), [
|
|
4546
6410
|
//documentIsNew,
|
|
4547
|
-
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction]);
|
|
6411
|
+
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction, translateAction]);
|
|
4548
6412
|
const emptyAction = react.useMemo(() => node({
|
|
4549
6413
|
type: "action",
|
|
4550
6414
|
hidden: !assistSupported,
|
|
@@ -4554,7 +6418,7 @@ const assistFieldActions = {
|
|
|
4554
6418
|
title: pluginTitleShort,
|
|
4555
6419
|
selected: isSelected
|
|
4556
6420
|
}), [assistSupported, manageInstructions, isSelected]);
|
|
4557
|
-
if (instructionsLength === 0 && !imageCaptionAction) {
|
|
6421
|
+
if (instructionsLength === 0 && !imageCaptionAction && !translateAction) {
|
|
4558
6422
|
return emptyAction;
|
|
4559
6423
|
}
|
|
4560
6424
|
return group;
|
|
@@ -4667,11 +6531,11 @@ function AssistDocumentInputWrapper(props) {
|
|
|
4667
6531
|
documentId
|
|
4668
6532
|
});
|
|
4669
6533
|
}
|
|
4670
|
-
function AssistDocumentInput(
|
|
6534
|
+
function AssistDocumentInput(_ref22) {
|
|
4671
6535
|
let {
|
|
4672
6536
|
documentId,
|
|
4673
6537
|
...props
|
|
4674
|
-
} =
|
|
6538
|
+
} = _ref22;
|
|
4675
6539
|
useInstructionToaster(documentId, props.schemaType);
|
|
4676
6540
|
return /* @__PURE__ */jsxRuntime.jsx(FirstAssistedPathProvider, {
|
|
4677
6541
|
members: props.members,
|
|
@@ -4716,11 +6580,11 @@ function AssistDocumentPresence(props) {
|
|
|
4716
6580
|
const anyPresence2 = (_b = (_a = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _a.filter(run => !run.ended && !run.reason)) == null ? void 0 : _b.flatMap(run => {
|
|
4717
6581
|
var _a2;
|
|
4718
6582
|
return (_a2 = run.presence) != null ? _a2 : [];
|
|
4719
|
-
}).find(f => f.started && /* @__PURE__ */new Date().getTime() - new Date(f.started).getTime() < 3e4);
|
|
6583
|
+
}).find(f => f.started && ( /* @__PURE__ */new Date()).getTime() - new Date(f.started).getTime() < 3e4);
|
|
4720
6584
|
if (anyPresence2) {
|
|
4721
6585
|
return aiPresence(anyPresence2, []);
|
|
4722
6586
|
}
|
|
4723
|
-
const anyRun = (_d = (_c = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _c.filter(run => !run.ended && !run.reason)) == null ? void 0 : _d.find(f => f.started && /* @__PURE__ */new Date().getTime() - new Date(f.started).getTime() < 3e4);
|
|
6587
|
+
const anyRun = (_d = (_c = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _c.filter(run => !run.ended && !run.reason)) == null ? void 0 : _d.find(f => f.started && ( /* @__PURE__ */new Date()).getTime() - new Date(f.started).getTime() < 3e4);
|
|
4724
6588
|
return anyRun ? aiPresence({
|
|
4725
6589
|
started: anyRun.started,
|
|
4726
6590
|
path: documentRootKey,
|
|
@@ -4749,6 +6613,9 @@ const assist = sanity.definePlugin(config => {
|
|
|
4749
6613
|
schema: {
|
|
4750
6614
|
types: schemaTypes
|
|
4751
6615
|
},
|
|
6616
|
+
i18n: {
|
|
6617
|
+
bundles: [{}]
|
|
6618
|
+
},
|
|
4752
6619
|
document: {
|
|
4753
6620
|
inspectors: (prev, context) => {
|
|
4754
6621
|
const docSchema = context.schema.get(context.documentType);
|
|
@@ -4757,15 +6624,23 @@ const assist = sanity.definePlugin(config => {
|
|
|
4757
6624
|
}
|
|
4758
6625
|
return prev;
|
|
4759
6626
|
},
|
|
4760
|
-
unstable_fieldActions: prev => {
|
|
4761
|
-
|
|
6627
|
+
unstable_fieldActions: (prev, _ref23) => {
|
|
6628
|
+
let {
|
|
6629
|
+
documentType,
|
|
6630
|
+
schema
|
|
6631
|
+
} = _ref23;
|
|
6632
|
+
const docSchema = schema.get(documentType);
|
|
6633
|
+
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
6634
|
+
return [...prev, assistFieldActions];
|
|
6635
|
+
}
|
|
6636
|
+
return prev;
|
|
4762
6637
|
},
|
|
4763
|
-
unstable_languageFilter: (prev,
|
|
6638
|
+
unstable_languageFilter: (prev, _ref24) => {
|
|
4764
6639
|
let {
|
|
4765
6640
|
documentId,
|
|
4766
6641
|
schema,
|
|
4767
6642
|
schemaType
|
|
4768
|
-
} =
|
|
6643
|
+
} = _ref24;
|
|
4769
6644
|
const docSchema = schema.get(schemaType);
|
|
4770
6645
|
if (docSchema && sanity.isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
|
|
4771
6646
|
return [...prev, createAssistDocumentPresence(documentId, docSchema)];
|