@copilotkit/react-textarea 1.0.0-beta.0 → 1.0.0-beta.2

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.
Files changed (28) hide show
  1. package/.turbo/turbo-build.log +240 -240
  2. package/CHANGELOG.md +20 -0
  3. package/dist/{chunk-3SVQJA5A.mjs → chunk-PAP4ZNRG.mjs} +21 -14
  4. package/dist/chunk-PAP4ZNRG.mjs.map +1 -0
  5. package/dist/{chunk-5KLAWLCD.mjs → chunk-TTOZXUEA.mjs} +12 -8
  6. package/dist/chunk-TTOZXUEA.mjs.map +1 -0
  7. package/dist/{chunk-IF7CDWEH.mjs → chunk-WPV52EMI.mjs} +3 -3
  8. package/dist/components/copilot-textarea/copilot-textarea.js +27 -18
  9. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  10. package/dist/components/copilot-textarea/copilot-textarea.mjs +3 -3
  11. package/dist/components/index.js +27 -18
  12. package/dist/components/index.js.map +1 -1
  13. package/dist/components/index.mjs +3 -3
  14. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +9 -6
  15. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  16. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  17. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +18 -12
  18. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  19. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  20. package/dist/index.js +27 -18
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +4 -4
  23. package/package.json +4 -4
  24. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +9 -6
  25. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +17 -10
  26. package/dist/chunk-3SVQJA5A.mjs.map +0 -1
  27. package/dist/chunk-5KLAWLCD.mjs.map +0 -1
  28. /package/dist/{chunk-IF7CDWEH.mjs.map → chunk-WPV52EMI.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -4,9 +4,9 @@ import "./chunk-WADHCMPK.mjs";
4
4
  import "./chunk-MMVDU6DF.mjs";
5
5
  import {
6
6
  CopilotTextarea
7
- } from "./chunk-IF7CDWEH.mjs";
8
- import "./chunk-3SVQJA5A.mjs";
9
- import "./chunk-5KLAWLCD.mjs";
7
+ } from "./chunk-WPV52EMI.mjs";
8
+ import "./chunk-PAP4ZNRG.mjs";
9
+ import "./chunk-TTOZXUEA.mjs";
10
10
  import "./chunk-RUV6NBIF.mjs";
