{"version":3,"file":"index.mjs","names":["READ_ONLY","runConnectionCheck","ConnectionV1","WorkflowV1","manifestJson"],"sources":["../../powerhouse.manifest.json","../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../document-models/document-models.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["","// Ambient runtime client for the AI tools, which run outside any editor.\n// Editors never import this: each one gets its own client from RuntimeProvider.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n  createRuntimeClient,\n  DEFAULT_RUNTIME_URL,\n  type RunsScope,\n  type RuntimeClient,\n} from \"./runtime-client.js\";\nimport {\n  blockFormQuery,\n  catalogQuery,\n  createRuntimeQueryClient,\n} from \"./runtime-queries.js\";\n\nexport type * from \"./runtime-client.js\";\nexport { DEFAULT_RUNTIME_URL };\n\nlet ambient: RuntimeClient = createRuntimeClient(DEFAULT_RUNTIME_URL);\n// Keys start with the URL, so switching runtimes needs no cache reset.\nconst ambientQueries = createRuntimeQueryClient();\n\nexport function setRuntimeUrl(url: string): void {\n  if (url !== ambient.url) ambient = createRuntimeClient(url);\n}\n\nexport const getBlockForm = (block: BlockRef) =>\n  ambientQueries.fetchQuery(blockFormQuery(ambient, block));\nexport const fetchPieceCatalog = () =>\n  ambientQueries.fetchQuery(catalogQuery(ambient));\nexport const fetchPieceActions = (packageName: string) =>\n  ambient.fetchPieceActions(packageName);\nexport const fetchPieceTriggers = (packageName: string) =>\n  ambient.fetchPieceTriggers(packageName);\nexport const fetchConnections = () => ambient.fetchConnections();\nexport const checkConnection = (connectionId: string) =>\n  ambient.checkConnection(connectionId);\nexport const fetchRuns = (scope?: RunsScope) => ambient.fetchRuns(scope);\nexport const fireWorkflow = (workflowId: string, payload?: unknown) =>\n  ambient.fireWorkflow(workflowId, payload);\n","// Points the module-level runtime client at the selected drive's\n// workflow-runtime subgraph before an AI tool talks to it.\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n  DEFAULT_RUNTIME_URL,\n  setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nexport function syncRuntimeUrl(): void {\n  if (typeof window === \"undefined\") return;\n  const switchboard = resolveDriveSwitchboard(window.ph?.selectedDriveId);\n  // No resolvable switchboard (no selection, or a local/unsynced drive):\n  // reset to the default rather than leaving a prior drive's URL attached.\n  setRuntimeUrl(\n    switchboard\n      ? `${switchboard.graphqlUrl}/workflow-runtime`\n      : DEFAULT_RUNTIME_URL,\n  );\n}\n","// AI tool descriptors for authoring and running workflows: the pinned blocks\n// a piece offers, a block's config props, the built-in core blocks with\n// the expression syntax, run history and manual firing. Complements the\n// connector/connection tools in tools.ts, which cover the catalog and auth.\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n  fetchPieceActions,\n  fetchPieceTriggers,\n  fetchRuns,\n  fireWorkflow,\n  getBlockForm,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport type { BlockFormProp } from \"../editors/workflow-editor/ui/forms.js\";\nimport {\n  CORE_PIECE,\n  type BlockRef,\n} from \"../editors/workflow-editor/ui/blocks.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { flowPorts } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst READ_ONLY = {\n  readOnlyHint: true,\n  destructiveHint: false,\n  idempotentHint: true,\n  openWorldHint: false,\n} as const;\n\nfunction kindOf(block: BlockRef): \"trigger\" | \"step\" {\n  return block.kind === \"trigger\" ? \"trigger\" : \"step\";\n}\n\n// The fields ADD_STEP or SET_TRIGGER takes for the block.\nfunction blockFields(block: BlockRef) {\n  return {\n    pieceName: block.pieceName,\n    pieceVersion: block.pieceVersion,\n    ...(block.kind === \"trigger\"\n      ? { triggerName: block.name }\n      : { actionName: block.name }),\n  };\n}\n\n// The onward ports the block's descriptor declares; \"error\" is a failure route.\nfunction portsFor(form: { ports?: readonly string[] }): string[] {\n  return flowPorts(form.ports ?? []);\n}\n\nfunction describeProp(prop: BlockFormProp) {\n  return {\n    name: prop.name,\n    label: prop.displayName,\n    type: prop.type,\n    required: prop.required,\n    ...(prop.description ? { description: prop.description } : {}),\n    ...(prop.defaultValue !== undefined ? { default: prop.defaultValue } : {}),\n    ...(prop.staticOptions\n      ? { options: prop.staticOptions.map((option) => option.value) }\n      : {}),\n    ...(prop.hasDynamicResolver ? { dynamicOptions: true } : {}),\n  };\n}\n\nconst EXPRESSIONS = [\n  \"Step configs and edge conditions may contain expressions in double braces.\",\n  \"{{trigger.payload.<field>}} reads the trigger payload: for the core manual trigger the payload passed to fireWorkflow; for the reactor piece's document triggers it carries documentId, documentType, driveId and name.\",\n  \"{{steps.<key>.output.<path>}} reads an upstream step's output by that step's key, e.g. {{steps.fetch.output.body.title}}.\",\n  \"{{variables.<key>}} reads a workflow variable.\",\n  \"'a' || 'b' picks the first non-empty value, e.g. {{trigger.payload.url || 'https://example.com'}}.\",\n  \"A whole-string expression yields the raw value; text around expressions is interpolated.\",\n];\n\nconst GRAPH_RULES = [\n  \"A workflow is a powerhouse/workflow document. Build it with SET_TRIGGER once, ADD_STEP per step (each with a unique id and key), and ADD_EDGE from the trigger id to the first step and between steps.\",\n  \"An edge must leave on a port its source declares (getWorkflowBlockConfig lists them): 'next' for the trigger and ordinary steps, 'true' and 'false' for the core branch action, 'error' to route a failure. An edge on any other port is never taken, and the run is flagged with a warning.\",\n  \"A step names its block with pieceName, pieceVersion and actionName; the trigger with pieceName, pieceVersion and triggerName. pieceVersion is an exact semver: copy the fields getWorkflowPieceBlocks or listWorkflowCoreBlocks return.\",\n  `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,\n  \"Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).\",\n  \"Runs execute the published snapshot, not the draft. PUBLISH_WORKFLOW only snapshots the draft, so publish again after every edit that should run.\",\n  \"Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW does not enable: to turn a workflow on, dispatch SET_WORKFLOW_STATUS ENABLED after PUBLISH_WORKFLOW (the same batch works). SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once.\",\n];\n\nexport const getWorkflowPieceBlocksTool: PhAiToolDescriptor = {\n  name: \"getWorkflowPieceBlocks\",\n  description:\n    \"Lists the actions and triggers of one piece, each with the pieceName, pieceVersion and actionName or triggerName to use in ADD_STEP or SET_TRIGGER. Takes the piece package name from getConnectors. Call getWorkflowBlockConfig next for a block's config props.\",\n  inputSchema: {\n    packageName: z\n      .string()\n      .describe(\"Piece package name, e.g. @activepieces/piece-http.\"),\n  },\n  annotations: { title: \"Get Workflow Piece Blocks\", ...READ_ONLY },\n  callback: async (args: { packageName: string }) => {\n    syncRuntimeUrl();\n    const [actions, triggers] = await Promise.all([\n      fetchPieceActions(args.packageName),\n      fetchPieceTriggers(args.packageName),\n    ]);\n    return {\n      packageName: args.packageName,\n      actions: actions.map((action) => ({\n        pieceName: action.pieceName,\n        pieceVersion: action.pieceVersion,\n        actionName: action.name,\n        displayName: action.displayName,\n        description: action.description,\n      })),\n      triggers: triggers.map((trigger) => ({\n        pieceName: trigger.pieceName,\n        pieceVersion: trigger.pieceVersion,\n        triggerName: trigger.name,\n        displayName: trigger.displayName,\n        description: trigger.description,\n        strategy: trigger.strategy,\n      })),\n    };\n  },\n};\n\nexport const getWorkflowBlockConfigTool: PhAiToolDescriptor = {\n  name: \"getWorkflowBlockConfig\",\n  description:\n    \"Describes the config of one block (a core block or a piece's action or trigger): prop names, types, whether required, allowed options, the output ports, and whether a connection is needed. Use it before writing a step or trigger config.\",\n  inputSchema: {\n    pieceName: z\n      .string()\n      .describe(\n        `Piece package name, e.g. ${CORE_PIECE} or @activepieces/piece-http.`,\n      ),\n    pieceVersion: z.string().describe(\"Exact semver of the piece.\"),\n    name: z\n      .string()\n      .describe(\"Action or trigger name, e.g. branch or send_request.\"),\n    kind: z.enum([\"action\", \"trigger\"]).describe(\"action or trigger.\"),\n  },\n  annotations: { title: \"Get Workflow Block Config\", ...READ_ONLY },\n  callback: async (args: BlockRef) => {\n    const block: BlockRef = {\n      pieceName: args.pieceName,\n      pieceVersion: args.pieceVersion,\n      name: args.name,\n      kind: args.kind,\n    };\n    syncRuntimeUrl();\n    const form = await getBlockForm(block);\n    if (!form) {\n      return {\n        ...blockFields(block),\n        error:\n          \"Unknown block. Use getConnectors and getWorkflowPieceBlocks to find valid blocks (documents live in @powerhousedao/piece-reactor), or listWorkflowCoreBlocks for built-ins.\",\n      };\n    }\n    return {\n      ...blockFields(block),\n      title: form.title,\n      kind: kindOf(block),\n      requiresConnection: form.auth === \"required\",\n      props: form.props.map(describeProp),\n      ports: portsFor(form),\n    };\n  },\n};\n\nexport const listWorkflowCoreBlocksTool: PhAiToolDescriptor = {\n  name: \"listWorkflowCoreBlocks\",\n  description: `Lists the built-in blocks of the ${CORE_PIECE} piece (manual, schedule and webhook triggers, branch and assert) with their pinned fields and config props, plus the expression syntax and the rules for building a powerhouse/workflow document. Documents are read and written by the @powerhousedao/piece-reactor blocks; list those with getWorkflowPieceBlocks.`,\n  inputSchema: {},\n  annotations: { title: \"List Workflow Core Blocks\", ...READ_ONLY },\n  callback: async () => {\n    syncRuntimeUrl();\n    // The reactor serves the core piece's descriptors, as it does any piece's.\n    const [actions, triggers] = await Promise.all([\n      fetchPieceActions(CORE_PIECE),\n      fetchPieceTriggers(CORE_PIECE),\n    ]);\n    const blocks: BlockRef[] = [\n      ...triggers.map((entry) => ({ ...entry, kind: \"trigger\" as const })),\n      ...actions.map((entry) => ({ ...entry, kind: \"action\" as const })),\n    ].map((entry) => ({\n      pieceName: entry.pieceName,\n      pieceVersion: entry.pieceVersion,\n      name: entry.name,\n      kind: entry.kind,\n    }));\n    const forms = await Promise.all(blocks.map(getBlockForm));\n    return {\n      blocks: blocks.flatMap((block, index) => {\n        const form = forms[index];\n        if (!form) return [];\n        return [\n          {\n            ...blockFields(block),\n            title: form.title,\n            kind: kindOf(block),\n            props: form.props.map(describeProp),\n            ports: portsFor(form),\n          },\n        ];\n      }),\n      expressions: EXPRESSIONS,\n      rules: GRAPH_RULES,\n    };\n  },\n};\n\nexport const listWorkflowRunsTool: PhAiToolDescriptor = {\n  name: \"listWorkflowRuns\",\n  description:\n    \"Lists recent workflow runs, newest first, with status, error and each step's outcome. Filter by workflowId to inspect one workflow, or by driveId for every workflow in a drive.\",\n  inputSchema: {\n    workflowId: z\n      .string()\n      .optional()\n      .describe(\"Workflow document id to filter by.\"),\n    driveId: z\n      .string()\n      .optional()\n      .describe(\"Drive id to filter by (all workflows in that drive).\"),\n    limit: z\n      .number()\n      .int()\n      .min(1)\n      .max(100)\n      .optional()\n      .describe(\"Maximum runs to return (default 10).\"),\n  },\n  annotations: { title: \"List Workflow Runs\", ...READ_ONLY },\n  callback: async (args: {\n    workflowId?: string;\n    driveId?: string;\n    limit?: number;\n  }) => {\n    syncRuntimeUrl();\n    const runs = await fetchRuns({\n      workflowId: args.workflowId,\n      driveId: args.driveId,\n      limit: args.limit ?? 10,\n    });\n    return {\n      runs: runs.map((run) => ({\n        id: run.id,\n        workflowId: run.workflowId,\n        workflowName: run.workflowName,\n        status: run.status,\n        error: run.error,\n        triggerKind: run.triggerKind,\n        startedAt: run.startedAt,\n        endedAt: run.endedAt,\n        steps: run.steps.map((step) => ({\n          key: step.stepKey,\n          status: step.status,\n          error: step.error,\n        })),\n      })),\n    };\n  },\n};\n\nexport const fireWorkflowTool: PhAiToolDescriptor = {\n  name: \"fireWorkflow\",\n  description:\n    \"Fires an ENABLED workflow whose trigger is the core manual trigger and runs its published snapshot to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.\",\n  inputSchema: {\n    workflowId: z.string().describe(\"Workflow document id.\"),\n    payload: z\n      .record(z.string(), z.unknown())\n      .optional()\n      .describe(\"Trigger payload object.\"),\n  },\n  annotations: {\n    title: \"Fire Workflow\",\n    readOnlyHint: false,\n    destructiveHint: true,\n    idempotentHint: false,\n    openWorldHint: false,\n  },\n  callback: (args: {\n    workflowId: string;\n    payload?: Record<string, unknown>;\n  }) => {\n    syncRuntimeUrl();\n    return fireWorkflow(args.workflowId, args.payload ?? {});\n  },\n};\n\n/** Workflow authoring and run tools, merged into `aiTools` in tools.ts. */\nexport const workflowTools: PhAiToolDescriptor[] = [\n  getWorkflowPieceBlocksTool,\n  getWorkflowBlockConfigTool,\n  listWorkflowCoreBlocksTool,\n  listWorkflowRunsTool,\n  fireWorkflowTool,\n];\n","// Read-only AI tool descriptors for the Connect assistant: the project's\n// piece catalog, connection documents, and connection health. The `aiTools`\n// export is how the host app discovers this package's tools (the line in the\n// project index is synced by `ph generate`).\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n  connectorIdForPiece,\n  isConfigValueMissing,\n  packageFromConnectorId,\n  planFromAuth,\n  type AuthField,\n} from \"../editors/connection-editor/piece-auth.js\";\nimport {\n  checkConnection as runConnectionCheck,\n  fetchConnections,\n  fetchPieceActions,\n  fetchPieceCatalog,\n  fetchPieceTriggers,\n  type PieceSummary,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { workflowTools } from \"./workflow-tools.js\";\n\nconst MAX_CONNECTORS = 20;\n\nexport interface ConnectorField {\n  name: string;\n  label: string;\n  required: boolean;\n  description?: string;\n  secret: boolean;\n}\n\nexport interface ConnectorDetail {\n  connectorId: string;\n  pieceName: string;\n  displayName: string;\n  description: string;\n  version: string;\n  authType: string;\n  /** False for auth kinds the runtime cannot execute yet (OIDC). */\n  supported: boolean;\n  /** OAUTH2: a person finishes it by signing in from the connection editor. */\n  signIn?: \"oauth2\";\n  fields: ConnectorField[];\n  actions: string[];\n  triggers: string[];\n}\n\nfunction toField(field: AuthField, secret: boolean): ConnectorField {\n  return {\n    name: field.name,\n    label: field.displayName,\n    required: field.required,\n    description: field.description,\n    secret,\n  };\n}\n\nasync function connectorDetail(piece: PieceSummary): Promise<ConnectorDetail> {\n  const plan = planFromAuth(piece.auth);\n  const [actions, triggers] = await Promise.all([\n    fetchPieceActions(piece.name),\n    fetchPieceTriggers(piece.name),\n  ]);\n  return {\n    connectorId: connectorIdForPiece(piece.name),\n    pieceName: piece.name,\n    displayName: piece.displayName,\n    description: piece.description,\n    version: piece.version,\n    authType: plan.authType,\n    supported: plan.supported,\n    ...(plan.oauth2 ? { signIn: \"oauth2\" as const } : {}),\n    fields: [\n      ...plan.configFields.map((field) => toField(field, false)),\n      ...plan.secretFields.map((field) => toField(field, true)),\n    ],\n    actions: actions.map((action) => action.name),\n    triggers: triggers.map((trigger) => trigger.name),\n  };\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed to a\n * case-insensitive substring match on name, display name, or description,\n * capped at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is\n * fetched only for the surviving entries (stage two).\n */\nexport async function getConnectors(query?: string): Promise<{\n  total: number;\n  matches: number;\n  truncated: boolean;\n  connectors: ConnectorDetail[];\n}> {\n  syncRuntimeUrl();\n  const catalog = await fetchPieceCatalog();\n  const needle = query?.trim().toLowerCase();\n  const matches = needle\n    ? catalog.filter((piece) =>\n        [piece.name, piece.displayName, piece.description].some((field) =>\n          field.toLowerCase().includes(needle),\n        ),\n      )\n    : [...catalog];\n  const page = matches.slice(0, MAX_CONNECTORS);\n  const connectors = await Promise.all(page.map(connectorDetail));\n  return {\n    total: catalog.length,\n    matches: matches.length,\n    truncated: matches.length > page.length,\n    connectors,\n  };\n}\n\ninterface ConnectionState {\n  config?: unknown;\n  secretRefs?: { name: string }[];\n}\n\nexport interface ConnectionDetail {\n  id: string;\n  name: string;\n  connectorId: string;\n  authType: string;\n  status: string;\n  accountLabel: string | null;\n  /** Required secret fields with no stored ref, by auth property name. */\n  missingSecrets: string[];\n  /** Required config fields with no value, by auth property name. */\n  missingConfig: string[];\n}\n\n/**\n * Every connection document with its credential state compared against the\n * piece's auth plan. Only field names and opaque refs are surfaced; secret\n * values never do.\n */\nexport async function getConnections(): Promise<{\n  connections: ConnectionDetail[];\n}> {\n  syncRuntimeUrl();\n  const [catalog, summaries] = await Promise.all([\n    fetchPieceCatalog(),\n    fetchConnections(),\n  ]);\n  const client =\n    typeof window !== \"undefined\" ? window.ph?.reactorClient : undefined;\n  const connections = await Promise.all(\n    summaries.map(async (summary) => {\n      const piece = catalog.find(\n        (entry) => entry.name === packageFromConnectorId(summary.connectorId),\n      );\n      const plan = planFromAuth(piece?.auth ?? null);\n      let state: ConnectionState | undefined;\n      if (client) {\n        try {\n          const document = await client.get(summary.id);\n          state = (document.state as { global?: ConnectionState }).global;\n        } catch {\n          state = undefined;\n        }\n      }\n      const refNames = new Set(\n        (state?.secretRefs ?? []).map((ref) => ref.name),\n      );\n      const config = (state?.config ?? {}) as Record<string, unknown>;\n      return {\n        id: summary.id,\n        name: summary.name,\n        connectorId: summary.connectorId,\n        authType: summary.authType,\n        status: summary.status,\n        accountLabel: summary.accountLabel,\n        missingSecrets: plan.secretFields\n          .filter((field) => field.required && !refNames.has(field.name))\n          .map((field) => field.name),\n        missingConfig: plan.configFields\n          .filter(\n            (field) =>\n              field.required && isConfigValueMissing(config[field.name]),\n          )\n          .map((field) => field.name),\n      };\n    }),\n  );\n  return { connections };\n}\n\nconst READ_ONLY = {\n  readOnlyHint: true,\n  destructiveHint: false,\n  idempotentHint: true,\n  openWorldHint: false,\n} as const;\n\nexport const getConnectorsTool: PhAiToolDescriptor = {\n  name: \"getConnectors\",\n  description:\n    \"Lists the connectors (Activepieces pieces) available to the workflow runtime with their auth fields, actions, and triggers. Without a query it returns up to 20 connectors; pass `query` to search by name or description. Secret fields are listed by name only, never by value.\",\n  inputSchema: { query: z.string().optional() },\n  annotations: { title: \"Get Connectors\", ...READ_ONLY },\n  callback: (args: { query?: string }) => getConnectors(args.query),\n};\n\nexport const getConnectionsTool: PhAiToolDescriptor = {\n  name: \"getConnections\",\n  description:\n    \"Lists the project's connection documents with their credential status: which required secrets and config values are still missing, and the last account label. Secret values are never included.\",\n  inputSchema: {},\n  annotations: { title: \"Get Connections\", ...READ_ONLY },\n  callback: () => getConnections(),\n};\n\nexport const checkConnectionTool: PhAiToolDescriptor = {\n  name: \"checkConnection\",\n  description:\n    \"Runs a connection's own check against its stored credentials to verify they work. Takes a connection id (from getConnections) and reports success, the failure detail, and the account label when the provider returns one.\",\n  inputSchema: { connectionId: z.string() },\n  annotations: { title: \"Check Connection\", ...READ_ONLY },\n  callback: (args: { connectionId: string }) => {\n    syncRuntimeUrl();\n    return runConnectionCheck(args.connectionId);\n  },\n};\n\n/** Tool descriptors the host app offers the AI assistant. */\nexport const aiTools: PhAiToolDescriptor[] = [\n  getConnectorsTool,\n  getConnectionsTool,\n  checkConnectionTool,\n  ...workflowTools,\n];\n","import { Connection as ConnectionV1 } from \"document-models/connection/v1\";\nimport { Workflow as WorkflowV1 } from \"document-models/workflow/v1\";\n\n/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\n\nexport const documentModels = [ConnectionV1, WorkflowV1] as const;\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { EditorModule } from \"document-model\";\nimport { ConnectionEditor } from \"./connection-editor/module.js\";\nimport { WorkflowEditor } from \"./workflow-editor/module.js\";\nimport { WorkflowStudio } from \"./workflow-studio/module.js\";\n\nexport const editors: EditorModule[] = [\n  ConnectionEditor,\n  WorkflowEditor,\n  WorkflowStudio,\n];\n","import type { Manifest } from \"document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\n\nexport { aiTools } from \"./ai/tools.js\";\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { upgradeManifests } from \"./document-models/upgrade-manifests.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest = manifestJson as Manifest;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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