{"version":3,"file":"composition.cjs","names":["pluginSelectionAxes","stripAnsi","isDesktopClient","pluginModes","pluginActivityGroups","subscribeWebPluginRegistry","webPluginRegistryRevision","t","pluginDockFaces","useSyncExternalStore","useT","pluginFileLinks","useCallback"],"sources":["../../../src/web/lib/composition.ts"],"sourcesContent":["import type {\n  ActivityGroupContribution,\n  DockFaceContribution,\n  FileLinkMention,\n  ModeContribution,\n  SelectionAxisContribution,\n  TransientTab,\n} from '@agimon-ai/po-core/web';\nimport { t, useT } from '@agimon-ai/po-core/web';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nimport type { ModeProjection, ModeRecordProjection } from '../../types/hub';\nimport {\n  isDesktopClient,\n  pluginActivityGroups,\n  pluginDockFaces,\n  pluginFileLinks,\n  pluginModes,\n  pluginSelectionAxes,\n  subscribeWebPluginRegistry,\n  webPluginRegistryRevision,\n} from './pluginRegistry';\nimport { stripAnsi } from './statusLine';\n\nexport interface SelectionAxis {\n  name: string;\n  command: string;\n  /** The current selections, empty while the session reports none; one at most unless multi. */\n  values: string[];\n  emptyLabel: string;\n  multi: boolean;\n}\n\nconst AXIS_LIST_SEPARATOR = ',';\n\n/**\n * The fallback axis table for the packaged bundle; a synced bundle carries\n * each axis as its owning package's plugin declaration, and the registry\n * list wins whenever any plugin declares one. Exported only so the workspace\n * composition test can hold it equal to what the packages declare.\n */\nexport const PACKAGED_SELECTION_AXES: readonly SelectionAxisContribution[] = [\n  { name: 'profile', command: 'profile', statusKey: 'po-profile', emptyLabel: 'None', order: 10 },\n  { name: 'domains', command: 'domains', statusKey: 'po-domain', emptyLabel: 'no domains', multi: true, order: 20 },\n];\n\n/**\n * The declared axes the session actually offers: an axis whose status key\n * the session never published stays off the bar entirely, which is how a\n * package withholds its axis when there is nothing to select.\n */\nexport function selectionAxes(statuses: Record<string, string>): SelectionAxis[] {\n  const declared = pluginSelectionAxes();\n  const sources: readonly SelectionAxisContribution[] = declared.length > 0 ? declared : PACKAGED_SELECTION_AXES;\n  return sources.flatMap((source) => {\n    const raw = statuses[source.statusKey];\n    if (raw === undefined) return [];\n    const multi = source.multi === true;\n    const values = (multi ? stripAnsi(raw).split(AXIS_LIST_SEPARATOR) : [stripAnsi(raw)])\n      .map((value) => value.trim())\n      .filter(Boolean);\n    return [{ name: source.name, command: source.command, values, emptyLabel: source.emptyLabel, multi }];\n  });\n}\n\nexport type ModeAvailability = 'unavailable' | 'off' | 'on';\n\nexport interface Mode {\n  name: string;\n  /** The catalog id /mode accepts; the display name until the catalog reports. */\n  id: string;\n  /** Leader Space key path, as the TUI documents it. */\n  keys: string;\n  availability: ModeAvailability;\n  /** What the mode itself is reporting while on. */\n  detail: string;\n  /** Activity group to focus instead of invoking the mode command from the cockpit. */\n  activityGroup?: string;\n  /** The mark the mode's package declares; the host draws a generic one without it. */\n  icon?: ModeContribution['icon'];\n  /** The action that flips the row in one click, when the mode offers it without input. */\n  toggle?: ModeToggleAction;\n  /**\n   * Why the mode cannot be driven from here, in the words of the mode itself.\n   * Empty when it can. A mode may be installed and still refuse a cockpit:\n   * autonomous voice captures from the terminal's own microphone, which a\n   * browser talking to a headless agent does not have.\n   */\n  unavailableReason: string;\n}\n\nexport interface ModeSource {\n  name: string;\n  /** The catalog mode this row drives, when the runtime registers it under another id. */\n  modeId?: string;\n  /** Leader Space key path, as the TUI documents it. */\n  keys: string;\n  /** Activity group to focus instead of invoking the mode command from the cockpit. */\n  activityGroup?: string;\n  icon?: ModeContribution['icon'];\n  statusKey?: string;\n  widgetKey?: string;\n  hideWhenMissing?: boolean;\n  desktopOnly?: boolean;\n}\n\n/**\n * The fallback mode table for the packaged bundle.\n *\n * A synced bundle carries each mode as its package's own web plugin\n * contribution, and the registry list wins whenever any plugin declares one.\n * This literal survives only so the built-in-only bundle keeps rendering the\n * modes Po ships; help is listed without a signal on purpose: it\n * registers no footer entry, so the cockpit reports it as unavailable rather\n * than guessing it is off. Exported only for the workspace composition test.\n */\nexport const PACKAGED_MODES: readonly ModeSource[] = [\n  { name: 'help', keys: 'h e' },\n  { name: 'plan', keys: 'p e', statusKey: 'plan-mode' },\n  { name: 'goal', keys: 'g e', statusKey: 'goal' },\n  // `v e` drives autonomous capture, which the runtime registers as 'voice-auto'.\n  { name: 'voice', modeId: 'voice-auto', keys: 'v e', statusKey: 'po-voice' },\n  {\n    name: 'computer use',\n    modeId: 'computer-use',\n    keys: 'c e',\n    statusKey: 'po-computer-use-mode',\n    hideWhenMissing: true,\n  },\n];\n\n/** What a mode's own package declares about how its row looks and where it leads. */\nfunction presented(source: ModeSource | undefined): Pick<Mode, 'activityGroup' | 'icon'> {\n  return {\n    ...(source?.activityGroup === undefined ? {} : { activityGroup: source.activityGroup }),\n    ...(source?.icon === undefined ? {} : { icon: source.icon }),\n  };\n}\n\nexport type ModeToggleAction = 'activate' | 'deactivate' | 'end';\nconst OFF_ACTIONS: readonly ModeToggleAction[] = ['deactivate', 'end'];\nconst ON_ACTIONS: readonly ModeToggleAction[] = ['activate'];\n\n/** The one-click action for a mode: an enabled, input-free activate when off, or deactivate/end when on. */\nexport function modeToggle(mode: ModeRecordProjection): ModeToggleAction | undefined {\n  const on = mode.activation === 'active' || mode.activation === 'deactivating';\n  return (on ? OFF_ACTIONS : ON_ACTIONS).find((id) =>\n    mode.actions.some((action) => action.id === id && action.enabled && !action.needsInput),\n  );\n}\n\n/** The declared source a catalog mode corresponds to, by id, id stem, or label. */\nfunction sourceFor(sources: readonly ModeSource[], mode: ModeRecordProjection): ModeSource | undefined {\n  const candidates = new Set([mode.id.toLowerCase(), mode.id.toLowerCase().split('.')[0], mode.label.toLowerCase()]);\n  return sources.find((source) =>\n    [source.name, source.modeId].some((identity) => identity !== undefined && candidates.has(identity.toLowerCase())),\n  );\n}\n\n/**\n * Catalog-backed rows: the runtime's own activation state per mode, with the\n * declared leader keys attached where a plugin documents them. Declared modes\n * the catalog does not know are still listed, as unavailable, so a mode that\n * is missing from a composition stays visible rather than silently gone.\n */\nfunction catalogModes(sources: readonly ModeSource[], projection: ModeProjection): Mode[] {\n  const rows: Mode[] = projection.modes\n    .filter((mode) => !sourceFor(sources, mode)?.desktopOnly || isDesktopClient())\n    .map((mode) => {\n      const source = sourceFor(sources, mode);\n      const on = mode.activation === 'active' || mode.activation === 'deactivating';\n      // The catalog says per action whether it can run here and why not. A mode\n      // with nothing runnable is offered as a row that cannot be clicked rather\n      // than one that answers \"no actions available\" after the fact.\n      const blocked = mode.actions.length > 0 && mode.actions.every((action) => !action.enabled);\n      const reason = blocked ? (mode.actions.find((action) => action.disabledReason)?.disabledReason ?? '') : '';\n      const toggle = modeToggle(mode);\n      return {\n        name: source?.name ?? mode.label.toLowerCase(),\n        id: mode.id,\n        keys: source?.keys ?? '',\n        availability: blocked && !on ? 'unavailable' : on ? 'on' : 'off',\n        ...presented(source),\n        ...(toggle ? { toggle } : {}),\n        detail: mode.detail ?? (mode.activation === 'activating' ? 'activating' : ''),\n        unavailableReason: reason,\n      };\n    });\n  const seen = new Set(rows.map((row) => row.name));\n  for (const source of sources) {\n    if (source.hideWhenMissing === true || (source.desktopOnly && !isDesktopClient())) continue;\n    if (!seen.has(source.name)) {\n      rows.push({\n        name: source.name,\n        id: source.modeId ?? source.name,\n        keys: source.keys,\n        availability: 'unavailable',\n        ...presented(source),\n        detail: '',\n        unavailableReason: 'No package in this session registers this mode.',\n      });\n    }\n  }\n  return rows;\n}\n\nexport function resolveModes(\n  statuses: Record<string, string>,\n  widgets: readonly string[],\n  projection: ModeProjection | null = null,\n): Mode[] {\n  const declared = pluginModes();\n  const sources: readonly ModeSource[] = declared.length > 0 ? declared : PACKAGED_MODES;\n  if (projection) return catalogModes(sources, projection);\n  return sources.flatMap((source) => {\n    if (source.desktopOnly && !isDesktopClient()) return [];\n    if (source.statusKey !== undefined) {\n      const raw = statuses[source.statusKey];\n      if (raw === undefined) {\n        if (source.hideWhenMissing === true) return [];\n        return [\n          {\n            name: source.name,\n            id: source.modeId ?? source.name,\n            keys: source.keys,\n            availability: 'unavailable' as const,\n            ...presented(source),\n            detail: '',\n            unavailableReason: 'This session has not reported the mode.',\n          },\n        ];\n      }\n      const detail = stripAnsi(raw).trim();\n      return {\n        name: source.name,\n        id: source.modeId ?? source.name,\n        keys: source.keys,\n        availability: detail ? ('on' as const) : ('off' as const),\n        ...presented(source),\n        detail,\n        unavailableReason: '',\n      };\n    }\n    if (source.widgetKey !== undefined && widgets.includes(source.widgetKey)) {\n      return {\n        name: source.name,\n        id: source.modeId ?? source.name,\n        keys: source.keys,\n        availability: 'off' as const,\n        ...presented(source),\n        detail: '',\n        unavailableReason: '',\n      };\n    }\n    return {\n      name: source.name,\n      id: source.name,\n      keys: source.keys,\n      availability: 'unavailable' as const,\n      ...presented(source),\n      detail: '',\n      unavailableReason: 'This session has not reported the mode.',\n    };\n  });\n}\n\nexport interface ActivityGroup {\n  name: string;\n  keys: string;\n  /** The heading visual its package declares; the dock draws a generic one without it. */\n  icon?: ActivityGroupContribution['icon'];\n  /** The heading text its package declares; the host sentence-cases the name without it. */\n  label?: string;\n  /** What the publishing extension is reporting, empty when it reports nothing. */\n  summary: string;\n  active: boolean;\n  marksBackgroundWork?: boolean;\n  collapsible?: boolean;\n  /** The temporary tab the group's name opens, when its package declares one. */\n  transientTab?: () => TransientTab;\n  /** Keeps the group visible below the dock's scrolling ordinary groups. */\n  placement?: 'bottom';\n}\n\n/** Subscribe to package-owned activity sources, rewiring when the focused composition changes. */\nexport function subscribeActivitySources(listener: () => void): () => void {\n  let subscriptions: (() => void)[] = [];\n  const unsubscribeSources = (): void => {\n    subscriptions.forEach((unsubscribe) => unsubscribe());\n    subscriptions = [];\n  };\n  const subscribeSources = (): void => {\n    subscriptions = pluginActivityGroups().flatMap((source) =>\n      source.activeSource === undefined ? [] : [source.activeSource.subscribe(listener)],\n    );\n  };\n  subscribeSources();\n  const unsubscribeRegistry = subscribeWebPluginRegistry(() => {\n    unsubscribeSources();\n    subscribeSources();\n    listener();\n  });\n  return () => {\n    unsubscribeRegistry();\n    unsubscribeSources();\n  };\n}\n\nfunction activitySourceFingerprint(sessionId: string | null): string {\n  const activeSources = pluginActivityGroups()\n    .map((source) => (source.activeSource?.isActive(sessionId) === true ? '1' : '0'))\n    .join('');\n  return `${webPluginRegistryRevision()}:${activeSources}`;\n}\n\n/**\n * The groups available in this plugin composition. Status and widget signals\n * reveal legacy groups. A package-owned active source also reveals its group,\n * including while idle, so the section can remain a stable launcher unless it\n * opts into `hideWhenEmpty`.\n *\n * A group that declared `hideWhenEmpty` goes away once its session stops\n * reporting. Clearing a status reaches the page as an empty string rather than\n * an absent key, because the same map tells the selection bar which modes\n * exist and an absent key means \"not reported\" there. Emptiness is read here,\n * where only the dock is looking.\n */\nexport function activityGroups(\n  statuses: Record<string, string>,\n  widgets: readonly string[],\n  sessionId: string | null = null,\n  translate: typeof t = t,\n): ActivityGroup[] {\n  const groups: ActivityGroup[] = [];\n  for (const source of pluginActivityGroups()) {\n    const tab = source.transientTab === undefined ? {} : { transientTab: source.transientTab };\n    const placement = {\n      ...(source.placement === undefined ? {} : { placement: source.placement }),\n      ...(source.marksBackgroundWork === false ? { marksBackgroundWork: false } : {}),\n      ...(source.collapsible === false ? { collapsible: false } : {}),\n      ...(source.icon === undefined ? {} : { icon: source.icon }),\n      ...(source.label === undefined\n        ? {}\n        : { label: typeof source.label === 'function' ? source.label(translate) : source.label }),\n    };\n    if (source.statusKey !== undefined && statuses[source.statusKey] !== undefined) {\n      const summary = stripAnsi(statuses[source.statusKey] ?? '').trim();\n      const active =\n        source.activeSource?.isActive(sessionId) ?? (source.marksBackgroundWork !== false && summary.length > 0);\n      if (summary.length === 0 && source.hideWhenEmpty === true && !active) continue;\n      groups.push({ name: source.name, keys: source.keys, summary, active, ...tab, ...placement });\n      continue;\n    }\n    if (source.widgetKeys !== undefined && source.widgetKeys.some((key) => widgets.includes(key))) {\n      const activeKeys = source.activeWidgetKeys ?? source.widgetKeys;\n      const active =\n        source.activeSource?.isActive(sessionId) ??\n        (source.marksBackgroundWork !== false && activeKeys.some((key) => widgets.includes(key)));\n      groups.push({ name: source.name, keys: source.keys, summary: '', active, ...tab, ...placement });\n      continue;\n    }\n    if (source.activeSource !== undefined) {\n      const active = source.activeSource.isActive(sessionId);\n      if (source.hideWhenEmpty === true && !active) continue;\n      groups.push({\n        name: source.name,\n        keys: source.keys,\n        summary: '',\n        active,\n        ...tab,\n        ...placement,\n      });\n    }\n  }\n  return groups;\n}\n\n/** Dock faces update when the active session composition changes. */\nexport function useDockFaces(sessionId: string | null): readonly DockFaceContribution[] {\n  useSyncExternalStore(subscribeWebPluginRegistry, webPluginRegistryRevision, webPluginRegistryRevision);\n  const subscribe = (listener: () => void) => {\n    const releases = pluginDockFaces().flatMap((face) =>\n      face.visibility ? [face.visibility.subscribe(listener)] : [],\n    );\n    return () => releases.forEach((release) => release());\n  };\n  const snapshot = () =>\n    pluginDockFaces()\n      .map((face) => (face.visibility?.isVisible(sessionId) !== false ? '1' : '0'))\n      .join('');\n  useSyncExternalStore(subscribe, snapshot, snapshot);\n  return pluginDockFaces().filter((face) => face.visibility?.isVisible(sessionId) !== false);\n}\n\n/** Each face's badge count for the session, re-read when a face reports a change. */\nexport function useDockFaceBadges(\n  faces: readonly DockFaceContribution[],\n  sessionId: string | null,\n): Readonly<Record<string, number>> {\n  const subscribe = (listener: () => void) => {\n    const releases = faces.flatMap((face) => (face.badge ? [face.badge.subscribe(listener)] : []));\n    return () => releases.forEach((release) => release());\n  };\n  // A string snapshot keeps useSyncExternalStore stable between unrelated renders.\n  const snapshot = () =>\n    faces.map((face) => `${face.id}=${face.badge ? Math.max(0, face.badge.count(sessionId)) : 0}`).join('\\n');\n  const counts = useSyncExternalStore(subscribe, snapshot, snapshot);\n  return Object.fromEntries(\n    counts\n      .split('\\n')\n      .filter(Boolean)\n      .map((entry) => {\n        const separator = entry.lastIndexOf('=');\n        return [entry.slice(0, separator), Number(entry.slice(separator + 1))];\n      }),\n  );\n}\n\n/** Activity groups that update when either host signals or a plugin's session store changes. */\nexport function useActivityGroups(\n  statuses: Record<string, string>,\n  widgets: readonly string[],\n  sessionId: string | null,\n): ActivityGroup[] {\n  useSyncExternalStore(\n    subscribeActivitySources,\n    () => activitySourceFingerprint(sessionId),\n    () => activitySourceFingerprint(sessionId),\n  );\n  const translate = useT();\n  return activityGroups(statuses, widgets, sessionId, translate);\n}\n\n/** The tab one path opens, or undefined when no installed plugin recognises it. */\nexport type FileLinkResolver = (path: string) => TransientTab | undefined;\n\ninterface FileLinkModes {\n  active(sessionId: string | null): readonly string[];\n  subscribe(sessionId: string | null, listener: () => void): () => void;\n}\nlet fileLinkModes: FileLinkModes | undefined;\nconst modeBindings = new Set<() => void>();\n\n/** Binds host session facts without making the composition library own session state. */\nexport function bindFileLinkModes(source: FileLinkModes): () => void {\n  fileLinkModes = source;\n  modeBindings.forEach((listener) => listener());\n  return () => {\n    if (fileLinkModes !== source) return;\n    fileLinkModes = undefined;\n    modeBindings.forEach((listener) => listener());\n  };\n}\nfunction subscribeFileLinks(sessionId: string | null, listener: () => void): () => void {\n  let unsubscribeModes = fileLinkModes?.subscribe(sessionId, listener);\n  const rebindModes = () => {\n    unsubscribeModes?.();\n    unsubscribeModes = fileLinkModes?.subscribe(sessionId, listener);\n    listener();\n  };\n  modeBindings.add(rebindModes);\n  let subscriptions: (() => void)[] = [];\n  const unsubscribeSources = (): void => {\n    subscriptions.forEach((unsubscribe) => unsubscribe());\n    subscriptions = [];\n  };\n  const subscribeSources = (): void => {\n    subscriptions = pluginFileLinks().map((source) => source.subscribe(listener));\n  };\n  subscribeSources();\n  const unsubscribeRegistry = subscribeWebPluginRegistry(() => {\n    unsubscribeSources();\n    subscribeSources();\n    listener();\n  });\n  return () => {\n    modeBindings.delete(rebindModes);\n    unsubscribeModes?.();\n    unsubscribeRegistry();\n    unsubscribeSources();\n  };\n}\n\nfunction activeFileLinkSources(sessionId: string | null) {\n  const enabled = new Set(fileLinkModes?.active(sessionId) ?? []);\n  return pluginFileLinks(sessionId).filter(\n    (source) => source.requiredMode === undefined || enabled.has(source.requiredMode),\n  );\n}\n\nfunction fileLinkFingerprint(sessionId: string | null): string {\n  const sourceFingerprints = activeFileLinkSources(sessionId)\n    .map((source) => `${source.requiredMode ?? ''}:${source.fingerprint(sessionId)}`)\n    .join('\\n');\n  return `${webPluginRegistryRevision()}:${sourceFingerprints}`;\n}\n\n/**\n * The tab a path opens, from the first source that claims it.\n *\n * A path no source claims is not a link. The host cannot tell a file name from\n * a class name, and the plugin that tracks the session's files can, so the\n * decision belongs there rather than in a heuristic here.\n */\nexport function fileLinkFor(sessionId: string | null, path: string): TransientTab | undefined {\n  for (const source of activeFileLinkSources(sessionId)) {\n    const tab = source.resolve(sessionId, path);\n    if (tab !== undefined) return tab;\n  }\n  return undefined;\n}\n\n/** References plugins that own a path namespace offer for an `@` being typed, such as `artifact:plan.md`. */\nexport function fileLinkMentions(sessionId: string, query: string): FileLinkMention[] {\n  return activeFileLinkSources(sessionId).flatMap((source) => source.mentions?.(sessionId, query) ?? []);\n}\n\n/**\n * The tab a path the caller is sure about opens: a tool call's path argument,\n * not a token spotted in prose.\n *\n * A source that offers `openPath` answers here, and it may claim a file the\n * session never changed, which `resolve` deliberately will not. Sources\n * without it fall back to the same guess prose gets.\n */\nexport function fileTabForPath(sessionId: string | null, path: string): TransientTab | undefined {\n  for (const source of activeFileLinkSources(sessionId)) {\n    const tab = source.openPath?.(sessionId, path) ?? source.resolve(sessionId, path);\n    if (tab !== undefined) return tab;\n  }\n  return undefined;\n}\n/**\n * Resolves the paths a message names against the plugins that track them.\n *\n * The resolver's identity is stable while the linkable set is, so a component\n * that hands it to a renderer does not rebuild that renderer on every frame of\n * a streaming reply.\n */\nexport function useFileLinks(sessionId: string | null): FileLinkResolver {\n  const fingerprint = useSyncExternalStore(\n    useCallback((listener: () => void) => subscribeFileLinks(sessionId, listener), [sessionId]),\n    () => fileLinkFingerprint(sessionId),\n    () => fileLinkFingerprint(sessionId),\n  );\n  return useCallback(\n    (path: string) => fileLinkFor(sessionId, path),\n    // The fingerprint is the dependency: the same path resolves differently\n    // once the session's set of tracked files changes.\n    // eslint-disable-next-line react-hooks/exhaustive-deps -- fingerprint is a deliberate identity buster, not a value the callback reads.\n    [sessionId, fingerprint],\n  );\n}\n"],"mappings":";;;;;AAiCA,MAAM,sBAAsB;;;;;;;AAQ5B,MAAa,0BAAgE,CAC3E;CAAE,MAAM;CAAW,SAAS;CAAW,WAAW;CAAc,YAAY;CAAQ,OAAO;AAAG,GAC9F;CAAE,MAAM;CAAW,SAAS;CAAW,WAAW;CAAa,YAAY;CAAc,OAAO;CAAM,OAAO;AAAG,CAClH;;;;;;AAOA,SAAgB,cAAc,UAAmD;CAC/E,MAAM,WAAWA,uBAAAA,oBAAoB;CAErC,QADsD,SAAS,SAAS,IAAI,WAAW,wBAAA,CACxE,SAAS,WAAW;EACjC,MAAM,MAAM,SAAS,OAAO;EAC5B,IAAI,QAAQ,KAAA,GAAW,OAAO,CAAC;EAC/B,MAAM,QAAQ,OAAO,UAAU;EAC/B,MAAM,UAAU,QAAQC,mBAAAA,UAAU,GAAG,CAAC,CAAC,MAAM,mBAAmB,IAAI,CAACA,mBAAAA,UAAU,GAAG,CAAC,EAAA,CAChF,KAAK,UAAU,MAAM,KAAK,CAAC,CAAC,CAC5B,OAAO,OAAO;EACjB,OAAO,CAAC;GAAE,MAAM,OAAO;GAAM,SAAS,OAAO;GAAS;GAAQ,YAAY,OAAO;GAAY;EAAM,CAAC;CACtG,CAAC;AACH;;;;;;;;;;;AAqDA,MAAa,iBAAwC;CACnD;EAAE,MAAM;EAAQ,MAAM;CAAM;CAC5B;EAAE,MAAM;EAAQ,MAAM;EAAO,WAAW;CAAY;CACpD;EAAE,MAAM;EAAQ,MAAM;EAAO,WAAW;CAAO;CAE/C;EAAE,MAAM;EAAS,QAAQ;EAAc,MAAM;EAAO,WAAW;CAAW;CAC1E;EACE,MAAM;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACX,iBAAiB;CACnB;AACF;;AAGA,SAAS,UAAU,QAAsE;CACvF,OA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