@sanity/assist 6.1.20 → 6.1.21

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/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import "@sanity/ui/styles.css";
2
2
  import { FormBuilder, FormCallbacksProvider, FormFieldHeaderText, FormInput, MemberFieldError, ObjectInputMember, PatchEvent, PerspectiveProvider, PresenceOverlay, StatusButton, VirtualizerScrollInstanceProvider, createPatchChannel, defineArrayMember, defineField, definePlugin, defineType, fromMutationPatches, getDraftId, getPublishedId, getVersionFromId, getVersionId, insert, isArrayOfObjectsSchemaType, isArraySchemaType, isDocumentSchemaType, isKeySegment, isObjectSchemaType, isRecord, isVersionId, pathToString, set, setIfMissing, stringToPath, typed, unset, useClient, useColorSchemeValue, useCurrentUser, useDocumentPresence, useDocumentStore, useEditState, useFormCallbacks, usePerspective, useSchema, useSyncState, useWorkspaceSchemaId } from "sanity";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { Box, Button, Card, Checkbox, Container, Dialog, ErrorBoundary, Flex, Label, Radio, Spinner, Stack, Switch, Text, TextArea, ThemeProvider, focusFirstDescendant, rgba, useClickOutsideEvent, useGlobalKeyDown, useLayer, useTheme } from "@sanity/ui";
5
- import { createContext, isValidElement, useCallback, useContext, useEffect, useEffectEvent, useId, useMemo, useReducer, useRef, useState } from "react";
6
5
  import { DocumentInspectorHeader, DocumentPaneProvider, PaneRouterContext, useDocumentPane, usePaneRouter } from "sanity/structure";
6
+ import { createContext, isValidElement, useCallback, useContext, useEffect, useEffectEvent, useId, useMemo, useReducer, useRef, useState } from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { useToast } from "@sanity/ui/toast";
9
9
  import { addSeconds } from "date-fns/addSeconds";
@@ -350,7 +350,7 @@ const FirstAssistedPathContext = createContext(void 0);
350
350
  function FirstAssistedPathProvider(props) {
351
351
  let $ = c(5), { members } = props, t0;
352
352
  if ($[0] !== members) {
353
- let firstAssisted = members.find(_temp$15);
353
+ let firstAssisted = members.find(_temp$16);
354
354
  t0 = firstAssisted?.field.path ? pathToString(firstAssisted?.field.path) : void 0, $[0] = members, $[1] = t0;
355
355
  } else t0 = $[1];
356
356
  let firstAssistedPath = t0, t1;
@@ -359,7 +359,7 @@ function FirstAssistedPathProvider(props) {
359
359
  children: props.children
360
360
  }), $[2] = firstAssistedPath, $[3] = props.children, $[4] = t1) : t1 = $[4], t1;
361
361
  }
