@copilotkit/web-components 2.0.0-rc.3 → 2.0.0-rc.30

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.
@@ -1 +1 @@
1
- {"version":3,"file":"copilotkit-threads-drawer.mjs","names":[],"sources":["../../src/threads-drawer/copilotkit-threads-drawer.ts"],"sourcesContent":["import { LitElement, html, nothing } from \"lit\";\nimport type { PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { drawerStyles } from \"./styles\";\nimport type { DrawerFilter, DrawerThread, LicensedDetail } from \"./types\";\n\n/** Tag name the element registers under. */\nexport const COPILOTKIT_THREADS_DRAWER_TAG =\n \"copilotkit-threads-drawer\" as const;\n\n/** Mobile breakpoint (px). At or below this width the drawer is a modal overlay. */\nconst MOBILE_BREAKPOINT = 768;\n\n/**\n * Whether an inbound error message should surface an error state. Only a\n * non-empty, non-whitespace string counts — `null`, `\"\"`, and whitespace-only\n * strings are treated as \"no error\" so an empty error never conflates with a\n * real one (and never blanks the list behind an empty error panel).\n */\nfunction hasErrorMessage(value: string | null): value is string {\n return value !== null && value.trim().length > 0;\n}\n\n/**\n * Builds the per-row slot name (`row:<id>`) used for consumer projection, but\n * only when the thread id is safe to embed in a slot `name` / `slot` attribute\n * token. A slot name is matched character-for-character against the consumer's\n * `slot=\"...\"` attribute; whitespace splits attribute tokens and quotes/angle\n * brackets can break attribute serialization, so an id containing any of those\n * would silently fail projection. For such an id we return `null` and the row\n * renders its default name span (no per-row slot), which is the safe fallback.\n */\nfunction rowSlotName(id: string): string | null {\n // Reject whitespace and characters that are unsafe in an HTML attribute token.\n if (id.length === 0 || /[\\s\"'<>=]/.test(id)) return null;\n return `row:${id}`;\n}\n\n/**\n * Inline row-action icons. The element is framework-agnostic Lit, so it cannot\n * depend on a React icon library — these are the lucide `archive`,\n * `archive-restore`, and `trash-2` glyphs inlined as SVG, drawn with\n * `currentColor` so they inherit the button's themed color.\n */\nconst iconArchive = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"20\" height=\"5\" x=\"2\" y=\"3\" rx=\"1\" />\n <path d=\"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8\" />\n <path d=\"M10 12h4\" />\n </svg>\n`;\nconst iconUnarchive = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"20\" height=\"5\" x=\"2\" y=\"3\" rx=\"1\" />\n <path d=\"M4 8v11a2 2 0 0 0 2 2h2\" />\n <path d=\"M20 8v11a2 2 0 0 1-2 2h-2\" />\n <path d=\"m9 15 3-3 3 3\" />\n <path d=\"M12 12v9\" />\n </svg>\n`;\nconst iconDelete = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 6h18\" />\n <path\n d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"\n />\n <line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\" />\n <line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\" />\n </svg>\n`;\n// Sidebar/panel glyph (the Figma toggle icon). Used for the desktop collapse\n// toggle, the desktop collapsed cluster's expand toggle, the mobile launcher\n// (open), and the mobile header dismiss (close) — the toggle glyph is identical\n// in every state, matching the Figma.\nconst iconSidebar = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" />\n <path d=\"M9 3v18\" />\n </svg>\n`;\n\n/**\n * Header / control icons for the redesigned drawer chrome (ENT-1051). Inlined\n * lucide glyphs (`square-plus`, `filter`, `ellipsis-vertical`) drawn with\n * `currentColor` so they inherit the button's themed color — the element cannot\n * depend on a React icon library.\n */\nconst iconPlusSquare = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" />\n <path d=\"M8 12h8\" />\n <path d=\"M12 8v8\" />\n </svg>\n`;\nconst iconFunnel = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"3\" y1=\"5\" x2=\"21\" y2=\"5\" />\n <line x1=\"6\" y1=\"12\" x2=\"18\" y2=\"12\" />\n <line x1=\"10\" y1=\"19\" x2=\"14\" y2=\"19\" />\n </svg>\n`;\nconst iconKebab = html`\n <svg class=\"icon\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"5\" r=\"1.6\" />\n <circle cx=\"12\" cy=\"12\" r=\"1.6\" />\n <circle cx=\"12\" cy=\"19\" r=\"1.6\" />\n </svg>\n`;\n\n/**\n * `<copilotkit-threads-drawer>` — a public, self-contained, controlled, framework-agnostic\n * threads drawer rendered into a shadow root.\n *\n * Pure VIEW: domain data (threads/loading/error/etc.) comes IN as properties and\n * user intent goes OUT as bubbling+composed DOM `CustomEvent`s. The element owns\n * VIEW state (open, Active/All filter, confirm-delete dialog, per-row\n * animations) while the consumer owns DOMAIN state. `open` is additionally\n * externally controllable via the `open` property + `open-change` event so a\n * host can coordinate mobile open/close.\n *\n * The element is AUTHORITATIVE over row order and the Active/All filter.\n */\nexport class CopilotKitThreadsDrawer extends LitElement {\n static styles = drawerStyles;\n\n static properties = {\n // Inbound domain properties.\n threads: { attribute: false },\n loading: { type: Boolean },\n error: { type: String },\n activeThreadId: { attribute: \"active-thread-id\", type: String },\n licensed: { type: Boolean },\n licenseUrl: { attribute: \"license-url\", type: String },\n hasMore: { attribute: \"has-more\", type: Boolean },\n fetchingMore: { attribute: \"fetching-more\", type: Boolean },\n fetchMoreError: { attribute: \"fetch-more-error\", type: String },\n // Inbound: configurable label for the drawer region and default header.\n label: { type: String },\n // Inbound: configurable \"Recent Conversations\" section heading text.\n recentLabel: { attribute: \"recent-label\", type: String },\n collapsible: { type: Boolean },\n // Externally-controllable VIEW state.\n open: { type: Boolean, reflect: true },\n collapsed: { type: Boolean, reflect: true },\n // Internal VIEW state.\n _filter: { state: true },\n _confirmingDeleteId: { state: true },\n _viewportIsMobile: { state: true },\n _hasHeader: { state: true },\n _hasMemories: { state: true },\n _hasFooter: { state: true },\n _filterOpen: { state: true },\n _openMenuId: { state: true },\n };\n\n /**\n * Inbound: accessible label for the drawer region — drives the screen-reader\n * region name (on `.root`) and the listbox name (on `.list`) ONLY. The\n * redesign has no visible title; project visible header chrome via the\n * optional `header` slot instead. Defaults to `\"Threads\"`.\n */\n label = \"Threads\";\n\n /**\n * Inbound: text for the \"Recent Conversations\" section heading above the list.\n * Attribute: `recent-label`. Defaults to `\"Recent Conversations\"`.\n */\n recentLabel = \"Recent Conversations\";\n\n /** Inbound: thread records to render. The element re-orders/filters them. */\n threads: DrawerThread[] = [];\n /** Inbound: initial-fetch loading flag. */\n loading = false;\n /** Inbound: initial-fetch error message (actionable Retry shown when set). */\n error: string | null = null;\n /** Inbound: currently-open thread id (drives row selection highlight). */\n activeThreadId: string | null = null;\n /** Inbound: whether the org is licensed for threads; `false` shows the locked view. */\n licensed = true;\n /**\n * Inbound: destination the Upgrade CTA opens (new tab) when the locked view's\n * default button is clicked. Defaults to the CopilotKit Intelligence docs.\n * Set to an empty string to suppress the default navigation and rely solely\n * on the `licensed` event.\n */\n licenseUrl = \"https://docs.copilotkit.ai/intelligence\";\n /** Inbound: whether more pages are available. */\n hasMore = false;\n /** Inbound: whether a fetch-more is in flight. */\n fetchingMore = false;\n /** Inbound: fetch-more error message (inline, list preserved). */\n fetchMoreError: string | null = null;\n\n /**\n * Externally-controllable: whether the drawer is open (mobile coordination).\n * Defaults to `false` so a mobile-width first render does NOT paint the open\n * modal (backdrop + body scroll-lock + focus steal) for one frame before a\n * wrapper's post-mount effect can close it. Desktop is unaffected — only\n * `.root.mobile.open` / `_isMobileModalOpen()` consume `open`.\n */\n open = false;\n /**\n * Externally-controllable: whether the drawer is collapsed to the floating\n * cluster on desktop. Defaults to `false` (expanded). Reflected so hosts can\n * theme on `[collapsed]`. Ignored on mobile, where open/closed governs the\n * off-canvas modal instead.\n */\n collapsed = false;\n /**\n * Inbound: whether the user may collapse the drawer on desktop. Defaults to\n * `true`. When `false` the header omits the collapse toggle and the drawer\n * NEVER renders the collapsed cluster on desktop (it stays expanded even if\n * `collapsed` is set) — mobile off-canvas open/close is independent.\n */\n collapsible = true;\n\n private _filter: DrawerFilter = \"active\";\n private _confirmingDeleteId: string | null = null;\n private _viewportIsMobile = false;\n private _hasHeader = false;\n private _hasMemories = false;\n private _hasFooter = false;\n /** Whether the funnel filter popover (Active/All) is open. */\n private _filterOpen = false;\n /** Id of the row whose kebab actions menu is open (only one at a time). */\n private _openMenuId: string | null = null;\n\n private _mediaQuery: MediaQueryList | null = null;\n private readonly _onMediaChange = (event: MediaQueryListEvent) => {\n this._viewportIsMobile = event.matches;\n };\n private readonly _onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n if (this._openMenuId !== null) {\n this._openMenuId = null;\n event.stopPropagation();\n return;\n }\n if (this._filterOpen) {\n this._filterOpen = false;\n event.stopPropagation();\n return;\n }\n // The confirm-delete <dialog> is opened with showModal(): the browser\n // dismisses it natively via the dialog's `cancel` event. But that Escape\n // keydown still bubbles from the modal to this host handler, so we must\n // stop here — otherwise it falls through to the mobile branch below and\n // closes the whole drawer along with the confirmation.\n if (this._confirmingDeleteId !== null) {\n event.stopPropagation();\n return;\n }\n if (this._viewportIsMobile && this.open) {\n this._setOpen(false);\n event.stopPropagation();\n }\n return;\n }\n // Tab focus-trap for the mobile modal. Handled at the HOST (not on `.root`)\n // so it fires wherever focus sits in the shadow root — including the\n // backdrop button, which renders as a sibling OUTSIDE `.root`. A trap bound\n // only to `.root` lets Tab from the backdrop (or any out-of-root node)\n // escape the modal to the page behind it.\n if (event.key === \"Tab\") {\n this._trapTab(event);\n }\n };\n\n /**\n * Dismisses the funnel filter popover and/or an open row-actions menu when a\n * pointerdown lands outside them. Bound to `document` (composed events bubble\n * out of the shadow root), so we discriminate inside vs. outside via\n * `composedPath()` rather than target identity. A click on a popover's own\n * trigger is treated as \"inside\" so its own `@click` toggle handles the close\n * (avoids a double-toggle that would immediately reopen it).\n */\n private readonly _onDocumentPointerDown = (event: Event) => {\n if (!this._filterOpen && this._openMenuId === null) return;\n const path = event.composedPath();\n if (this._filterOpen) {\n const popover = this.renderRoot.querySelector('[part=\"filters\"]');\n const trigger = this.renderRoot.querySelector('[part=\"filter-toggle\"]');\n const inside =\n (popover && path.includes(popover)) ||\n (trigger && path.includes(trigger));\n if (!inside) this._filterOpen = false;\n }\n if (this._openMenuId !== null) {\n const popover = this.renderRoot.querySelector(\n '[part=\"row-menu-popover\"]',\n );\n const trigger = this.renderRoot.querySelector(\n '.row.menu-open [part=\"row-menu\"]',\n );\n const inside =\n (popover && path.includes(popover)) ||\n (trigger && path.includes(trigger));\n if (!inside) this._openMenuId = null;\n }\n };\n\n /** Thread ids previously seen as named, so we can animate the null→named reveal. */\n private readonly _seenNamed = new Set<string>();\n /** Thread ids whose name just transitioned null→named in this update cycle. */\n private _justRevealed = new Set<string>();\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (typeof window !== \"undefined\" && window.matchMedia) {\n this._mediaQuery = window.matchMedia(\n `(max-width: ${MOBILE_BREAKPOINT}px)`,\n );\n this._viewportIsMobile = this._mediaQuery.matches;\n this._mediaQuery.addEventListener(\"change\", this._onMediaChange);\n }\n this.addEventListener(\"keydown\", this._onKeyDown);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"pointerdown\", this._onDocumentPointerDown);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._mediaQuery?.removeEventListener(\"change\", this._onMediaChange);\n this.removeEventListener(\"keydown\", this._onKeyDown);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"pointerdown\", this._onDocumentPointerDown);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"scroll\", this._repositionConfirm, true);\n window.removeEventListener(\"resize\", this._repositionConfirm);\n }\n // Release the reserved-width override we may have set on the document root.\n if (typeof document !== \"undefined\") {\n document.documentElement.style.removeProperty(\n \"--cpk-drawer-reserved-width\",\n );\n }\n this._releaseScrollLock();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n // Compute the null→named reveal set BEFORE render, so render stays pure.\n if (changed.has(\"threads\")) {\n const presentIds = new Set<string>();\n const revealed = new Set<string>();\n for (const thread of this.threads) {\n presentIds.add(thread.id);\n const hasName = thread.name !== null && thread.name !== \"\";\n if (hasName && !this._seenNamed.has(thread.id)) {\n revealed.add(thread.id);\n }\n if (hasName) this._seenNamed.add(thread.id);\n }\n // Prune ids no longer present so `_seenNamed` cannot grow without bound\n // across a long-lived, high-churn session.\n for (const id of this._seenNamed) {\n if (!presentIds.has(id)) this._seenNamed.delete(id);\n }\n this._justRevealed = revealed;\n\n // Auto-dismiss a pending confirm-delete whose target is no longer in the\n // visible threads (the consumer removed/archived/filtered it away while\n // the dialog was open). Without this the dialog could emit `delete` with a\n // stale id. Reconciled against the SAME visible set the user is acting on.\n if (this._confirmingDeleteId !== null) {\n const stillVisible = this._visibleThreads().some(\n (t) => t.id === this._confirmingDeleteId,\n );\n if (!stillVisible) this._confirmingDeleteId = null;\n }\n\n // Same reconciliation for an open row-actions menu: if the row whose\n // kebab menu is open is no longer visible (removed/archived/filtered\n // away), close the menu so it cannot linger detached from any row.\n if (this._openMenuId !== null) {\n const stillVisible = this._visibleThreads().some(\n (t) => t.id === this._openMenuId,\n );\n if (!stillVisible) this._openMenuId = null;\n }\n }\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n // Scroll-lock is a mobile-modal concern only.\n if (\n changed.has(\"open\") ||\n changed.has(\"_viewportIsMobile\" as keyof CopilotKitThreadsDrawer)\n ) {\n if (this._isMobileModalOpen()) {\n this._applyScrollLock();\n this._focusFirstFocusable();\n } else {\n this._releaseScrollLock();\n }\n }\n\n // Reclaim the reserved layout column when the desktop collapse state (or the\n // viewport) changes.\n if (\n changed.has(\"collapsed\") ||\n changed.has(\"collapsible\") ||\n changed.has(\"_viewportIsMobile\" as keyof CopilotKitThreadsDrawer)\n ) {\n this._syncReservedWidth();\n }\n\n // Drive the native top-layer <dialog> from the confirm state. Opening with\n // showModal() places it in the browser top layer (above every stacking\n // context) so it is never clipped; we then re-center it over the drawer\n // panel via _positionConfirmDialog(). Feature-detect showModal/close because\n // jsdom implements neither — fall back to toggling the `open` attribute so\n // unit tests still observe the open/closed state.\n const dialog = this.renderRoot.querySelector(\"dialog\");\n if (dialog) {\n const id = this._confirmingDeleteId;\n if (id !== null && !dialog.open) {\n typeof dialog.showModal === \"function\"\n ? dialog.showModal()\n : dialog.setAttribute(\"open\", \"\");\n this._positionConfirmDialog();\n window.addEventListener(\"scroll\", this._repositionConfirm, true);\n window.addEventListener(\"resize\", this._repositionConfirm);\n } else if (id === null && dialog.open) {\n typeof dialog.close === \"function\"\n ? dialog.close()\n : dialog.removeAttribute(\"open\");\n window.removeEventListener(\"scroll\", this._repositionConfirm, true);\n window.removeEventListener(\"resize\", this._repositionConfirm);\n }\n }\n\n // The reveal animation fires exactly once per real name-arrival. Clearing\n // the set after the render that applied the `revealed` class prevents any\n // later, unrelated re-render from re-adding the class and re-firing the\n // animation. `_justRevealed` is a plain field (not reactive), so resetting\n // it here does not schedule another update.\n if (this._justRevealed.size > 0) {\n this._justRevealed = new Set<string>();\n }\n }\n\n // --- View-state helpers ----------------------------------------------------\n\n private _isMobileModalOpen(): boolean {\n return this._viewportIsMobile && this.open;\n }\n\n private _setOpen(next: boolean): void {\n if (this.open === next) return;\n this.open = next;\n this._emit(\"open-change\", { open: next });\n }\n\n private _setCollapsed(next: boolean): void {\n if (this.collapsed === next) return;\n this.collapsed = next;\n this._emit(\"collapse-change\", { collapsed: next });\n }\n\n /**\n * Signal the drawer's reserved layout width to the host so a desktop collapse\n * reclaims the column instead of leaving an empty gap. On desktop-collapse we\n * set `--cpk-drawer-reserved-width: 0px` on the document root; a host whose\n * grid reads `grid-template-columns: var(--cpk-drawer-reserved-width, 320px) …`\n * inherits it and collapses the track (with its own transition). Expanded/mobile\n * clears the override so the host's fallback width applies — which also means\n * the default (expanded) render never sets it, so there is no hydration flicker.\n *\n * It is set on `document.documentElement` (not `parentElement`) BECAUSE the\n * element is nested inside a framework wrapper host, so its parent is the\n * wrapper — not the grid container, which is an ancestor a child's custom\n * property can't reach. `:root` inheritance reaches the grid regardless of\n * wrapper nesting. Best-effort + namespaced, single-drawer-per-document; a host\n * with multiple drawers or a custom layout should instead react to the\n * `collapse-change` event.\n */\n private _syncReservedWidth(): void {\n if (typeof document === \"undefined\") return;\n const desktopCollapsed =\n this.collapsible && this.collapsed && !this._viewportIsMobile;\n const root = document.documentElement;\n if (desktopCollapsed) {\n root.style.setProperty(\"--cpk-drawer-reserved-width\", \"0px\");\n } else {\n root.style.removeProperty(\"--cpk-drawer-reserved-width\");\n }\n }\n\n /**\n * Center the confirm-delete <dialog> over the drawer PANEL's on-screen box\n * (not the viewport). The dialog stays a top-layer `showModal()` element so it\n * is never clipped, but we drive its center via `--confirm-cx/cy` measured\n * from the visible `.root` rect — so it reads as \"inside the drawer\" per the\n * ENT-1051 design while keeping the top-layer robustness. Falls back to\n * viewport-center (the CSS default) when the panel isn't measurable\n * (SSR/jsdom).\n */\n private _positionConfirmDialog(): void {\n const dialog = this.renderRoot.querySelector<HTMLDialogElement>(\"dialog\");\n const root = this.renderRoot.querySelector<HTMLElement>(\".root\");\n if (!dialog) return;\n const rect = root?.getBoundingClientRect();\n if (!rect || (rect.width === 0 && rect.height === 0)) {\n dialog.style.removeProperty(\"--confirm-cx\");\n dialog.style.removeProperty(\"--confirm-cy\");\n return;\n }\n // Center over the drawer's VISIBLE box (its rect intersected with the\n // viewport), not the raw rect: a host grid that doesn't bound the drawer's\n // row lets `.root` grow to content height, so a raw-rect center would land\n // far down the page. Intersecting with the viewport keeps the modal centered\n // in the on-screen drawer band regardless of how the host sizes the panel.\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const visLeft = Math.max(rect.left, 0);\n const visRight = Math.min(rect.right, vw);\n const visTop = Math.max(rect.top, 0);\n const visBottom = Math.min(rect.bottom, vh);\n dialog.style.setProperty(\"--confirm-cx\", `${(visLeft + visRight) / 2}px`);\n dialog.style.setProperty(\"--confirm-cy\", `${(visTop + visBottom) / 2}px`);\n }\n\n /** Bound reposition handler for scroll/resize while the confirm dialog is open. */\n private _repositionConfirm = () => this._positionConfirmDialog();\n\n private _setFilter(next: DrawerFilter): void {\n if (this._filter === next) return;\n this._filter = next;\n this._emit(\"filter-change\", { filter: next });\n }\n\n /**\n * Element-authoritative ordering + filtering. Active filter hides archived\n * threads; ordering is most-recent-first by `lastRunAt`/`updatedAt`.\n */\n private _visibleThreads(): DrawerThread[] {\n const filtered =\n this._filter === \"active\"\n ? this.threads.filter((t) => !t.archived)\n : this.threads;\n // Parse to a timestamp; a malformed/absent value yields `null` (NOT epoch 0)\n // so bad data is never silently treated as 1970. Threads with a valid\n // timestamp sort most-recent-first; threads with no parseable timestamp\n // keep their incoming relative order and sort after the dated ones.\n const ts = (t: DrawerThread): number | null => {\n const raw = t.lastRunAt ?? t.updatedAt ?? t.createdAt;\n const parsed = Date.parse(raw);\n return Number.isNaN(parsed) ? null : parsed;\n };\n return [...filtered]\n .map((thread, index) => ({ thread, index, ts: ts(thread) }))\n .sort((a, b) => {\n if (a.ts === null && b.ts === null) return a.index - b.index;\n if (a.ts === null) return 1;\n if (b.ts === null) return -1;\n if (a.ts !== b.ts) return b.ts - a.ts;\n return a.index - b.index;\n })\n .map((entry) => entry.thread);\n }\n\n private _emit<T>(type: string, detail: T): void {\n this.dispatchEvent(\n new CustomEvent(type, { detail, bubbles: true, composed: true }),\n );\n }\n\n // --- Scroll lock + focus (mobile modal only) -------------------------------\n\n private _scrollLocked = false;\n private _prevBodyOverflow = \"\";\n\n private _applyScrollLock(): void {\n if (this._scrollLocked || typeof document === \"undefined\") return;\n this._prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this._scrollLocked = true;\n }\n\n private _releaseScrollLock(): void {\n if (!this._scrollLocked || typeof document === \"undefined\") return;\n document.body.style.overflow = this._prevBodyOverflow;\n this._scrollLocked = false;\n }\n\n /**\n * Returns the focusable elements in the composed/flattened tree of the drawer\n * root, INCLUDING slotted light-DOM content (so a focus trap covers slotted\n * rows). Walks assigned nodes of each `<slot>`.\n */\n private _composedFocusable(): HTMLElement[] {\n const selector =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n const out: HTMLElement[] = [];\n // The backdrop button is a modal-owned focusable rendered as a sibling of\n // `.root`. Include it first (it precedes `.root` in DOM order) so the focus\n // trap treats it as part of the modal's cycle rather than an escape hatch.\n const backdrop = this.renderRoot.querySelector<HTMLElement>(\".backdrop\");\n if (backdrop) out.push(backdrop);\n const root = this.renderRoot.querySelector(\".root\");\n if (!root) return out;\n const collect = (node: ParentNode) => {\n node\n .querySelectorAll<HTMLElement>(selector)\n .forEach((el) => out.push(el));\n };\n collect(root);\n root.querySelectorAll(\"slot\").forEach((slot) => {\n (slot as HTMLSlotElement)\n .assignedElements({ flatten: true })\n .forEach((assigned) => {\n if (assigned.matches(selector)) out.push(assigned as HTMLElement);\n collect(assigned);\n });\n });\n return out;\n }\n\n private _focusFirstFocusable(): void {\n // Defer so the rendered tree exists.\n queueMicrotask(() => {\n const focusable = this._composedFocusable();\n // Prefer the first real control over the backdrop scrim so opening the\n // modal lands focus on actionable content, not the close-on-click overlay\n // (the backdrop is still part of the trap cycle below).\n const backdrop = this.renderRoot.querySelector(\".backdrop\");\n const target = focusable.find((el) => el !== backdrop) ?? focusable[0];\n target?.focus();\n });\n }\n\n private readonly _trapTab = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\" || !this._isMobileModalOpen()) return;\n const focusable = this._composedFocusable();\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n const active =\n (this.renderRoot as ShadowRoot).activeElement ?? document.activeElement;\n if (event.shiftKey && active === first) {\n last.focus();\n event.preventDefault();\n } else if (!event.shiftKey && active === last) {\n first.focus();\n event.preventDefault();\n }\n };\n\n // --- Render ----------------------------------------------------------------\n\n override render() {\n // Collapsed to the floating cluster on desktop (gated on `collapsible`), OR\n // closed on mobile — both show the same launcher cluster and hide the panel\n // body. Mobile keeps the body rendered (off-canvas, ready to slide in);\n // desktop-collapsed omits it entirely so the reserved column can reclaim.\n const desktopCollapsed =\n this.collapsible && this.collapsed && !this._viewportIsMobile;\n const mobileClosed = this._viewportIsMobile && !this.open;\n const showCluster = desktopCollapsed || mobileClosed;\n const rootClasses = {\n root: true,\n mobile: this._viewportIsMobile,\n open: this.open,\n collapsed: desktopCollapsed,\n };\n\n return html`\n ${showCluster ? this._renderCluster() : nothing}\n ${\n this._isMobileModalOpen()\n ? html`<button\n class=\"backdrop\"\n part=\"backdrop\"\n aria-label=\"Close threads drawer\"\n @click=${() => this._setOpen(false)}\n ></button>`\n : nothing\n }\n <div\n class=${classMap(rootClasses)}\n part=\"root\"\n role=${this._isMobileModalOpen() ? \"dialog\" : \"region\"}\n aria-modal=${this._isMobileModalOpen() ? \"true\" : nothing}\n aria-hidden=${desktopCollapsed ? \"true\" : nothing}\n aria-label=${this.label}\n >\n ${\n desktopCollapsed\n ? nothing\n : html`${this._renderHeader()} ${this._renderBody()}\n ${this._renderMemories()} ${this._renderFooter()}\n ${this._renderConfirmDialog()}`\n }\n </div>\n `;\n }\n\n /**\n * Floating launcher cluster from the Figma \"closed\" mockup: a sidebar-glyph\n * toggle + a \"New Conversation\" (+) icon button. Shown in TWO states — the\n * mobile closed state (toggle opens the off-canvas modal) and the desktop\n * collapsed state (toggle expands the sidebar). The primary toggle keeps\n * `part=\"launcher\"` for mobile-launcher theme compat; the new-thread button is\n * suppressed in the locked/unlicensed view, mirroring the New Conversation row.\n */\n private _renderCluster() {\n const onToggle = this._viewportIsMobile\n ? () => this._setOpen(true)\n : () => this._setCollapsed(false);\n const toggleLabel = this._viewportIsMobile\n ? \"Open threads\"\n : \"Expand threads\";\n return html`\n <div class=\"launcher-cluster\" part=\"launcher-cluster\">\n <button\n class=\"launcher\"\n part=\"launcher\"\n aria-label=${toggleLabel}\n @click=${onToggle}\n >\n <slot name=\"launcher-icon\">${iconSidebar}</slot>\n </button>\n ${\n this.licensed\n ? html`<button\n class=\"launcher launcher-new-thread\"\n part=\"launcher-new-thread\"\n aria-label=\"New Conversation\"\n @click=${() => this._emit(\"new-thread\", {})}\n >\n ${iconPlusSquare}\n </button>`\n : nothing\n }\n </div>\n `;\n }\n\n private _renderHeader() {\n // The header is a reserved consumer-projection surface with no built-in\n // controls (search and the desktop collapse toggle were both removed), so\n // it stays hidden until a consumer projects `slot=\"header\"` content — a\n // `slotchange` listener drives `_hasHeader`, mirroring the memories/footer\n // gating. Without this gate the empty padded header bar would render above\n // the \"New Conversation\" row. The \"New Conversation\" row is suppressed in\n // the locked/unlicensed view (only the Upgrade panel shows), mirroring the\n // section-heading gating.\n // On mobile the drawer is an off-canvas modal, so it needs an in-header\n // close affordance (desktop is a persistent sidebar — nothing to close).\n // The header therefore also renders when the mobile modal is open, even\n // with no projected `slot=\"header\"` content.\n const showMobileClose = this._viewportIsMobile && this.open;\n // Desktop collapse toggle: always available on desktop when collapsing is\n // permitted, so the header renders on desktop even with no projected\n // `slot=\"header\"` content. Mobile uses the launcher/close affordances.\n const showCollapseToggle = this.collapsible && !this._viewportIsMobile;\n return html`\n <div\n class=\"header\"\n part=\"header\"\n ?hidden=${!this._hasHeader && !showMobileClose && !showCollapseToggle}\n >\n <slot\n name=\"header\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasHeader = slot.assignedElements().length > 0;\n }}\n ></slot>\n ${\n // Toggle sits at the END so it right-aligns (the projected header slot\n // has flex:1 and pushes it over) — matching the mobile close button.\n showCollapseToggle\n ? html`<button\n class=\"icon-btn\"\n part=\"collapse-toggle\"\n aria-label=\"Collapse threads\"\n @click=${() => this._setCollapsed(true)}\n >\n ${iconSidebar}\n </button>`\n : nothing\n }\n ${\n showMobileClose\n ? html`<button\n class=\"icon-btn\"\n part=\"close-toggle\"\n aria-label=\"Close threads\"\n @click=${() => this._setOpen(false)}\n >\n ${iconSidebar}\n </button>`\n : nothing\n }\n </div>\n ${this.licensed ? this._renderNewConversation() : nothing}\n ${this._renderSectionHeading()}\n `;\n }\n\n /**\n * Dedicated full-width \"New Conversation\" row. Keeps `part=\"new-thread-button\"`\n * and fires the existing `new-thread` event, so wrappers/themes that hook the\n * old header pill are unaffected.\n */\n private _renderNewConversation() {\n return html`\n <button\n class=\"new-conversation\"\n part=\"new-thread-button\"\n @click=${() => this._emit(\"new-thread\", {})}\n >\n ${iconPlusSquare}\n <span>New Conversation</span>\n </button>\n `;\n }\n\n /**\n * \"Recent Conversations\" section heading with a funnel button that opens the\n * Active/All filter popover. Only shown when the list region is shown\n * (licensed, and not the full-panel error/empty-before-load) — mirrors the\n * old filters gate. The popover options keep `part=\"filter-active\"` /\n * `part=\"filter-all\"` and still emit `filter-change` via `_setFilter`.\n */\n private _renderSectionHeading() {\n if (\n !this.licensed ||\n (hasErrorMessage(this.error) && this.threads.length === 0)\n ) {\n return nothing;\n }\n return html`\n <div class=\"section-heading\" part=\"section-heading\">\n <span class=\"section-title\">${this.recentLabel}</span>\n <button\n class=\"icon-btn small\"\n part=\"filter-toggle\"\n aria-label=\"Filter threads\"\n aria-expanded=${this._filterOpen}\n @click=${() => (this._filterOpen = !this._filterOpen)}\n >\n ${iconFunnel}\n ${\n // \"Filter applied\" indicator dot — shown whenever the active filter\n // is not the default (\"active\"), matching the Figma's archived view.\n this._filter !== \"active\"\n ? html`\n <span class=\"filter-dot\" part=\"filter-indicator\"></span>\n `\n : nothing\n }\n </button>\n ${\n this._filterOpen\n ? html`<div\n class=\"filter-popover\"\n part=\"filters\"\n role=\"group\"\n aria-label=\"Filter threads\"\n >\n <button\n class=\"filter-opt\"\n part=\"filter-active\"\n aria-pressed=${this._filter === \"active\"}\n @click=${() => {\n this._setFilter(\"active\");\n this._filterOpen = false;\n }}\n >\n Active\n </button>\n <button\n class=\"filter-opt\"\n part=\"filter-all\"\n aria-pressed=${this._filter === \"all\"}\n @click=${() => {\n this._setFilter(\"all\");\n this._filterOpen = false;\n }}\n >\n All\n </button>\n </div>`\n : nothing\n }\n </div>\n `;\n }\n\n private _renderBody() {\n // The locked view beats error: an unlicensed org always sees it, never the\n // initial-fetch error.\n if (!this.licensed) return this._renderLicensed();\n // The full-panel error replaces the list ONLY when there is nothing to show\n // (a failed initial fetch). The bound `error` reflects the core store error,\n // which a failed mutation (delete/rename/archive) also sets — a delete\n // rollback restores its row, so when threads are still present we keep the\n // list visible rather than blanking it behind a \"couldn't load\" panel.\n if (hasErrorMessage(this.error) && this.threads.length === 0) {\n return this._renderError();\n }\n // Full-panel loading only when there is nothing to show yet (initial fetch).\n // A refetch (e.g. filter toggle Active<->All) keeps `loading` true while the\n // list is already populated — keep showing the known threads rather than\n // flashing the loading state over them.\n if (this.loading && this.threads.length === 0) return this._renderLoading();\n return this._renderList();\n }\n\n /**\n * Handles the Upgrade CTA click in the locked view. Dispatches a cancelable\n * `licensed` event carrying the resolved `licenseUrl`; unless a host calls\n * `preventDefault()`, opens that URL in a new tab. A blank `licenseUrl`\n * suppresses navigation so the event alone drives host behavior.\n */\n private _onLicensedCta(): void {\n const proceed = this.dispatchEvent(\n new CustomEvent(\"licensed\", {\n detail: { licenseUrl: this.licenseUrl } satisfies LicensedDetail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (proceed && this.licenseUrl && typeof window !== \"undefined\") {\n window.open(this.licenseUrl, \"_blank\", \"noopener,noreferrer\");\n }\n }\n\n private _renderLicensed() {\n return html`\n <div class=\"licensed\" part=\"licensed\" data-testid=\"drawer-licensed\">\n <slot name=\"licensed\">\n <p>Threads are a CopilotKit Intelligence feature.</p>\n <button\n class=\"primary\"\n part=\"licensed-cta\"\n @click=${() => this._onLicensedCta()}\n >\n Upgrade\n </button>\n </slot>\n </div>\n `;\n }\n\n private _renderError() {\n return html`\n <div\n class=\"state error\"\n part=\"error\"\n role=\"alert\"\n data-testid=\"drawer-error\"\n >\n <p>${this.error}</p>\n <button\n class=\"primary\"\n part=\"retry-button\"\n @click=${() => this._emit(\"retry\", { scope: \"initial\" })}\n >\n Retry\n </button>\n </div>\n `;\n }\n\n private _renderLoading() {\n return html`\n <div class=\"state\" part=\"loading\" data-testid=\"drawer-loading\" aria-busy=\"true\">\n Loading threads…\n </div>\n `;\n }\n\n private _renderList() {\n const visible = this._visibleThreads();\n if (visible.length === 0) {\n return html`\n <div class=\"state\" part=\"empty\" data-testid=\"drawer-empty\">\n <slot name=\"empty\">No threads yet.</slot>\n </div>\n `;\n }\n return html`\n <ul\n class=${this._openMenuId !== null ? \"list menu-open\" : \"list\"}\n part=\"list\"\n role=\"listbox\"\n aria-label=${this.label}\n >\n ${repeat(\n visible,\n (thread) => thread.id,\n (thread, index) => this._renderRow(thread, index, visible.length),\n )}\n </ul>\n ${this._renderFetchMore()}\n `;\n }\n\n private _renderRow(thread: DrawerThread, index = 0, total = 1) {\n const isActive = thread.id === this.activeThreadId;\n const hasName = thread.name !== null && thread.name !== \"\";\n // Shared display-name fallback: an empty-string (or null) name reads as\n // \"New thread\" for BOTH the visible label and every row-action aria-label,\n // so a screen reader never announces \"Actions for \" / \"Archive thread \".\n const displayName = hasName ? (thread.name as string) : \"New thread\";\n const justRevealed = this._justRevealed.has(thread.id);\n\n const menuOpen = this._openMenuId === thread.id;\n // The kebab popover opens downward by default (`top: 100%`). For rows in the\n // lower portion of the list, a downward menu would be clipped by the list's\n // `overflow-y: auto` scroll box (which also clips the x-axis). Flip those\n // rows' menu to open UPWARD (toward the list interior) via `menu-up`, so the\n // popover for bottom rows is never lost behind the list's bottom edge.\n const menuUp = menuOpen && total > 1 && index >= total / 2;\n\n const rowClasses = {\n row: true,\n active: isActive,\n archived: thread.archived,\n \"menu-open\": menuOpen,\n \"menu-up\": menuUp,\n };\n const nameClasses = {\n \"row-name\": true,\n placeholder: !hasName,\n revealed: justRevealed,\n };\n const slotName = rowSlotName(thread.id);\n // A long thread name is clipped with an ellipsis (no hover tooltip — the\n // designer opted against name bubbles). The name text lives in an inner span\n // that owns the ellipsis truncation.\n const nameSpan = html`<span class=${classMap(nameClasses)} part=\"row-name\">\n <span class=\"row-name-text\">${displayName}</span>\n </span>`;\n\n return html`\n <li\n class=${classMap(rowClasses)}\n part=${isActive ? \"row row-active\" : \"row\"}\n role=\"option\"\n aria-selected=${isActive ? \"true\" : \"false\"}\n tabindex=\"0\"\n data-thread-id=${thread.id}\n @click=${() => {\n // Selecting a row dismisses any open kebab menu (it belongs to a row,\n // not the selection) before emitting the selection intent.\n this._openMenuId = null;\n this._emit(\"thread-selected\", { threadId: thread.id });\n }}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n this._openMenuId = null;\n this._emit(\"thread-selected\", { threadId: thread.id });\n }\n }}\n >\n ${\n slotName !== null\n ? html`<slot name=${slotName}>${nameSpan}</slot>`\n : nameSpan\n }\n <button\n class=\"row-menu\"\n part=\"row-menu\"\n aria-label=${`Actions for ${displayName}`}\n aria-haspopup=\"menu\"\n aria-expanded=${menuOpen}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = menuOpen ? null : thread.id;\n }}\n >\n ${iconKebab}\n </button>\n ${\n menuOpen\n ? html`<div\n class=\"row-menu-popover\"\n part=\"row-menu-popover\"\n role=\"menu\"\n >\n ${\n thread.archived\n ? html`<button\n class=\"row-menu-item\"\n part=\"row-unarchive\"\n role=\"menuitem\"\n aria-label=${`Unarchive thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._emit(\"unarchive\", { threadId: thread.id });\n }}\n >\n ${iconUnarchive}<span>Unarchive</span>\n </button>`\n : html`<button\n class=\"row-menu-item\"\n part=\"row-archive\"\n role=\"menuitem\"\n aria-label=${`Archive thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._emit(\"archive\", { threadId: thread.id });\n }}\n >\n ${iconArchive}<span>Archive</span>\n </button>`\n }\n <button\n class=\"row-menu-item danger\"\n part=\"row-delete\"\n role=\"menuitem\"\n aria-label=${`Delete thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._confirmingDeleteId = thread.id;\n }}\n >\n ${iconDelete}<span>Delete</span>\n </button>\n </div>`\n : nothing\n }\n </li>\n `;\n }\n\n private _renderFetchMore() {\n if (hasErrorMessage(this.fetchMoreError)) {\n return html`\n <div class=\"fetch-more-error\" part=\"fetch-more-error\" role=\"alert\">\n Couldn't load more —\n <button\n class=\"row-action\"\n part=\"fetch-more-retry\"\n @click=${() => this._emit(\"retry\", { scope: \"fetch-more\" })}\n >\n retry\n </button>\n </div>\n `;\n }\n if (this.fetchingMore) {\n return html`\n <div class=\"state\" part=\"fetching-more\" aria-busy=\"true\">Loading more…</div>\n `;\n }\n if (this.hasMore) {\n return html`\n <button\n class=\"load-more\"\n part=\"load-more\"\n @click=${() => this._emit(\"load-more\", {})}\n >\n Load more\n </button>\n `;\n }\n return nothing;\n }\n\n private _renderMemories() {\n // Reserved region — hidden until a consumer projects content into the slot.\n // A `slotchange` listener drives `_hasMemories` so light-DOM mutations after\n // first render reactively reveal/hide the region.\n return html`\n <div class=\"memories\" part=\"memories\" ?hidden=${!this._hasMemories}>\n <slot\n name=\"memories\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasMemories = slot.assignedElements().length > 0;\n }}\n ></slot>\n </div>\n `;\n }\n\n private _renderFooter() {\n // Reserved region — hidden until a consumer projects content into the\n // `footer` slot. Without this gate the footer's top border + padding render\n // as an empty box at the bottom of the drawer. Mirrors `_renderMemories`.\n return html`\n <div class=\"footer\" part=\"footer\" ?hidden=${!this._hasFooter}>\n <slot\n name=\"footer\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasFooter = slot.assignedElements().length > 0;\n }}\n ></slot>\n </div>\n `;\n }\n\n /**\n * Confirm-delete dialog, rendered as a native `<dialog>` that is ALWAYS\n * present in the shadow DOM so `updated()` can drive `showModal()`/`close()`\n * against it. Opening with `showModal()` puts it in the browser TOP LAYER, so\n * it can never be painted under other UI — the previous CSS-positioned overlay\n * was trapped in the drawer host's stacking context and appeared under the\n * chat's welcome view (ENT-1051). The `::backdrop` pseudo-element (styled in\n * styles.ts) provides the scrim natively.\n *\n * The actionable content (message + Cancel/Delete, bound to the captured id)\n * renders only while confirming, so a closed dialog holds nothing stale.\n * Native dismissal is wired via `@cancel` (Escape) and a backdrop-click check.\n */\n private _renderConfirmDialog() {\n const id = this._confirmingDeleteId;\n return html`\n <dialog\n class=\"dialog\"\n part=\"confirm-dialog\"\n role=\"alertdialog\"\n aria-label=\"Confirm delete\"\n data-testid=\"drawer-confirm-delete\"\n @cancel=${(event: Event) => {\n // Native Escape dismissal: prevent the default close (we drive open\n // state from `_confirmingDeleteId` in `updated()`) and reset it.\n event.preventDefault();\n this._confirmingDeleteId = null;\n }}\n @click=${(event: MouseEvent) => {\n // A click whose target is the <dialog> itself (not the inner card)\n // landed on the ::backdrop — dismiss, mirroring a scrim click.\n if (event.target === event.currentTarget) {\n this._confirmingDeleteId = null;\n }\n }}\n >\n ${\n id !== null\n ? html`\n <p>Delete this thread? This cannot be undone.</p>\n <div class=\"dialog-actions\">\n <button\n class=\"row-action\"\n part=\"confirm-cancel\"\n @click=${() => (this._confirmingDeleteId = null)}\n >\n Cancel\n </button>\n <button\n class=\"primary\"\n part=\"confirm-delete\"\n @click=${() => {\n this._confirmingDeleteId = null;\n this._emit(\"delete\", { threadId: id });\n }}\n >\n Delete\n </button>\n </div>\n `\n : nothing\n }\n </dialog>\n `;\n }\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gCACX;;AAGF,MAAM,oBAAoB;;;;;;;AAQ1B,SAAS,gBAAgB,OAAuC;AAC9D,QAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,SAAS;;;;;;;;;;;AAYjD,SAAS,YAAY,IAA2B;AAE9C,KAAI,GAAG,WAAW,KAAK,YAAY,KAAK,GAAG,CAAE,QAAO;AACpD,QAAO,OAAO;;;;;;;;AAShB,MAAM,cAAc,IAAI;;;;;;;;;;;;;;;;AAgBxB,MAAM,gBAAgB,IAAI;;;;;;;;;;;;;;;;;;AAkB1B,MAAM,aAAa,IAAI;;;;;;;;;;;;;;;;;;;AAuBvB,MAAM,cAAc,IAAI;;;;;;;;;;;;;;;;;;;;;AAsBxB,MAAM,iBAAiB,IAAI;;;;;;;;;;;;;;;;AAgB3B,MAAM,aAAa,IAAI;;;;;;;;;;;;;;;;AAgBvB,MAAM,YAAY,IAAI;;;;;;;;;;;;;;;;;;;;AAqBt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MAAK,sBAAsB;IAE7B;;UAGA,OAAO,OACH,IAAI;;;;;;mCAMkB,KAAK,sBAAsB,KAAM;;;;;;;mCAOlC;AACb,QAAK,sBAAsB;AAC3B,QAAK,MAAM,UAAU,EAAE,UAAU,IAAI,CAAC;IACtC;;;;;kBAMR,QACL"}
1
+ {"version":3,"file":"copilotkit-threads-drawer.mjs","names":[],"sources":["../../src/threads-drawer/copilotkit-threads-drawer.ts"],"sourcesContent":["import { LitElement, html, nothing } from \"lit\";\nimport type { PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { drawerStyles } from \"./styles\";\nimport type { DrawerFilter, DrawerThread, LicensedDetail } from \"./types\";\n\n/** Tag name the element registers under. */\nexport const COPILOTKIT_THREADS_DRAWER_TAG =\n \"copilotkit-threads-drawer\" as const;\n\n/** Mobile breakpoint (px). At or below this width the drawer is a modal overlay. */\nconst MOBILE_BREAKPOINT = 768;\n\n/**\n * Whether an inbound error message should surface an error state. Only a\n * non-empty, non-whitespace string counts — `null`, `\"\"`, and whitespace-only\n * strings are treated as \"no error\" so an empty error never conflates with a\n * real one (and never blanks the list behind an empty error panel).\n */\nfunction hasErrorMessage(value: string | null): value is string {\n return value !== null && value.trim().length > 0;\n}\n\n/**\n * Builds the per-row slot name (`row:<id>`) used for consumer projection, but\n * only when the thread id is safe to embed in a slot `name` / `slot` attribute\n * token. A slot name is matched character-for-character against the consumer's\n * `slot=\"...\"` attribute; whitespace splits attribute tokens and quotes/angle\n * brackets can break attribute serialization, so an id containing any of those\n * would silently fail projection. For such an id we return `null` and the row\n * renders its default name span (no per-row slot), which is the safe fallback.\n */\nfunction rowSlotName(id: string): string | null {\n // Reject whitespace and characters that are unsafe in an HTML attribute token.\n if (id.length === 0 || /[\\s\"'<>=]/.test(id)) return null;\n return `row:${id}`;\n}\n\n/**\n * Inline row-action icons. The element is framework-agnostic Lit, so it cannot\n * depend on a React icon library — these are the lucide `archive`,\n * `archive-restore`, and `trash-2` glyphs inlined as SVG, drawn with\n * `currentColor` so they inherit the button's themed color.\n */\nconst iconArchive = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"20\" height=\"5\" x=\"2\" y=\"3\" rx=\"1\" />\n <path d=\"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8\" />\n <path d=\"M10 12h4\" />\n </svg>\n`;\nconst iconUnarchive = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"20\" height=\"5\" x=\"2\" y=\"3\" rx=\"1\" />\n <path d=\"M4 8v11a2 2 0 0 0 2 2h2\" />\n <path d=\"M20 8v11a2 2 0 0 1-2 2h-2\" />\n <path d=\"m9 15 3-3 3 3\" />\n <path d=\"M12 12v9\" />\n </svg>\n`;\nconst iconDelete = html`\n <svg\n class=\"row-action-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 6h18\" />\n <path\n d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"\n />\n <line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\" />\n <line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\" />\n </svg>\n`;\n// Sidebar/panel glyph (the Figma toggle icon). Used for the desktop collapse\n// toggle, the desktop collapsed cluster's expand toggle, the mobile launcher\n// (open), and the mobile header dismiss (close) — the toggle glyph is identical\n// in every state, matching the Figma.\nconst iconSidebar = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" />\n <path d=\"M9 3v18\" />\n </svg>\n`;\n\n/**\n * Header / control icons for the redesigned drawer chrome (ENT-1051). Inlined\n * lucide glyphs (`square-plus`, `filter`, `ellipsis-vertical`) drawn with\n * `currentColor` so they inherit the button's themed color — the element cannot\n * depend on a React icon library.\n */\nconst iconPlusSquare = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" />\n <path d=\"M8 12h8\" />\n <path d=\"M12 8v8\" />\n </svg>\n`;\nconst iconFunnel = html`\n <svg\n class=\"icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"3\" y1=\"5\" x2=\"21\" y2=\"5\" />\n <line x1=\"6\" y1=\"12\" x2=\"18\" y2=\"12\" />\n <line x1=\"10\" y1=\"19\" x2=\"14\" y2=\"19\" />\n </svg>\n`;\nconst iconKebab = html`\n <svg class=\"icon\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"5\" r=\"1.6\" />\n <circle cx=\"12\" cy=\"12\" r=\"1.6\" />\n <circle cx=\"12\" cy=\"19\" r=\"1.6\" />\n </svg>\n`;\n\n/**\n * Most recent first, by `lastRunAt`, then `updatedAt`, then `createdAt`,\n * compared as parsed instants. A timestamp that does not parse sorts last, and\n * ties keep their input order. This is the order of `sortThreadsByRecency` in\n * `@copilotkit/core` (`packages/core/src/threads.ts`), which sorts the\n * threads the framework drawers pass in, so the element keeps their order.\n * Keep the two in step: this package does not depend on core.\n */\nfunction sortThreadsByRecency(threads: readonly DrawerThread[]) {\n return [...threads].sort((left, right) => recencyOf(right) - recencyOf(left));\n}\n\nfunction recencyOf(thread: DrawerThread): number {\n const time = Date.parse(\n thread.lastRunAt ?? thread.updatedAt ?? thread.createdAt,\n );\n return Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;\n}\n\n/**\n * `<copilotkit-threads-drawer>` — a public, self-contained, controlled, framework-agnostic\n * threads drawer rendered into a shadow root.\n *\n * Pure VIEW: domain data (threads/loading/error/etc.) comes IN as properties and\n * user intent goes OUT as bubbling+composed DOM `CustomEvent`s. The element owns\n * VIEW state (open, Active/All filter, confirm-delete dialog, per-row\n * animations) while the consumer owns DOMAIN state. `open` is additionally\n * externally controllable via the `open` property + `open-change` event so a\n * host can coordinate mobile open/close.\n *\n * The element is AUTHORITATIVE over row order and the Active/All filter.\n */\nexport class CopilotKitThreadsDrawer extends LitElement {\n static styles = drawerStyles;\n\n static properties = {\n // Inbound domain properties.\n threads: { attribute: false },\n loading: { type: Boolean },\n error: { type: String },\n activeThreadId: { attribute: \"active-thread-id\", type: String },\n licensed: { type: Boolean },\n licenseUrl: { attribute: \"license-url\", type: String },\n hasMore: { attribute: \"has-more\", type: Boolean },\n fetchingMore: { attribute: \"fetching-more\", type: Boolean },\n fetchMoreError: { attribute: \"fetch-more-error\", type: String },\n // Inbound: configurable label for the drawer region and default header.\n label: { type: String },\n // Inbound: configurable \"Recent Conversations\" section heading text.\n recentLabel: { attribute: \"recent-label\", type: String },\n collapsible: { type: Boolean },\n // Externally-controllable VIEW state.\n open: { type: Boolean, reflect: true },\n collapsed: { type: Boolean, reflect: true },\n // Internal VIEW state.\n _filter: { state: true },\n _confirmingDeleteId: { state: true },\n _viewportIsMobile: { state: true },\n _hasHeader: { state: true },\n _hasMemories: { state: true },\n _hasFooter: { state: true },\n _filterOpen: { state: true },\n _openMenuId: { state: true },\n };\n\n /**\n * Inbound: accessible label for the drawer region — drives the screen-reader\n * region name (on `.root`) and the listbox name (on `.list`) ONLY. The\n * redesign has no visible title; project visible header chrome via the\n * optional `header` slot instead. Defaults to `\"Threads\"`.\n */\n label = \"Threads\";\n\n /**\n * Inbound: text for the \"Recent Conversations\" section heading above the list.\n * Attribute: `recent-label`. Defaults to `\"Recent Conversations\"`.\n */\n recentLabel = \"Recent Conversations\";\n\n /** Inbound: thread records to render. The element re-orders/filters them. */\n threads: DrawerThread[] = [];\n /** Inbound: initial-fetch loading flag. */\n loading = false;\n /** Inbound: initial-fetch error message (actionable Retry shown when set). */\n error: string | null = null;\n /** Inbound: currently-open thread id (drives row selection highlight). */\n activeThreadId: string | null = null;\n /** Inbound: whether the org is licensed for threads; `false` shows the locked view. */\n licensed = true;\n /**\n * Inbound: destination the Upgrade CTA opens (new tab) when the locked view's\n * default button is clicked. Defaults to the CopilotKit Intelligence docs.\n * Set to an empty string to suppress the default navigation and rely solely\n * on the `licensed` event.\n */\n licenseUrl = \"https://docs.copilotkit.ai/intelligence\";\n /** Inbound: whether more pages are available. */\n hasMore = false;\n /** Inbound: whether a fetch-more is in flight. */\n fetchingMore = false;\n /** Inbound: fetch-more error message (inline, list preserved). */\n fetchMoreError: string | null = null;\n\n /**\n * Externally-controllable: whether the drawer is open (mobile coordination).\n * Defaults to `false` so a mobile-width first render does NOT paint the open\n * modal (backdrop + body scroll-lock + focus steal) for one frame before a\n * wrapper's post-mount effect can close it. Desktop is unaffected — only\n * `.root.mobile.open` / `_isMobileModalOpen()` consume `open`.\n */\n open = false;\n /**\n * Externally-controllable: whether the drawer is collapsed to the floating\n * cluster on desktop. Defaults to `false` (expanded). Reflected so hosts can\n * theme on `[collapsed]`. Ignored on mobile, where open/closed governs the\n * off-canvas modal instead.\n */\n collapsed = false;\n /**\n * Inbound: whether the user may collapse the drawer on desktop. Defaults to\n * `true`. When `false` the header omits the collapse toggle and the drawer\n * NEVER renders the collapsed cluster on desktop (it stays expanded even if\n * `collapsed` is set) — mobile off-canvas open/close is independent.\n */\n collapsible = true;\n\n private _filter: DrawerFilter = \"active\";\n private _confirmingDeleteId: string | null = null;\n private _viewportIsMobile = false;\n private _hasHeader = false;\n private _hasMemories = false;\n private _hasFooter = false;\n /** Whether the funnel filter popover (Active/All) is open. */\n private _filterOpen = false;\n /** Id of the row whose kebab actions menu is open (only one at a time). */\n private _openMenuId: string | null = null;\n\n private _mediaQuery: MediaQueryList | null = null;\n private readonly _onMediaChange = (event: MediaQueryListEvent) => {\n this._viewportIsMobile = event.matches;\n };\n private readonly _onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n if (this._openMenuId !== null) {\n this._openMenuId = null;\n event.stopPropagation();\n return;\n }\n if (this._filterOpen) {\n this._filterOpen = false;\n event.stopPropagation();\n return;\n }\n // The confirm-delete <dialog> is opened with showModal(): the browser\n // dismisses it natively via the dialog's `cancel` event. But that Escape\n // keydown still bubbles from the modal to this host handler, so we must\n // stop here — otherwise it falls through to the mobile branch below and\n // closes the whole drawer along with the confirmation.\n if (this._confirmingDeleteId !== null) {\n event.stopPropagation();\n return;\n }\n if (this._viewportIsMobile && this.open) {\n this._setOpen(false);\n event.stopPropagation();\n }\n return;\n }\n // Tab focus-trap for the mobile modal. Handled at the HOST (not on `.root`)\n // so it fires wherever focus sits in the shadow root — including the\n // backdrop button, which renders as a sibling OUTSIDE `.root`. A trap bound\n // only to `.root` lets Tab from the backdrop (or any out-of-root node)\n // escape the modal to the page behind it.\n if (event.key === \"Tab\") {\n this._trapTab(event);\n }\n };\n\n /**\n * Dismisses the funnel filter popover and/or an open row-actions menu when a\n * pointerdown lands outside them. Bound to `document` (composed events bubble\n * out of the shadow root), so we discriminate inside vs. outside via\n * `composedPath()` rather than target identity. A click on a popover's own\n * trigger is treated as \"inside\" so its own `@click` toggle handles the close\n * (avoids a double-toggle that would immediately reopen it).\n */\n private readonly _onDocumentPointerDown = (event: Event) => {\n if (!this._filterOpen && this._openMenuId === null) return;\n const path = event.composedPath();\n if (this._filterOpen) {\n const popover = this.renderRoot.querySelector('[part=\"filters\"]');\n const trigger = this.renderRoot.querySelector('[part=\"filter-toggle\"]');\n const inside =\n (popover && path.includes(popover)) ||\n (trigger && path.includes(trigger));\n if (!inside) this._filterOpen = false;\n }\n if (this._openMenuId !== null) {\n const popover = this.renderRoot.querySelector(\n '[part=\"row-menu-popover\"]',\n );\n const trigger = this.renderRoot.querySelector(\n '.row.menu-open [part=\"row-menu\"]',\n );\n const inside =\n (popover && path.includes(popover)) ||\n (trigger && path.includes(trigger));\n if (!inside) this._openMenuId = null;\n }\n };\n\n /** Thread ids previously seen as named, so we can animate the null→named reveal. */\n private readonly _seenNamed = new Set<string>();\n /** Thread ids whose name just transitioned null→named in this update cycle. */\n private _justRevealed = new Set<string>();\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (typeof window !== \"undefined\" && window.matchMedia) {\n this._mediaQuery = window.matchMedia(\n `(max-width: ${MOBILE_BREAKPOINT}px)`,\n );\n this._viewportIsMobile = this._mediaQuery.matches;\n this._mediaQuery.addEventListener(\"change\", this._onMediaChange);\n }\n this.addEventListener(\"keydown\", this._onKeyDown);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"pointerdown\", this._onDocumentPointerDown);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._mediaQuery?.removeEventListener(\"change\", this._onMediaChange);\n this.removeEventListener(\"keydown\", this._onKeyDown);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"pointerdown\", this._onDocumentPointerDown);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"scroll\", this._repositionConfirm, true);\n window.removeEventListener(\"resize\", this._repositionConfirm);\n }\n // Release the reserved-width override we may have set on the document root.\n if (typeof document !== \"undefined\") {\n document.documentElement.style.removeProperty(\n \"--cpk-drawer-reserved-width\",\n );\n }\n this._releaseScrollLock();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n // Compute the null→named reveal set BEFORE render, so render stays pure.\n if (changed.has(\"threads\")) {\n const presentIds = new Set<string>();\n const revealed = new Set<string>();\n for (const thread of this.threads) {\n presentIds.add(thread.id);\n const hasName = thread.name !== null && thread.name !== \"\";\n if (hasName && !this._seenNamed.has(thread.id)) {\n revealed.add(thread.id);\n }\n if (hasName) this._seenNamed.add(thread.id);\n }\n // Prune ids no longer present so `_seenNamed` cannot grow without bound\n // across a long-lived, high-churn session.\n for (const id of this._seenNamed) {\n if (!presentIds.has(id)) this._seenNamed.delete(id);\n }\n this._justRevealed = revealed;\n\n // Auto-dismiss a pending confirm-delete whose target is no longer in the\n // visible threads (the consumer removed/archived/filtered it away while\n // the dialog was open). Without this the dialog could emit `delete` with a\n // stale id. Reconciled against the SAME visible set the user is acting on.\n if (this._confirmingDeleteId !== null) {\n const stillVisible = this._visibleThreads().some(\n (t) => t.id === this._confirmingDeleteId,\n );\n if (!stillVisible) this._confirmingDeleteId = null;\n }\n\n // Same reconciliation for an open row-actions menu: if the row whose\n // kebab menu is open is no longer visible (removed/archived/filtered\n // away), close the menu so it cannot linger detached from any row.\n if (this._openMenuId !== null) {\n const stillVisible = this._visibleThreads().some(\n (t) => t.id === this._openMenuId,\n );\n if (!stillVisible) this._openMenuId = null;\n }\n }\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n // Scroll-lock is a mobile-modal concern only.\n if (\n changed.has(\"open\") ||\n changed.has(\"_viewportIsMobile\" as keyof CopilotKitThreadsDrawer)\n ) {\n if (this._isMobileModalOpen()) {\n this._applyScrollLock();\n this._focusFirstFocusable();\n } else {\n this._releaseScrollLock();\n }\n }\n\n // Reclaim the reserved layout column when the desktop collapse state (or the\n // viewport) changes.\n if (\n changed.has(\"collapsed\") ||\n changed.has(\"collapsible\") ||\n changed.has(\"_viewportIsMobile\" as keyof CopilotKitThreadsDrawer)\n ) {\n this._syncReservedWidth();\n }\n\n // Drive the native top-layer <dialog> from the confirm state. Opening with\n // showModal() places it in the browser top layer (above every stacking\n // context) so it is never clipped; we then re-center it over the drawer\n // panel via _positionConfirmDialog(). Feature-detect showModal/close because\n // jsdom implements neither — fall back to toggling the `open` attribute so\n // unit tests still observe the open/closed state.\n const dialog = this.renderRoot.querySelector(\"dialog\");\n if (dialog) {\n const id = this._confirmingDeleteId;\n if (id !== null && !dialog.open) {\n typeof dialog.showModal === \"function\"\n ? dialog.showModal()\n : dialog.setAttribute(\"open\", \"\");\n this._positionConfirmDialog();\n window.addEventListener(\"scroll\", this._repositionConfirm, true);\n window.addEventListener(\"resize\", this._repositionConfirm);\n } else if (id === null && dialog.open) {\n typeof dialog.close === \"function\"\n ? dialog.close()\n : dialog.removeAttribute(\"open\");\n window.removeEventListener(\"scroll\", this._repositionConfirm, true);\n window.removeEventListener(\"resize\", this._repositionConfirm);\n }\n }\n\n // The reveal animation fires exactly once per real name-arrival. Clearing\n // the set after the render that applied the `revealed` class prevents any\n // later, unrelated re-render from re-adding the class and re-firing the\n // animation. `_justRevealed` is a plain field (not reactive), so resetting\n // it here does not schedule another update.\n if (this._justRevealed.size > 0) {\n this._justRevealed = new Set<string>();\n }\n }\n\n // --- View-state helpers ----------------------------------------------------\n\n private _isMobileModalOpen(): boolean {\n return this._viewportIsMobile && this.open;\n }\n\n private _setOpen(next: boolean): void {\n if (this.open === next) return;\n this.open = next;\n this._emit(\"open-change\", { open: next });\n }\n\n private _setCollapsed(next: boolean): void {\n if (this.collapsed === next) return;\n this.collapsed = next;\n this._emit(\"collapse-change\", { collapsed: next });\n }\n\n /**\n * Signal the drawer's reserved layout width to the host so a desktop collapse\n * reclaims the column instead of leaving an empty gap. On desktop-collapse we\n * set `--cpk-drawer-reserved-width: 0px` on the document root; a host whose\n * grid reads `grid-template-columns: var(--cpk-drawer-reserved-width, 320px) …`\n * inherits it and collapses the track (with its own transition). Expanded/mobile\n * clears the override so the host's fallback width applies — which also means\n * the default (expanded) render never sets it, so there is no hydration flicker.\n *\n * It is set on `document.documentElement` (not `parentElement`) BECAUSE the\n * element is nested inside a framework wrapper host, so its parent is the\n * wrapper — not the grid container, which is an ancestor a child's custom\n * property can't reach. `:root` inheritance reaches the grid regardless of\n * wrapper nesting. Best-effort + namespaced, single-drawer-per-document; a host\n * with multiple drawers or a custom layout should instead react to the\n * `collapse-change` event.\n */\n private _syncReservedWidth(): void {\n if (typeof document === \"undefined\") return;\n const desktopCollapsed =\n this.collapsible && this.collapsed && !this._viewportIsMobile;\n const root = document.documentElement;\n if (desktopCollapsed) {\n root.style.setProperty(\"--cpk-drawer-reserved-width\", \"0px\");\n } else {\n root.style.removeProperty(\"--cpk-drawer-reserved-width\");\n }\n }\n\n /**\n * Center the confirm-delete <dialog> over the drawer PANEL's on-screen box\n * (not the viewport). The dialog stays a top-layer `showModal()` element so it\n * is never clipped, but we drive its center via `--confirm-cx/cy` measured\n * from the visible `.root` rect — so it reads as \"inside the drawer\" per the\n * ENT-1051 design while keeping the top-layer robustness. Falls back to\n * viewport-center (the CSS default) when the panel isn't measurable\n * (SSR/jsdom).\n */\n private _positionConfirmDialog(): void {\n const dialog = this.renderRoot.querySelector<HTMLDialogElement>(\"dialog\");\n const root = this.renderRoot.querySelector<HTMLElement>(\".root\");\n if (!dialog) return;\n const rect = root?.getBoundingClientRect();\n if (!rect || (rect.width === 0 && rect.height === 0)) {\n dialog.style.removeProperty(\"--confirm-cx\");\n dialog.style.removeProperty(\"--confirm-cy\");\n return;\n }\n // Center over the drawer's VISIBLE box (its rect intersected with the\n // viewport), not the raw rect: a host grid that doesn't bound the drawer's\n // row lets `.root` grow to content height, so a raw-rect center would land\n // far down the page. Intersecting with the viewport keeps the modal centered\n // in the on-screen drawer band regardless of how the host sizes the panel.\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const visLeft = Math.max(rect.left, 0);\n const visRight = Math.min(rect.right, vw);\n const visTop = Math.max(rect.top, 0);\n const visBottom = Math.min(rect.bottom, vh);\n dialog.style.setProperty(\"--confirm-cx\", `${(visLeft + visRight) / 2}px`);\n dialog.style.setProperty(\"--confirm-cy\", `${(visTop + visBottom) / 2}px`);\n }\n\n /** Bound reposition handler for scroll/resize while the confirm dialog is open. */\n private _repositionConfirm = () => this._positionConfirmDialog();\n\n private _setFilter(next: DrawerFilter): void {\n if (this._filter === next) return;\n this._filter = next;\n this._emit(\"filter-change\", { filter: next });\n }\n\n /**\n * Element-authoritative ordering + filtering. Active filter hides archived\n * threads; ordering is most-recent-first by `lastRunAt`/`updatedAt`.\n */\n private _visibleThreads(): DrawerThread[] {\n const filtered =\n this._filter === \"active\"\n ? this.threads.filter((t) => !t.archived)\n : this.threads;\n return sortThreadsByRecency(filtered);\n }\n\n private _emit<T>(type: string, detail: T): void {\n this.dispatchEvent(\n new CustomEvent(type, { detail, bubbles: true, composed: true }),\n );\n }\n\n // --- Scroll lock + focus (mobile modal only) -------------------------------\n\n private _scrollLocked = false;\n private _prevBodyOverflow = \"\";\n\n private _applyScrollLock(): void {\n if (this._scrollLocked || typeof document === \"undefined\") return;\n this._prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this._scrollLocked = true;\n }\n\n private _releaseScrollLock(): void {\n if (!this._scrollLocked || typeof document === \"undefined\") return;\n document.body.style.overflow = this._prevBodyOverflow;\n this._scrollLocked = false;\n }\n\n /**\n * Returns the focusable elements in the composed/flattened tree of the drawer\n * root, INCLUDING slotted light-DOM content (so a focus trap covers slotted\n * rows). Walks assigned nodes of each `<slot>`.\n */\n private _composedFocusable(): HTMLElement[] {\n const selector =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n const out: HTMLElement[] = [];\n // The backdrop button is a modal-owned focusable rendered as a sibling of\n // `.root`. Include it first (it precedes `.root` in DOM order) so the focus\n // trap treats it as part of the modal's cycle rather than an escape hatch.\n const backdrop = this.renderRoot.querySelector<HTMLElement>(\".backdrop\");\n if (backdrop) out.push(backdrop);\n const root = this.renderRoot.querySelector(\".root\");\n if (!root) return out;\n const collect = (node: ParentNode) => {\n node\n .querySelectorAll<HTMLElement>(selector)\n .forEach((el) => out.push(el));\n };\n collect(root);\n root.querySelectorAll(\"slot\").forEach((slot) => {\n (slot as HTMLSlotElement)\n .assignedElements({ flatten: true })\n .forEach((assigned) => {\n if (assigned.matches(selector)) out.push(assigned as HTMLElement);\n collect(assigned);\n });\n });\n return out;\n }\n\n private _focusFirstFocusable(): void {\n // Defer so the rendered tree exists.\n queueMicrotask(() => {\n const focusable = this._composedFocusable();\n // Prefer the first real control over the backdrop scrim so opening the\n // modal lands focus on actionable content, not the close-on-click overlay\n // (the backdrop is still part of the trap cycle below).\n const backdrop = this.renderRoot.querySelector(\".backdrop\");\n const target = focusable.find((el) => el !== backdrop) ?? focusable[0];\n target?.focus();\n });\n }\n\n private readonly _trapTab = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\" || !this._isMobileModalOpen()) return;\n const focusable = this._composedFocusable();\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n const active =\n (this.renderRoot as ShadowRoot).activeElement ?? document.activeElement;\n if (event.shiftKey && active === first) {\n last.focus();\n event.preventDefault();\n } else if (!event.shiftKey && active === last) {\n first.focus();\n event.preventDefault();\n }\n };\n\n // --- Render ----------------------------------------------------------------\n\n override render() {\n // Collapsed to the floating cluster on desktop (gated on `collapsible`), OR\n // closed on mobile — both show the same launcher cluster and hide the panel\n // body. Mobile keeps the body rendered (off-canvas, ready to slide in);\n // desktop-collapsed omits it entirely so the reserved column can reclaim.\n const desktopCollapsed =\n this.collapsible && this.collapsed && !this._viewportIsMobile;\n const mobileClosed = this._viewportIsMobile && !this.open;\n const showCluster = desktopCollapsed || mobileClosed;\n const rootClasses = {\n root: true,\n mobile: this._viewportIsMobile,\n open: this.open,\n collapsed: desktopCollapsed,\n };\n\n return html`\n ${showCluster ? this._renderCluster() : nothing}\n ${\n this._isMobileModalOpen()\n ? html`<button\n class=\"backdrop\"\n part=\"backdrop\"\n aria-label=\"Close threads drawer\"\n @click=${() => this._setOpen(false)}\n ></button>`\n : nothing\n }\n <div\n class=${classMap(rootClasses)}\n part=\"root\"\n role=${this._isMobileModalOpen() ? \"dialog\" : \"region\"}\n aria-modal=${this._isMobileModalOpen() ? \"true\" : nothing}\n aria-hidden=${desktopCollapsed ? \"true\" : nothing}\n aria-label=${this.label}\n >\n ${\n desktopCollapsed\n ? nothing\n : html`${this._renderHeader()} ${this._renderBody()}\n ${this._renderMemories()} ${this._renderFooter()}\n ${this._renderConfirmDialog()}`\n }\n </div>\n `;\n }\n\n /**\n * Floating launcher cluster from the Figma \"closed\" mockup: a sidebar-glyph\n * toggle + a \"New Conversation\" (+) icon button. Shown in TWO states — the\n * mobile closed state (toggle opens the off-canvas modal) and the desktop\n * collapsed state (toggle expands the sidebar). The primary toggle keeps\n * `part=\"launcher\"` for mobile-launcher theme compat; the new-thread button is\n * suppressed in the locked/unlicensed view, mirroring the New Conversation row.\n */\n private _renderCluster() {\n const onToggle = this._viewportIsMobile\n ? () => this._setOpen(true)\n : () => this._setCollapsed(false);\n const toggleLabel = this._viewportIsMobile\n ? \"Open threads\"\n : \"Expand threads\";\n return html`\n <div class=\"launcher-cluster\" part=\"launcher-cluster\">\n <button\n class=\"launcher\"\n part=\"launcher\"\n aria-label=${toggleLabel}\n @click=${onToggle}\n >\n <slot name=\"launcher-icon\">${iconSidebar}</slot>\n </button>\n ${\n this.licensed\n ? html`<button\n class=\"launcher launcher-new-thread\"\n part=\"launcher-new-thread\"\n aria-label=\"New Conversation\"\n @click=${() => this._emit(\"new-thread\", {})}\n >\n ${iconPlusSquare}\n </button>`\n : nothing\n }\n </div>\n `;\n }\n\n private _renderHeader() {\n // The header is a reserved consumer-projection surface with no built-in\n // controls (search and the desktop collapse toggle were both removed), so\n // it stays hidden until a consumer projects `slot=\"header\"` content — a\n // `slotchange` listener drives `_hasHeader`, mirroring the memories/footer\n // gating. Without this gate the empty padded header bar would render above\n // the \"New Conversation\" row. The \"New Conversation\" row is suppressed in\n // the locked/unlicensed view (only the Upgrade panel shows), mirroring the\n // section-heading gating.\n // On mobile the drawer is an off-canvas modal, so it needs an in-header\n // close affordance (desktop is a persistent sidebar — nothing to close).\n // The header therefore also renders when the mobile modal is open, even\n // with no projected `slot=\"header\"` content.\n const showMobileClose = this._viewportIsMobile && this.open;\n // Desktop collapse toggle: always available on desktop when collapsing is\n // permitted, so the header renders on desktop even with no projected\n // `slot=\"header\"` content. Mobile uses the launcher/close affordances.\n const showCollapseToggle = this.collapsible && !this._viewportIsMobile;\n return html`\n <div\n class=\"header\"\n part=\"header\"\n ?hidden=${!this._hasHeader && !showMobileClose && !showCollapseToggle}\n >\n <slot\n name=\"header\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasHeader = slot.assignedElements().length > 0;\n }}\n ></slot>\n ${\n // Toggle sits at the END so it right-aligns (the projected header slot\n // has flex:1 and pushes it over) — matching the mobile close button.\n showCollapseToggle\n ? html`<button\n class=\"icon-btn\"\n part=\"collapse-toggle\"\n aria-label=\"Collapse threads\"\n @click=${() => this._setCollapsed(true)}\n >\n ${iconSidebar}\n </button>`\n : nothing\n }\n ${\n showMobileClose\n ? html`<button\n class=\"icon-btn\"\n part=\"close-toggle\"\n aria-label=\"Close threads\"\n @click=${() => this._setOpen(false)}\n >\n ${iconSidebar}\n </button>`\n : nothing\n }\n </div>\n ${this.licensed ? this._renderNewConversation() : nothing}\n ${this._renderSectionHeading()}\n `;\n }\n\n /**\n * Dedicated full-width \"New Conversation\" row. Keeps `part=\"new-thread-button\"`\n * and fires the existing `new-thread` event, so wrappers/themes that hook the\n * old header pill are unaffected.\n */\n private _renderNewConversation() {\n return html`\n <button\n class=\"new-conversation\"\n part=\"new-thread-button\"\n @click=${() => this._emit(\"new-thread\", {})}\n >\n ${iconPlusSquare}\n <span>New Conversation</span>\n </button>\n `;\n }\n\n /**\n * \"Recent Conversations\" section heading with a funnel button that opens the\n * Active/All filter popover. Only shown when the list region is shown\n * (licensed, and not the full-panel error/empty-before-load) — mirrors the\n * old filters gate. The popover options keep `part=\"filter-active\"` /\n * `part=\"filter-all\"` and still emit `filter-change` via `_setFilter`.\n */\n private _renderSectionHeading() {\n if (\n !this.licensed ||\n (hasErrorMessage(this.error) && this.threads.length === 0)\n ) {\n return nothing;\n }\n return html`\n <div class=\"section-heading\" part=\"section-heading\">\n <span class=\"section-title\">${this.recentLabel}</span>\n <button\n class=\"icon-btn small\"\n part=\"filter-toggle\"\n aria-label=\"Filter threads\"\n aria-expanded=${this._filterOpen}\n @click=${() => (this._filterOpen = !this._filterOpen)}\n >\n ${iconFunnel}\n ${\n // \"Filter applied\" indicator dot — shown whenever the active filter\n // is not the default (\"active\"), matching the Figma's archived view.\n this._filter !== \"active\"\n ? html`\n <span class=\"filter-dot\" part=\"filter-indicator\"></span>\n `\n : nothing\n }\n </button>\n ${\n this._filterOpen\n ? html`<div\n class=\"filter-popover\"\n part=\"filters\"\n role=\"group\"\n aria-label=\"Filter threads\"\n >\n <button\n class=\"filter-opt\"\n part=\"filter-active\"\n aria-pressed=${this._filter === \"active\"}\n @click=${() => {\n this._setFilter(\"active\");\n this._filterOpen = false;\n }}\n >\n Active\n </button>\n <button\n class=\"filter-opt\"\n part=\"filter-all\"\n aria-pressed=${this._filter === \"all\"}\n @click=${() => {\n this._setFilter(\"all\");\n this._filterOpen = false;\n }}\n >\n All\n </button>\n </div>`\n : nothing\n }\n </div>\n `;\n }\n\n private _renderBody() {\n // The locked view beats error: an unlicensed org always sees it, never the\n // initial-fetch error.\n if (!this.licensed) return this._renderLicensed();\n // The full-panel error replaces the list ONLY when there is nothing to show\n // (a failed initial fetch). The bound `error` reflects the core store error,\n // which a failed mutation (delete/rename/archive) also sets — a delete\n // rollback restores its row, so when threads are still present we keep the\n // list visible rather than blanking it behind a \"couldn't load\" panel.\n if (hasErrorMessage(this.error) && this.threads.length === 0) {\n return this._renderError();\n }\n // Full-panel loading only when there is nothing to show yet (initial fetch).\n // A refetch (e.g. filter toggle Active<->All) keeps `loading` true while the\n // list is already populated — keep showing the known threads rather than\n // flashing the loading state over them.\n if (this.loading && this.threads.length === 0) return this._renderLoading();\n return this._renderList();\n }\n\n /**\n * Handles the Upgrade CTA click in the locked view. Dispatches a cancelable\n * `licensed` event carrying the resolved `licenseUrl`; unless a host calls\n * `preventDefault()`, opens that URL in a new tab. A blank `licenseUrl`\n * suppresses navigation so the event alone drives host behavior.\n */\n private _onLicensedCta(): void {\n const proceed = this.dispatchEvent(\n new CustomEvent(\"licensed\", {\n detail: { licenseUrl: this.licenseUrl } satisfies LicensedDetail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (proceed && this.licenseUrl && typeof window !== \"undefined\") {\n window.open(this.licenseUrl, \"_blank\", \"noopener,noreferrer\");\n }\n }\n\n private _renderLicensed() {\n return html`\n <div class=\"licensed\" part=\"licensed\" data-testid=\"drawer-licensed\">\n <slot name=\"licensed\">\n <p>Threads are a CopilotKit Intelligence feature.</p>\n <button\n class=\"primary\"\n part=\"licensed-cta\"\n @click=${() => this._onLicensedCta()}\n >\n Upgrade\n </button>\n </slot>\n </div>\n `;\n }\n\n private _renderError() {\n return html`\n <div\n class=\"state error\"\n part=\"error\"\n role=\"alert\"\n data-testid=\"drawer-error\"\n >\n <p>${this.error}</p>\n <button\n class=\"primary\"\n part=\"retry-button\"\n @click=${() => this._emit(\"retry\", { scope: \"initial\" })}\n >\n Retry\n </button>\n </div>\n `;\n }\n\n private _renderLoading() {\n return html`\n <div class=\"state\" part=\"loading\" data-testid=\"drawer-loading\" aria-busy=\"true\">\n Loading threads…\n </div>\n `;\n }\n\n private _renderList() {\n const visible = this._visibleThreads();\n if (visible.length === 0) {\n return html`\n <div class=\"state\" part=\"empty\" data-testid=\"drawer-empty\">\n <slot name=\"empty\">No threads yet.</slot>\n </div>\n `;\n }\n return html`\n <ul\n class=${this._openMenuId !== null ? \"list menu-open\" : \"list\"}\n part=\"list\"\n role=\"listbox\"\n aria-label=${this.label}\n >\n ${repeat(\n visible,\n (thread) => thread.id,\n (thread, index) => this._renderRow(thread, index, visible.length),\n )}\n </ul>\n ${this._renderFetchMore()}\n `;\n }\n\n private _renderRow(thread: DrawerThread, index = 0, total = 1) {\n const isActive = thread.id === this.activeThreadId;\n const hasName = thread.name !== null && thread.name !== \"\";\n // Shared display-name fallback: an empty-string (or null) name reads as\n // \"New thread\" for BOTH the visible label and every row-action aria-label,\n // so a screen reader never announces \"Actions for \" / \"Archive thread \".\n const displayName = hasName ? (thread.name as string) : \"New thread\";\n const justRevealed = this._justRevealed.has(thread.id);\n\n const menuOpen = this._openMenuId === thread.id;\n // The kebab popover opens downward by default (`top: 100%`). For rows in the\n // lower portion of the list, a downward menu would be clipped by the list's\n // `overflow-y: auto` scroll box (which also clips the x-axis). Flip those\n // rows' menu to open UPWARD (toward the list interior) via `menu-up`, so the\n // popover for bottom rows is never lost behind the list's bottom edge.\n const menuUp = menuOpen && total > 1 && index >= total / 2;\n\n const rowClasses = {\n row: true,\n active: isActive,\n archived: thread.archived,\n \"menu-open\": menuOpen,\n \"menu-up\": menuUp,\n };\n const nameClasses = {\n \"row-name\": true,\n placeholder: !hasName,\n revealed: justRevealed,\n };\n const slotName = rowSlotName(thread.id);\n // A long thread name is clipped with an ellipsis (no hover tooltip — the\n // designer opted against name bubbles). The name text lives in an inner span\n // that owns the ellipsis truncation.\n const nameSpan = html`<span class=${classMap(nameClasses)} part=\"row-name\">\n <span class=\"row-name-text\">${displayName}</span>\n </span>`;\n\n return html`\n <li\n class=${classMap(rowClasses)}\n part=${isActive ? \"row row-active\" : \"row\"}\n role=\"option\"\n aria-selected=${isActive ? \"true\" : \"false\"}\n tabindex=\"0\"\n data-thread-id=${thread.id}\n @click=${() => {\n // Selecting a row dismisses any open kebab menu (it belongs to a row,\n // not the selection) before emitting the selection intent.\n this._openMenuId = null;\n this._emit(\"thread-selected\", { threadId: thread.id });\n }}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n this._openMenuId = null;\n this._emit(\"thread-selected\", { threadId: thread.id });\n }\n }}\n >\n ${\n slotName !== null\n ? html`<slot name=${slotName}>${nameSpan}</slot>`\n : nameSpan\n }\n <button\n class=\"row-menu\"\n part=\"row-menu\"\n aria-label=${`Actions for ${displayName}`}\n aria-haspopup=\"menu\"\n aria-expanded=${menuOpen}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = menuOpen ? null : thread.id;\n }}\n >\n ${iconKebab}\n </button>\n ${\n menuOpen\n ? html`<div\n class=\"row-menu-popover\"\n part=\"row-menu-popover\"\n role=\"menu\"\n >\n ${\n thread.archived\n ? html`<button\n class=\"row-menu-item\"\n part=\"row-unarchive\"\n role=\"menuitem\"\n aria-label=${`Unarchive thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._emit(\"unarchive\", { threadId: thread.id });\n }}\n >\n ${iconUnarchive}<span>Unarchive</span>\n </button>`\n : html`<button\n class=\"row-menu-item\"\n part=\"row-archive\"\n role=\"menuitem\"\n aria-label=${`Archive thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._emit(\"archive\", { threadId: thread.id });\n }}\n >\n ${iconArchive}<span>Archive</span>\n </button>`\n }\n <button\n class=\"row-menu-item danger\"\n part=\"row-delete\"\n role=\"menuitem\"\n aria-label=${`Delete thread ${displayName}`}\n @click=${(e: Event) => {\n e.stopPropagation();\n this._openMenuId = null;\n this._confirmingDeleteId = thread.id;\n }}\n >\n ${iconDelete}<span>Delete</span>\n </button>\n </div>`\n : nothing\n }\n </li>\n `;\n }\n\n private _renderFetchMore() {\n if (hasErrorMessage(this.fetchMoreError)) {\n return html`\n <div class=\"fetch-more-error\" part=\"fetch-more-error\" role=\"alert\">\n Couldn't load more —\n <button\n class=\"row-action\"\n part=\"fetch-more-retry\"\n @click=${() => this._emit(\"retry\", { scope: \"fetch-more\" })}\n >\n retry\n </button>\n </div>\n `;\n }\n if (this.fetchingMore) {\n return html`\n <div class=\"state\" part=\"fetching-more\" aria-busy=\"true\">Loading more…</div>\n `;\n }\n if (this.hasMore) {\n return html`\n <button\n class=\"load-more\"\n part=\"load-more\"\n @click=${() => this._emit(\"load-more\", {})}\n >\n Load more\n </button>\n `;\n }\n return nothing;\n }\n\n private _renderMemories() {\n // Reserved region — hidden until a consumer projects content into the slot.\n // A `slotchange` listener drives `_hasMemories` so light-DOM mutations after\n // first render reactively reveal/hide the region.\n return html`\n <div class=\"memories\" part=\"memories\" ?hidden=${!this._hasMemories}>\n <slot\n name=\"memories\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasMemories = slot.assignedElements().length > 0;\n }}\n ></slot>\n </div>\n `;\n }\n\n private _renderFooter() {\n // Reserved region — hidden until a consumer projects content into the\n // `footer` slot. Without this gate the footer's top border + padding render\n // as an empty box at the bottom of the drawer. Mirrors `_renderMemories`.\n return html`\n <div class=\"footer\" part=\"footer\" ?hidden=${!this._hasFooter}>\n <slot\n name=\"footer\"\n @slotchange=${(e: Event) => {\n const slot = e.target as HTMLSlotElement;\n this._hasFooter = slot.assignedElements().length > 0;\n }}\n ></slot>\n </div>\n `;\n }\n\n /**\n * Confirm-delete dialog, rendered as a native `<dialog>` that is ALWAYS\n * present in the shadow DOM so `updated()` can drive `showModal()`/`close()`\n * against it. Opening with `showModal()` puts it in the browser TOP LAYER, so\n * it can never be painted under other UI — the previous CSS-positioned overlay\n * was trapped in the drawer host's stacking context and appeared under the\n * chat's welcome view (ENT-1051). The `::backdrop` pseudo-element (styled in\n * styles.ts) provides the scrim natively.\n *\n * The actionable content (message + Cancel/Delete, bound to the captured id)\n * renders only while confirming, so a closed dialog holds nothing stale.\n * Native dismissal is wired via `@cancel` (Escape) and a backdrop-click check.\n */\n private _renderConfirmDialog() {\n const id = this._confirmingDeleteId;\n return html`\n <dialog\n class=\"dialog\"\n part=\"confirm-dialog\"\n role=\"alertdialog\"\n aria-label=\"Confirm delete\"\n data-testid=\"drawer-confirm-delete\"\n @cancel=${(event: Event) => {\n // Native Escape dismissal: prevent the default close (we drive open\n // state from `_confirmingDeleteId` in `updated()`) and reset it.\n event.preventDefault();\n this._confirmingDeleteId = null;\n }}\n @click=${(event: MouseEvent) => {\n // A click whose target is the <dialog> itself (not the inner card)\n // landed on the ::backdrop — dismiss, mirroring a scrim click.\n if (event.target === event.currentTarget) {\n this._confirmingDeleteId = null;\n }\n }}\n >\n ${\n id !== null\n ? html`\n <p>Delete this thread? This cannot be undone.</p>\n <div class=\"dialog-actions\">\n <button\n class=\"row-action\"\n part=\"confirm-cancel\"\n @click=${() => (this._confirmingDeleteId = null)}\n >\n Cancel\n </button>\n <button\n class=\"primary\"\n part=\"confirm-delete\"\n @click=${() => {\n this._confirmingDeleteId = null;\n this._emit(\"delete\", { threadId: id });\n }}\n >\n Delete\n </button>\n </div>\n `\n : nothing\n }\n </dialog>\n `;\n }\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gCACX;;AAGF,MAAM,oBAAoB;;;;;;;AAQ1B,SAAS,gBAAgB,OAAuC;AAC9D,QAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,SAAS;;;;;;;;;;;AAYjD,SAAS,YAAY,IAA2B;AAE9C,KAAI,GAAG,WAAW,KAAK,YAAY,KAAK,GAAG,CAAE,QAAO;AACpD,QAAO,OAAO;;;;;;;;AAShB,MAAM,cAAc,IAAI;;;;;;;;;;;;;;;;AAgBxB,MAAM,gBAAgB,IAAI;;;;;;;;;;;;;;;;;;AAkB1B,MAAM,aAAa,IAAI;;;;;;;;;;;;;;;;;;;AAuBvB,MAAM,cAAc,IAAI;;;;;;;;;;;;;;;;;;;;;AAsBxB,MAAM,iBAAiB,IAAI;;;;;;;;;;;;;;;;AAgB3B,MAAM,aAAa,IAAI;;;;;;;;;;;;;;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 @@
1
1
  {
2
2
  "name": "@copilotkit/web-components",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.30",
4
4
  "private": false,
5
5
  "description": "Framework-agnostic shadow-DOM web components for CopilotKit - includes the <copilotkit-threads-drawer> threads drawer element",
6
6
  "keywords": [
@@ -55,13 +55,12 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "peerDependencies": {
58
+ "dependencies": {
59
59
  "lit": "^3.3.2"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "^22.15.3",
63
63
  "jsdom": "^26.1.0",
64
- "lit": "^3.3.2",
65
64
  "tsdown": "^0.20.3",
66
65
  "tsx": "^4.19.2",
67
66
  "typescript": "5.9.2",