11
11
  import {
12
12
  defaultAutosuggestionsConfig
@@ -48,8 +48,8 @@ import {
48
48
  } from "./chunk-OJXLHIYQ.mjs";
49
49
  import "./chunk-224UKA7C.mjs";
50
50
  import "./chunk-XW3ICO4S.mjs";
51
- import "./chunk-IU3WTXLQ.mjs";
52
51
  import "./chunk-H4VKQGVU.mjs";
52
+ import "./chunk-IU3WTXLQ.mjs";
53
53
  import "./chunk-DFTV4TST.mjs";
54
54
  import "./chunk-T6MTDQZ7.mjs";
55
55
  import "./chunk-ECR45NSD.mjs";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.0.0-beta.0",
7
+ "version": "1.0.0-beta.2",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -63,9 +63,9 @@
63
63
  "slate-history": "^0.93.0",
64
64
  "slate-react": "^0.98.1",
65
65
  "tailwind-merge": "^1.13.2",
66
- "@copilotkit/react-core": "1.0.0-beta.0",
67
- "@copilotkit/runtime-client-gql": "1.0.0-beta.0",
68
- "@copilotkit/shared": "1.0.0-beta.0"
66
+ "@copilotkit/react-core": "1.0.0-beta.2",
67
+ "@copilotkit/runtime-client-gql": "1.0.0-beta.2",
68
+ "@copilotkit/shared": "1.0.0-beta.2"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "tsup --clean",
@@ -12,8 +12,8 @@ import {
12
12
  TextMessage,
13
13
  convertGqlOutputToMessages,
14
14
  convertMessagesToGqlInput,
15
+ CopilotRequestType,
15
16
  } from "@copilotkit/runtime-client-gql";
16
- import { nanoid } from "nanoid";
17
17
 
18
18
  /**
19
19
  * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
@@ -72,16 +72,19 @@ export function useMakeStandardAutosuggestionFunction(
72
72
  });
73
73
 
74
74
  const response = await runtimeClient
75
- .generateCopilotResponse(
76
- {
75
+ .generateCopilotResponse({
76
+ data: {
77
77
  frontend: {
78
78
  actions: [],
79
79
  },
80
80
  messages: convertMessagesToGqlInput(messages),
81
+ metadata: {
82
+ requestType: CopilotRequestType.TextareaCompletion,
83
+ },
81
84
  },
82
- copilotApiConfig.properties,
83
- abortSignal,
84
- )
85
+ properties: copilotApiConfig.properties,
86
+ signal: abortSignal,
87
+ })
85
88
  .toPromise();
86
89
 
87
90
  let result = "";
@@ -8,6 +8,7 @@ import {
8
8
  TextMessage,
9
9
  convertGqlOutputToMessages,
10
10
  convertMessagesToGqlInput,
11
+ CopilotRequestType,
11
12
  } from "@copilotkit/runtime-client-gql";
12
13
  import { retry } from "../../lib/retry";
13
14
  import {
@@ -119,16 +120,19 @@ export function useMakeStandardInsertionOrEditingFunction(
119
120
  ];
120
121
 
121
122
  return runtimeClientResponseToStringStream(
122
- runtimeClient.generateCopilotResponse(
123
- {
123
+ runtimeClient.generateCopilotResponse({
124
+ data: {
124
125
  frontend: {
125
126
  actions: [],
126
127
  },
127
128
  messages: convertMessagesToGqlInput(messages),
129
+ metadata: {
130
+ requestType: CopilotRequestType.TextareaCompletion,
131
+ },
128
132
  },
129
- copilotApiConfig.properties,
130
- abortSignal,
131
- ),
133
+ properties: copilotApiConfig.properties,
134
+ signal: abortSignal,
135
+ }),
132
136
  );
133
137
  });
134
138
 
@@ -179,16 +183,19 @@ export function useMakeStandardInsertionOrEditingFunction(
179
183
  });
180
184
 
181
185
  return runtimeClientResponseToStringStream(
182
- runtimeClient.generateCopilotResponse(
183
- {
186
+ runtimeClient.generateCopilotResponse({
187
+ data: {
184
188
  frontend: {
185
189
  actions: [],
186
190
  },
187
191
  messages: convertMessagesToGqlInput(messages),
192
+ metadata: {
193
+ requestType: CopilotRequestType.TextareaCompletion,
194
+ },
188
195
  },
189
- copilotApiConfig.properties,
190
- abortSignal,
191
- ),
196
+ properties: copilotApiConfig.properties,
197
+ signal: abortSignal,
198
+ }),
192
199
  );
193
200
  });
194
201
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { retry } from \"../../lib/retry\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { InsertionsApiConfig } from \"../../types/autosuggestions-config/insertions-api-config\";\nimport { EditingApiConfig } from \"../../types/autosuggestions-config/editing-api-config\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\nimport { nanoid } from \"nanoid\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardInsertionOrEditingFunction(\n textareaPurpose: string,\n contextCategories: string[],\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig,\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n const headers = {\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const runtimeClient = new CopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n });\n\n async function runtimeClientResponseToStringStream(\n responsePromise: ReturnType<typeof runtimeClient.generateCopilotResponse>,\n ) {\n const messagesStream = await CopilotRuntimeClient.asStream(responsePromise);\n\n return new ReadableStream({\n async start(controller) {\n const reader = messagesStream.getReader();\n let sentContent = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n const messages = convertGqlOutputToMessages(value.generateCopilotResponse.messages);\n\n let newContent = \"\";\n\n for (const message of messages) {\n if (message instanceof TextMessage) {\n newContent += message.content;\n }\n }\n if (newContent) {\n const contentToSend = newContent.slice(sentContent.length);\n controller.enqueue(contentToSend);\n sentContent += contentToSend;\n }\n }\n controller.close();\n },\n });\n }\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: Message[] = [\n new TextMessage({\n role: Role.System,\n content: insertionApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n }),\n ...insertionApiConfig.fewShotMessages,\n new TextMessage({\n role: Role.User,\n content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<InsertionPrompt>${insertionPrompt}</InsertionPrompt>`,\n }),\n ];\n\n return runtimeClientResponseToStringStream(\n runtimeClient.generateCopilotResponse(\n {\n frontend: {\n actions: [],\n },\n messages: convertMessagesToGqlInput(messages),\n },\n copilotApiConfig.properties,\n abortSignal,\n ),\n );\n });\n\n return res;\n },\n [insertionApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const editingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n editingPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: Message[] = [\n new TextMessage({\n role: Role.System,\n content: editingApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n }),\n ...editingApiConfig.fewShotMessages,\n new TextMessage({\n role: Role.User,\n content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextToEdit>${editorState.selectedText}</TextToEdit>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<EditingPrompt>${editingPrompt}</EditingPrompt>`,\n }),\n ];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n });\n\n return runtimeClientResponseToStringStream(\n runtimeClient.generateCopilotResponse(\n {\n frontend: {\n actions: [],\n },\n messages: convertMessagesToGqlInput(messages),\n },\n copilotApiConfig.properties,\n abortSignal,\n ),\n );\n });\n\n return res;\n },\n [editingApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const insertionOrEditingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);\n } else {\n return await editingFunction(editorState, insertionPrompt, documents, abortSignal);\n }\n },\n [insertionFunction, editingFunction],\n );\n\n return insertionOrEditingFunction;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,2CAA2C;AACpD,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AACxC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAwBA,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AACxE,QAAM,UAAU,mBACV,iBAAiB,eACjB,EAAE,CAAC,mCAAmC,GAAG,iBAAiB,aAAa,IACvE,CAAC;AAGP,QAAM,gBAAgB,IAAI,qBAAqB;AAAA,IAC7C,KAAK,iBAAiB;AAAA,IACtB,cAAc,iBAAiB;AAAA,IAC/B;AAAA,EACF,CAAC;AAED,WAAe,oCACb,iBACA;AAAA;AACA,YAAM,iBAAiB,MAAM,qBAAqB,SAAS,eAAe;AAE1E,aAAO,IAAI,eAAe;AAAA,QAClB,MAAM,YAAY;AAAA;AACtB,kBAAM,SAAS,eAAe,UAAU;AACxC,gBAAI,cAAc;AAElB,mBAAO,MAAM;AACX,oBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,kBAAI,MAAM;AACR;AAAA,cACF;AAEA,oBAAM,WAAW,2BAA2B,MAAM,wBAAwB,QAAQ;AAElF,kBAAI,aAAa;AAEjB,yBAAW,WAAW,UAAU;AAC9B,oBAAI,mBAAmB,aAAa;AAClC,gCAAc,QAAQ;AAAA,gBACxB;AAAA,cACF;AACA,kBAAI,YAAY;AACd,sBAAM,gBAAgB,WAAW,MAAM,YAAY,MAAM;AACzD,2BAAW,QAAQ,aAAa;AAChC,+BAAe;AAAA,cACjB;AAAA,YACF;AACA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A,UACpB,IAAI,YAAY;AAAA,YACd,MAAM,KAAK;AAAA,YACX,SAAS,qBAAqB,YAAY;AAAA,UAC5C,CAAC;AAAA,UACD,IAAI,YAAY;AAAA,YACd,MAAM,KAAK;AAAA,YACX,SAAS,eAAe,YAAY;AAAA,UACtC,CAAC;AAAA,UACD,IAAI,YAAY;AAAA,YACd,MAAM,KAAK;AAAA,YACX,SAAS,oBAAoB,YAAY;AAAA,UAC3C,CAAC;AAAA,UACD,IAAI,YAAY;AAAA,YACd,MAAM,KAAK;AAAA,YACX,SAAS,kBAAkB;AAAA,UAC7B,CAAC;AAAA,QACH;AAEA,cAAMA,iBAAgB,IAAI,qBAAqB;AAAA,UAC7C,KAAK,iBAAiB;AAAA,UACtB,cAAc,iBAAiB;AAAA,UAC/B;AAAA,QACF,CAAC;AAED,eAAO;AAAA,UACLA,eAAc;AAAA,YACZ;AAAA,cACE,UAAU;AAAA,gBACR,SAAS,CAAC;AAAA,cACZ;AAAA,cACA,UAAU,0BAA0B,QAAQ;AAAA,YAC9C;AAAA,YACA,iBAAiB;AAAA,YACjB;AAAA,UACF;AAAA,QACF;AAAA,MACF,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,kBAAkB,mBAAmB,eAAe;AAAA,EACzE;AAEA,QAAM,6BAA6B;AAAA,IACjC,CACE,aACA,iBACA,WACA,gBACG;AACH,UAAI,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM,kBAAkB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACnF;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT;","names":["runtimeClient"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { AutosuggestionsBareFunction } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\nimport {\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { nanoid } from \"nanoid\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[],\n apiConfig: SuggestionsApiConfig,\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n const publicApiKey = copilotApiConfig.publicApiKey;\n const headers = {\n ...(publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {}),\n };\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: Message[] = [\n new TextMessage({\n role: Role.System,\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString([], contextCategories),\n ),\n }),\n ...apiConfig.fewShotMessages,\n new TextMessage({\n role: Role.User,\n content: editorState.textAfterCursor,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`,\n }),\n ];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers: copilotApiConfig.headers,\n });\n\n const response = await runtimeClient\n .generateCopilotResponse(\n {\n frontend: {\n actions: [],\n },\n messages: convertMessagesToGqlInput(messages),\n },\n copilotApiConfig.properties,\n abortSignal,\n )\n .toPromise();\n\n let result = \"\";\n for (const message of convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages ?? [],\n )) {\n if (abortSignal.aborted) {\n break;\n }\n if (message instanceof TextMessage) {\n result += message.content;\n console.log(message.content);\n }\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,2CAA2C;AACpD,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAKxC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBA,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AACxE,QAAM,eAAe,iBAAiB;AACtC,QAAM,UAAU,mBACV,eAAe,EAAE,CAAC,mCAAmC,GAAG,aAAa,IAAI,CAAC;AAGhF,SAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AA3C1C;AA4CQ,cAAM,WAAsB;AAAA,UAC1B,IAAI,YAAY;AAAA,YACd,MAAM,KAAK;AAAA,YACX,SAAS,UAAU;AAAA,cACjB;AAAA,cACA,iBAAiB,CAAC,GAAG,iBAAiB;AA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