362
- function _temp$15(member) {
362
+ function _temp$16(member) {
363
363
  return member.kind === "field" && isAssistSupported(member.field.schemaType);
364
364
  }
365
365
  const releaseAnnouncementUrl = "https://www.sanity.io/blog/sanity-ai-assist-announcement?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", packageName = "@sanity/assist", pluginTitle = "Sanity AI Assist", pluginTitleShort = "AI Assist", maxHistoryVisibilityMs = minutesToMilliseconds(30), illegalIdChars = /[^a-zA-Z0-9._-]/g;
@@ -374,7 +374,7 @@ function useDocumentState(id, docType) {
374
374
  return state.draft || state.published;
375
375
  }
376
376
  function useStudioAssistDocument(t0) {
377
- let $ = c(15), { documentId, schemaType, initDoc } = t0, documentTypeName = schemaType.name, currentUser = useCurrentUser(), t1;
377
+ let $ = c(17), { documentId, schemaType, initDoc } = t0, documentTypeName = schemaType.name, currentUser = useCurrentUser(), t1;
378
378
  $[0] === documentTypeName ? t1 = $[1] : (t1 = assistDocumentId(documentTypeName), $[0] = documentTypeName, $[1] = t1);
379
379
  let assistDocument = useDocumentState(t1, assistDocumentTypeName), t2 = documentId ?? "", t3;
380
380
  $[2] === t2 ? t3 = $[3] : (t3 = assistTasksStatusId(t2), $[2] = t2, $[3] = t3);
@@ -385,7 +385,7 @@ function useStudioAssistDocument(t0) {
385
385
  !assistDocument && initDoc && client.createIfNotExists({
386
386
  _id: assistDocumentId(documentTypeName),
387
387
  _type: assistDocumentTypeName
388
- }).catch(_temp$14);
388
+ }).catch(_temp$15);
389
389
  }, t6 = [
390
390
  client,
391
391
  assistDocument,
@@ -400,7 +400,9 @@ function useStudioAssistDocument(t0) {
400
400
  }
401
401
  let t8;
402
402
  if ($[11] !== assistDocument || $[12] !== assistTasksStatus?.tasks || $[13] !== currentUser?.id) {
403
- let tasks = assistTasksStatus?.tasks ?? [], fields = (assistDocument?.fields ?? []).map((assistField) => ({
403
+ let tasks = assistTasksStatus?.tasks ?? [], t9;
404
+ $[15] === assistDocument?.fields ? t9 = $[16] : (t9 = assistDocument?.fields ?? [], $[15] = assistDocument?.fields, $[16] = t9);
405
+ let fields = t9.map((assistField) => ({
404
406
  ...assistField,
405
407
  tasks: tasks.filter((task) => task.path === assistField.path),
406
408
  instructions: assistField.instructions?.filter((p) => !p.userId || p.userId === currentUser?.id).map((instruction) => asStudioInstruction(instruction, tasks))
@@ -421,7 +423,7 @@ function useStudioAssistDocument(t0) {
421
423
  }
422
424
  return t7;
423
425
  }
424
- function _temp$14() {}
426
+ function _temp$15() {}
425
427
  function asStudioInstruction(instruction, run) {
426
428
  return {
427
429
  ...instruction,
@@ -439,11 +441,11 @@ function useInstructionToaster(documentId, documentSchemaType) {
439
441
  $[3] !== assistDocLoaded || $[4] !== currentUser?.id || $[5] !== tasks || $[6] !== toast ? (t1 = () => {
440
442
  if (assistDocLoaded) {
441
443
  if (previousTasks.current !== "initial") {
442
- let prevTaskByKey = Object.fromEntries((previousTasks.current ?? NO_TASKS).map(_temp$13));
444
+ let prevTaskByKey = Object.fromEntries((previousTasks.current ?? NO_TASKS).map(_temp$14));
443
445
  (tasks?.filter((task) => task.startedByUserId === currentUser?.id).filter((task_0) => {
444
446
  let prevTask = prevTaskByKey[task_0._key];
445
447
  return !prevTask && task_0.ended || !prevTask?.ended && task_0.ended;
446
- }).filter(_temp2$7))?.forEach((task_2) => {
448
+ }).filter(_temp2$9))?.forEach((task_2) => {
447
449
  let title = task_2.title ?? getInstructionTitle(task_2.instruction);
448
450
  task_2.reason === "error" ? toast.push({
449
451
  title: `Failed: ${title}`,
@@ -481,10 +483,10 @@ function useInstructionToaster(documentId, documentSchemaType) {
481
483
  assistDocLoaded
482
484
  ], $[8] = assistDocLoaded, $[9] = currentUser, $[10] = tasks, $[11] = toast, $[12] = t2) : t2 = $[12], useEffect(t1, t2);
483
485
  }
484
- function _temp2$7(task_1) {
486
+ function _temp2$9(task_1) {
485
487
  return task_1.ended && isAfter(addSeconds(new Date(task_1.ended), 30), /* @__PURE__ */ new Date());
486
488
  }
487
- function _temp$13(run) {
489
+ function _temp$14(run) {
488
490
  return [run._key, run];
489
491
  }
490
492
  function AssistDocumentInputWrapper(props) {
@@ -856,7 +858,7 @@ function isUserInputBlock(block) {
856
858
  function RunInstructionProvider(props) {
857
859
  let $ = c(33), { config } = useAiAssistanceConfig(), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(useApiClient(config?.__customApiClient)), id = useId(), [inputs, setInputs] = useState(NO_INPUT), [runRequest, setRunRequest] = useState(), [resolveUserInput, setResolveUserInput] = useState(), t0;
858
860
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = async (t1) => {
859
- let { title, inputs: inputs_0 } = t1, userInputBlocks = inputs_0.map(_temp$12);
861
+ let { title, inputs: inputs_0 } = t1, userInputBlocks = inputs_0.map(_temp$13);
860
862
  if (userInputBlocks.length) return setRunRequest({
861
863
  dialogTitle: title,
862
864
  userInputBlocks
@@ -867,7 +869,7 @@ function RunInstructionProvider(props) {
867
869
  let getUserInput = t0, t1;
868
870
  $[1] !== loading || $[2] !== runInstructionRequest ? (t1 = (req) => {
869
871
  if (loading) return;
870
- let { instruction, ...request } = req, instructionKey = instruction._key, userInputBlocks_0 = instruction?.prompt?.flatMap(_temp2$6).filter(isUserInputBlock);
872
+ let { instruction, ...request } = req, instructionKey = instruction._key, userInputBlocks_0 = instruction?.prompt?.flatMap(_temp2$8).filter(isUserInputBlock);
871
873
  if (!userInputBlocks_0?.length) {
872
874
  runInstructionRequest({
873
875
  ...request,
@@ -893,7 +895,7 @@ function RunInstructionProvider(props) {
893
895
  runInstructionRequest({
894
896
  ...request_0,
895
897
  instructionKey: instruction_0._key,
896
- userTexts: Object.entries(inputs).map(_temp3$4)
898
+ userTexts: Object.entries(inputs).map(_temp3$6)
897
899
  });
898
900
  } else {
899
901
  let userInputs = Object.values(inputs).map((input_0, i_0) => {
@@ -915,7 +917,7 @@ function RunInstructionProvider(props) {
915
917
  let runWithInput = t3, open = !!runRequest;
916
918
  runRequest?.userInputBlocks;
917
919
  let t4;
918
- $[12] === inputs ? t4 = $[13] : (t4 = Object.entries(inputs).filter(_temp4$2), $[12] = inputs, $[13] = t4);
920
+ $[12] === inputs ? t4 = $[13] : (t4 = Object.entries(inputs).filter(_temp4$4), $[12] = inputs, $[13] = t4);
919
921
  let runDisabled = (runRequest?.userInputBlocks?.length ?? 0) > t4.length, t5;
920
922
  $[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = { width: "100%" }, $[14] = t5) : t5 = $[14];
921
923
  let t6;
@@ -973,21 +975,21 @@ function RunInstructionProvider(props) {
973
975
  children: [t8, props.children]
974
976
  }), $[29] = contextValue, $[30] = props.children, $[31] = t8, $[32] = t9) : t9 = $[32], t9;
975
977
  }
976
- function _temp4$2(t0) {
978
+ function _temp4$4(t0) {
977
979
  let [, value_0] = t0;
978
980
  return !!value_0;
979
981
  }
980
- function _temp3$4(t0) {
982
+ function _temp3$6(t0) {
981
983
  let [key, value] = t0;
982
984
  return {
983
985
  blockKey: key,
984
986
  userInput: value
985
987
  };
986
988
  }
987
- function _temp2$6(block) {
989
+ function _temp2$8(block) {
988
990
  return block._type === "block" ? block.children.filter(isUserInputBlock) : [block];
989
991
  }
990
- function _temp$12(input, i) {
992
+ function _temp$13(input, i) {
991
993
  return {
992
994
  _type: userInputTypeName,
993
995
  _key: input.id ?? `${i}`,
@@ -1126,7 +1128,7 @@ function useAssistDocumentContextValue(documentId, documentType) {
1126
1128
  return t9;
1127
1129
  }
1128
1130
  function useSyntheticTasks(assistableDocumentId) {
1129
- let $ = c(7), [syntheticTasks, setSyntheticTasks] = useState(_temp$11), t0;
1131
+ let $ = c(7), [syntheticTasks, setSyntheticTasks] = useState(_temp$12), t0;
1130
1132
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (task) => {
1131
1133
  setSyntheticTasks((current) => [...current, task]);
1132
1134
  }, $[0] = t0) : t0 = $[0];
@@ -1147,7 +1149,7 @@ function useSyntheticTasks(assistableDocumentId) {
1147
1149
  removeSyntheticTask
1148
1150
  }, $[5] = syntheticTasks, $[6] = t4), t4;
1149
1151
  }
1150
- function _temp$11() {
1152
+ function _temp$12() {
1151
1153
  return [];
1152
1154
  }
1153
1155
  function AssistDocumentContextProvider(props) {
@@ -1169,7 +1171,7 @@ function AssistDocumentLayout(props) {
1169
1171
  }
1170
1172
  const fadeIn = keyframes`0%{opacity:0;transform:scale(0.75);}40%{opacity:0;transform:scale(0.75);}100%{opacity:1;transform:scale(1);}`, FadeInDiv = styled.div.withConfig({
1171
1173
  displayName: "FadeInDiv",
1172
- componentId: "sc-ui50f7-0"
1174
+ componentId: "sc-gocic8-0"
1173
1175
  })`animation-name:${fadeIn};animation-timing-function:ease-in-out;`;
1174
1176
  function FadeInContent(t0) {
1175
1177
  let $ = c(6), { children, durationMs: t1, ref } = t0, t2 = `${t1 === void 0 ? 250 : t1}ms`, t3;
@@ -1183,43 +1185,59 @@ function FadeInContent(t0) {
1183
1185
  }
1184
1186
  const Root = styled.span.withConfig({
1185
1187
  displayName: "Root",
1186
- componentId: "sc-6srsjv-0"
1188
+ componentId: "sc-kyfo1k-0"
1187
1189
  })`display:block;width:25px;height:25px;position:relative;`, dash = keyframes`0%{transform:rotate(0);}100%{transform:rotate(43deg);}`, Outline = styled.svg.withConfig({
1188
1190
  displayName: "Outline",
1189
- componentId: "sc-6srsjv-1"
1191
+ componentId: "sc-kyfo1k-1"
1190
1192
  })`display:block;position:absolute;top:0;left:0;& > circle{stroke:var(--ai-avatar-stroke-color);stroke-width:1.5px;stroke-linecap:round;transform-origin:center;animation:${dash} 500ms ease-in-out infinite;transition:stroke-dasharray 200ms ease-in-out;stroke-dasharray:2.34px 0;[data-state='active'] > &{stroke-dasharray:2px 2.34px;}}`, IconDisc = styled.span.withConfig({
1191
1193
  displayName: "IconDisc",
1192
- componentId: "sc-6srsjv-2"
1194
+ componentId: "sc-kyfo1k-2"
1193
1195
  })`background:var(--ai-avatar-disc-color);color:white;width:21px;height:21px;display:flex;align-items:center;justify-content:center;border-radius:10.5px;position:absolute;top:2px;left:2px;`;
1194
1196
  function AssistAvatar(props) {
1195
- let { state = "present" } = props, scheme = useColorSchemeValue(), style = useMemo(() => scheme === "dark" ? {
1196
- "--ai-avatar-stroke-color": purple[400].hex,
1197
- "--ai-avatar-disc-color": purple[600].hex
1198
- } : {
1199
- "--ai-avatar-stroke-color": purple[500].hex,
1200
- "--ai-avatar-disc-color": purple[600].hex
1201
- }, [scheme]);
1202
- return /* @__PURE__ */ jsxs(Root, {
1197
+ let $ = c(8), { state: t0 } = props, state = t0 === void 0 ? "present" : t0, scheme = useColorSchemeValue(), t1;
1198
+ bb0: {
1199
+ if (scheme === "dark") {
1200
+ let t2;
1201
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
1202
+ "--ai-avatar-stroke-color": purple[400].hex,
1203
+ "--ai-avatar-disc-color": purple[600].hex
1204
+ }, $[0] = t2) : t2 = $[0], t1 = t2;
1205
+ break bb0;
1206
+ }
1207
+ let t2;
1208
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
1209
+ "--ai-avatar-stroke-color": purple[500].hex,
1210
+ "--ai-avatar-disc-color": purple[600].hex
1211
+ }, $[1] = t2) : t2 = $[1], t1 = t2;
1212
+ }
1213
+ let style = t1, t2;
1214
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Outline, {
1215
+ width: "25",
1216
+ height: "25",
1217
+ viewBox: "0 0 25 25",
1218
+ fill: "none",
1219
+ xmlns: "http://www.w3.org/2000/svg",
1220
+ children: /* @__PURE__ */ jsx("circle", {
1221
+ cx: "12.5",
1222
+ cy: "12.5",
1223
+ r: "11.75"
1224
+ })
1225
+ }), $[2] = t2) : t2 = $[2];
1226
+ let t3;
1227
+ $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = { color: "inherit" }, $[3] = t3) : t3 = $[3];
1228
+ let t4;
1229
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, {
1230
+ as: "span",
1231
+ size: 0,
1232
+ style: t3,
1233
+ children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } })
1234
+ }) }), $[4] = t4) : t4 = $[4];
1235
+ let t5;
1236
+ return $[5] !== state || $[6] !== style ? (t5 = /* @__PURE__ */ jsxs(Root, {
1203
1237
  "data-state": state,
1204
1238
  style,
1205
- children: [/* @__PURE__ */ jsx(Outline, {
1206
- width: "25",
1207
- height: "25",
1208
- viewBox: "0 0 25 25",
1209
- fill: "none",
1210
- xmlns: "http://www.w3.org/2000/svg",
1211
- children: /* @__PURE__ */ jsx("circle", {
1212
- cx: "12.5",
1213
- cy: "12.5",
1214
- r: "11.75"
1215
- })
1216
- }), /* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, {
1217
- as: "span",
1218
- size: 0,
1219
- style: { color: "inherit" },
1220
- children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } })
1221
- }) })]
1222
- });
1239
+ children: [t2, t4]
1240
+ }), $[5] = state, $[6] = style, $[7] = t5) : t5 = $[7], t5;
1223
1241
  }
1224
1242
  function AiFieldPresence(_props) {
1225
1243
  let $ = c(3), t0;
@@ -1258,7 +1276,7 @@ function useAssistPresence(path, showFocusWithin) {
1258
1276
  let $ = c(6), context = useAssistDocumentContext(), tasks = (context && "assistDocument" in context ? context.assistDocument : void 0)?.tasks, t0;
1259
1277
  if ($[0] !== path || $[1] !== showFocusWithin || $[2] !== tasks) {
1260
1278
  bb0: {
1261
- let activePresence = tasks?.filter(_temp$10)?.flatMap(_temp2$5)?.filter(_temp3$3).filter((presence) => {
1279
+ let activePresence = tasks?.filter(_temp$11)?.flatMap(_temp2$7)?.filter(_temp3$5).filter((presence) => {
1262
1280
  if (!presence.path || !path.length) return !1;
1263
1281
  let statusPath = stringToPath(presence.path);
1264
1282
  return !showFocusWithin && statusPath.length !== path.length ? !1 : path.every((pathSegment, i) => {
@@ -1277,13 +1295,13 @@ function useAssistPresence(path, showFocusWithin) {
1277
1295
  } else t0 = $[3];
1278
1296
  return t0;
1279
1297
  }
1280
- function _temp3$3(p) {
1298
+ function _temp3$5(p) {
1281
1299
  return p.started && (/* @__PURE__ */ new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs;
1282
1300
  }
1283
- function _temp2$5(task_0) {
1301
+ function _temp2$7(task_0) {
1284
1302
  return task_0.presence ?? [];
1285
1303
  }
1286
- function _temp$10(task) {
1304
+ function _temp$11(task) {
1287
1305
  return !task.ended;
1288
1306
  }
1289
1307
  function aiPresence(presence, path, _title) {
@@ -1334,7 +1352,7 @@ function AssistField(props) {
1334
1352
  }
1335
1353
  const WrapPreCard = styled(Card).withConfig({
1336
1354
  displayName: "WrapPreCard",
1337
- componentId: "sc-v6xax4-0"
1355
+ componentId: "sc-flgt1j-0"
1338
1356
  })`& pre{white-space:pre-wrap !important;}`;
1339
1357
  function SafeValueInput(props) {
1340
1358
  let $ = c(5), t0;
@@ -1463,7 +1481,7 @@ function AssistItem(props) {
1463
1481
  children: t1
1464
1482
  }), $[3] = t1, $[4] = t2);
1465
1483
  let t3;
1466
- $[5] === presence ? t3 = $[6] : (t3 = presence.map(_temp$9), $[5] = presence, $[6] = t3);
1484
+ $[5] === presence ? t3 = $[6] : (t3 = presence.map(_temp$10), $[5] = presence, $[6] = t3);
1467
1485
  let t4;
1468
1486
  return $[7] !== t2 || $[8] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Flex, {
1469
1487
  align: "center",
@@ -1471,7 +1489,7 @@ function AssistItem(props) {
1471
1489
  children: [t2, t3]
1472
1490
  }), $[7] = t2, $[8] = t3, $[9] = t4) : t4 = $[9], t4;
1473
1491
  }
1474
- function _temp$9(pre) {
1492
+ function _temp$10(pre) {
1475
1493
  return /* @__PURE__ */ jsx(Box, {
1476
1494
  style: {
1477
1495
  position: "absolute",
@@ -1693,7 +1711,7 @@ function extractConditionalPaths(node, maxDepth) {
1693
1711
  }
1694
1712
  const SparklesIllustration = /* @__PURE__ */ styled(SparklesIcon).withConfig({
1695
1713
  displayName: "SparklesIllustration",
1696
- componentId: "sc-2lc3by-0"
1714
+ componentId: "sc-xzej1l-0"
1697
1715
  })({
1698
1716
  fontSize: "3.125em",
1699
1717
  "& path": { strokeWidth: "0.6px !important" }
@@ -1787,9 +1805,9 @@ function FieldAutocomplete(props) {
1787
1805
  let currentField = t1, t2;
1788
1806
  if ($[11] !== fieldRefs || $[12] !== filter) {
1789
1807
  let t3;
1790
- $[14] === filter ? t3 = $[15] : (t3 = (field) => !filter || filter(field), $[14] = filter, $[15] = t3), t2 = fieldRefs.filter(t3).filter(_temp$8).map(_temp2$4), $[11] = fieldRefs, $[12] = filter, $[13] = t2;
1808
+ $[14] === filter ? t3 = $[15] : (t3 = (field) => !filter || filter(field), $[14] = filter, $[15] = t3), t2 = fieldRefs.filter(t3).filter(_temp$9).map(_temp2$6), $[11] = fieldRefs, $[12] = filter, $[13] = t2;
1791
1809
  } else t2 = $[13];
1792
- let autocompleteOptions = t2, renderOption = _temp3$2, renderValue = _temp4$1, filterOption = _temp5, t3 = currentField ? currentField.icon : SearchIcon, t4 = currentField?.key, t5;
1810
+ let autocompleteOptions = t2, renderOption = _temp3$4, renderValue = _temp4$3, filterOption = _temp5$2, t3 = currentField ? currentField.icon : SearchIcon, t4 = currentField?.key, t5;
1793
1811
  return $[16] !== autocompleteOptions || $[17] !== id || $[18] !== onSelect || $[19] !== t3 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(Autocomplete, {
1794
1812
  fontSize: 1,
1795
1813
  icon: t3,
@@ -1805,14 +1823,14 @@ function FieldAutocomplete(props) {
1805
1823
  filterOption
1806
1824
  }), $[16] = autocompleteOptions, $[17] = id, $[18] = onSelect, $[19] = t3, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
1807
1825
  }
1808
- function _temp5(query, option_1) {
1826
+ function _temp5$2(query, option_1) {
1809
1827
  let lQuery = query.toLowerCase();
1810
1828
  return option_1?.value?.toLowerCase().includes(lQuery) || option_1?.field?.title?.toLowerCase().includes(lQuery);
1811
1829
  }
1812
- function _temp4$1(value_0, option_0) {
1830
+ function _temp4$3(value_0, option_0) {
1813
1831
  return option_0?.field.title ?? value_0;
1814
1832
  }
1815
- function _temp3$2(option) {
1833
+ function _temp3$4(option) {
1816
1834
  let { value, field: field_1 } = option;
1817
1835
  return value ? isType(field_1.schemaType, "document") ? /* @__PURE__ */ jsx(Card, {
1818
1836
  as: "button",
@@ -1845,13 +1863,13 @@ function _temp3$2(option) {
1845
1863
  })
1846
1864
  });
1847
1865
  }
1848
- function _temp2$4(field_0) {
1866
+ function _temp2$6(field_0) {
1849
1867
  return {
1850
1868
  value: field_0.key,
1851
1869
  field: field_0
1852
1870
  };
1853
1871
  }
1854
- function _temp$8(f_0) {
1872
+ function _temp$9(f_0) {
1855
1873
  return !isType(f_0.schemaType, "reference");
1856
1874
  }
1857
1875
  function FieldTitle(props) {
@@ -1868,7 +1886,7 @@ function FieldTitle(props) {
1868
1886
  size: 1,
1869
1887
  children: "/"
1870
1888
  })
1871
- }), $[10] = t1) : t1 = $[10], t2 = 1, t3 = splitTitle.slice(0, splitTitle.length - 1).map(_temp6), $[0] = props.field.title, $[1] = T0, $[2] = T1, $[3] = splitTitle, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4);
1889
+ }), $[10] = t1) : t1 = $[10], t2 = 1, t3 = splitTitle.slice(0, splitTitle.length - 1).map(_temp6$1), $[0] = props.field.title, $[1] = T0, $[2] = T1, $[3] = splitTitle, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4);
1872
1890
  let t5 = splitTitle[splitTitle.length - 1], t6;
1873
1891
  $[11] === t5 ? t6 = $[12] : (t6 = /* @__PURE__ */ jsx(Box, {
1874
1892
  marginTop: 1,
@@ -1891,7 +1909,7 @@ function FieldTitle(props) {
1891
1909
  children: t7
1892
1910
  }), $[20] = T1, $[21] = t4, $[22] = t7, $[23] = t8) : t8 = $[23], t8;
1893
1911
  }
1894
- function _temp6(pt, i) {
1912
+ function _temp6$1(pt, i) {
1895
1913
  return /* @__PURE__ */ jsx(Box, {
1896
1914
  marginTop: 1,
1897
1915
  children: /* @__PURE__ */ jsx(Text, {
@@ -1902,13 +1920,13 @@ function _temp6(pt, i) {
1902
1920
  }, i);
1903
1921
  }
1904
1922
  function useInterval(ms) {
1905
- let $ = c(3), [tick, update] = useReducer(_temp$7, 0), t0, t1;
1923
+ let $ = c(3), [tick, update] = useReducer(_temp$8, 0), t0, t1;
1906
1924
  return $[0] === ms ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
1907
1925
  let i = setInterval(update, ms);
1908
1926
  return () => clearInterval(i);
1909
1927
  }, t1 = [ms], $[0] = ms, $[1] = t0, $[2] = t1), useEffect(t0, t1), tick;
1910
1928
  }
1911
- function _temp$7(n) {
1929
+ function _temp$8(n) {
1912
1930
  return n + 1;
1913
1931
  }
1914
1932
  function TimeAgo(t0) {
@@ -1924,7 +1942,7 @@ function TimeAgo(t0) {
1924
1942
  }
1925
1943
  const rotate = keyframes`0%{transform:rotate(0);}100%{transform:rotate(360deg);}`, SyncSpinningIcon = styled(SyncIcon).withConfig({
1926
1944
  displayName: "SyncSpinningIcon",
1927
- componentId: "sc-mtdfu7-0"
1945
+ componentId: "sc-chle4-0"
1928
1946
  })`animation:${rotate} 1s linear infinite;`, TASK_CONFIG = {
1929
1947
  aborted: {
1930
1948
  title: "Canceled",
@@ -1948,55 +1966,82 @@ const rotate = keyframes`0%{transform:rotate(0);}100%{transform:rotate(360deg);}
1948
1966
  }
1949
1967
  };
1950
1968
  function InstructionTaskHistoryButton(props) {
1951
- let { tasks, instructions, documentId, showTitles } = props, client = useClient({ apiVersion: "2023-01-01" }), cancelRun = useCallback((taskKey) => {
1969
+ let $ = c(32), { tasks, instructions, documentId, showTitles } = props, t0;
1970
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "2023-01-01" }, $[0] = t0) : t0 = $[0];
1971
+ let client = useClient(t0), t1;
1972
+ $[1] !== client || $[2] !== documentId ? (t1 = (taskKey) => {
1952
1973
  if (!documentId) return;
1953
1974
  let statusDocId = assistTasksStatusId(documentId), basePath = `${typed("tasks")}[_key=="${taskKey}"]`;
1954
1975
  client.patch(statusDocId).set({
1955
1976
  [`${basePath}.${typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
1956
1977
  [`${basePath}.${typed("reason")}`]: typed("aborted")
1957
1978
  }).commit().catch(console.error);
1958
- }, [client, documentId]), titledTasks = useMemo(() => {
1959
- let t = tasks?.filter((task) => task.started && (/* @__PURE__ */ new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs).map((task_0) => {
1960
- let instruction = instructions?.find((i) => i._key === task_0.instructionKey);
1961
- return {
1962
- ...task_0,
1963
- title: showTitles ? task_0.title ?? getInstructionTitle(instruction) : void 0,
1964
- cancel: () => cancelRun(task_0._key)
1965
- };
1966
- }) ?? [];
1967
- return t.sort((a, b) => new Date(b.started ?? "").getTime() - new Date(a.started ?? "").getTime()), t;
1968
- }, [
1969
- tasks,
1970
- instructions,
1971
- cancelRun,
1972
- showTitles
1973
- ]), isRunning = useMemo(() => titledTasks.some((r) => !r.ended), [titledTasks]), hasErrors = useMemo(() => titledTasks.some((r_0) => r_0.reason === "error" || r_0.reason === "timeout"), [titledTasks]), [open, setOpen] = useState(!1), toggleOpen = useCallback(() => setOpen((v) => !v), []), [button, setButton] = useState(null), [popover, setPopover] = useState(null), handleClickOutside = useCallback(() => {
1979
+ }, $[1] = client, $[2] = documentId, $[3] = t1) : t1 = $[3];
1980
+ let cancelRun = t1, t;
1981
+ $[4] !== cancelRun || $[5] !== instructions || $[6] !== showTitles || $[7] !== tasks ? (t = tasks?.filter(_temp$7).map((task_0) => {
1982
+ let instruction = instructions?.find((i) => i._key === task_0.instructionKey);
1983
+ return {
1984
+ ...task_0,
1985
+ title: showTitles ? task_0.title ?? getInstructionTitle(instruction) : void 0,
1986
+ cancel: () => cancelRun(task_0._key)
1987
+ };
1988
+ }) ?? [], t.sort(_temp2$5), $[4] = cancelRun, $[5] = instructions, $[6] = showTitles, $[7] = tasks, $[8] = t) : t = $[8];
1989
+ let titledTasks = t, t2;
1990
+ $[9] === titledTasks ? t2 = $[10] : (t2 = titledTasks.some(_temp3$3), $[9] = titledTasks, $[10] = t2);
1991
+ let isRunning = t2, t3;
1992
+ $[11] === titledTasks ? t3 = $[12] : (t3 = titledTasks.some(_temp4$2), $[11] = titledTasks, $[12] = t3);
1993
+ let hasErrors = t3, [open, setOpen] = useState(!1), t4;
1994
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setOpen(_temp5$1), $[13] = t4) : t4 = $[13];
1995
+ let toggleOpen = t4, [button, setButton] = useState(null), [popover, setPopover] = useState(null), t5;
1996
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
1974
1997
  setOpen(!1);
1975
- }, []);
1976
- useClickOutsideEvent(handleClickOutside, () => [button, popover]);
1977
- let handleEscape = useCallback(() => {
1998
+ }, $[14] = t5) : t5 = $[14];
1999
+ let handleClickOutside = t5, t6;
2000
+ $[15] !== button || $[16] !== popover ? (t6 = () => [button, popover], $[15] = button, $[16] = popover, $[17] = t6) : t6 = $[17], useClickOutsideEvent(handleClickOutside, t6);
2001
+ let t7;
2002
+ $[18] === button ? t7 = $[19] : (t7 = () => {
1978
2003
  setOpen(!1), button?.focus();
1979
- }, [button]);
1980
- return /* @__PURE__ */ jsx(Popover, {
2004
+ }, $[18] = button, $[19] = t7);
2005
+ let handleEscape = t7, t8;
2006
+ $[20] !== handleEscape || $[21] !== titledTasks ? (t8 = /* @__PURE__ */ jsx(TaskList, {
2007
+ onEscape: handleEscape,
2008
+ tasks: titledTasks
2009
+ }), $[20] = handleEscape, $[21] = titledTasks, $[22] = t8) : t8 = $[22];
2010
+ let t9 = open && !!titledTasks?.length, t10 = !titledTasks?.length, t11;
2011
+ $[23] !== hasErrors || $[24] !== isRunning || $[25] !== open || $[26] !== t10 ? (t11 = /* @__PURE__ */ jsx(TaskStatusButton, {
2012
+ disabled: t10,
2013
+ hasErrors,
2014
+ isRunning,
2015
+ onClick: toggleOpen,
2016
+ ref: setButton,
2017
+ selected: open
2018
+ }), $[23] = hasErrors, $[24] = isRunning, $[25] = open, $[26] = t10, $[27] = t11) : t11 = $[27];
2019
+ let t12;
2020
+ return $[28] !== t11 || $[29] !== t8 || $[30] !== t9 ? (t12 = /* @__PURE__ */ jsx(Popover, {
1981
2021
  constrainSize: !0,
1982
- content: /* @__PURE__ */ jsx(TaskList, {
1983
- onEscape: handleEscape,
1984
- tasks: titledTasks
1985
- }),
1986
- open: open && !!titledTasks?.length,
2022
+ content: t8,
2023
+ open: t9,
1987
2024
  placement: "top",
1988
2025
  portal: !0,
1989
2026
  ref: setPopover,
1990
2027
  width: 0,
1991
- children: /* @__PURE__ */ jsx(TaskStatusButton, {
1992
- disabled: !titledTasks?.length,
1993
- hasErrors,
1994
- isRunning,
1995
- onClick: toggleOpen,
1996
- ref: setButton,
1997
- selected: open
1998
- })
1999
- });
2028
+ children: t11
2029
+ }), $[28] = t11, $[29] = t8, $[30] = t9, $[31] = t12) : t12 = $[31], t12;
2030
+ }
2031
+ function _temp5$1(v) {
2032
+ return !v;
2033
+ }
2034
+ function _temp4$2(r_0) {
2035
+ return r_0.reason === "error" || r_0.reason === "timeout";
2036
+ }
2037
+ function _temp3$3(r) {
2038
+ return !r.ended;
2039
+ }
2040
+ function _temp2$5(a, b) {
2041
+ return new Date(b.started ?? "").getTime() - new Date(a.started ?? "").getTime();
2042
+ }
2043
+ function _temp$7(task) {
2044
+ return task.started && (/* @__PURE__ */ new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs;
2000
2045
  }
2001
2046
  const TASK_STATUS_BUTTON_TOOLTIP_PROPS = { placement: "top" };
2002
2047
  function TaskStatusButton(props) {
@@ -2020,7 +2065,7 @@ function TaskList(props) {
2020
2065
  isTopLayer && event.key === "Escape" && onEscape();
2021
2066
  }, $[0] = isTopLayer, $[1] = onEscape, $[2] = t0) : t0 = $[2], useGlobalKeyDown(t0);
2022
2067
  let t1;
2023
- $[3] === tasks ? t1 = $[4] : (t1 = tasks.map(_temp$6), $[3] = tasks, $[4] = t1);
2068
+ $[3] === tasks ? t1 = $[4] : (t1 = tasks.map(_temp6), $[3] = tasks, $[4] = t1);
2024
2069
  let t2;
2025
2070
  return $[5] === t1 ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(Stack, {
2026
2071
  padding: 1,
@@ -2028,7 +2073,7 @@ function TaskList(props) {
2028
2073
  children: t1
2029
2074
  }), $[5] = t1, $[6] = t2), t2;
2030
2075
  }
2031
- function _temp$6(task) {
2076
+ function _temp6(task) {
2032
2077
  return /* @__PURE__ */ jsx(TaskItem, { task }, task._key);
2033
2078
  }
2034
2079
  function TaskItem(props) {
@@ -2131,10 +2176,10 @@ function isolatePathParams(nextParams, hostParams) {
2131
2176
  }
2132
2177
  const EMPTY_PANE_PARAMS = {}, CardWithShadowBelow = styled(Card).withConfig({
2133
2178
  displayName: "CardWithShadowBelow",
2134
- componentId: "sc-56ewtn-0"
2179
+ componentId: "sc-pz26f7-0"
2135
2180
  })`position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;bottom:-1px;border-bottom:1px solid var(--card-border-color);opacity:0.5;z-index:100;}`, CardWithShadowAbove = styled(Card).withConfig({
2136
2181
  displayName: "CardWithShadowAbove",
2137
- componentId: "sc-56ewtn-1"
2182
+ componentId: "sc-pz26f7-1"
2138
2183
  })`position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;top:-1px;border-top:1px solid var(--card-border-color);opacity:0.5;z-index:100;}`;
2139
2184
  function AssistInspectorWrapper(props) {
2140
2185
  let $ = c(43), context = useAiAssistanceConfig();
@@ -2310,7 +2355,7 @@ function AssistInspector(props) {
2310
2355
  documentId,
2311
2356
  schemaType,
2312
2357
  initDoc: !0
2313
- }), instruction = (assistDocument?.fields?.find((f) => f.path === typePath))?.instructions?.find((i) => i._key === instructionKey), tasks = useMemo(() => assistDocument?.tasks?.filter((i_0) => !instructionKey || i_0.instructionKey === instructionKey), [assistDocument?.tasks, instructionKey]), instructions = useMemo(() => assistDocument?.fields?.flatMap((f_0) => f_0.instructions ?? []), [assistDocument?.fields]), promptValue = instruction?.prompt, isEmptyPrompt = useMemo(() => {
2358
+ }), instruction = (assistDocument?.fields?.find((f) => f.path === typePath))?.instructions?.find((i) => i._key === instructionKey), tasks = useMemo(() => assistDocument?.tasks?.filter((i) => !instructionKey || i.instructionKey === instructionKey), [assistDocument?.tasks, instructionKey]), instructions = useMemo(() => assistDocument?.fields?.flatMap((f) => f.instructions ?? []), [assistDocument?.fields]), promptValue = instruction?.prompt, isEmptyPrompt = useMemo(() => {
2314
2359
  if (!promptValue?.length) return !0;
2315
2360
  let children = promptValue[0]?.children;
2316
2361
  return promptValue.length == 1 && children?.length === 1 && !children?.[0]?.text?.length;
@@ -2639,14 +2684,12 @@ const options = {
2639
2684
  }
2640
2685
  };
2641
2686
  function AssistConnectorsOverlay(props) {
2642
- let $ = c(13), { connectors } = props, [, setRedraw] = useState(!1), t0;
2643
- $[0] === setRedraw ? t0 = $[1] : (t0 = () => {
2687
+ let $ = c(12), { connectors } = props, [, setRedraw] = useState(!1), t0, t1;
2688
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => {
2644
2689
  setRedraw(!0);
2645
- }, $[0] = setRedraw, $[1] = t0);
2646
- let t1;
2647
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[2] = t1) : t1 = $[2], useEffect(t0, t1);
2690
+ }, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), useEffect(t0, t1);
2648
2691
  let t2;
2649
- $[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
2692
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
2650
2693
  position: "absolute",
2651
2694
  top: 0,
2652
2695
  left: 0,
@@ -2654,23 +2697,23 @@ function AssistConnectorsOverlay(props) {
2654
2697
  height: "100%",
2655
2698
  pointerEvents: "none",
2656
2699
  zIndex: 150
2657
- }, $[3] = t2) : t2 = $[3];
2700
+ }, $[2] = t2) : t2 = $[2];
2658
2701
  let t3;
2659
- $[4] === connectors ? t3 = $[5] : (t3 = connectors.map(_temp$5), $[4] = connectors, $[5] = t3);
2702
+ $[3] === connectors ? t3 = $[4] : (t3 = connectors.map(_temp$6), $[3] = connectors, $[4] = t3);
2660
2703
  let t4;
2661
- $[6] === t3 ? t4 = $[7] : (t4 = /* @__PURE__ */ jsx("svg", {
2704
+ $[5] === t3 ? t4 = $[6] : (t4 = /* @__PURE__ */ jsx("svg", {
2662
2705
  fill: "none",
2663
2706
  width: window.innerWidth,
2664
2707
  height: window.innerHeight,
2665
2708
  style: t2,
2666
2709
  children: t3
2667
- }), $[6] = t3, $[7] = t4);
2710
+ }), $[5] = t3, $[6] = t4);
2668
2711
  let t5;
2669
- $[8] === connectors ? t5 = $[9] : (t5 = !1, $[8] = connectors, $[9] = t5);
2712
+ $[7] === connectors ? t5 = $[8] : (t5 = !1, $[7] = connectors, $[8] = t5);
2670
2713
  let t6;
2671
- return $[10] !== t4 || $[11] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] }), $[10] = t4, $[11] = t5, $[12] = t6) : t6 = $[12], t6;
2714
+ return $[9] !== t4 || $[10] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] }), $[9] = t4, $[10] = t5, $[11] = t6) : t6 = $[11], t6;
2672
2715
  }
2673
- function _temp$5(connector) {
2716
+ function _temp$6(connector) {
2674
2717
  return /* @__PURE__ */ jsx(ConnectorPath, {
2675
2718
  from: connector.from,
2676
2719
  options,
@@ -2836,7 +2879,7 @@ function FieldTranslationProvider(props) {
2836
2879
  }
2837
2880
  let preferred = getPreferredToFieldLanguages(from.id), allToLanguages = languages_0.filter((l) => l.id !== from?.id), filteredToLanguages = allToLanguages.filter((l_0) => !preferred.length || preferred.includes(l_0.id));
2838
2881
  setToLanguages(filteredToLanguages);
2839
- let fromId = from?.id, allToIds = allToLanguages?.map(_temp$4) ?? [], docMembers = getDocumentMembersFlat(document, documentSchema, config?.maxPathDepth);
2882
+ let fromId = from?.id, allToIds = allToLanguages?.map(_temp$5) ?? [], docMembers = getDocumentMembersFlat(document, documentSchema, config?.maxPathDepth);
2840
2883
  if (fromId && allToIds?.length) {
2841
2884
  let transMap = getFieldLanguageMap(documentSchema, docMembers, fromId, allToIds.filter((toId) => fromId !== toId), config?.translationOutputs ?? defaultLanguageOutputs);
2842
2885
  setFieldLanguageMaps(transMap);
@@ -2846,7 +2889,7 @@ function FieldTranslationProvider(props) {
2846
2889
  $[6] === fromLanguage ? t4 = $[7] : (t4 = (toggledLang, toLanguages_0, languages_1) => {
2847
2890
  if (!languages_1 || !fromLanguage) return;
2848
2891
  let wasSelected = !!toLanguages_0?.find((l_2) => l_2.id === toggledLang.id), newToLangs = languages_1.filter((anyLang) => !!toLanguages_0?.find((selectedLang) => toggledLang.id !== selectedLang.id && selectedLang.id === anyLang.id) || toggledLang.id === anyLang.id && !wasSelected);
2849
- setToLanguages(newToLangs), setPreferredToFieldLanguages(fromLanguage.id, newToLangs.map(_temp2$3));
2892
+ setToLanguages(newToLangs), setPreferredToFieldLanguages(fromLanguage.id, newToLangs.map(_temp2$4));
2850
2893
  }, $[6] = fromLanguage, $[7] = t4);
2851
2894
  let toggleToLanguage = t4, t5;
2852
2895
  $[8] !== config || $[9] !== languageClient || $[10] !== selectFromLanguage ? (t5 = async (params_0) => {
@@ -2966,10 +3009,10 @@ function FieldTranslationProvider(props) {
2966
3009
  children: [t11, props.children]
2967
3010
  }), $[45] = contextValue, $[46] = props.children, $[47] = t11, $[48] = t12) : t12 = $[48], t12;
2968
3011
  }
2969
- function _temp2$3(l_3) {
3012
+ function _temp2$4(l_3) {
2970
3013
  return l_3.id;
2971
3014
  }
2972
- function _temp$4(l_1) {
3015
+ function _temp$5(l_1) {
2973
3016
  return l_1.id;
2974
3017
  }
2975
3018
  function ToLanguageCheckbox(props) {
@@ -3452,7 +3495,7 @@ function useCustomFieldActions(props) {
3452
3495
  pushToast,
3453
3496
  addSyntheticTask,
3454
3497
  removeSyntheticTask
3455
- })).filter(isDefined), onlyGroups = customActions?.length && customActions?.every((node_0) => node_0.type === "group");
3498
+ })).filter(isDefined), onlyGroups = customActions?.length && customActions?.every((node) => node.type === "group");
3456
3499
  return (customActions?.length ? onlyGroups ? customActions : [{
3457
3500
  type: "group",
3458
3501
  title: title || "Custom actions",
@@ -3781,26 +3824,57 @@ function createAssistDocumentPresence(documentId) {
3781
3824
  };
3782
3825
  }
3783
3826
  function AssistDocumentPresence() {
3784
- let { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence_0 = useMemo(() => {
3785
- let anyPresence = [...assistDocument?.tasks ?? [], ...syntheticTasks ?? []].filter((run) => !run.ended && !run.reason)?.flatMap((run_0) => run_0.presence ?? []).find((f) => f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4);
3786
- if (anyPresence) return aiPresence(anyPresence, []);
3787
- let anyRun = assistDocument?.tasks?.filter((run_1) => !run_1.ended && !run_1.reason)?.find((f_0) => f_0.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f_0.started).getTime() < 3e4);
3788
- return anyRun ? aiPresence({
3789
- started: anyRun.started,
3790
- path: documentRootKey,
3791
- _key: anyRun._key,
3792
- _type: fieldPresenceTypeName
3793
- }, []) : void 0;
3794
- }, [assistDocument?.tasks, syntheticTasks]);
3795
- return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Flex, {
3827
+ let $ = c(9), { assistDocument, syntheticTasks } = useAssistDocumentContext();
3828
+ assistDocument?.tasks;
3829
+ let t0;
3830
+ if ($[0] !== assistDocument?.tasks || $[1] !== syntheticTasks) {
3831
+ bb0: {
3832
+ let anyPresence = [...assistDocument?.tasks ?? [], ...syntheticTasks ?? []].filter(_temp$4)?.flatMap(_temp2$3).find(_temp3$2);
3833
+ if (anyPresence) {
3834
+ t0 = aiPresence(anyPresence, []);
3835
+ break bb0;
3836
+ }
3837
+ let t1;
3838
+ if ($[3] !== assistDocument?.tasks) {
3839
+ let anyRun = assistDocument?.tasks?.filter(_temp4$1)?.find(_temp5);
3840
+ t1 = anyRun ? aiPresence({
3841
+ started: anyRun.started,
3842
+ path: documentRootKey,
3843
+ _key: anyRun._key,
3844
+ _type: fieldPresenceTypeName
3845
+ }, []) : void 0, $[3] = assistDocument?.tasks, $[4] = t1;
3846
+ } else t1 = $[4];
3847
+ t0 = t1;
3848
+ }
3849
+ $[0] = assistDocument?.tasks, $[1] = syntheticTasks, $[2] = t0;
3850
+ } else t0 = $[2];
3851
+ let anyPresence_0 = t0, t1;
3852
+ $[5] === anyPresence_0 ? t1 = $[6] : (t1 = anyPresence_0 && /* @__PURE__ */ jsx(AiFieldPresence, { presence: anyPresence_0 }), $[5] = anyPresence_0, $[6] = t1);
3853
+ let t2;
3854
+ return $[7] === t1 ? t2 = $[8] : (t2 = /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Flex, {
3796
3855
  flex: 1,
3797
3856
  justify: "flex-end",
3798
3857
  children: /* @__PURE__ */ jsx(Flex, {
3799
3858
  gap: 2,
3800
3859
  align: "center",
3801
- children: anyPresence_0 && /* @__PURE__ */ jsx(AiFieldPresence, { presence: anyPresence_0 })
3860
+ children: t1
3802
3861
  })
3803
- }) });
3862
+ }) }), $[7] = t1, $[8] = t2), t2;
3863
+ }
3864
+ function _temp5(f_0) {
3865
+ return f_0.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f_0.started).getTime() < 3e4;
3866
+ }
3867
+ function _temp4$1(run_1) {
3868
+ return !run_1.ended && !run_1.reason;
3869
+ }
3870
+ function _temp3$2(f) {
3871
+ return f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4;
3872
+ }
3873
+ function _temp2$3(run_0) {
3874
+ return run_0.presence ?? [];
3875
+ }
3876
+ function _temp$4(run) {
3877
+ return !run.ended && !run.reason;
3804
3878
  }
3805
3879
  function BackToInstructionListLink() {
3806
3880
  let $ = c(4), { openInspector } = useDocumentPane(), t0;
@@ -3962,37 +4036,40 @@ function _temp$3(m) {
3962
4036
  return m.kind === "error" && m.fieldName === "fields";
3963
4037
  }
3964
4038
  function useSelectedSchema(fieldPath, documentSchema) {
3965
- let $ = c(2), t0;
3966
- bb0: {
3967
- if (!fieldPath) {
3968
- t0 = void 0;
3969
- break bb0;
3970
- }
3971
- if (fieldPath === "<document>") {
3972
- t0 = documentSchema;
3973
- break bb0;
3974
- }
3975
- let t1;
3976
- $[0] === fieldPath ? t1 = $[1] : (t1 = stringToPath(fieldPath), $[0] = fieldPath, $[1] = t1);
3977
- let path = t1, currentSchema = documentSchema;
3978
- for (let i = 0; i < path.length; i++) {
3979
- let segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
3980
- if (!field) {
4039
+ let $ = c(5), t0;
4040
+ if ($[0] !== documentSchema || $[1] !== fieldPath) {
4041
+ bb0: {
4042
+ if (!fieldPath) {
3981
4043
  t0 = void 0;
3982
4044
  break bb0;
3983
4045
  }
3984
- if (i === path.length - 1) {
3985
- t0 = field.type;
4046
+ if (fieldPath === "<document>") {
4047
+ t0 = documentSchema;
3986
4048
  break bb0;
3987
4049
  }
3988
- if (field.type.jsonType !== "object") {
3989
- t0 = void 0;
3990
- break bb0;
4050
+ let t1;
4051
+ $[3] === fieldPath ? t1 = $[4] : (t1 = stringToPath(fieldPath), $[3] = fieldPath, $[4] = t1);
4052
+ let path = t1, currentSchema = documentSchema;
4053
+ for (let i = 0; i < path.length; i++) {
4054
+ let segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
4055
+ if (!field) {
4056
+ t0 = void 0;
4057
+ break bb0;
4058
+ }
4059
+ if (i === path.length - 1) {
4060
+ t0 = field.type;
4061
+ break bb0;
4062
+ }
4063
+ if (field.type.jsonType !== "object") {
4064
+ t0 = void 0;
4065
+ break bb0;
4066
+ }
4067
+ currentSchema = field.type;
3991
4068
  }
3992
- currentSchema = field.type;
4069
+ t0 = currentSchema;
3993
4070
  }
3994
- t0 = currentSchema;
3995
- }
4071
+ $[0] = documentSchema, $[1] = fieldPath, $[2] = t0;
4072
+ } else t0 = $[2];
3996
4073
  return t0;
3997
4074
  }
3998
4075
  function FieldsInitializer(t0) {
@@ -4188,16 +4265,15 @@ function InstructionInput(props) {
4188
4265
  }), $[1] = props, $[2] = t1), t1;
4189
4266
  }
4190
4267
  function ObjectMember(t0) {
4191
- let $ = c(6), props, t1;
4192
- if ($[0] !== t0) {
4193
- let { fieldName, ...t2 } = t0;
4194
- props = t2, t1 = findFieldMember(props.members, fieldName), $[0] = t0, $[1] = props, $[2] = t1;
4195
- } else props = $[1], t1 = $[2];
4268
+ let $ = c(9), fieldName, props;
4269
+ $[0] === t0 ? (fieldName = $[1], props = $[2]) : ({fieldName, ...props} = t0, $[0] = t0, $[1] = fieldName, $[2] = props);
4270
+ let t1;
4271
+ $[3] !== fieldName || $[4] !== props.members ? (t1 = findFieldMember(props.members, fieldName), $[3] = fieldName, $[4] = props.members, $[5] = t1) : t1 = $[5];
4196
4272
  let member = t1, t2;
4197
- return $[3] !== member || $[4] !== props ? (t2 = member ? /* @__PURE__ */ jsx(ObjectInputMember, {
4273
+ return $[6] !== member || $[7] !== props ? (t2 = member ? /* @__PURE__ */ jsx(ObjectInputMember, {
4198
4274
  ...props,
4199
4275
  member
4200
- }) : null, $[3] = member, $[4] = props, $[5] = t2) : t2 = $[5], t2;
4276
+ }) : null, $[6] = member, $[7] = props, $[8] = t2) : t2 = $[8], t2;
4201
4277
  }
4202
4278
  const NONE = [];
4203
4279
  function NameField(props) {
@@ -4483,7 +4559,7 @@ function Selectable(t0) {
4483
4559
  }
4484
4560
  const PteMods = styled(Box).withConfig({
4485
4561
  displayName: "PteMods",
4486
- componentId: "sc-lrz2c-0"
4562
+ componentId: "sc-lca06y-0"
4487
4563
  })`& [data-testid='pt-editor__toolbar-card'] > div > div:last-child{display:none;}& [data-testid='pt-editor']{min-height:300px;}& [data-testid='pt-editor'] .pt-inline-object *{max-width:400px;}`;
4488
4564
  function PromptInput(props) {
4489
4565
  let $ = c(5);