@shipfox/api-integration-github 12.7.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/dist/api/client.d.ts +21 -3
  4. package/dist/api/client.d.ts.map +1 -1
  5. package/dist/api/client.js +115 -6
  6. package/dist/api/client.js.map +1 -1
  7. package/dist/api/installation-token-envelope.d.ts.map +1 -1
  8. package/dist/api/installation-token-envelope.js.map +1 -1
  9. package/dist/core/agent-tools.d.ts.map +1 -1
  10. package/dist/core/agent-tools.js +2 -6
  11. package/dist/core/agent-tools.js.map +1 -1
  12. package/dist/core/bot-identity.d.ts +4 -0
  13. package/dist/core/bot-identity.d.ts.map +1 -0
  14. package/dist/core/bot-identity.js +15 -0
  15. package/dist/core/bot-identity.js.map +1 -0
  16. package/dist/core/source-control.d.ts +4 -2
  17. package/dist/core/source-control.d.ts.map +1 -1
  18. package/dist/core/source-control.js +42 -11
  19. package/dist/core/source-control.js.map +1 -1
  20. package/dist/index.d.ts +78 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/tsconfig.test.tsbuildinfo +1 -1
  25. package/package.json +3 -3
  26. package/src/api/client.test.ts +267 -9
  27. package/src/api/client.ts +184 -9
  28. package/src/api/installation-token-envelope.ts +3 -1
  29. package/src/core/agent-tools.test.ts +1 -0
  30. package/src/core/agent-tools.ts +2 -9
  31. package/src/core/bot-identity.test.ts +19 -0
  32. package/src/core/bot-identity.ts +19 -0
  33. package/src/core/install.test.ts +3 -0
  34. package/src/core/source-control.test.ts +180 -1
  35. package/src/core/source-control.ts +65 -11
  36. package/src/index.test.ts +3 -1
  37. package/src/index.ts +2 -0
  38. package/src/presentation/routes/install.test.ts +3 -0
  39. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":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,CAAC;IACjE,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,4BAA4B,EAAE,8BAA8B,CAAC;IAC7D,mCAAmC,CAAC,EAAE,OAAO,mCAAmC,GAAG,SAAS,CAAC;IAC7F,aAAa,CAAC,EACV,CAAC,CAAC,MAAM,EAAE;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GACvE,SAAS,CAAC;IACd,UAAU,CAAC,EAAE;QAAC,aAAa,EAAE,+BAA+B,CAAA;KAAC,GAAG,SAAS,CAAC;CAC3E;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,sCAAsC;cAmBjF,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAIhB,cAAc;QACd,WAAW;;sCAK2B;QAAC,EAAE,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;;4BA8BlD,QAAQ;;;EAE3C"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { githubEventCatalog } from '@shipfox/api-integration-github-dto';
1
2
  import { createGithubApiClient } from '#api/client.js';
2
3
  import { deleteGithubInstallationTokenSecret } from '#api/installation-token-provider.js';
3
4
  import { GithubAgentToolsProvider } from '#core/agent-tools.js';
@@ -35,6 +36,7 @@ export function createGithubIntegrationProvider(options) {
35
36
  return {
36
37
  provider: 'github',
37
38
  displayName: 'GitHub',
39
+ eventCatalog: githubEventCatalog,
38
40
  adapters: {
39
41
  source_control: new GithubSourceControlProvider(github),
40
42
  agent_tools: new GithubAgentToolsProvider({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n GetIntegrationConnectionByIdFn,\n PublishIntegrationEventReceivedFn,\n PublishSourcePushFn,\n PublishSourceRepositoryUpdatedFn,\n RecordDeliveryOnlyFn,\n} from '@shipfox/api-integration-spi';\nimport type {NodePgDatabase} from 'drizzle-orm/node-postgres';\nimport {createGithubApiClient, type GithubApiClient} from '#api/client.js';\nimport type {GithubInstallationTokenProvider} from '#api/installation-token-provider.js';\nimport {deleteGithubInstallationTokenSecret} from '#api/installation-token-provider.js';\nimport {GithubAgentToolsProvider} from '#core/agent-tools.js';\nimport {GithubSourceControlProvider} from '#core/source-control.js';\nimport {createGithubWebhookProcessor} from '#core/webhook-processor.js';\nimport {closeDb, db} from '#db/db.js';\nimport {getGithubInstallationByConnectionId} from '#db/installations.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {\n type CreateGithubE2eRoutesOptions,\n createGithubE2eRoutes,\n} from '#presentation/e2eRoutes/index.js';\nimport {\n type CreateGithubIntegrationRoutesOptions,\n createGithubIntegrationRoutes,\n} from '#presentation/routes/install.js';\nimport {createGithubWebhookRoutes} from '#presentation/routes/webhooks.js';\n\nexport type {GithubApiClient} from '#api/client.js';\nexport {\n encodeInstallationTokenEnvelope,\n githubInstallationTokenNamespace,\n} from '#api/installation-token-envelope.js';\nexport {\n createGithubInstallationTokenProvider,\n type GithubInstallationTokenProvider,\n} from '#api/installation-token-provider.js';\nexport {\n type GithubAgentToolCatalogEntry,\n type GithubAgentToolCategory,\n type GithubAgentToolId,\n type GithubAgentToolPermission,\n type GithubAgentToolPermissionAccess,\n type GithubAgentToolRequiredPermission,\n type GithubAgentToolRequiredScope,\n GithubAgentToolsProvider,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from '#core/agent-tools.js';\nexport {GithubIntegrationProviderError} from '#core/errors.js';\nexport type {ConnectGithubInstallationInput} from '#core/install.js';\nexport {handleGithubCallback} from '#core/install.js';\nexport {signGithubInstallState, verifyGithubInstallState} from '#core/state.js';\nexport type {HandleGithubEventOutcome} from '#core/webhook.js';\nexport {handleGithubEvent} from '#core/webhook.js';\nexport type {\n CreateGithubWebhookProcessorOptions,\n GithubWebhookProcessor,\n} from '#core/webhook-processor.js';\nexport {createGithubWebhookProcessor} from '#core/webhook-processor.js';\nexport type {GithubInstallation, UpsertGithubInstallationParams} from '#db/installations.js';\nexport {\n getGithubInstallationByConnectionId,\n getGithubInstallationByInstallationId,\n upsertGithubInstallation,\n} from '#db/installations.js';\nexport {type CreateGithubE2eRoutesOptions, closeDb, createGithubE2eRoutes, db, migrationsPath};\n\nexport interface CreateGithubIntegrationProviderOptions\n extends Omit<CreateGithubIntegrationRoutesOptions, 'github'> {\n github?: GithubApiClient | undefined;\n coreDb: () => NodePgDatabase<Record<string, unknown>>;\n publishIntegrationEventReceived: PublishIntegrationEventReceivedFn;\n publishSourceRepositoryUpdated: PublishSourceRepositoryUpdatedFn;\n publishSourcePush: PublishSourcePushFn;\n recordDeliveryOnly: RecordDeliveryOnlyFn;\n getIntegrationConnectionById: GetIntegrationConnectionByIdFn;\n getGithubInstallationByConnectionId?: typeof getGithubInstallationByConnectionId | undefined;\n deleteSecrets?:\n | ((params: {workspaceId: string; namespace: string}) => Promise<number>)\n | undefined;\n agentTools?: {tokenProvider: GithubInstallationTokenProvider} | undefined;\n}\n\nexport function createGithubIntegrationProvider(options: CreateGithubIntegrationProviderOptions) {\n const github = options.github ?? createGithubApiClient();\n const getInstallationByConnectionId =\n options.getGithubInstallationByConnectionId ?? getGithubInstallationByConnectionId;\n const deleteSecrets = options.deleteSecrets;\n const deleteInstallationTokenSecret = deleteSecrets\n ? (params: {workspaceId: string; installationId: number}) =>\n deleteGithubInstallationTokenSecret({\n workspaceId: params.workspaceId,\n installationId: params.installationId,\n deleteSecrets,\n })\n : undefined;\n const webhookProcessor = createGithubWebhookProcessor({\n ...options,\n deleteInstallationTokenSecret,\n });\n\n return {\n provider: 'github' as const,\n displayName: 'GitHub',\n adapters: {\n source_control: new GithubSourceControlProvider(github),\n agent_tools: new GithubAgentToolsProvider({\n getInstallationByConnectionId: getInstallationByConnectionId,\n tokenProvider: options.agentTools?.tokenProvider,\n }),\n },\n async connectionExternalUrl(connection: {id: string}): Promise<string | undefined> {\n const installation = await getInstallationByConnectionId(connection.id);\n if (!installation) return undefined;\n const installationId = encodeURIComponent(installation.installationId);\n if (installation.accountType === 'Organization') {\n const login = encodeURIComponent(installation.accountLogin);\n return `https://github.com/organizations/${login}/settings/installations/${installationId}`;\n }\n return `https://github.com/settings/installations/${installationId}`;\n },\n routes: [\n createGithubIntegrationRoutes({\n github,\n getExistingGithubConnection: options.getExistingGithubConnection,\n connectGithubInstallation: options.connectGithubInstallation,\n ...(options.requireActiveWorkspaceMembership\n ? {requireActiveWorkspaceMembership: options.requireActiveWorkspaceMembership}\n : {}),\n }),\n createGithubWebhookRoutes({\n coreDb: options.coreDb,\n publishIntegrationEventReceived: options.publishIntegrationEventReceived,\n publishSourceRepositoryUpdated: options.publishSourceRepositoryUpdated,\n publishSourcePush: options.publishSourcePush,\n recordDeliveryOnly: options.recordDeliveryOnly,\n getIntegrationConnectionById: options.getIntegrationConnectionById,\n deleteInstallationTokenSecret,\n processor: webhookProcessor,\n }),\n ],\n webhookProcessors: [{routeIds: ['github'] as const, processor: webhookProcessor}],\n };\n}\n"],"names":["createGithubApiClient","deleteGithubInstallationTokenSecret","GithubAgentToolsProvider","GithubSourceControlProvider","createGithubWebhookProcessor","closeDb","db","getGithubInstallationByConnectionId","migrationsPath","createGithubE2eRoutes","createGithubIntegrationRoutes","createGithubWebhookRoutes","encodeInstallationTokenEnvelope","githubInstallationTokenNamespace","createGithubInstallationTokenProvider","githubAgentToolCatalog","githubAgentToolSelectionCatalog","GithubIntegrationProviderError","handleGithubCallback","signGithubInstallState","verifyGithubInstallState","handleGithubEvent","getGithubInstallationByInstallationId","upsertGithubInstallation","createGithubIntegrationProvider","options","github","getInstallationByConnectionId","deleteSecrets","deleteInstallationTokenSecret","params","workspaceId","installationId","undefined","webhookProcessor","provider","displayName","adapters","source_control","agent_tools","tokenProvider","agentTools","connectionExternalUrl","connection","installation","id","encodeURIComponent","accountType","login","accountLogin","routes","getExistingGithubConnection","connectGithubInstallation","requireActiveWorkspaceMembership","coreDb","publishIntegrationEventReceived","publishSourceRepositoryUpdated","publishSourcePush","recordDeliveryOnly","getIntegrationConnectionById","processor","webhookProcessors","routeIds"],"mappings":"AAQA,SAAQA,qBAAqB,QAA6B,iBAAiB;AAE3E,SAAQC,mCAAmC,QAAO,sCAAsC;AACxF,SAAQC,wBAAwB,QAAO,uBAAuB;AAC9D,SAAQC,2BAA2B,QAAO,0BAA0B;AACpE,SAAQC,4BAA4B,QAAO,6BAA6B;AACxE,SAAQC,OAAO,EAAEC,EAAE,QAAO,YAAY;AACtC,SAAQC,mCAAmC,QAAO,uBAAuB;AACzE,SAAQC,cAAc,QAAO,oBAAoB;AACjD,SAEEC,qBAAqB,QAChB,mCAAmC;AAC1C,SAEEC,6BAA6B,QACxB,kCAAkC;AACzC,SAAQC,yBAAyB,QAAO,mCAAmC;AAG3E,SACEC,+BAA+B,EAC/BC,gCAAgC,QAC3B,sCAAsC;AAC7C,SACEC,qCAAqC,QAEhC,sCAAsC;AAC7C,SAQEZ,wBAAwB,EACxBa,sBAAsB,EACtBC,+BAA+B,QAC1B,uBAAuB;AAC9B,SAAQC,8BAA8B,QAAO,kBAAkB;AAE/D,SAAQC,oBAAoB,QAAO,mBAAmB;AACtD,SAAQC,sBAAsB,EAAEC,wBAAwB,QAAO,iBAAiB;AAEhF,SAAQC,iBAAiB,QAAO,mBAAmB;AAKnD,SAAQjB,4BAA4B,QAAO,6BAA6B;AAExE,SACEG,mCAAmC,EACnCe,qCAAqC,EACrCC,wBAAwB,QACnB,uBAAuB;AAC9B,SAA2ClB,OAAO,EAAEI,qBAAqB,EAAEH,EAAE,EAAEE,cAAc,GAAE;AAkB/F,OAAO,SAASgB,gCAAgCC,OAA+C;IAC7F,MAAMC,SAASD,QAAQC,MAAM,IAAI1B;IACjC,MAAM2B,gCACJF,QAAQlB,mCAAmC,IAAIA;IACjD,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BAClE9B;gBACA+B,WAAW1B;YACb;SACD;QACD2B,mBAAmB;YAAC;gBAACC,UAAU;oBAAC;iBAAS;gBAAWF,WAAW1B;YAAgB;SAAE;IACnF;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {githubEventCatalog} from '@shipfox/api-integration-github-dto';\nimport type {\n GetIntegrationConnectionByIdFn,\n PublishIntegrationEventReceivedFn,\n PublishSourcePushFn,\n PublishSourceRepositoryUpdatedFn,\n RecordDeliveryOnlyFn,\n} from '@shipfox/api-integration-spi';\nimport type {NodePgDatabase} from 'drizzle-orm/node-postgres';\nimport {createGithubApiClient, type GithubApiClient} from '#api/client.js';\nimport type {GithubInstallationTokenProvider} from '#api/installation-token-provider.js';\nimport {deleteGithubInstallationTokenSecret} from '#api/installation-token-provider.js';\nimport {GithubAgentToolsProvider} from '#core/agent-tools.js';\nimport {GithubSourceControlProvider} from '#core/source-control.js';\nimport {createGithubWebhookProcessor} from '#core/webhook-processor.js';\nimport {closeDb, db} from '#db/db.js';\nimport {getGithubInstallationByConnectionId} from '#db/installations.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {\n type CreateGithubE2eRoutesOptions,\n createGithubE2eRoutes,\n} from '#presentation/e2eRoutes/index.js';\nimport {\n type CreateGithubIntegrationRoutesOptions,\n createGithubIntegrationRoutes,\n} from '#presentation/routes/install.js';\nimport {createGithubWebhookRoutes} from '#presentation/routes/webhooks.js';\n\nexport type {GithubApiClient} from '#api/client.js';\nexport {\n encodeInstallationTokenEnvelope,\n githubInstallationTokenNamespace,\n} from '#api/installation-token-envelope.js';\nexport {\n createGithubInstallationTokenProvider,\n type GithubInstallationTokenProvider,\n} from '#api/installation-token-provider.js';\nexport {\n type GithubAgentToolCatalogEntry,\n type GithubAgentToolCategory,\n type GithubAgentToolId,\n type GithubAgentToolPermission,\n type GithubAgentToolPermissionAccess,\n type GithubAgentToolRequiredPermission,\n type GithubAgentToolRequiredScope,\n GithubAgentToolsProvider,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from '#core/agent-tools.js';\nexport {GithubIntegrationProviderError} from '#core/errors.js';\nexport type {ConnectGithubInstallationInput} from '#core/install.js';\nexport {handleGithubCallback} from '#core/install.js';\nexport {signGithubInstallState, verifyGithubInstallState} from '#core/state.js';\nexport type {HandleGithubEventOutcome} from '#core/webhook.js';\nexport {handleGithubEvent} from '#core/webhook.js';\nexport type {\n CreateGithubWebhookProcessorOptions,\n GithubWebhookProcessor,\n} from '#core/webhook-processor.js';\nexport {createGithubWebhookProcessor} from '#core/webhook-processor.js';\nexport type {GithubInstallation, UpsertGithubInstallationParams} from '#db/installations.js';\nexport {\n getGithubInstallationByConnectionId,\n getGithubInstallationByInstallationId,\n upsertGithubInstallation,\n} from '#db/installations.js';\nexport {type CreateGithubE2eRoutesOptions, closeDb, createGithubE2eRoutes, db, migrationsPath};\n\nexport interface CreateGithubIntegrationProviderOptions\n extends Omit<CreateGithubIntegrationRoutesOptions, 'github'> {\n github?: GithubApiClient | undefined;\n coreDb: () => NodePgDatabase<Record<string, unknown>>;\n publishIntegrationEventReceived: PublishIntegrationEventReceivedFn;\n publishSourceRepositoryUpdated: PublishSourceRepositoryUpdatedFn;\n publishSourcePush: PublishSourcePushFn;\n recordDeliveryOnly: RecordDeliveryOnlyFn;\n getIntegrationConnectionById: GetIntegrationConnectionByIdFn;\n getGithubInstallationByConnectionId?: typeof getGithubInstallationByConnectionId | undefined;\n deleteSecrets?:\n | ((params: {workspaceId: string; namespace: string}) => Promise<number>)\n | undefined;\n agentTools?: {tokenProvider: GithubInstallationTokenProvider} | undefined;\n}\n\nexport function createGithubIntegrationProvider(options: CreateGithubIntegrationProviderOptions) {\n const github = options.github ?? createGithubApiClient();\n const getInstallationByConnectionId =\n options.getGithubInstallationByConnectionId ?? getGithubInstallationByConnectionId;\n const deleteSecrets = options.deleteSecrets;\n const deleteInstallationTokenSecret = deleteSecrets\n ? (params: {workspaceId: string; installationId: number}) =>\n deleteGithubInstallationTokenSecret({\n workspaceId: params.workspaceId,\n installationId: params.installationId,\n deleteSecrets,\n })\n : undefined;\n const webhookProcessor = createGithubWebhookProcessor({\n ...options,\n deleteInstallationTokenSecret,\n });\n\n return {\n provider: 'github' as const,\n displayName: 'GitHub',\n eventCatalog: githubEventCatalog,\n adapters: {\n source_control: new GithubSourceControlProvider(github),\n agent_tools: new GithubAgentToolsProvider({\n getInstallationByConnectionId: getInstallationByConnectionId,\n tokenProvider: options.agentTools?.tokenProvider,\n }),\n },\n async connectionExternalUrl(connection: {id: string}): Promise<string | undefined> {\n const installation = await getInstallationByConnectionId(connection.id);\n if (!installation) return undefined;\n const installationId = encodeURIComponent(installation.installationId);\n if (installation.accountType === 'Organization') {\n const login = encodeURIComponent(installation.accountLogin);\n return `https://github.com/organizations/${login}/settings/installations/${installationId}`;\n }\n return `https://github.com/settings/installations/${installationId}`;\n },\n routes: [\n createGithubIntegrationRoutes({\n github,\n getExistingGithubConnection: options.getExistingGithubConnection,\n connectGithubInstallation: options.connectGithubInstallation,\n ...(options.requireActiveWorkspaceMembership\n ? {requireActiveWorkspaceMembership: options.requireActiveWorkspaceMembership}\n : {}),\n }),\n createGithubWebhookRoutes({\n coreDb: options.coreDb,\n publishIntegrationEventReceived: options.publishIntegrationEventReceived,\n publishSourceRepositoryUpdated: options.publishSourceRepositoryUpdated,\n publishSourcePush: options.publishSourcePush,\n recordDeliveryOnly: options.recordDeliveryOnly,\n getIntegrationConnectionById: options.getIntegrationConnectionById,\n deleteInstallationTokenSecret,\n processor: webhookProcessor,\n }),\n ],\n webhookProcessors: [{routeIds: ['github'] as const, processor: webhookProcessor}],\n };\n}\n"],"names":["githubEventCatalog","createGithubApiClient","deleteGithubInstallationTokenSecret","GithubAgentToolsProvider","GithubSourceControlProvider","createGithubWebhookProcessor","closeDb","db","getGithubInstallationByConnectionId","migrationsPath","createGithubE2eRoutes","createGithubIntegrationRoutes","createGithubWebhookRoutes","encodeInstallationTokenEnvelope","githubInstallationTokenNamespace","createGithubInstallationTokenProvider","githubAgentToolCatalog","githubAgentToolSelectionCatalog","GithubIntegrationProviderError","handleGithubCallback","signGithubInstallState","verifyGithubInstallState","handleGithubEvent","getGithubInstallationByInstallationId","upsertGithubInstallation","createGithubIntegrationProvider","options","github","getInstallationByConnectionId","deleteSecrets","deleteInstallationTokenSecret","params","workspaceId","installationId","undefined","webhookProcessor","provider","displayName","eventCatalog","adapters","source_control","agent_tools","tokenProvider","agentTools","connectionExternalUrl","connection","installation","id","encodeURIComponent","accountType","login","accountLogin","routes","getExistingGithubConnection","connectGithubInstallation","requireActiveWorkspaceMembership","coreDb","publishIntegrationEventReceived","publishSourceRepositoryUpdated","publishSourcePush","recordDeliveryOnly","getIntegrationConnectionById","processor","webhookProcessors","routeIds"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,sCAAsC;AASvE,SAAQC,qBAAqB,QAA6B,iBAAiB;AAE3E,SAAQC,mCAAmC,QAAO,sCAAsC;AACxF,SAAQC,wBAAwB,QAAO,uBAAuB;AAC9D,SAAQC,2BAA2B,QAAO,0BAA0B;AACpE,SAAQC,4BAA4B,QAAO,6BAA6B;AACxE,SAAQC,OAAO,EAAEC,EAAE,QAAO,YAAY;AACtC,SAAQC,mCAAmC,QAAO,uBAAuB;AACzE,SAAQC,cAAc,QAAO,oBAAoB;AACjD,SAEEC,qBAAqB,QAChB,mCAAmC;AAC1C,SAEEC,6BAA6B,QACxB,kCAAkC;AACzC,SAAQC,yBAAyB,QAAO,mCAAmC;AAG3E,SACEC,+BAA+B,EAC/BC,gCAAgC,QAC3B,sCAAsC;AAC7C,SACEC,qCAAqC,QAEhC,sCAAsC;AAC7C,SAQEZ,wBAAwB,EACxBa,sBAAsB,EACtBC,+BAA+B,QAC1B,uBAAuB;AAC9B,SAAQC,8BAA8B,QAAO,kBAAkB;AAE/D,SAAQC,oBAAoB,QAAO,mBAAmB;AACtD,SAAQC,sBAAsB,EAAEC,wBAAwB,QAAO,iBAAiB;AAEhF,SAAQC,iBA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