@aceshooting/lyra-ui 9.0.0 → 9.1.1
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.
- package/CHANGELOG.md +369 -0
- package/README.md +9 -2
- package/custom-elements.json +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.styles.js +2 -2
- package/dist/components/agent-tools/agent-run/agent-run.class.js +1 -1
- package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +1 -0
- package/dist/components/agent-tools/agent-trace/agent-trace.class.js +1 -1
- package/dist/components/agent-tools/browser-frame/browser-frame.class.js +1 -1
- package/dist/components/agent-tools/commit-card/commit-card.class.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/context-inspector/context-inspector.class.js +1 -1
- package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
- package/dist/components/agent-tools/policy-summary/policy-summary.class.js +1 -1
- package/dist/components/agent-tools/schema-viewer/schema-viewer.styles.js +2 -2
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +1 -1
- package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
- package/dist/components/agent-tools/test-results/test-results.class.js +1 -1
- package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +2 -2
- package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +2 -2
- package/dist/components/agent-tools/trace-tree/trace-tree.class.js +2 -2
- package/dist/components/charts/chart/bar-chart.class.js +1 -1
- package/dist/components/charts/chart/bubble-chart.class.js +1 -1
- package/dist/components/charts/chart/chart.class.js +1 -1
- package/dist/components/charts/chart/doughnut-chart.class.js +1 -1
- package/dist/components/charts/chart/histogram.class.js +1 -1
- package/dist/components/charts/chart/line-chart.class.js +1 -1
- package/dist/components/charts/chart/lite-chart.class.js +1 -1
- package/dist/components/charts/chart/pie-chart.class.js +1 -1
- package/dist/components/charts/chart/polar-area-chart.class.js +1 -1
- package/dist/components/charts/chart/radar-chart.class.js +1 -1
- package/dist/components/charts/chart/scatter-chart.class.js +1 -1
- package/dist/components/conversation/chat-message/chat-message.class.js +2 -2
- package/dist/components/conversation/chat-message/chat-message.styles.js +6 -0
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/generation-metrics/generation-metrics.class.js +2 -2
- package/dist/components/conversation/realtime-session/realtime-session.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.styles.js +9 -0
- package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap.class.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/table/table.class.js +1 -1
- package/dist/components/forms/button/button.styles.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/combobox/combobox.class.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/switch/switch.styles.js +3 -1
- package/dist/components/layout/card/card.styles.js +2 -2
- package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.d.ts +1 -0
- package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.styles.js +29 -9
- package/dist/components/media/attachment-chip/attachment-chip.class.js +2 -2
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +2 -2
- package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +2 -2
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.js +1 -1
- package/dist/components/media/flag/flag.class.js +1 -1
- package/dist/components/media/lightbox/lightbox.styles.js +2 -0
- package/dist/components/overlays/callout/callout.styles.js +2 -2
- package/dist/components/overlays/kbd/kbd.class.js +1 -1
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/overlay/tooltip.class.js +2 -2
- package/dist/components/overlays/popup/popup.class.js +2 -2
- package/dist/components/overlays/spinner/spinner.styles.js +2 -2
- package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
- package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +1 -1
- package/dist/components/retrieval/entity-card/entity-card.class.d.ts +1 -0
- package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +1 -0
- package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +1 -0
- package/dist/components/retrieval/graph-legend/graph-legend.class.d.ts +1 -0
- package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +2 -2
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +1 -0
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +11 -0
- package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +1 -1
- package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
- package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +1 -1
- package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
- package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
- package/dist/components/viewers/document-compare/document-compare.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/internal/dev-mode-attribute-warning.d.ts +7 -0
- package/dist/internal/dev-mode-attribute-warning.js +1 -0
- package/dist/internal/lyra-element.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/llms/components/lr-archive-viewer.md +5 -0
- package/llms/components/lr-attachment-trigger.md +2 -2
- package/llms/components/lr-ebook-viewer.md +3 -0
- package/llms/components/lr-heatmap.md +1 -1
- package/llms/index.md +1 -1
- package/llms/migration.md +3 -3
- package/llms/peers.md +1 -1
- package/llms/shared.md +13 -0
- package/llms-full.txt +24 -3
- package/package.json +5 -3
- package/vscode-html-data.json +1 -1
- package/web-types.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{literalSetConverter,trueDefaultBooleanConverter}from"../../../internal/converters.js";import{styles}from"./thinking-panel.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_thinking,LYRA_DEFAULT_thinkingPanelLabel,LYRA_DEFAULT_thoughtFor}from"../../../internal/default-strings.generated.js";const THINKING_PANEL_MODE=literalSetConverter(["live","post-hoc"],"live"),NEAR_BOTTOM_PX=48;class LyraThinkingPanel extends LyraElement{constructor(){super(...arguments),this.compact=!1,this.frame="card",this.expanded=!1,this._mode="live",this.follow=!0,this.bodyId=nextId("thinking-panel-body"),this.realmGeneration=0,this.onScroll=e=>{const body=e.currentTarget,following=body.scrollHeight-body.scrollTop-body.clientHeight<=NEAR_BOTTOM_PX;following!==this.follow&&(this.follow=following,this.emit("lr-follow-change",{following}))},this.onContentMutated=()=>{if(this.mode!=="live"||!this.expanded||!this.follow||this.scrollRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected)return;const generation=this.realmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{this.scrollRafId!==handle||this.scrollRafOwner!==ownerWindow||this.realmGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||(this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.mode==="live"&&this.expanded&&this.follow&&this.scrollToBottom())});this.scrollRafId=handle,this.scrollRafOwner=ownerWindow},this.toggle=()=>{const expanded=!this.expanded;this.emit("lr-toggle-request",{expanded},{cancelable:!0}).defaultPrevented||(this.expanded=expanded,this.emit("lr-toggle",{expanded:this.expanded}))}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,thinking:LYRA_DEFAULT_thinking,thinkingPanelLabel:LYRA_DEFAULT_thinkingPanelLabel,thoughtFor:LYRA_DEFAULT_thoughtFor}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=THINKING_PANEL_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}connectedCallback(){super.connectedCallback(),this.armContentObserver()}disconnectedCallback(){super.disconnectedCallback(),this.resetOwnerRealmWork()}adoptedCallback(){super.adoptedCallback(),this.resetOwnerRealmWork()}willUpdate(changed){super.willUpdate(changed),(changed.has("expanded")||changed.has("mode"))&&this.expanded&&this.mode==="live"&&(this.follow=!0)}armContentObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.contentObserver&&this.contentObserverDocument===ownerDocument)return;this.contentObserver?.disconnect(),this.contentObserver=void 0,this.contentObserverDocument=void 0;const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.realmGeneration,observer=new MutationObserverCtor(()=>{this.contentObserver!==observer||this.contentObserverDocument!==ownerDocument||this.realmGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onContentMutated()});this.contentObserver=observer,this.contentObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,characterData:!0})}resetOwnerRealmWork(){this.realmGeneration+=1,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.contentObserverDocument=void 0,this.scrollRafId!==void 0&&this.scrollRafOwner?.cancelAnimationFrame(this.scrollRafId),this.scrollRafId=void 0,this.scrollRafOwner=void 0}updated(changed){super.updated(changed),(changed.has("expanded")||changed.has("mode"))&&this.expanded&&this.mode==="live"&&this.scrollToBottom()}scrollToBottom(){this.follow=!0;const body=this.renderRoot.querySelector('[part="body"]');body&&(body.scrollTop=body.scrollHeight)}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}get durationDisplay(){const durationMs=this.safeDurationMs;if(durationMs!=null){const duration=durationMessageValue(durationMs),value=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value);return{text:this.localize("thoughtFor",void 0,{duration:this.localize(duration.key,void 0,{value})}),pending:!1}}return this.mode==="live"?{text:this.localize("thinking"),pending:!0}:null}render(){const duration=this.durationDisplay,label=this.label==null?this.localize("thinkingPanelLabel"):this.label;return html`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{literalSetConverter,trueDefaultBooleanConverter}from"../../../internal/converters.js";import{styles}from"./thinking-panel.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_thinking,LYRA_DEFAULT_thinkingPanelLabel,LYRA_DEFAULT_thoughtFor}from"../../../internal/default-strings.generated.js";const THINKING_PANEL_MODE=literalSetConverter(["live","post-hoc"],"live"),NEAR_BOTTOM_PX=48;class LyraThinkingPanel extends LyraElement{constructor(){super(...arguments),this.compact=!1,this.frame="card",this.expanded=!1,this._mode="live",this.follow=!0,this.bodyId=nextId("thinking-panel-body"),this.realmGeneration=0,this.onScroll=e=>{const body=e.currentTarget,following=body.scrollHeight-body.scrollTop-body.clientHeight<=NEAR_BOTTOM_PX;following!==this.follow&&(this.follow=following,this.emit("lr-follow-change",{following}))},this.onContentMutated=()=>{if(this.mode!=="live"||!this.expanded||!this.follow||this.scrollRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected)return;const generation=this.realmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{this.scrollRafId!==handle||this.scrollRafOwner!==ownerWindow||this.realmGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||(this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.mode==="live"&&this.expanded&&this.follow&&this.scrollToBottom())});this.scrollRafId=handle,this.scrollRafOwner=ownerWindow},this.toggle=()=>{const expanded=!this.expanded;this.emit("lr-toggle-request",{expanded},{cancelable:!0}).defaultPrevented||(this.expanded=expanded,this.emit("lr-toggle",{expanded:this.expanded}))}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,thinking:LYRA_DEFAULT_thinking,thinkingPanelLabel:LYRA_DEFAULT_thinkingPanelLabel,thoughtFor:LYRA_DEFAULT_thoughtFor}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=THINKING_PANEL_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}connectedCallback(){super.connectedCallback(),this.armContentObserver()}disconnectedCallback(){super.disconnectedCallback(),this.resetOwnerRealmWork()}adoptedCallback(){super.adoptedCallback(),this.resetOwnerRealmWork()}willUpdate(changed){super.willUpdate(changed),(changed.has("expanded")||changed.has("mode"))&&this.expanded&&this.mode==="live"&&(this.follow=!0)}armContentObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.contentObserver&&this.contentObserverDocument===ownerDocument)return;this.contentObserver?.disconnect(),this.contentObserver=void 0,this.contentObserverDocument=void 0;const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.realmGeneration,observer=new MutationObserverCtor(()=>{this.contentObserver!==observer||this.contentObserverDocument!==ownerDocument||this.realmGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onContentMutated()});this.contentObserver=observer,this.contentObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,characterData:!0})}resetOwnerRealmWork(){this.realmGeneration+=1,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.contentObserverDocument=void 0,this.scrollRafId!==void 0&&this.scrollRafOwner?.cancelAnimationFrame(this.scrollRafId),this.scrollRafId=void 0,this.scrollRafOwner=void 0}updated(changed){super.updated(changed),(changed.has("expanded")||changed.has("mode"))&&this.expanded&&this.mode==="live"&&this.scrollToBottom()}scrollToBottom(){this.follow=!0;const body=this.renderRoot.querySelector('[part="body"]');body&&(body.scrollTop=body.scrollHeight)}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}get durationDisplay(){const durationMs=this.safeDurationMs;if(durationMs!=null){const duration=durationMessageValue(durationMs),value=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value);return{text:this.localize("thoughtFor",void 0,{duration:this.localize(duration.key,void 0,{value})}),pending:!1}}return this.mode==="live"?{text:this.localize("thinking"),pending:!0}:null}render(){const duration=this.durationDisplay,label=this.label==null?this.localize("thinkingPanelLabel"):this.label;return html`
|
|
2
2
|
<div part="base">
|
|
3
3
|
<button
|
|
4
4
|
part="header"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{place}from"../../../internal/positioner.js";import{nextId}from"../../../internal/a11y.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{styles}from"./tool-call-chip.styles.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{place}from"../../../internal/positioner.js";import{nextId}from"../../../internal/a11y.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{styles}from"./tool-call-chip.styles.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -15,7 +15,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
15
15
|
<circle cx="12" cy="12" r="9"></circle>
|
|
16
16
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
17
17
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
18
|
-
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolCallChip extends LyraElement{constructor(){super(...arguments),this.name="",this.category="",this.status="pending",this.summary="",this.icon="",this.callId="",this.hasDetailSlot=!1,this.tooltipOpen=!1,this.tooltipId=nextId("tool-call-chip-tooltip"),this.hovering=!1,this.focused=!1,this.onDetailSlotChange=e=>{this.hasDetailSlot=this.hasPreviewNodes(e.target.assignedNodes({flatten:!0})),this.hasDetailSlot||this.hideTooltip()},this.onMouseEnter=()=>{this.hovering=!0,this.showTooltip()},this.onMouseLeave=()=>{this.hovering=!1,!this.focused&&this.hideTooltip()},this.onFocus=()=>{this.focused=!0,this.showTooltip()},this.onBlur=()=>{this.focused=!1,!this.hovering&&this.hideTooltip()},this.onKeyDown=e=>{e.key==="Escape"&&this.tooltipOpen&&(e.stopPropagation(),this.hideTooltip())},this.onClick=()=>{this.emit("lr-tool-call-chip-select",{name:this.name,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}hasPreviewNodes(nodes){return nodes.some(node=>node.nodeType===3?!!node.textContent?.trim():node.nodeType===1&&!node.hasAttribute("slot"))}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasDetailSlot=this.hasPreviewNodes(Array.from(this.childNodes)))}updated(changed){if(super.updated(changed),changed.has("tooltipOpen")&&(this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOpen)){const anchor=this.renderRoot.querySelector('[part="base"]'),tooltip=this.renderRoot.querySelector('[part="tooltip"]');anchor&&tooltip&&(this.cleanupPositioner=place(anchor,tooltip,{placement:"top-start"}))}}disconnectedCallback(){super.disconnectedCallback(),this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOpen=!1,this.hovering=!1,this.focused=!1}showTooltip(){!this.hasDetailSlot||this.tooltipOpen||(this.tooltipOpen=!0)}hideTooltip(){this.tooltipOpen&&(this.tooltipOpen=!1)}focus(options){this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}click(){this.baseEl?.click()}get effectiveStatus(){return STATUS_VALUES.has(this.status)?this.status:"pending"}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}get accessibleLabel(){const parts=[this.name||this.localize("toolCall")];this.summary&&parts.push(this.summary),parts.push(this.localize(STATUS_LABEL_KEY[this.effectiveStatus]));const durationMs=this.safeDurationMs;return durationMs!=null&&parts.push(this.localizedDuration(durationMs)),parts.join(this.localize("accessibleLabelSeparator"))}localizedDuration(ms){const duration=durationMessageValue(ms);return this.localize(duration.key,void 0,{value:getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value)})}render(){const hasCategory=this.category.length>0,hasSummary=this.summary.length>0,durationMs=this.safeDurationMs,hasDuration=durationMs!=null,status=this.effectiveStatus;return html`
|
|
18
|
+
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolCallChip extends LyraElement{constructor(){super(...arguments),this.name="",this.category="",this.status="pending",this.summary="",this.icon="",this.callId="",this.hasDetailSlot=!1,this.tooltipOpen=!1,this.tooltipId=nextId("tool-call-chip-tooltip"),this.hovering=!1,this.focused=!1,this.onDetailSlotChange=e=>{this.hasDetailSlot=this.hasPreviewNodes(e.target.assignedNodes({flatten:!0})),this.hasDetailSlot||this.hideTooltip()},this.onMouseEnter=()=>{this.hovering=!0,this.showTooltip()},this.onMouseLeave=()=>{this.hovering=!1,!this.focused&&this.hideTooltip()},this.onFocus=()=>{this.focused=!0,this.showTooltip()},this.onBlur=()=>{this.focused=!1,!this.hovering&&this.hideTooltip()},this.onKeyDown=e=>{e.key==="Escape"&&this.tooltipOpen&&(e.stopPropagation(),this.hideTooltip())},this.onClick=()=>{this.emit("lr-tool-call-chip-select",{name:this.name,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}hasPreviewNodes(nodes){return nodes.some(node=>node.nodeType===3?!!node.textContent?.trim():node.nodeType===1&&!node.hasAttribute("slot"))}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasDetailSlot=this.hasPreviewNodes(Array.from(this.childNodes)))}updated(changed){if(super.updated(changed),changed.has("tooltipOpen")&&(this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOpen)){const anchor=this.renderRoot.querySelector('[part="base"]'),tooltip=this.renderRoot.querySelector('[part="tooltip"]');anchor&&tooltip&&(this.cleanupPositioner=place(anchor,tooltip,{placement:"top-start"}))}}disconnectedCallback(){super.disconnectedCallback(),this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOpen=!1,this.hovering=!1,this.focused=!1}showTooltip(){!this.hasDetailSlot||this.tooltipOpen||(this.tooltipOpen=!0)}hideTooltip(){this.tooltipOpen&&(this.tooltipOpen=!1)}focus(options){this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}click(){this.baseEl?.click()}get effectiveStatus(){return STATUS_VALUES.has(this.status)?this.status:"pending"}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}get accessibleLabel(){const parts=[this.name||this.localize("toolCall")];this.summary&&parts.push(this.summary),parts.push(this.localize(STATUS_LABEL_KEY[this.effectiveStatus]));const durationMs=this.safeDurationMs;return durationMs!=null&&parts.push(this.localizedDuration(durationMs)),parts.join(this.localize("accessibleLabelSeparator"))}localizedDuration(ms){const duration=durationMessageValue(ms);return this.localize(duration.key,void 0,{value:getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value)})}render(){const hasCategory=this.category.length>0,hasSummary=this.summary.length>0,durationMs=this.safeDurationMs,hasDuration=durationMs!=null,status=this.effectiveStatus;return html`
|
|
19
19
|
<button
|
|
20
20
|
part="base"
|
|
21
21
|
type="button"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{closeIcon,expandIcon}from"../../../internal/icons.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{styles}from"./tool-result-dialog.styles.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_maximize,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{closeIcon,expandIcon}from"../../../internal/icons.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{durationMessageValue}from"../../../internal/duration.js";import{styles}from"./tool-result-dialog.styles.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_maximize,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -20,7 +20,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
20
20
|
<circle cx="12" cy="12" r="9"></circle>
|
|
21
21
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
22
22
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
23
|
-
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolResultDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.accessibleLabel=null,this.toolName="",this.status="pending",this.maximized=!1,this.hasFooterSlot=!1,this.titleId=nextId("tool-result-dialog-title"),this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{this.close("close-button")},this.toggleMaximized=()=>{this.maximized=!this.maximized,this.emit("lr-maximize-change",Object.freeze({maximized:this.maximized}))}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,maximize:LYRA_DEFAULT_maximize,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("open")&&(this.open?this.activateOverlay():this.deactivateOverlay())}updated(changed){super.updated(changed),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueMicrotask(()=>this.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback(),this.overlay?.suspend()}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",reason))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>this.close("backdrop"),lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}localizedDuration(ms){const duration=durationMessageValue(ms);return this.localize(duration.key,void 0,{value:getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value)})}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}render(){const durationMs=this.safeDurationMs,panelLabel=hostAriaLabel(this)===null&&this.accessibleLabel?this.accessibleLabel:null;return html`
|
|
23
|
+
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolResultDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.accessibleLabel=null,this.toolName="",this.status="pending",this.maximized=!1,this.hasFooterSlot=!1,this.titleId=nextId("tool-result-dialog-title"),this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{this.close("close-button")},this.toggleMaximized=()=>{this.maximized=!this.maximized,this.emit("lr-maximize-change",Object.freeze({maximized:this.maximized}))}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,maximize:LYRA_DEFAULT_maximize,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("open")&&(this.open?this.activateOverlay():this.deactivateOverlay())}updated(changed){super.updated(changed),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueMicrotask(()=>this.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback(),this.overlay?.suspend()}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",reason))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>this.close("backdrop"),lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}localizedDuration(ms){const duration=durationMessageValue(ms);return this.localize(duration.key,void 0,{value:getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value)})}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}render(){const durationMs=this.safeDurationMs,panelLabel=hostAriaLabel(this)===null&&this.accessibleLabel?this.accessibleLabel:null;return html`
|
|
24
24
|
<div part="backdrop" @click=${this.onBackdropClick}></div>
|
|
25
25
|
<div
|
|
26
26
|
part="panel"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteCount}from"../../../internal/numbers.js";import{chevronIcon}from"../../../internal/icons.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{styles}from"./trace-tree.styles.js";import{MAX_RENDERED_LYRA_SPANS,normalizeLyraSpans}from"./span.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_cost,LYRA_DEFAULT_details,LYRA_DEFAULT_duration,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_spanKindAgent,LYRA_DEFAULT_spanKindEmbedding,LYRA_DEFAULT_spanKindLlm,LYRA_DEFAULT_spanKindOther,LYRA_DEFAULT_spanKindRetriever,LYRA_DEFAULT_spanKindTool,LYRA_DEFAULT_spanProjectionLimit,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut,LYRA_DEFAULT_traceTree,LYRA_DEFAULT_traceTreeMetricLabel,LYRA_DEFAULT_traceTreeSpanStatus}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function glyph(paths){return svg`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteCount}from"../../../internal/numbers.js";import{chevronIcon}from"../../../internal/icons.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{styles}from"./trace-tree.styles.js";import{MAX_RENDERED_LYRA_SPANS,normalizeLyraSpans}from"./span.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_cost,LYRA_DEFAULT_details,LYRA_DEFAULT_duration,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_spanKindAgent,LYRA_DEFAULT_spanKindEmbedding,LYRA_DEFAULT_spanKindLlm,LYRA_DEFAULT_spanKindOther,LYRA_DEFAULT_spanKindRetriever,LYRA_DEFAULT_spanKindTool,LYRA_DEFAULT_spanProjectionLimit,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut,LYRA_DEFAULT_traceTree,LYRA_DEFAULT_traceTreeMetricLabel,LYRA_DEFAULT_traceTreeSpanStatus}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function glyph(paths){return svg`
|
|
2
2
|
<svg width="1em" height="1em" viewBox=${ICON_VIEW_BOX} fill="none" stroke="currentColor"
|
|
3
3
|
stroke-width=${ICON_STROKE_WIDTH} stroke-linecap="round" stroke-linejoin="round"
|
|
4
4
|
aria-hidden="true" focusable="false">${paths}</svg>
|
|
5
|
-
`}function agentIcon(){return glyph(svg`<rect x="5" y="8" width="14" height="10" rx="2"></rect><circle cx="9.5" cy="13" r="1"></circle><circle cx="14.5" cy="13" r="1"></circle><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle>`)}function llmIcon(){return glyph(svg`<path d="M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6z"></path><path d="M18.5 15l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7z"></path>`)}function toolIcon(){return glyph(svg`<path d="M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17l3 3 5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-2-2z"></path>`)}function retrieverIcon(){return glyph(svg`<circle cx="10.5" cy="10.5" r="6.5"></circle><line x1="15.5" y1="15.5" x2="20" y2="20"></line>`)}function embeddingIcon(){return glyph(svg`<circle cx="6" cy="6" r="1.6"></circle><circle cx="18" cy="6" r="1.6"></circle><circle cx="6" cy="18" r="1.6"></circle><circle cx="18" cy="18" r="1.6"></circle><circle cx="12" cy="12" r="1.6"></circle><line x1="7.3" y1="7.3" x2="10.8" y2="10.8"></line><line x1="16.7" y1="7.3" x2="13.2" y2="10.8"></line><line x1="7.3" y1="16.7" x2="10.8" y2="13.2"></line><line x1="16.7" y1="16.7" x2="13.2" y2="13.2"></line>`)}function otherIcon(){return glyph(svg`<circle cx="12" cy="12" r="8"></circle>`)}const KIND_ICON={agent:agentIcon,llm:llmIcon,tool:toolIcon,retriever:retrieverIcon,embedding:embeddingIcon,other:otherIcon},KIND_LABEL_KEY={agent:"spanKindAgent",llm:"spanKindLlm",tool:"spanKindTool",retriever:"spanKindRetriever",embedding:"spanKindEmbedding",other:"spanKindOther"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"};class LyraTraceTree extends LyraElement{constructor(){super(...arguments),this.spans=[],this.activeSpanId=null,this.showTokens=!1,this.showCost=!1,this.hideBars=!1,this.collapsedIds=new Set,this.focusedId=null,this.previousStatuses=new Map,this.pendingAnnouncements=[],this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.renderedProjectionTruncated=!1,this.onKeyDown=e=>{const rows=this.buildRows();if(rows.length===0)return;const currentIndex=rows.findIndex(r=>r.span.id===this.focusedId),current=currentIndex>=0?rows[currentIndex]:rows[0];if(!current)return;const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(rows[Math.min(rows.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusRow(rows[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusRow(rows[0]);break;case"End":e.preventDefault(),this.focusRow(rows[rows.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else{const child=rows[currentIndex+1];child&&child.depth>current.depth&&this.focusRow(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&!this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else for(let i=currentIndex-1;i>=0;i--){const row=rows[i];if(row&&row.depth<current.depth){this.focusRow(row);break}}break;case"Enter":case" ":e.preventDefault(),this.selectRow(current.span.id);break;default:return}}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,cost:LYRA_DEFAULT_cost,details:LYRA_DEFAULT_details,duration:LYRA_DEFAULT_duration,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,spanKindAgent:LYRA_DEFAULT_spanKindAgent,spanKindEmbedding:LYRA_DEFAULT_spanKindEmbedding,spanKindLlm:LYRA_DEFAULT_spanKindLlm,spanKindOther:LYRA_DEFAULT_spanKindOther,spanKindRetriever:LYRA_DEFAULT_spanKindRetriever,spanKindTool:LYRA_DEFAULT_spanKindTool,spanProjectionLimit:LYRA_DEFAULT_spanProjectionLimit,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut,traceTree:LYRA_DEFAULT_traceTree,traceTreeMetricLabel:LYRA_DEFAULT_traceTreeMetricLabel,traceTreeSpanStatus:LYRA_DEFAULT_traceTreeSpanStatus}}static{this.ownedCollectionProperties=Object.freeze(["spans"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.syncLimitAnnouncementSink(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.renderedProjectionTruncated}disconnectedCallback(){this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,this.syncLimitAnnouncementSink()}syncLimitAnnouncementSink(){!this.isConnected||this.limitAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}buildHierarchy(){const{spans,byId,truncated}=normalizeLyraSpans(this.spans,this.activeSpanId),childrenOf=new Map,parentOf=new Map,roots=[],hasCyclicParentChain=span=>{const visited=new Set([span.id]);let parentId=span.parentId;for(;parentId!=null;){if(visited.has(parentId))return!0;visited.add(parentId),parentId=byId.get(parentId)?.parentId}return!1};for(const span of spans){const parent=span.parentId!=null&&!hasCyclicParentChain(span)?byId.get(span.parentId):void 0;if(parent&&parent.id!==span.id){const list=childrenOf.get(parent.id)??[];list.push(span),childrenOf.set(parent.id,list),parentOf.set(span.id,parent.id)}else roots.push(span)}const byStart=(a,b)=>a.startMs-b.startMs;roots.sort(byStart);for(const list of childrenOf.values())list.sort(byStart);return{spans,byId,childrenOf,parentOf,roots,truncated}}buildRows(hierarchy=this.buildHierarchy()){const rows=[],stack=[...hierarchy.roots].reverse().map((span,reverseIndex)=>({span,depth:0,posInSet:hierarchy.roots.length-reverseIndex,setSize:hierarchy.roots.length})),visited=new Set;for(;stack.length>0&&rows.length<MAX_RENDERED_LYRA_SPANS;){const current=stack.pop();if(!current||visited.has(current.span.id))continue;visited.add(current.span.id);const children=hierarchy.childrenOf.get(current.span.id)??[];if(rows.push({...current,hasChildren:children.length>0}),!(children.length===0||this.collapsedIds.has(current.span.id)))for(let index=children.length-1;index>=0;index--){const child=children[index];child&&stack.push({span:child,depth:current.depth+1,posInSet:index+1,setSize:children.length})}}return rows}traceExtent(spans=this.buildHierarchy().spans){let max=0;for(const s of spans)max=Math.max(max,s.endMs??s.startMs,s.startMs);return max||1}formatDuration(ms){if(ms==null)return"";const number=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:ms<1e3?0:1});return ms<1e3?this.localize("durationMilliseconds",void 0,{value:number.format(ms)}):this.localize("durationSeconds",void 0,{value:number.format(ms/1e3)})}formatNumber(n){return getNumberFormat(this.effectiveLocale).format(finiteCount(n))}validTokenMetric(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0}toggleSpan(id){const collapsed=this.collapsedIds.has(id);collapsed||this.renderedRowById(id)?.focus();const next=new Set(this.collapsedIds);collapsed?next.delete(id):next.add(id),this.collapsedIds=next,this.focusedId=id,this.emit("lr-span-toggle",{spanId:id,expanded:collapsed})}async expandAll(){this.collapsedIds=new Set,await this.updateComplete}collapseAll(){const next=new Set,hierarchy=this.buildHierarchy(),{byId,parentOf}=hierarchy,hasChild=new Set(hierarchy.childrenOf.keys());for(const id of hasChild)next.add(id);if(this.collapsedIds=next,this.focusedId!=null){let current=byId.get(this.focusedId);for(;current&&parentOf.has(current.id);)current=byId.get(parentOf.get(current.id));this.focusedId=current?.id??null,current&&this.renderedRowById(current.id)?.focus()}}focusRow(row){row&&(this.focusedId=row.span.id,this.updateComplete.then(()=>{this.renderedRowById(row.span.id)?.focus()}))}selectRow(id){this.focusedId=id,this.emit("lr-span-select",{spanId:id})}willUpdate(changed){if(super.willUpdate(changed),changed.has("spans")||changed.has("activeSpanId")||changed.has("collapsedIds")){const hierarchy=this.buildHierarchy(),ids=new Set(hierarchy.byId.keys());let pruned=null;for(const id of this.collapsedIds)ids.has(id)||(pruned??=new Set(this.collapsedIds),pruned.delete(id));if(pruned&&(this.collapsedIds=pruned),(changed.has("spans")||changed.has("activeSpanId"))&&this.activeSpanId&&hierarchy.byId.has(this.activeSpanId)){const revealed=new Set(this.collapsedIds);let currentId=this.activeSpanId,changedCollapse=!1;for(;hierarchy.parentOf.has(currentId);)currentId=hierarchy.parentOf.get(currentId),revealed.delete(currentId)&&(changedCollapse=!0);changedCollapse&&(this.collapsedIds=revealed)}const rows=this.buildRows(hierarchy),visibleIds=new Set(rows.map(row=>row.span.id));if((this.focusedId==null||!ids.has(this.focusedId))&&(this.focusedId=this.activeSpanId&&visibleIds.has(this.activeSpanId)?this.activeSpanId:rows[0]?.span.id??null),changed.has("spans")){for(const row of rows){const{span}=row,prev=this.previousStatuses.get(span.id);prev!==void 0&&prev!==span.status&&this.pendingAnnouncements.push(this.localize("traceTreeSpanStatus",void 0,{name:span.name,status:this.localize(STATUS_LABEL_KEY[span.status])}))}this.previousStatuses=new Map(hierarchy.spans.map(span=>[span.id,span.status]))}const visibleAncestor=id=>{let current=id?hierarchy.byId.get(id):void 0;for(;current;){if(visibleIds.has(current.id))return current.id;current=hierarchy.parentOf.has(current.id)?hierarchy.byId.get(hierarchy.parentOf.get(current.id)):void 0}return null};this.focusedId=visibleAncestor(this.activeSpanId)??visibleAncestor(this.focusedId)??rows[0]?.span.id??null}}renderedRowById(id){const ownerCss=this.ownerDocument.defaultView?.CSS;return typeof ownerCss?.escape=="function"?this.renderRoot.querySelector(`[data-id="${ownerCss.escape(id)}"]`):Array.from(this.renderRoot.querySelectorAll("[data-id]")).find(element=>element.dataset.id===id)??null}updated(changed){if(super.updated(changed),(changed.has("activeSpanId")||changed.has("spans")||changed.has("collapsedIds"))&&this.activeSpanId){const row=this.renderedRowById(this.activeSpanId);if(row){const ownerWindow=row.ownerDocument.defaultView,reducedMotion=!ownerWindow||prefersReducedMotion(ownerWindow);row.scrollIntoView({block:"nearest",behavior:reducedMotion?"auto":"smooth"})}}if(this.pendingAnnouncements.length>0){const texts=this.pendingAnnouncements;this.pendingAnnouncements=[];for(const text of texts)this.liveRegion?.announce(text)}this.limitAnnouncementInitialized&&this.renderedProjectionTruncated&&!this.previouslyTruncated&&this.limitAnnouncementSink?.announce(this.localize("spanProjectionLimit",void 0,{count:MAX_RENDERED_LYRA_SPANS})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.renderedProjectionTruncated}renderHeader(){return html`
|
|
5
|
+
`}function agentIcon(){return glyph(svg`<rect x="5" y="8" width="14" height="10" rx="2"></rect><circle cx="9.5" cy="13" r="1"></circle><circle cx="14.5" cy="13" r="1"></circle><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle>`)}function llmIcon(){return glyph(svg`<path d="M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6z"></path><path d="M18.5 15l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7z"></path>`)}function toolIcon(){return glyph(svg`<path d="M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17l3 3 5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-2-2z"></path>`)}function retrieverIcon(){return glyph(svg`<circle cx="10.5" cy="10.5" r="6.5"></circle><line x1="15.5" y1="15.5" x2="20" y2="20"></line>`)}function embeddingIcon(){return glyph(svg`<circle cx="6" cy="6" r="1.6"></circle><circle cx="18" cy="6" r="1.6"></circle><circle cx="6" cy="18" r="1.6"></circle><circle cx="18" cy="18" r="1.6"></circle><circle cx="12" cy="12" r="1.6"></circle><line x1="7.3" y1="7.3" x2="10.8" y2="10.8"></line><line x1="16.7" y1="7.3" x2="13.2" y2="10.8"></line><line x1="7.3" y1="16.7" x2="10.8" y2="13.2"></line><line x1="16.7" y1="16.7" x2="13.2" y2="13.2"></line>`)}function otherIcon(){return glyph(svg`<circle cx="12" cy="12" r="8"></circle>`)}const KIND_ICON={agent:agentIcon,llm:llmIcon,tool:toolIcon,retriever:retrieverIcon,embedding:embeddingIcon,other:otherIcon},KIND_LABEL_KEY={agent:"spanKindAgent",llm:"spanKindLlm",tool:"spanKindTool",retriever:"spanKindRetriever",embedding:"spanKindEmbedding",other:"spanKindOther"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"};class LyraTraceTree extends LyraElement{constructor(){super(...arguments),this.spans=[],this.activeSpanId=null,this.showTokens=!1,this.showCost=!1,this.hideBars=!1,this.collapsedIds=new Set,this.focusedId=null,this.previousStatuses=new Map,this.pendingAnnouncements=[],this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.renderedProjectionTruncated=!1,this.onKeyDown=e=>{const rows=this.buildRows();if(rows.length===0)return;const currentIndex=rows.findIndex(r=>r.span.id===this.focusedId),current=currentIndex>=0?rows[currentIndex]:rows[0];if(!current)return;const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(rows[Math.min(rows.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusRow(rows[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusRow(rows[0]);break;case"End":e.preventDefault(),this.focusRow(rows[rows.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else{const child=rows[currentIndex+1];child&&child.depth>current.depth&&this.focusRow(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&!this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else for(let i=currentIndex-1;i>=0;i--){const row=rows[i];if(row&&row.depth<current.depth){this.focusRow(row);break}}break;case"Enter":case" ":e.preventDefault(),this.selectRow(current.span.id);break;default:return}}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,cost:LYRA_DEFAULT_cost,details:LYRA_DEFAULT_details,duration:LYRA_DEFAULT_duration,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,spanKindAgent:LYRA_DEFAULT_spanKindAgent,spanKindEmbedding:LYRA_DEFAULT_spanKindEmbedding,spanKindLlm:LYRA_DEFAULT_spanKindLlm,spanKindOther:LYRA_DEFAULT_spanKindOther,spanKindRetriever:LYRA_DEFAULT_spanKindRetriever,spanKindTool:LYRA_DEFAULT_spanKindTool,spanProjectionLimit:LYRA_DEFAULT_spanProjectionLimit,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut,traceTree:LYRA_DEFAULT_traceTree,traceTreeMetricLabel:LYRA_DEFAULT_traceTreeMetricLabel,traceTreeSpanStatus:LYRA_DEFAULT_traceTreeSpanStatus}}static{this.ownedCollectionProperties=Object.freeze(["spans"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.syncLimitAnnouncementSink(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.renderedProjectionTruncated}disconnectedCallback(){this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,this.syncLimitAnnouncementSink()}syncLimitAnnouncementSink(){!this.isConnected||this.limitAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}buildHierarchy(){const{spans,byId,truncated}=normalizeLyraSpans(this.spans,this.activeSpanId),childrenOf=new Map,parentOf=new Map,roots=[],hasCyclicParentChain=span=>{const visited=new Set([span.id]);let parentId=span.parentId;for(;parentId!=null;){if(visited.has(parentId))return!0;visited.add(parentId),parentId=byId.get(parentId)?.parentId}return!1};for(const span of spans){const parent=span.parentId!=null&&!hasCyclicParentChain(span)?byId.get(span.parentId):void 0;if(parent&&parent.id!==span.id){const list=childrenOf.get(parent.id)??[];list.push(span),childrenOf.set(parent.id,list),parentOf.set(span.id,parent.id)}else roots.push(span)}const byStart=(a,b)=>a.startMs-b.startMs;roots.sort(byStart);for(const list of childrenOf.values())list.sort(byStart);return{spans,byId,childrenOf,parentOf,roots,truncated}}buildRows(hierarchy=this.buildHierarchy()){const rows=[],stack=[...hierarchy.roots].reverse().map((span,reverseIndex)=>({span,depth:0,posInSet:hierarchy.roots.length-reverseIndex,setSize:hierarchy.roots.length})),visited=new Set;for(;stack.length>0&&rows.length<MAX_RENDERED_LYRA_SPANS;){const current=stack.pop();if(!current||visited.has(current.span.id))continue;visited.add(current.span.id);const children=hierarchy.childrenOf.get(current.span.id)??[];if(rows.push({...current,hasChildren:children.length>0}),!(children.length===0||this.collapsedIds.has(current.span.id)))for(let index=children.length-1;index>=0;index--){const child=children[index];child&&stack.push({span:child,depth:current.depth+1,posInSet:index+1,setSize:children.length})}}return rows}traceExtent(spans=this.buildHierarchy().spans){let max=0;for(const s of spans)max=Math.max(max,s.endMs??s.startMs,s.startMs);return max||1}formatDuration(ms){if(ms==null)return"";const number=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:ms<1e3?0:1});return ms<1e3?this.localize("durationMilliseconds",void 0,{value:number.format(ms)}):this.localize("durationSeconds",void 0,{value:number.format(ms/1e3)})}formatNumber(n){return getNumberFormat(this.effectiveLocale).format(finiteCount(n))}validTokenMetric(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0}toggleSpan(id){const collapsed=this.collapsedIds.has(id);collapsed||this.renderedRowById(id)?.focus();const next=new Set(this.collapsedIds);collapsed?next.delete(id):next.add(id),this.collapsedIds=next,this.focusedId=id,this.emit("lr-span-toggle",{spanId:id,expanded:collapsed})}async expandAll(){this.collapsedIds=new Set,await this.updateComplete}collapseAll(){const next=new Set,hierarchy=this.buildHierarchy(),{byId,parentOf}=hierarchy,hasChild=new Set(hierarchy.childrenOf.keys());for(const id of hasChild)next.add(id);if(this.collapsedIds=next,this.focusedId!=null){let current=byId.get(this.focusedId);for(;current&&parentOf.has(current.id);)current=byId.get(parentOf.get(current.id));this.focusedId=current?.id??null,current&&this.renderedRowById(current.id)?.focus()}}focusRow(row){row&&(this.focusedId=row.span.id,this.updateComplete.then(()=>{this.renderedRowById(row.span.id)?.focus()}))}selectRow(id){this.focusedId=id,this.emit("lr-span-select",{spanId:id})}willUpdate(changed){if(super.willUpdate(changed),changed.has("spans")||changed.has("activeSpanId")||changed.has("collapsedIds")){const hierarchy=this.buildHierarchy(),ids=new Set(hierarchy.byId.keys());let pruned=null;for(const id of this.collapsedIds)ids.has(id)||(pruned??=new Set(this.collapsedIds),pruned.delete(id));if(pruned&&(this.collapsedIds=pruned),(changed.has("spans")||changed.has("activeSpanId"))&&this.activeSpanId&&hierarchy.byId.has(this.activeSpanId)){const revealed=new Set(this.collapsedIds);let currentId=this.activeSpanId,changedCollapse=!1;for(;hierarchy.parentOf.has(currentId);)currentId=hierarchy.parentOf.get(currentId),revealed.delete(currentId)&&(changedCollapse=!0);changedCollapse&&(this.collapsedIds=revealed)}const rows=this.buildRows(hierarchy),visibleIds=new Set(rows.map(row=>row.span.id));if((this.focusedId==null||!ids.has(this.focusedId))&&(this.focusedId=this.activeSpanId&&visibleIds.has(this.activeSpanId)?this.activeSpanId:rows[0]?.span.id??null),changed.has("spans")){for(const row of rows){const{span}=row,prev=this.previousStatuses.get(span.id);prev!==void 0&&prev!==span.status&&this.pendingAnnouncements.push(this.localize("traceTreeSpanStatus",void 0,{name:span.name,status:this.localize(STATUS_LABEL_KEY[span.status])}))}this.previousStatuses=new Map(hierarchy.spans.map(span=>[span.id,span.status]))}const visibleAncestor=id=>{let current=id?hierarchy.byId.get(id):void 0;for(;current;){if(visibleIds.has(current.id))return current.id;current=hierarchy.parentOf.has(current.id)?hierarchy.byId.get(hierarchy.parentOf.get(current.id)):void 0}return null};this.focusedId=visibleAncestor(this.activeSpanId)??visibleAncestor(this.focusedId)??rows[0]?.span.id??null}}renderedRowById(id){const ownerCss=this.ownerDocument.defaultView?.CSS;return typeof ownerCss?.escape=="function"?this.renderRoot.querySelector(`[data-id="${ownerCss.escape(id)}"]`):Array.from(this.renderRoot.querySelectorAll("[data-id]")).find(element=>element.dataset.id===id)??null}updated(changed){if(super.updated(changed),(changed.has("activeSpanId")||changed.has("spans")||changed.has("collapsedIds"))&&this.activeSpanId){const row=this.renderedRowById(this.activeSpanId);if(row){const ownerWindow=row.ownerDocument.defaultView,reducedMotion=!ownerWindow||prefersReducedMotion(ownerWindow);row.scrollIntoView({block:"nearest",behavior:reducedMotion?"auto":"smooth"})}}if(this.pendingAnnouncements.length>0){const texts=this.pendingAnnouncements;this.pendingAnnouncements=[];for(const text of texts)this.liveRegion?.announce(text)}this.limitAnnouncementInitialized&&this.renderedProjectionTruncated&&!this.previouslyTruncated&&this.limitAnnouncementSink?.announce(this.localize("spanProjectionLimit",void 0,{count:MAX_RENDERED_LYRA_SPANS})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.renderedProjectionTruncated}renderHeader(){return html`
|
|
6
6
|
<div part="header">
|
|
7
7
|
<span class="col-toggle" aria-hidden="true"></span>
|
|
8
8
|
<span class="col-icon" aria-hidden="true"></span>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraBarChart extends LyraChart{constructor(){super(...arguments),this.type="bar"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraBarChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraBarChart extends LyraChart{constructor(){super(...arguments),this.type="bar"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraBarChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraBubbleChart extends LyraChart{constructor(){super(...arguments),this.type="bubble"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraBubbleChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraBubbleChart extends LyraChart{constructor(){super(...arguments),this.type="bubble"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraBubbleChart};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{resolveCanvasColor,seriesPalette,translucentAreaColor}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_resetZoom,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";import{seriesPalette as seriesPalette2}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]),CHART_TYPE_MESSAGE_KEYS={line:"chartTypeLine",bar:"chartTypeBar",scatter:"chartTypeScatter",pie:"chartTypePie",doughnut:"chartTypeDoughnut",radar:"chartTypeRadar",polarArea:"chartTypePolarArea",bubble:"chartTypeBubble"};function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"||isPlainObject(value)&&Object.values(value).every(candidate=>typeof candidate=="number"&&Number.isFinite(candidate))?value:"top"}function isPlainObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]),FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function deepMerge(base,override,seen=new WeakMap){if(typeof override=="object"&&override!==null){const previous=seen.get(override);if(previous!==void 0)return previous}if(!isPlainObject(base)||!isPlainObject(override))return override===void 0?base:override;const result={...base};seen.set(override,result);try{for(const key of Object.keys(override))UNSAFE_KEYS.has(key)||(result[key]=deepMerge(base[key],override[key],seen))}finally{seen.delete(override)}return result}function isChartPoint(value){return isPlainObject(value)?Number.isFinite(value.x)&&Number.isFinite(value.y):!1}function normalizedChartPoint(value){if(!isChartPoint(value))return null;const radius=value.r;return{x:value.x,y:value.y,...typeof radius=="number"&&Number.isFinite(radius)&&radius>=0?{r:radius}:{},...typeof value.label=="string"?{label:value.label}:{}}}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value){return value==null?"":Array.isArray(value)?value.map(labelText).join(" "):String(value)}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,resetZoom:LYRA_DEFAULT_resetZoom,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}constructor(){super(),this.type="bar",this.labels=[],this.datasets=[],this.description=null,this.grid="both",this.indexAxis="x",this.label=null,this.legendPosition="top",this.max=null,this.min=null,this.plugins=[],this.area=!1,this.zoom=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.beginAtZero=!0,this.showDataTable=!1,this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.loading=!0,this.loadFailed=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const script=event.currentTarget.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");isPlainObject(parsed)&&(next=parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const generated={labels:this.labels,datasets:this.datasets.map(series=>({...series,data:[...series.points??series.data??[]],yAxisID:series.axis==="y2"?"y2":"y"}))},override=this.effectiveConfig()?.data,merged=isPlainObject(override)?deepMerge(generated,override):generated;return{labels:Array.isArray(merged.labels)?merged.labels:[],datasets:Array.isArray(merged.datasets)?merged.datasets.filter(isPlainObject):[]}}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.hiddenDatasets,effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>dataset.hidden===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceDatasetCount=this.effectiveData().datasets.length,controlled=normalizeHiddenDatasets(this.hiddenDatasets,sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;this.chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}return datasetCount>0}hasExplicitConfigData(){const config=this.effectiveConfig();return isPlainObject(config)&&Object.prototype.hasOwnProperty.call(config,"data")}datasetLabel(dataset,index){return labelText(dataset.label)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return Array.isArray(dataset.data)?dataset.data:[]}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(isChartPoint)}appendData(label,values,maxPoints=0){const limit=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0;if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=isPlainObject(effectiveConfig?.data)?effectiveConfig.data:{},explicitLabels=Array.isArray(currentData.labels),explicitDatasets=Array.isArray(currentData.datasets),nextLabels=limit>0?labels2.slice(-limit):labels2;if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(series.points)return series;const current=series.data??[],data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...series,data:limit>0?data.slice(-limit):data}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...dataset,data:limit>0?data.slice(-limit):data}})),this.config={...effectiveConfig,data:nextData}}return}let domainLength=this.labels.length;for(const series of this.datasets)series.points||(domainLength=Math.max(domainLength,series.data?.length??0));const labels=[...this.labels,...Array.from({length:Math.max(0,domainLength-this.labels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>series.points?series:{...series,data:[...series.data??[],...Array.from({length:Math.max(0,domainLength-(series.data?.length??0))},()=>null),values[index]??null]});this.labels=limit>0?labels.slice(-limit):labels,this.datasets=limit>0?datasets.map(series=>series.points?series:{...series,data:series.data?.slice(-limit)}):datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.filter(isChartPoint);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>this.datasetValues(dataset)[index]).find(isChartPoint);return[labelText(effective.labels[index])||firstPoint?.label||"",...columns.flatMap(column=>{const value=this.datasetValues(column.dataset)[index];return column.point?isChartPoint(value)?[value.x,value.y,...column.radius?[value.r??""]:[],...column.pointLabel?[value.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]:[value??""]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{resolveCanvasColor,seriesPalette,translucentAreaColor}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_resetZoom,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";import{seriesPalette as seriesPalette2}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]),CHART_TYPE_MESSAGE_KEYS={line:"chartTypeLine",bar:"chartTypeBar",scatter:"chartTypeScatter",pie:"chartTypePie",doughnut:"chartTypeDoughnut",radar:"chartTypeRadar",polarArea:"chartTypePolarArea",bubble:"chartTypeBubble"};function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"||isPlainObject(value)&&Object.values(value).every(candidate=>typeof candidate=="number"&&Number.isFinite(candidate))?value:"top"}function isPlainObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]),FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function deepMerge(base,override,seen=new WeakMap){if(typeof override=="object"&&override!==null){const previous=seen.get(override);if(previous!==void 0)return previous}if(!isPlainObject(base)||!isPlainObject(override))return override===void 0?base:override;const result={...base};seen.set(override,result);try{for(const key of Object.keys(override))UNSAFE_KEYS.has(key)||(result[key]=deepMerge(base[key],override[key],seen))}finally{seen.delete(override)}return result}function isChartPoint(value){return isPlainObject(value)?Number.isFinite(value.x)&&Number.isFinite(value.y):!1}function normalizedChartPoint(value){if(!isChartPoint(value))return null;const radius=value.r;return{x:value.x,y:value.y,...typeof radius=="number"&&Number.isFinite(radius)&&radius>=0?{r:radius}:{},...typeof value.label=="string"?{label:value.label}:{}}}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value){return value==null?"":Array.isArray(value)?value.map(labelText).join(" "):String(value)}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,resetZoom:LYRA_DEFAULT_resetZoom,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}constructor(){super(),this.type="bar",this.labels=[],this.datasets=[],this.description=null,this.grid="both",this.indexAxis="x",this.label=null,this.legendPosition="top",this.max=null,this.min=null,this.plugins=[],this.area=!1,this.zoom=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.beginAtZero=!0,this.showDataTable=!1,this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.loading=!0,this.loadFailed=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const script=event.currentTarget.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");isPlainObject(parsed)&&(next=parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const generated={labels:this.labels,datasets:this.datasets.map(series=>({...series,data:[...series.points??series.data??[]],yAxisID:series.axis==="y2"?"y2":"y"}))},override=this.effectiveConfig()?.data,merged=isPlainObject(override)?deepMerge(generated,override):generated;return{labels:Array.isArray(merged.labels)?merged.labels:[],datasets:Array.isArray(merged.datasets)?merged.datasets.filter(isPlainObject):[]}}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.hiddenDatasets,effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>dataset.hidden===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceDatasetCount=this.effectiveData().datasets.length,controlled=normalizeHiddenDatasets(this.hiddenDatasets,sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;this.chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}return datasetCount>0}hasExplicitConfigData(){const config=this.effectiveConfig();return isPlainObject(config)&&Object.prototype.hasOwnProperty.call(config,"data")}datasetLabel(dataset,index){return labelText(dataset.label)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return Array.isArray(dataset.data)?dataset.data:[]}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(isChartPoint)}appendData(label,values,maxPoints=0){const limit=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0;if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=isPlainObject(effectiveConfig?.data)?effectiveConfig.data:{},explicitLabels=Array.isArray(currentData.labels),explicitDatasets=Array.isArray(currentData.datasets),nextLabels=limit>0?labels2.slice(-limit):labels2;if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(series.points)return series;const current=series.data??[],data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...series,data:limit>0?data.slice(-limit):data}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...dataset,data:limit>0?data.slice(-limit):data}})),this.config={...effectiveConfig,data:nextData}}return}let domainLength=this.labels.length;for(const series of this.datasets)series.points||(domainLength=Math.max(domainLength,series.data?.length??0));const labels=[...this.labels,...Array.from({length:Math.max(0,domainLength-this.labels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>series.points?series:{...series,data:[...series.data??[],...Array.from({length:Math.max(0,domainLength-(series.data?.length??0))},()=>null),values[index]??null]});this.labels=limit>0?labels.slice(-limit):labels,this.datasets=limit>0?datasets.map(series=>series.points?series:{...series,data:series.data?.slice(-limit)}):datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.filter(isChartPoint);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>this.datasetValues(dataset)[index]).find(isChartPoint);return[labelText(effective.labels[index])||firstPoint?.label||"",...columns.flatMap(column=>{const value=this.datasetValues(column.dataset)[index];return column.point?isChartPoint(value)?[value.x,value.y,...column.radius?[value.r??""]:[],...column.pointLabel?[value.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]:[value??""]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
|
|
2
2
|
`)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.visible=!0,this.armReducedMotionWatcher();const ownerWindow=this.ownerWindow,ResizeObserverCtor=ownerWindow?.ResizeObserver;ResizeObserverCtor&&(this.resizeObserver=new ResizeObserverCtor(entries=>{const width=entries[0]?.contentRect.width??this.getBoundingClientRect().width;if(Number.isFinite(width)&&this.lastObservedInlineSize!==void 0&&Math.abs(width-this.lastObservedInlineSize)<.5||(this.lastObservedInlineSize=width,this.resizeDrawFrame!==void 0))return;const frameOwner=this.ownerWindow;frameOwner&&(this.resizeDrawFrameOwner=frameOwner,this.resizeDrawFrame=frameOwner.requestAnimationFrame(()=>{this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,!(!this.isConnected||this.ownerWindow!==frameOwner)&&(this.updateAutoLegendPosition()||this.drawIfVisible())}))}),this.resizeObserver.observe(this)),this.updateAutoLegendPosition();const generation=++this.loadGeneration;this.zoom&&this.requestZoomFeature(),this.loadLibrary(this.zoom).then(async mod=>{try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),!(generation!==this.loadGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.loadFailed=!0;return}this.loadFailed=!1,this.chartJsModule=mod,this.drawIfVisible()}}),this.needsDataLabels&&this.requestDataLabelsFeature();const IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSinks(),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings.clear(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.resizeDrawFrame!==void 0&&this.resizeDrawFrameOwner?.cancelAnimationFrame(this.resizeDrawFrame),this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,this.lastObservedInlineSize=void 0,this.loadGeneration+=1,this.zoomLoadGeneration+=1,this.dataLabelsLoadGeneration+=1,this.discardChart(!1),this.builtPlugins=[],this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){const ownerWindow=this.ownerWindow;ownerWindow?.matchMedia&&(this.reducedMotionWindow===ownerWindow&&this.reducedMotionQuery||(this.disarmReducedMotionWatcher(),this.reducedMotionWindow=ownerWindow,this.reducedMotionQuery=ownerWindow.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedMotionQuery.addEventListener("change",this.onReducedMotionChange)))}disarmReducedMotionWatcher(){this.reducedMotionQuery?.removeEventListener("change",this.onReducedMotionChange),this.reducedMotionQuery=void 0,this.reducedMotionWindow=void 0}syncAnnouncementSinks(){!this.isConnected||this.politeAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.assertiveAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.politeAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}releaseAnnouncementSinks(){this.politeAnnouncementSink?.release(),this.politeAnnouncementSink=void 0,this.assertiveAnnouncementSink?.release(),this.assertiveAnnouncementSink=void 0}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}computedStyle(element=this){const view=this.ownerWindow;return view?view.getComputedStyle(element):"style"in element?element.style:this.style}applyDataLabelsPlugin(plugin){this.dataLabelsPlugin=plugin;let rebuilt=!1;plugin&&this.needsDataLabels&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],rebuilt=!0),this.drawIfVisible(),rebuilt&&this.showsLegend&&this.requestUpdate()}get zoomFeatureAvailable(){return this.zoom&&this.zoomFeatureState==="available"}featureWarningMessages(){if(this.loading||this.loadFailed)return[];const messages=[];return this.zoom&&this.zoomFeatureState==="unavailable"&&messages.push(this.localize("chartZoomUnavailable")),this.dataLabelsFeatureState==="unavailable"&&(this.dataLabels&&messages.push(this.localize("chartDataLabelsUnavailable")),this.stackTotals&&messages.push(this.localize("chartStackTotalsUnavailable"))),messages}requestZoomFeature(){const generation=++this.zoomLoadGeneration;if(!this.zoom){this.zoomFeatureState="idle";return}this.zoomFeatureState="loading",this.loadZoomFeature().then(result=>{generation!==this.zoomLoadGeneration||!this.isConnected||!this.zoom||(this.zoomFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.drawIfVisible(),this.requestUpdate())})}requestDataLabelsFeature(){const generation=++this.dataLabelsLoadGeneration;if(!this.needsDataLabels){this.dataLabelsFeatureState="idle";return}this.dataLabelsFeatureState="loading",this.loadDataLabelsFeature().then(result=>{generation!==this.dataLabelsLoadGeneration||!this.isConnected||!this.needsDataLabels||(this.dataLabelsFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.applyDataLabelsPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}willUpdate(changed){super.willUpdate(changed),this.zoomed&&this.effectiveType()!==this.builtType&&(this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1}))}updated(changed){if(super.updated(changed),!this.isConnected)return;const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.politeAnnouncementSink?.announce(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.assertiveAnnouncementSink?.announce(this.localize("chartMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed){const featureWarnings=this.featureWarningMessages();for(const warning of featureWarnings)this.announcedFeatureWarnings.has(warning)||this.assertiveAnnouncementSink?.announce(warning);this.announcedFeatureWarnings=new Set(featureWarnings),!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.politeAnnouncementSink?.announce(dataTruncation))}if(this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;changed.has("zoom")&&this.requestZoomFeature(),(changed.has("dataLabels")||changed.has("stackTotals"))&&this.requestDataLabelsFeature();const contentChanged=this.chartContentChanged(changed),effectiveDirection=this.effectiveDirection,effectiveLocale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==effectiveDirection||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==effectiveLocale;this.lastDrawnDirection=effectiveDirection,this.lastDrawnLocale=effectiveLocale,!(!contentChanged&&!contextChanged)&&this.drawIfVisible()}chartContentChanged(changed){return["type","labels","datasets","hiddenDatasets","description","grid","indexAxis","label","legendPosition","min","max","plugins","autoLegendPosition","valueFormatter","formatter","area","height","xLabel","yLabel","y2Label","beginAtZero","stacked","withoutAnimation","withoutLegend","withoutTooltip","dataLabels","stackTotals","config","slottedConfig","zoom","locale","strings","loading"].some(name=>changed.has(name))}seriesToDataset(s,index,palette,effectiveType,chartStyle=this.chartStyleOptions(palette),rowIndexes){const fullNormalizedData=s.points?s.points.map(normalizedChartPoint):(s.data??[]).map(value=>typeof value=="number"&&Number.isFinite(value)?value:null),normalizedData=rowIndexes?rowIndexes.map(rowIndex=>fullNormalizedData[rowIndex]??null):fullNormalizedData,borderFallback=chartStyle.borderColors[index%chartStyle.borderColors.length]??palette[index%palette.length],fillFallback=chartStyle.fillColors[index%chartStyle.fillColors.length]??palette[index%palette.length],authoredColors=Array.isArray(s.color)&&rowIndexes?rowIndexes.map(rowIndex=>s.color[rowIndex]??""):s.color,colors=typeof authoredColors=="string"?[resolveCanvasColor(this,authoredColors,borderFallback??"transparent")]:authoredColors?Array.from(authoredColors,color=>resolveCanvasColor(this,color,borderFallback??"transparent")):void 0,sliceChart=effectiveType==="pie"||effectiveType==="doughnut"||effectiveType==="polarArea",sliceFillColors=sliceChart&&chartStyle.fillColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.fillColors[sourceIndex%chartStyle.fillColors.length]}):void 0,sliceBorderColors=sliceChart&&chartStyle.borderColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.borderColors[sourceIndex%chartStyle.borderColors.length]}):void 0,fill=s.fill??this.area,backgroundColor=colors??sliceFillColors??fillFallback,datasetType=s.type??effectiveType,segmentColors=(s.segmentColors&&rowIndexes?rowIndexes.map(rowIndex=>s.segmentColors[rowIndex]??""):s.segmentColors)?.map(color=>resolveCanvasColor(this,color,colors?.[0]??borderFallback??"transparent")),resolvedBackgroundColor=datasetType==="line"&&fill&&(colors||!chartStyle.authoredFillColors[index%chartStyle.authoredFillColors.length])?Array.isArray(backgroundColor)?backgroundColor.map(color=>translucentAreaColor(this,color)):backgroundColor&&translucentAreaColor(this,backgroundColor):backgroundColor,encoding=forcedColorEncoding(index),encodedBackgroundColor=chartStyle.forcedColors?Array.isArray(resolvedBackgroundColor)?resolvedBackgroundColor.map((color,itemIndex)=>this.forcedColorPattern(sliceChart?itemIndex:index,color)):resolvedBackgroundColor&&this.forcedColorPattern(index,resolvedBackgroundColor):resolvedBackgroundColor,pointRadii=Array.isArray(s.pointRadius)?s.pointRadius:void 0;return{label:s.label,data:normalizedData,type:s.type,fill,borderRadius:chartStyle.borderRadius,borderWidth:nonNegativeFinite(s.width,datasetType==="line"?chartStyle.lineBorderWidth:chartStyle.borderWidth),borderDash:s.dash?[4,4]:chartStyle.forcedColors?[...encoding.dash]:void 0,pointStyle:chartStyle.forcedColors?encoding.pointStyle:void 0,backgroundColor:encodedBackgroundColor,borderColor:colors?.[0]??sliceBorderColors??borderFallback,pointBackgroundColor:(s.pointColors&&rowIndexes?rowIndexes.map(rowIndex=>s.pointColors[rowIndex]??""):s.pointColors)?.map(color=>resolveCanvasColor(this,color,colors?.[0]??borderFallback??"transparent")),pointRadius:pointRadii?(rowIndexes?rowIndexes.map(rowIndex=>pointRadii[rowIndex]):pointRadii).map(radius=>nonNegativeFinite(radius,chartStyle.pointRadius)):nonNegativeFinite(s.pointRadius,chartStyle.pointRadius),...segmentColors?.length?{segment:{borderColor:ctx=>segmentColors[ctx.p0DataIndex%segmentColors.length]}}:{},yAxisID:s.axis==="y2"?"y2":"y"}}themeColors(){const cs=this.computedStyle(),grid=cs.getPropertyValue("--grid-color").trim()||cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),tick=cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),legend=cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),tooltipBg=cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),tooltipText=cs.getPropertyValue("--lr-chart-tooltip-text").trim()||cs.getPropertyValue("--_lr-chart-tooltip-text").trim();return{grid:resolveCanvasColor(this,grid,FALLBACK_GRID_COLOR),tick:resolveCanvasColor(this,tick,FALLBACK_TICK_COLOR),legend:resolveCanvasColor(this,legend,FALLBACK_LEGEND_COLOR),tooltipBg:resolveCanvasColor(this,tooltipBg,FALLBACK_TOOLTIP_BG),tooltipText:resolveCanvasColor(this,tooltipText,FALLBACK_TOOLTIP_TEXT)}}styleColor(name,fallback){const value=this.computedStyle().getPropertyValue(name).trim();return value?resolveCanvasColor(this,value,fallback):fallback}styleNumber(name,fallbackToken,fallback){const computed=this.computedStyle(),value=computed.getPropertyValue(name).trim()||computed.getPropertyValue(fallbackToken).trim(),direct=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(?:px)?$/i.exec(value);if(direct){const resolved=Number.parseFloat(direct[1]);if(Number.isFinite(resolved)&&resolved>=0)return resolved}if(!value||!this.ownerWindow)return fallback;const probe=this.ownerDocument.createElement("span");probe.hidden=!0,probe.setAttribute("aria-hidden","true"),probe.style.inlineSize=value,(this.shadowRoot??this).append(probe);try{const resolved=Number.parseFloat(this.computedStyle(probe).inlineSize);return Number.isFinite(resolved)&&resolved>=0?resolved:fallback}finally{probe.remove()}}forcedColorPattern(index,background){return this.ownerWindow?createForcedColorPattern(this.ownerDocument,index,background,this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG)):background}chartStyleOptions(palette){const computed=this.computedStyle(),authoredFillColors=palette.map((_,index)=>index<6&&!!computed.getPropertyValue(`--fill-color-${index+1}`).trim()),borderColors=palette.map((fallback,index)=>index<6?this.styleColor(`--border-color-${index+1}`,fallback):fallback),fillColors=palette.map((fallback,index)=>index<6?this.styleColor(`--fill-color-${index+1}`,fallback):fallback);return{borderColors,fillColors,authoredFillColors,borderRadius:this.styleNumber("--border-radius","--lr-radius",6),borderWidth:this.styleNumber("--border-width","--lr-border-width-thin",1),gridBorderWidth:this.styleNumber("--grid-border-width","--lr-border-width-thin",1),lineBorderWidth:this.styleNumber("--line-border-width","--lr-border-width-medium",2),pointRadius:this.styleNumber("--point-radius","--lr-space-2xs",4),forcedColors:forcedColorsActive(this.ownerWindow)}}get needsDataLabels(){return this.dataLabels||this.stackTotals}datalabelsOptions(theme,effectiveType){if(!this.needsDataLabels)return{display:!1};const datasets=this.effectiveData().datasets,stackTotalsActive=this.stackTotals&&this.stacked&&(effectiveType==="bar"||effectiveType==="line"),topDatasetIndexByAxis=new Map;stackTotalsActive&&datasets.forEach((dataset,index)=>topDatasetIndexByAxis.set(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y",index));const totalsByAxis=stackTotalsActive?{y:this.computeStackTotals("y"),y2:this.computeStackTotals("y2")}:void 0;return{color:theme.tick,align:stackTotalsActive?"end":"center",anchor:stackTotalsActive?"end":"center",display:context=>{const datasetIndex=context.datasetIndex,dataset=datasets[datasetIndex],axis=dataset?.yAxisID==="y2"||dataset?.axis==="y2"?"y2":"y";return stackTotalsActive?topDatasetIndexByAxis.get(axis)!==datasetIndex?this.dataLabels:totalsByAxis?.[axis][context.dataIndex]==null?this.dataLabels:!0:this.dataLabels},formatter:(value,context)=>{const datasetIndex=context.datasetIndex,dataset=datasets[datasetIndex],axis=dataset?.yAxisID==="y2"||dataset?.axis==="y2"?"y2":"y";if(stackTotalsActive&&topDatasetIndexByAxis.get(axis)===datasetIndex){const total=totalsByAxis?.[axis][context.dataIndex];if(total!=null)return this.formatDataLabel(total)}const numeric=typeof value=="number"?value:Number(value?.y??value);return numeric==null||!Number.isFinite(numeric)?"":this.formatDataLabel(numeric)}}}formatDataLabel(value){if(this.formatter||this.valueFormatter){const formatted=this.formatter?.({value,surface:"visual"})??this.valueFormatter?.(value,"tooltip");if(formatted!=null)return String(formatted)}return value.toLocaleString(this.effectiveLocale)}computeStackTotals(axisId="y"){const effective=this.effectiveData(),members=effective.datasets.filter(dataset=>(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y")===axisId),categoryCount=members.reduce((max,dataset)=>Math.max(max,this.datasetValues(dataset).length),effective.labels.length),totals=[];for(let i=0;i<categoryCount;i++){let sum=0,any=!1;for(const dataset of members){const value=this.datasetValues(dataset)[i],numeric=isChartPoint(value)?value.y:value;numeric==null||!Number.isFinite(numeric)||(sum=finiteAdd(sum,numeric),any=!0)}totals.push(any?sum:null)}return totals}seriesPalette(){return seriesPalette(this)}tickOptions(theme,kind="value"){return{color:theme.tick,...(this.formatter||this.valueFormatter)&&kind==="value"?{callback:value=>this.formatValue(value,"tick")}:{}}}effectiveIndexAxis(){return this.indexAxis==="y"?"y":"x"}scaleBounds(){const min=this.min!==null&&Number.isFinite(this.min)?finiteNumber(this.min,0):void 0,max=this.max!==null&&Number.isFinite(this.max)?finiteNumber(this.max,0):void 0;return{...min!==void 0?{min}:{},...max!==void 0?{max}:{}}}gridAxisVisible(axis){const grid=normalizeChartGrid(this.grid);return grid==="both"||grid===axis}buildScales(effectiveType,theme,chartStyle){if(effectiveType==="pie"||effectiveType==="doughnut")return{};if(effectiveType==="radar"||effectiveType==="polarArea")return{r:{beginAtZero:this.beginAtZero,...this.scaleBounds(),ticks:{...this.tickOptions(theme),showLabelBackdrop:!1,z:1},grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},angleLines:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},pointLabels:{color:theme.tick}}};const hasY2=this.effectiveData().datasets.some(dataset=>dataset.yAxisID==="y2"||dataset.axis==="y2"),rtl=this.effectiveDirection==="rtl",stacked=this.stacked&&(effectiveType==="bar"||effectiveType==="line"),horizontalCategorical=(effectiveType==="bar"||effectiveType==="line")&&this.effectiveIndexAxis()==="y",xKind=effectiveType==="scatter"||effectiveType==="bubble"||horizontalCategorical?"value":"category",yKind=horizontalCategorical?"category":"value",valueAxis=horizontalCategorical?"x":"y",bounds=this.scaleBounds();return{x:{type:xKind==="value"?"linear":"category",beginAtZero:xKind==="value"?this.beginAtZero:void 0,...valueAxis==="x"?bounds:{},title:{display:!!this.xLabel,text:this.xLabel,color:theme.tick},ticks:this.tickOptions(theme,xKind),grid:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked},y:{type:yKind==="value"?"linear":"category",position:rtl?"right":"left",beginAtZero:yKind==="value"?this.beginAtZero:void 0,...valueAxis==="y"?bounds:{},title:{display:!!this.yLabel,text:this.yLabel,color:theme.tick},ticks:this.tickOptions(theme,yKind),grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked},...hasY2?{y2:{position:rtl?"left":"right",...valueAxis==="y"?bounds:{},grid:{drawOnChartArea:!1,color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},title:{display:!!this.y2Label,text:this.y2Label,color:theme.tick},ticks:this.tickOptions(theme),stacked}}:{}}}handlePointClick(event,chart){const hit=chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0)[0];if(!hit)return;const datasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,index=this.visualRowSourceIndexes?.[hit.index]??hit.index,effective=this.effectiveData(),value=this.datasetValues(effective.datasets[datasetIndex])[index]??null,label=isChartPoint(value)&&value.label!==void 0?value.label:labelText(effective.labels[index])||void 0;this.activateDatum({datasetIndex,index,label,value})}chartDatums(){const chartData=this.chart?.data,labels=chartData?.labels??this.labels,datasets=chartData?.datasets??this.datasets.map(series=>({data:series.points??series.data??[]}));let rowCount=labels.length;for(const dataset of datasets)rowCount=Math.max(rowCount,dataset.data?.length??0);const sample=sampleChartTableIndexes(rowCount,datasets.length),datums=[];return sample.seriesIndexes.forEach(datasetIndex=>{const dataset=datasets[datasetIndex];if(!dataset)return;const values=dataset.data??[];sample.rowIndexes.forEach(index=>{const value=values[index];value!=null&&(typeof value=="number"&&!Number.isFinite(value)||datums.push({datasetIndex:this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex,index:this.visualRowSourceIndexes?.[index]??index,label:isChartPoint(value)&&value.label!==void 0?value.label:labelText(labels[index])||void 0,value}))})}),datums}datumDisplayValue(value){if(isChartPoint(value)){const numberFormat=getNumberFormat(this.effectiveLocale),x=numberFormat.format(value.x),y=numberFormat.format(value.y),coordinates=value.r==null?this.localize("chartPointCoordinates",void 0,{x,y}):this.localize("chartBubblePointCoordinates",void 0,{x,y,radius:numberFormat.format(value.r)});return typeof value.label=="string"?this.localize("chartLabeledPoint",void 0,{label:value.label,coordinates}):coordinates}const numeric=typeof value=="number"?value:Number(typeof value=="object"&&value!==null?value.y??value.r??value.x:value);return Number.isFinite(numeric)?getNumberFormat(this.effectiveLocale).format(numeric):String(value)}datumAnnouncement(datum,position,total){const series=String(this.effectiveData().datasets[datum.datasetIndex]?.label??"")||this.localize("chartSeriesLabel");return this.localize("liteChartMarkSummary",void 0,{series,label:datum.label??this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(datum.index+1)}),value:this.datumDisplayValue(datum.value),index:getNumberFormat(this.effectiveLocale).format(position+1),total:getNumberFormat(this.effectiveLocale).format(total)})}activateDatum(datum){const datums=this.chartDatums(),position=datums.findIndex(candidate=>candidate.datasetIndex===datum.datasetIndex&&candidate.index===datum.index);position>=0&&(this.keyboardDatumIndex=position,this.keyboardDatumAnnouncement=this.datumAnnouncement(datum,position,datums.length));const type=this.effectiveType(),kind=type==="bar"?"bar":type==="pie"||type==="doughnut"||type==="polarArea"?"slice":type==="line"?"segment":"point";this.emit("lr-datum-activate",{...datum,kind}),this.emit("lr-point-click",datum)}onCanvasFocus(){const datums=this.chartDatums();datums.length&&(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[this.keyboardDatumIndex],this.keyboardDatumIndex,datums.length))}onCanvasKeyDown(event){const datums=this.chartDatums();if(!datums.length)return;if(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),event.key==="Enter"||event.key===" "){event.preventDefault(),this.activateDatum(datums[this.keyboardDatumIndex]);return}const rtl=this.effectiveDirection==="rtl",forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft";let next=this.keyboardDatumIndex;if(event.key===forward||event.key==="ArrowDown")next=Math.min(datums.length-1,next+1);else if(event.key===backward||event.key==="ArrowUp")next=Math.max(0,next-1);else if(event.key==="Home")next=0;else if(event.key==="End")next=datums.length-1;else return;event.preventDefault(),this.keyboardDatumIndex=next,this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[next],next,datums.length)}effectiveType(){return this.effectiveConfig()?.type??normalizeChartType(this.type)}localizedChartType(){const type=this.effectiveType(),key=CHART_TYPE_MESSAGE_KEYS[type];return key?this.localize(key):String(type)}formatValue(value,context){const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?this.formatter?.({value:numeric,surface:context})??this.valueFormatter?.(numeric,context)??value:value}legendValue(item,chart){const datasetIndex=item.datasetIndex;if(datasetIndex===void 0)return;const data=chart.data.datasets?.[datasetIndex]?.data;if(!data)return;const indexed=typeof item.index=="number"&&Number.isInteger(item.index)?Number(data[item.index]):NaN;if(Number.isFinite(indexed))return indexed;let sum=0,hasValue=!1;for(const datum of data){const value=Number(datum);Number.isFinite(value)&&(sum=finiteAdd(sum,value),hasValue=!0)}return hasValue?sum:void 0}legendLabels(chart){const generateLabels=this.chartJsModule?.defaults?.plugins?.legend?.labels?.generateLabels;return((generateLabels&&chart.legend&&chart.options?generateLabels(chart):void 0)??(chart.data.datasets??[]).map((dataset,index)=>({text:labelText(dataset.label)||String(index+1),datasetIndex:index}))).map(item=>{const value=this.legendValue(item,chart),formatted=this.formatValue(value,"legend");return formatted===value||formatted===void 0?item:{...item,text:this.localize("chartValueLabel",void 0,{label:String(item.text),value:String(formatted)})}})}tooltipLabel(context){const parsed=context.parsed,rawValue=isPlainObject(parsed)?parsed.y??parsed.r??parsed.x:parsed??context.raw,formatted=this.formatValue(rawValue,"tooltip");if(!(formatted===rawValue||formatted===void 0))return context.dataset?.label?this.localize("chartValueLabel",void 0,{label:String(context.dataset.label),value:String(formatted)}):String(formatted)}updateAutoLegendPosition(){const width=this.getBoundingClientRect().width||this.clientWidth,next=width>0&&width<480?"bottom":"right";return next===this.autoLegendPosition?!1:(this.autoLegendPosition=next,!0)}legendPositionForConfig(){const position=normalizeLegendPosition(this.legendPosition);return position==="auto"?this.autoLegendPosition:position==="start"?this.effectiveDirection==="rtl"?"right":"left":position==="end"?this.effectiveDirection==="rtl"?"left":"right":position}legendPositionForLayout(){const position=this.legendPositionForConfig();return position==="top"||position==="right"||position==="left"?position:"bottom"}legendGridPlacement(){const position=normalizeLegendPosition(this.legendPosition);if(position==="auto")return this.autoLegendPosition==="right"?"inline-end":"bottom";if(position==="start")return"inline-start";if(position==="end")return"inline-end";if(position==="top")return"top";const rtl=this.effectiveDirection==="rtl";return position==="left"?rtl?"inline-end":"inline-start":position==="right"?rtl?"inline-start":"inline-end":"bottom"}updateChartArea(chart=this.chart){const area=chart?.chartArea;if(!area)return;const next={top:Number(area.top),left:Number(area.left),right:Number(area.right),bottom:Number(area.bottom),width:Number(area.width),height:Number(area.height)};if(Object.values(next).some(value=>!Number.isFinite(value)))return;const previous=this.resolvedChartArea;previous&&Object.keys(next).every(key=>previous[key]===next[key])||(this.resolvedChartArea=next,this.chartAreaUpdateQueued||(this.chartAreaUpdateQueued=!0,queueMicrotask(()=>{this.chartAreaUpdateQueued=!1,this.isConnected&&this.requestUpdate()})))}get chartArea(){return this.resolvedChartArea}buildConfig(){const theme=this.themeColors(),effectiveType=this.effectiveType(),palette=this.seriesPalette(),chartStyle=this.chartStyleOptions(palette),rawDataEscapeHatch=this.hasExplicitConfigData();let visualRows,visualSeries;if(rawDataEscapeHatch)this.visualRowSourceIndexes=void 0,this.visualDatasetSourceIndexes=void 0;else{let rowCount=this.labels.length;for(const series of this.datasets)rowCount=Math.max(rowCount,(series.points??series.data??[]).length);const sample=sampleChartTableIndexes(rowCount,this.datasets.length);visualRows=sample.rowIndexes.length<rowCount?sample.rowIndexes:void 0,visualSeries=sample.seriesIndexes.length<this.datasets.length?sample.seriesIndexes:void 0,this.visualRowSourceIndexes=visualRows,this.visualDatasetSourceIndexes=visualSeries}const generated={type:effectiveType,data:{labels:visualRows?visualRows.map(index=>this.labels[index]??""):this.labels,datasets:visualSeries?visualSeries.map(sourceIndex=>this.seriesToDataset(this.datasets[sourceIndex],sourceIndex,palette,effectiveType,chartStyle,visualRows)):this.datasets.map((s,i)=>this.seriesToDataset(s,i,palette,effectiveType,chartStyle))},...this.plugins.length||this.needsDataLabels&&this.dataLabelsPlugin?{plugins:[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]]}:{},options:{locale:this.effectiveLocale,responsive:!0,maintainAspectRatio:!1,indexAxis:this.effectiveIndexAxis(),animation:this.withoutAnimation||prefersReducedMotion(this.ownerWindow)?!1:void 0,interaction:{intersect:!1,mode:effectiveType==="scatter"?"nearest":"index"},onClick:(event,_elements,chart)=>this.handlePointClick(event,chart),plugins:{legend:{display:!1,position:this.legendPositionForConfig(),labels:{color:theme.legend,...this.formatter||this.valueFormatter?{generateLabels:chart=>this.legendLabels(chart)}:{}}},tooltip:{enabled:!this.withoutTooltip,backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,...this.formatter||this.valueFormatter?{callbacks:{label:context=>this.tooltipLabel(context)}}:{},filter:item=>!this.effectiveData().datasets[item.datasetIndex]?.noTooltip},zoom:this.zoom&&this.zoomFeatureState!=="unavailable"?{pan:{enabled:!1},zoom:{wheel:{enabled:!0},drag:{enabled:!0},pinch:{enabled:!0},mode:"x",onZoomComplete:()=>{this.suppressZoomComplete||(this.zoomed=!0,this.emit("lr-zoom",{zoomed:!0}))}},limits:{x:{min:"original",max:"original"}}}:void 0,datalabels:this.datalabelsOptions(theme,effectiveType)},onResize:chart=>this.updateChartArea(chart),scales:this.buildScales(effectiveType,theme,chartStyle)}},effectiveConfig=this.effectiveConfig();if(!effectiveConfig)return generated;const merged=deepMerge(generated,effectiveConfig),requiredPlugins=[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]];if(requiredPlugins.length){const mergedPlugins=Array.isArray(merged.plugins)?merged.plugins:[];merged.plugins=[...mergedPlugins,...requiredPlugins.filter(plugin=>!mergedPlugins.includes(plugin))]}return merged}draw(){if(!this.chartJsModule||!this.canvasEl)return;const config=this.buildConfig(),effectiveType=config.type,nextPlugins=Array.isArray(config.plugins)?config.plugins:[],samePlugins=nextPlugins.length===this.builtPlugins.length&&nextPlugins.every((plugin,index)=>plugin===this.builtPlugins[index]);if(this.chart&&this.builtType===effectiveType&&samePlugins){this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none"),this.updateChartArea(this.chart);return}this.discardChart(!0),this.chart=new this.chartJsModule.Chart(this.canvasEl,config),this.builtType=effectiveType,this.builtPlugins=[...nextPlugins],this.hiddenDatasets!==void 0&&(this.applyDatasetVisibility(),this.chart.update("none")),this.updateChartArea(this.chart)}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}discardChart(announceZoomReset){this.chart?.destroy(),this.chart=void 0,this.resolvedChartArea=void 0,this.zoomed&&(this.zoomed=!1,announceZoomReset&&this.emit("lr-zoom",{zoomed:!1}))}renderChart(){this.drawIfVisible()}resetZoom(){this.suppressZoomComplete=!0;try{this.chart?.resetZoom?.()}finally{this.suppressZoomComplete=!1}this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1})}refreshTheme(){this.drawIfVisible(),this.showsLegend&&this.requestUpdate()}summarizeSeries(dataset){let count=0,first=0,last=0,min=0,max=0;for(const datum of this.datasetValues(dataset)){const value=isChartPoint(datum)?datum.y:datum;typeof value!="number"||!Number.isFinite(value)||(count===0&&(first=value,min=value,max=value),last=value,min=Math.min(min,value),max=Math.max(max,value),count++)}return count?{count,first,last,min,max}:void 0}formatSummaryValue(value){return getNumberFormat(this.effectiveLocale).format(value)}formatTableValue(value){return this.formatter?.({value,surface:"table"})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}tableStackAxes(){const type=this.effectiveType();if(!this.stackTotals||!this.stacked||type!=="bar"&&type!=="line")return[];const present=new Set;for(const dataset of this.effectiveData().datasets)present.add(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y");return["y","y2"].filter(axis=>present.has(axis))}tableStackTotalLabel(axis,axisCount){if(axisCount===1)return this.localize("chartTotal");const axisLabel=axis==="y2"?this.y2Label||this.localize("chartSecondaryAxis"):this.yLabel||this.localize("chartPrimaryAxis");return this.localize("chartAxisTotal",void 0,{axis:axisLabel})}accessibleName(fallback){return this.getAttribute("aria-label")??this.label??fallback}chartDescription(){if(this.description)return this.description;const effective=this.effectiveData(),sample=this.dataTableSample(effective),includePointDetails=!this.hasCustomDataTable(),summaries=sample.seriesIndexes.map(index=>{const dataset=effective.datasets[index],seriesLabel=this.datasetLabel(dataset,index),values=this.summarizeSeries(dataset);if(!values)return this.localize("chartSeriesNoData",void 0,{label:seriesLabel});const trend=values.last>values.first?this.localize("chartTrendIncreasing"):values.last<values.first?this.localize("chartTrendDecreasing"):this.localize("chartTrendFlat"),summary=this.localize("chartSummary",void 0,{label:seriesLabel,count:this.formatSummaryValue(values.count),min:this.formatSummaryValue(values.min),max:this.formatSummaryValue(values.max),trend}),rawValues=this.datasetValues(dataset),pointDetails=includePointDetails?sample.rowIndexes.flatMap(rowIndex=>{const point=rawValues[rowIndex];return isChartPoint(point)?[this.datumDisplayValue(point)]:[]}):[];return pointDetails.length?[summary,...pointDetails].join(this.localize("chartSummarySeparator")):summary});return summaries.length?this.localize("chartSummaryWithData",void 0,{type:this.localizedChartType(),summaries:summaries.join(this.localize("chartSummarySeparator"))}):this.localize("chartSummaryEmpty",void 0,{type:this.localizedChartType()})}dataTableSample(effective=this.effectiveData()){let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const indexes=sampleChartTableIndexes(rowCount,effective.datasets.length);return{rowCount,seriesCount:effective.datasets.length,...indexes}}generatedDataIsSampled(){if(this.hasCustomDataTable())return!1;const sample=this.dataTableSample();return sample.rowCount===0||sample.seriesCount===0?!1:sample.rowIndexes.length<sample.rowCount||sample.seriesIndexes.length<sample.seriesCount}dataTruncationMessage(){return this.generatedDataIsSampled()?this.localize("chartDataSampled"):""}renderDataTable(){const effective=this.effectiveData(),sample=this.dataTableSample(effective),stackAxes=this.tableStackAxes(),stackTotals=new Map(stackAxes.map(axis=>[axis,this.computeStackTotals(axis)]));return html`
|
|
3
3
|
<table class=${this.showDataTable?nothing:"sr-only"}>
|
|
4
4
|
<caption>${this.accessibleName(this.localize("chartData"))}</caption>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraDoughnutChart extends LyraChart{constructor(){super(...arguments),this.type="doughnut"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraDoughnutChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraDoughnutChart extends LyraChart{constructor(){super(...arguments),this.type="doughnut"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraDoughnutChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{property}from"lit/decorators.js";import{LyraChart}from"./chart.class.js";import{lockChartType}from"./chart-type-lock.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{binValues,normalizeHistogramBinCount}from"./histogram-bin.js";import{styles}from"./histogram.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_histogramFrequency,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraHistogram extends LyraChart{constructor(){super(...arguments),this.type="bar",this.bins=10,this.values=[],this.seriesLabel=""}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,histogramFrequency:LYRA_DEFAULT_histogramFrequency,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.ownedCollectionProperties=Object.freeze(["values"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}appendSamples(values,maxSamples=0){const appended=values.filter(value=>typeof value=="number"&&Number.isFinite(value)),combined=[...this.values,...appended],limit=Number.isFinite(maxSamples)?Math.max(0,Math.floor(maxSamples)):0;this.values=limit>0?combined.slice(-limit):combined}normalizeEffectiveConfig(config){if(!config)return;const normalized={...config};return delete normalized.type,delete normalized.data,normalized}appendData(_label,values,maxPoints=0){this.appendSamples(values,maxPoints)}chartContentChanged(changed){return super.chartContentChanged(changed)||["values","bins","seriesLabel"].some(name=>changed.has(name))}}__decorate([property({converter:{fromAttribute:value=>normalizeHistogramBinCount(value)}})],LyraHistogram.prototype,"bins",void 0),__decorate([property({attribute:!1})],LyraHistogram.prototype,"values",void 0),__decorate([property({attribute:"series-label"})],LyraHistogram.prototype,"seriesLabel",void 0);const bucketCache=new WeakMap;function binnedBuckets(el){const bins=normalizeHistogramBinCount(el.bins),locale=el.effectiveLocale,cached=bucketCache.get(el);if(cached&&cached.values===el.values&&cached.bins===bins&&cached.locale===locale)return cached.buckets;const buckets=binValues(el.values,bins,locale);return bucketCache.set(el,{values:el.values,bins,locale,buckets}),buckets}Object.defineProperty(LyraHistogram.prototype,"labels",{configurable:!0,enumerable:!0,get(){return binnedBuckets(this).map(b=>b.label)},set(_v){}}),Object.defineProperty(LyraHistogram.prototype,"datasets",{configurable:!0,enumerable:!0,get(){return[{label:this.seriesLabel||this.localize("histogramFrequency"),data:binnedBuckets(this).map(b=>b.count)}]},set(_v){}}),lockChartType(LyraHistogram,"bar");export{LyraHistogram,binnedBuckets};
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{property}from"lit/decorators.js";import{LyraChart}from"./chart.class.js";import{lockChartType}from"./chart-type-lock.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{binValues,normalizeHistogramBinCount}from"./histogram-bin.js";import{styles}from"./histogram.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_histogramFrequency,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraHistogram extends LyraChart{constructor(){super(...arguments),this.type="bar",this.bins=10,this.values=[],this.seriesLabel=""}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,histogramFrequency:LYRA_DEFAULT_histogramFrequency,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.ownedCollectionProperties=Object.freeze(["values"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}appendSamples(values,maxSamples=0){const appended=values.filter(value=>typeof value=="number"&&Number.isFinite(value)),combined=[...this.values,...appended],limit=Number.isFinite(maxSamples)?Math.max(0,Math.floor(maxSamples)):0;this.values=limit>0?combined.slice(-limit):combined}normalizeEffectiveConfig(config){if(!config)return;const normalized={...config};return delete normalized.type,delete normalized.data,normalized}appendData(_label,values,maxPoints=0){this.appendSamples(values,maxPoints)}chartContentChanged(changed){return super.chartContentChanged(changed)||["values","bins","seriesLabel"].some(name=>changed.has(name))}}__decorate([property({converter:{fromAttribute:value=>normalizeHistogramBinCount(value)}})],LyraHistogram.prototype,"bins",void 0),__decorate([property({attribute:!1})],LyraHistogram.prototype,"values",void 0),__decorate([property({attribute:"series-label"})],LyraHistogram.prototype,"seriesLabel",void 0);const bucketCache=new WeakMap;function binnedBuckets(el){const bins=normalizeHistogramBinCount(el.bins),locale=el.effectiveLocale,cached=bucketCache.get(el);if(cached&&cached.values===el.values&&cached.bins===bins&&cached.locale===locale)return cached.buckets;const buckets=binValues(el.values,bins,locale);return bucketCache.set(el,{values:el.values,bins,locale,buckets}),buckets}Object.defineProperty(LyraHistogram.prototype,"labels",{configurable:!0,enumerable:!0,get(){return binnedBuckets(this).map(b=>b.label)},set(_v){}}),Object.defineProperty(LyraHistogram.prototype,"datasets",{configurable:!0,enumerable:!0,get(){return[{label:this.seriesLabel||this.localize("histogramFrequency"),data:binnedBuckets(this).map(b=>b.count)}]},set(_v){}}),lockChartType(LyraHistogram,"bar");export{LyraHistogram,binnedBuckets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraLineChart extends LyraChart{constructor(){super(...arguments),this.type="line"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraLineChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraLineChart extends LyraChart{constructor(){super(...arguments),this.type="line"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraLineChart};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteAdd,finiteCount,finiteRange}from"../../../internal/numbers.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import"../../utility/live-region/live-region.class.js";import{styles}from"./lite-chart.styles.js";import{forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{literalSetConverter,trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{sanitizeCssColor,sanitizeCssLength}from"../../../internal/safe-css.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{MAX_RENDERED_CHART_RECORDS,sampleChartTableIndexes}from"./chart-table-sampling.js";import{chartChromeLegendPlacement,normalizeChartChromeLegendPosition}from"./chart-chrome.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_liteChartBarLabel,LYRA_DEFAULT_liteChartCustomMarkSummary,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings.generated.js";function normalizeLiteChartType(value){return value==="line"||value==="bar"?value:"bar"}const LITE_CHART_LAYOUT=literalSetConverter(["fit","scroll"],"fit"),DEFAULT_PALETTE=["var(--lr-chart-color-1, var(--lr-color-chart-1))","var(--lr-chart-color-2, var(--lr-color-chart-2))","var(--lr-chart-color-3, var(--lr-color-chart-3))","var(--lr-chart-color-4, var(--lr-color-chart-4))","var(--lr-chart-color-5, var(--lr-color-chart-5))","var(--lr-chart-color-6, var(--lr-color-chart-6))","var(--lr-chart-color-7, var(--lr-color-chart-7))","var(--lr-chart-color-8, var(--lr-color-chart-8))"],PAD_LEFT=36,PAD_RIGHT=8,PAD_TOP=8,PAD_BOTTOM=
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteAdd,finiteCount,finiteRange}from"../../../internal/numbers.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import"../../utility/live-region/live-region.class.js";import{styles}from"./lite-chart.styles.js";import{forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{literalSetConverter,trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{sanitizeCssColor,sanitizeCssLength}from"../../../internal/safe-css.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{MAX_RENDERED_CHART_RECORDS,sampleChartTableIndexes}from"./chart-table-sampling.js";import{chartChromeLegendPlacement,normalizeChartChromeLegendPosition}from"./chart-chrome.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_liteChartBarLabel,LYRA_DEFAULT_liteChartCustomMarkSummary,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings.generated.js";function normalizeLiteChartType(value){return value==="line"||value==="bar"?value:"bar"}const LITE_CHART_LAYOUT=literalSetConverter(["fit","scroll"],"fit"),DEFAULT_PALETTE=["var(--lr-chart-color-1, var(--lr-color-chart-1))","var(--lr-chart-color-2, var(--lr-color-chart-2))","var(--lr-chart-color-3, var(--lr-color-chart-3))","var(--lr-chart-color-4, var(--lr-color-chart-4))","var(--lr-chart-color-5, var(--lr-color-chart-5))","var(--lr-chart-color-6, var(--lr-color-chart-6))","var(--lr-chart-color-7, var(--lr-color-chart-7))","var(--lr-chart-color-8, var(--lr-color-chart-8))"],PAD_LEFT=36,PAD_RIGHT=8,PAD_TOP=8,PAD_BOTTOM=30,CATEGORY_LABEL_OFFSET=24,AXIS_TITLE_SPACE=14,TICK_COUNT=4,BAR_GROUP_GAP=.2,BAR_GAP=.08,BAR_CORNER_RADIUS=4,APPROX_LABEL_CHARACTER_WIDTH=7,MAX_SCROLL_CONTENT_WIDTH=1e6;function niceStep(span,count){const rough=span/Math.max(1,count),magnitude=10**Math.floor(Math.log10(rough)),residual=rough/magnitude;return(residual<1.5?1:residual<3?2:residual<7?5:10)*magnitude}function domainFraction(value,lo,hi){const span=hi-lo;if(Number.isFinite(span)&&span>0)return Math.min(1,Math.max(0,(value-lo)/span));const scale=Math.max(Math.abs(value),Math.abs(lo),Math.abs(hi),1),scaledSpan=hi/scale-lo/scale;if(!Number.isFinite(scaledSpan)||scaledSpan<=0)return 0;const fraction=(value/scale-lo/scale)/scaledSpan;return Number.isFinite(fraction)?Math.min(1,Math.max(0,fraction)):0}function safeDomainTicks(lo,hi,count){return Array.from({length:Math.max(1,count)+1},(_,index)=>{if(index===0)return lo;if(index===count)return hi;const ratio=index/count;return lo*(1-ratio)+hi*ratio}).filter(Number.isFinite)}function niceDomain(dataLo,dataHi,beginAtZero,count){let lo=beginAtZero?Math.min(0,dataLo):dataLo,hi=beginAtZero?Math.max(0,dataHi):dataHi;lo===hi&&(Math.abs(lo)>Number.MAX_VALUE/2?(lo=lo>0?lo/2:lo,hi=hi<0?hi/2:hi):(lo-=1,hi+=1));const span=hi-lo;if(!Number.isFinite(span))return{lo,hi,ticks:safeDomainTicks(lo,hi,count)};const step=niceStep(span,count);if(!Number.isFinite(step)||step<=0)return{lo,hi,ticks:safeDomainTicks(lo,hi,count)};const roundedLo=Math.floor(lo/step)*step,roundedHi=Math.ceil(hi/step)*step;Number.isFinite(roundedLo)&&(lo=roundedLo),Number.isFinite(roundedHi)&&(hi=roundedHi);const slots=Math.floor((hi-lo)/step);if(!Number.isFinite(slots)||slots<0||slots>100)return{lo,hi,ticks:safeDomainTicks(lo,hi,count)};const ticks=[];for(let index=0;index<=slots;index++){const value=lo+index*step;Number.isFinite(value)&&ticks.push(value)}return ticks.at(-1)!==hi&&ticks.push(hi),{lo,hi,ticks}}class LyraLiteChart extends LyraElement{constructor(){super(...arguments),this.type="bar",this.labels=[],this.datasets=[],this.legend=!1,this.legendPosition="bottom",this.height="280px",this.xLabel="",this.yLabel="",this.beginAtZero=!0,this.stacked=!1,this.tableTotals=!1,this._layout="fit",this.barWidth=32,this.roundedBars=!1,this.skipZero=!1,this.scale="linear",this.withoutValueAxis=!1,this.selectedIndices=[],this.label=null,this.description=null,this.forcedColorPatternId=nextId("lite-chart-pattern"),this.descriptionId=nextId("lite-chart-description"),this.plotWidth=0,this.plotHeight=0,this.fitMeasurementAvailable=!1,this.activeMarkIndex=0,this.resizeObserverGeneration=0,this.refocusMarkAfterUpdate=!1,this.refocusChartAfterUpdate=!1,this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.onForcedColorsChange=()=>{!this.isConnected||this.ownerDocument.defaultView!==this.forcedColorsWindow||this.requestUpdate()}}static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartTotal:LYRA_DEFAULT_chartTotal,liteChartBarLabel:LYRA_DEFAULT_liteChartBarLabel,liteChartCustomMarkSummary:LYRA_DEFAULT_liteChartCustomMarkSummary,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary}}static{this.ownedCollectionProperties=Object.freeze(["labels","datasets","selectedIndices"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get layout(){return this._layout}set layout(next){const normalized=LITE_CHART_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}appendData(label,values,maxPoints=0){const limit=Math.max(0,finiteCount(maxPoints,0));let domainLength=this.labels.length;for(const series of this.datasets)domainLength=Math.max(domainLength,series.data.length);const labels=[...this.labels,...Array.from({length:Math.max(0,domainLength-this.labels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>({...series,data:[...series.data,...Array.from({length:Math.max(0,domainLength-series.data.length)},()=>null),values[index]??null]}));this.labels=limit>0?labels.slice(-limit):labels,this.datasets=limit>0?datasets.map(series=>({...series,data:series.data.slice(-limit)})):datasets}exportData(format){if(format==="svg"){const XMLSerializerCtor=this.ownerDocument.defaultView?.XMLSerializer;return!this.svgEl||typeof XMLSerializerCtor!="function"?"":new XMLSerializerCtor().serializeToString(this.svgEl)}const header=["label",...this.datasets.map(series=>series.label)].map(escapeCsvField).join(","),rows=Array.from({length:this.recordCount()},(_,index)=>{const label=this.labels[index]??"";return[label,...this.datasets.map((series,datasetIndex)=>{const value=series.data[index];return typeof value=="number"&&Number.isFinite(value)?this.formatter?.({value,surface:"export",datasetIndex,index,label,seriesLabel:series.label})??value:""})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
|
|
2
2
|
`)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink(),this.armResizeObserver(),this.armForcedColorsWatcher()}armResizeObserver(){const target=this.svgEl,ownerDocument=this.ownerDocument;if(!this.isConnected||!target||this.resizeObserver&&this.resizeObserverDocument===ownerDocument&&this.resizeObserverTarget===target)return;this.resetResizeObserver();const ResizeObserverCtor=ownerDocument.defaultView?.ResizeObserver;if(!ResizeObserverCtor)return;const generation=this.resizeObserverGeneration,observer=new ResizeObserverCtor(entries=>{if(this.resizeObserver!==observer||this.resizeObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.resizeObserverTarget!==target)return;const box=entries[0]?.contentBoxSize?.[0];if(box)this.plotWidth=box.inlineSize,this.plotHeight=box.blockSize;else{const rect=this.svgEl?.getBoundingClientRect();rect&&(this.plotWidth=rect.width,this.plotHeight=rect.height)}});this.resizeObserver=observer,this.resizeObserverDocument=ownerDocument,this.resizeObserverTarget=target,target&&observer.observe(target)}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.resetResizeObserver(),this.disarmForcedColorsWatcher()}adoptedCallback(){super.adoptedCallback(),this.resetResizeObserver(),this.releaseAnnouncementSink(),this.syncAnnouncementSink(),this.refreshFitMeasurementAvailability(),this.armForcedColorsWatcher()}armForcedColorsWatcher(){const ownerWindow=this.ownerDocument?.defaultView??void 0;ownerWindow?.matchMedia&&(this.forcedColorsWindow===ownerWindow&&this.forcedColorsQuery||(this.disarmForcedColorsWatcher(),this.forcedColorsWindow=ownerWindow,this.forcedColorsQuery=ownerWindow.matchMedia("(forced-colors: active)"),this.forcedColorsQuery.addEventListener("change",this.onForcedColorsChange)))}disarmForcedColorsWatcher(){this.forcedColorsQuery?.removeEventListener("change",this.onForcedColorsChange),this.forcedColorsQuery=void 0,this.forcedColorsWindow=void 0}syncAnnouncementSink(){this.isConnected&&this.politeAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.politeAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}releaseAnnouncementSink(){this.politeAnnouncementSink?.release(),this.politeAnnouncementSink=void 0}resetResizeObserver(){this.resizeObserverGeneration+=1,this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.resizeObserverDocument=void 0,this.resizeObserverTarget=void 0}firstUpdated(changed){super.firstUpdated(changed),this.armResizeObserver()}willUpdate(changed){if(super.willUpdate(changed),this.seedFirstRenderState(()=>{this.refreshFitMeasurementAvailability()}),!["type","labels","datasets","skipZero"].some(name=>changed.has(name)))return;const active=activeElementIn(this.shadowRoot)??null,hadFocusedMark=active?.matches('[part="bar"], [part="point"]')??!1,priorPosition=Number(active?.getAttribute("data-mark-index")??this.activeMarkIndex),datasetAttribute=active?.getAttribute("data-dataset-index"),indexAttribute=active?.getAttribute("data-index"),datasetIndex=Number(datasetAttribute),index=Number(indexAttribute),marks=this.interactiveMarks(),sameIdentity=datasetAttribute!=null&&indexAttribute!==null&&indexAttribute!==void 0?marks.findIndex(mark=>mark.datasetIndex===datasetIndex&&mark.index===index):-1;this.activeMarkIndex=marks.length?sameIdentity>=0?sameIdentity:Math.min(Math.max(priorPosition,0),marks.length-1):0,this.refocusMarkAfterUpdate=hadFocusedMark&&marks.length>0,this.refocusChartAfterUpdate=hadFocusedMark&&marks.length===0}updated(changed){super.updated(changed);const wasMounting=this.isMounting;if(this.isMounting=!1,changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}const dataTruncation=this.dataTruncationMessage();wasMounting?this.lastDataTruncationAnnouncement=dataTruncation:dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.politeAnnouncementSink?.announce(dataTruncation)),this.refocusMarkAfterUpdate&&(this.refocusMarkAfterUpdate=!1,this.renderRoot.querySelectorAll('[part="bar"], [part="point"]')[this.normalizedMarkIndex()]?.focus()),this.refocusChartAfterUpdate&&(this.refocusChartAfterUpdate=!1,this.svgEl?.focus())}colorFor(index,series){return sanitizeCssColor(series.color)??DEFAULT_PALETTE[index%DEFAULT_PALETTE.length]}get effectiveType(){return normalizeLiteChartType(this.type)}forcedColors(){return forcedColorsActive(this.ownerDocument?.defaultView)}markPaint(index,series){const color=this.colorFor(index,series);return this.effectiveType==="bar"&&this.forcedColors()?`url(#${this.forcedColorPatternId}-${index})`:color}legendEncoding(index){return this.forcedColors()?forcedColorEncoding(index).name:nothing}markDash(index){if(!this.forcedColors())return nothing;const dash=forcedColorEncoding(index).dash;return dash.length?dash.join(" "):"none"}renderForcedColorPatterns(){if(this.effectiveType!=="bar"||!this.forcedColors())return nothing;const size=8,half=size/2,texture="var(--lr-color-surface)";return svg`<defs>
|
|
3
3
|
${this.recordSample().seriesIndexes.map(index=>{const series=this.datasets[index],encoding=forcedColorEncoding(index).name,shapes=(()=>{switch(encoding){case"horizontal":return svg`<rect y=${half} width=${size} height="1" fill=${texture}></rect>`;case"vertical":return svg`<rect x=${half} width="1" height=${size} fill=${texture}></rect>`;case"diagonal":return svg`<path
|
|
4
4
|
d=${`M${-half},${size} L${half},0 M${half},${size} L${size+half},0`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraPieChart extends LyraChart{constructor(){super(...arguments),this.type="pie"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraPieChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraPieChart extends LyraChart{constructor(){super(...arguments),this.type="pie"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraPieChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraPolarAreaChart extends LyraChart{constructor(){super(...arguments),this.type="polarArea"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraPolarAreaChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraPolarAreaChart extends LyraChart{constructor(){super(...arguments),this.type="polarArea"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraPolarAreaChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraRadarChart extends LyraChart{constructor(){super(...arguments),this.type="radar"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraRadarChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraRadarChart extends LyraChart{constructor(){super(...arguments),this.type="radar"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraRadarChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraScatterChart extends LyraChart{constructor(){super(...arguments),this.type="scatter"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraScatterChart};
|
|
1
|
+
import{LyraChart}from"./chart.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraScatterChart extends LyraChart{constructor(){super(...arguments),this.type="scatter"}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}}export{LyraScatterChart};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeLyraTimestamp}from"../timestamp.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{getDateTimeFormat}from"../../../internal/intl-cache.js";import"../../utility/live-region/live-region.class.js";import{styles}from"./chat-message.styles.js";import{LYRA_DEFAULT_chatCompleteAnnounce,LYRA_DEFAULT_chatFailedAnnounce,LYRA_DEFAULT_chatFailedToSend,LYRA_DEFAULT_chatResponding,LYRA_DEFAULT_chatSending,LYRA_DEFAULT_collapse,LYRA_DEFAULT_collapseMessage,LYRA_DEFAULT_details,LYRA_DEFAULT_expandMessage,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_promptStudioRoleAssistant,LYRA_DEFAULT_promptStudioRoleSystem,LYRA_DEFAULT_promptStudioRoleUser,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function retryIcon(){return svg`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeLyraTimestamp}from"../timestamp.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{getDateTimeFormat}from"../../../internal/intl-cache.js";import"../../utility/live-region/live-region.class.js";import{styles}from"./chat-message.styles.js";import{LYRA_DEFAULT_chatCompleteAnnounce,LYRA_DEFAULT_chatFailedAnnounce,LYRA_DEFAULT_chatFailedToSend,LYRA_DEFAULT_chatResponding,LYRA_DEFAULT_chatSending,LYRA_DEFAULT_collapse,LYRA_DEFAULT_collapseMessage,LYRA_DEFAULT_details,LYRA_DEFAULT_expandMessage,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_promptStudioRoleAssistant,LYRA_DEFAULT_promptStudioRoleSystem,LYRA_DEFAULT_promptStudioRoleUser,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function retryIcon(){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -11,7 +11,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
11
11
|
aria-hidden="true"
|
|
12
12
|
focusable="false"
|
|
13
13
|
><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>
|
|
14
|
-
`}function defaultFormatTimestamp(date,locale){return getDateTimeFormat(locale,{hour:"numeric",minute:"2-digit"}).format(date)}const STATUS_TEXT_KEY={sending:"chatSending",streaming:"chatResponding",failed:"chatFailedToSend"};class LyraChatMessage extends LyraElement{constructor(){super(...arguments),this.messageRole="assistant",this.messageId="",this.collapsible=!1,this.collapsed=!1,this.attachmentsPosition="after",this.actionsPosition="inside",this.hasAvatarSlot=!1,this.hasBadgesSlot=!1,this.hasAttachmentsSlot=!1,this.hasActionsSlot=!1,this.hasFailureSlot=!1,this.bodyId=nextId("chat-message-body"),this._status="sent",this.previousStatus="sent",this.isMounting=!0,this.onAvatarSlotChange=e=>{this.hasAvatarSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBadgesSlotChange=e=>{this.hasBadgesSlot=e.target.assignedElements({flatten:!0}).length>0},this.onAttachmentsSlotChange=e=>{this.hasAttachmentsSlot=e.target.assignedElements({flatten:!0}).length>0},this.onActionsSlotChange=e=>{this.hasActionsSlot=e.target.assignedElements({flatten:!0}).length>0},this.onFailureSlotChange=e=>{this.hasFailureSlot=e.target.assignedElements({flatten:!0}).length>0},this.toggleCollapsed=()=>{const detail={collapsed:!this.collapsed};this.emit("lr-toggle-request",detail,{cancelable:!0}).defaultPrevented||(this.collapsed=detail.collapsed,this.emit("lr-toggle",detail))},this.onRetryClick=()=>{this.emit("lr-message-retry",{messageId:this.messageId||void 0}),this.status!=="failed"&&this.bubbleEl?.focus()}}static{this.defaultStrings={...super.defaultStrings,chatCompleteAnnounce:LYRA_DEFAULT_chatCompleteAnnounce,chatFailedAnnounce:LYRA_DEFAULT_chatFailedAnnounce,chatFailedToSend:LYRA_DEFAULT_chatFailedToSend,chatResponding:LYRA_DEFAULT_chatResponding,chatSending:LYRA_DEFAULT_chatSending,collapse:LYRA_DEFAULT_collapse,collapseMessage:LYRA_DEFAULT_collapseMessage,details:LYRA_DEFAULT_details,expandMessage:LYRA_DEFAULT_expandMessage,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,promptStudioRoleAssistant:LYRA_DEFAULT_promptStudioRoleAssistant,promptStudioRoleSystem:LYRA_DEFAULT_promptStudioRoleSystem,promptStudioRoleUser:LYRA_DEFAULT_promptStudioRoleUser,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={status:{reflect:!0,noAccessor:!0}}}get status(){return this._status}set status(value){const old=this._status;value!==old&&(this.previousStatus=old,this._status=value,this.requestUpdate("status",old))}willUpdate(changed){super.willUpdate(changed),this.hasUpdated?changed.has("status")&&(this.status==="failed"?this.hasFailureSlot=this.hasSlotted("failure"):this.previousStatus==="failed"&&this.hasFailureSlot&&this.isFocusWithinFailureSlot()&&this.bubbleEl?.focus()):(this.hasAvatarSlot=this.hasSlotted("avatar"),this.hasBadgesSlot=this.hasSlotted("badges"),this.hasAttachmentsSlot=this.hasSlotted("attachments"),this.hasActionsSlot=this.hasSlotted("actions"),this.status==="failed"&&(this.hasFailureSlot=this.hasSlotted("failure")))}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("status")&&this.announceStatusChange(this.previousStatus)}connectedCallback(){super.connectedCallback(),this.statusAtDisconnect!==void 0&&(this.isMounting=this.status!==this.statusAtDisconnect&&this.isUpdatePending,this.statusAtDisconnect=void 0)}disconnectedCallback(){this.statusAtDisconnect=this.status,this.isMounting=!0,super.disconnectedCallback()}hasSlotted(name){return Array.from(this.children).some(el=>el.getAttribute("slot")===name)}isFocusWithinFailureSlot(){const active=this.ownerDocument.activeElement;return active?Array.from(this.children).some(el=>el.getAttribute("slot")==="failure"&&el.contains(active)):!1}get normalizedTimestamp(){return normalizeLyraTimestamp(this.timestamp)}get statusText(){return this.status==="sent"?void 0:this.localize(STATUS_TEXT_KEY[this.status])}announceStatusChange(previous){if(previous===this.status)return;const region=this.liveRegion;if(region)if(this.status==="failed"){if(this.hasFailureSlot)return;region.mode="assertive",region.announce(this.localize("chatFailedAnnounce"),{force:!0})}else previous==="streaming"&&this.status==="sent"&&(region.mode="polite",region.announce(this.localize("chatCompleteAnnounce"),{force:!0}))}render(){const ts=this.normalizedTimestamp,formatter=this.formatTimestamp??(date=>defaultFormatTimestamp(date,this.effectiveLocale)),suppressBuiltInFailedUi=this.status==="failed"&&this.hasFailureSlot,statusText=suppressBuiltInFailedUi?void 0:this.statusText,showHeader=this.hasAvatarSlot||this.hasBadgesSlot||this.collapsible,actionsOutside=this.actionsPosition==="outside",showFooter=!!statusText||!!ts||!actionsOutside&&this.hasActionsSlot,authorLabel=this.localize(this.messageRole==="user"?"promptStudioRoleUser":this.messageRole==="system"?"promptStudioRoleSystem":"promptStudioRoleAssistant"),articleLabel=this.hasAttribute("aria-label")?this.getAttribute("aria-label")??"":authorLabel,actionsBlock=html`<span part="actions" ?hidden=${!this.hasActionsSlot}
|
|
14
|
+
`}function defaultFormatTimestamp(date,locale){return getDateTimeFormat(locale,{hour:"numeric",minute:"2-digit"}).format(date)}const STATUS_TEXT_KEY={sending:"chatSending",streaming:"chatResponding",failed:"chatFailedToSend"};class LyraChatMessage extends LyraElement{constructor(){super(...arguments),this.messageRole="assistant",this.messageId="",this.collapsible=!1,this.collapsed=!1,this.attachmentsPosition="after",this.actionsPosition="inside",this.hasAvatarSlot=!1,this.hasBadgesSlot=!1,this.hasAttachmentsSlot=!1,this.hasActionsSlot=!1,this.hasFailureSlot=!1,this.bodyId=nextId("chat-message-body"),this._status="sent",this.previousStatus="sent",this.isMounting=!0,this.onAvatarSlotChange=e=>{this.hasAvatarSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBadgesSlotChange=e=>{this.hasBadgesSlot=e.target.assignedElements({flatten:!0}).length>0},this.onAttachmentsSlotChange=e=>{this.hasAttachmentsSlot=e.target.assignedElements({flatten:!0}).length>0},this.onActionsSlotChange=e=>{this.hasActionsSlot=e.target.assignedElements({flatten:!0}).length>0},this.onFailureSlotChange=e=>{this.hasFailureSlot=e.target.assignedElements({flatten:!0}).length>0},this.toggleCollapsed=()=>{const detail={collapsed:!this.collapsed};this.emit("lr-toggle-request",detail,{cancelable:!0}).defaultPrevented||(this.collapsed=detail.collapsed,this.emit("lr-toggle",detail))},this.onRetryClick=()=>{this.emit("lr-message-retry",{messageId:this.messageId||void 0}),this.status!=="failed"&&this.bubbleEl?.focus()}}static{this.defaultStrings={...super.defaultStrings,chatCompleteAnnounce:LYRA_DEFAULT_chatCompleteAnnounce,chatFailedAnnounce:LYRA_DEFAULT_chatFailedAnnounce,chatFailedToSend:LYRA_DEFAULT_chatFailedToSend,chatResponding:LYRA_DEFAULT_chatResponding,chatSending:LYRA_DEFAULT_chatSending,collapse:LYRA_DEFAULT_collapse,collapseMessage:LYRA_DEFAULT_collapseMessage,details:LYRA_DEFAULT_details,expandMessage:LYRA_DEFAULT_expandMessage,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,promptStudioRoleAssistant:LYRA_DEFAULT_promptStudioRoleAssistant,promptStudioRoleSystem:LYRA_DEFAULT_promptStudioRoleSystem,promptStudioRoleUser:LYRA_DEFAULT_promptStudioRoleUser,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={status:{reflect:!0,noAccessor:!0}}}get status(){return this._status}set status(value){const old=this._status;value!==old&&(this.previousStatus=old,this._status=value,this.requestUpdate("status",old))}willUpdate(changed){super.willUpdate(changed),this.hasUpdated?changed.has("status")&&(this.status==="failed"?this.hasFailureSlot=this.hasSlotted("failure"):this.previousStatus==="failed"&&this.hasFailureSlot&&this.isFocusWithinFailureSlot()&&this.bubbleEl?.focus()):(this.hasAvatarSlot=this.hasSlotted("avatar"),this.hasBadgesSlot=this.hasSlotted("badges"),this.hasAttachmentsSlot=this.hasSlotted("attachments"),this.hasActionsSlot=this.hasSlotted("actions"),this.status==="failed"&&(this.hasFailureSlot=this.hasSlotted("failure")))}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("status")&&this.announceStatusChange(this.previousStatus)}connectedCallback(){super.connectedCallback(),this.statusAtDisconnect!==void 0&&(this.isMounting=this.status!==this.statusAtDisconnect&&this.isUpdatePending,this.statusAtDisconnect=void 0)}disconnectedCallback(){this.statusAtDisconnect=this.status,this.isMounting=!0,super.disconnectedCallback()}hasSlotted(name){return Array.from(this.children).some(el=>el.getAttribute("slot")===name)}isFocusWithinFailureSlot(){const active=this.ownerDocument.activeElement;return active?Array.from(this.children).some(el=>el.getAttribute("slot")==="failure"&&el.contains(active)):!1}get normalizedTimestamp(){return normalizeLyraTimestamp(this.timestamp)}get statusText(){return this.status==="sent"?void 0:this.localize(STATUS_TEXT_KEY[this.status])}announceStatusChange(previous){if(previous===this.status)return;const region=this.liveRegion;if(region)if(this.status==="failed"){if(this.hasFailureSlot)return;region.mode="assertive",region.announce(this.localize("chatFailedAnnounce"),{force:!0})}else previous==="streaming"&&this.status==="sent"&&(region.mode="polite",region.announce(this.localize("chatCompleteAnnounce"),{force:!0}))}render(){const ts=this.normalizedTimestamp,formatter=this.formatTimestamp??(date=>defaultFormatTimestamp(date,this.effectiveLocale)),suppressBuiltInFailedUi=this.status==="failed"&&this.hasFailureSlot,statusText=suppressBuiltInFailedUi?void 0:this.statusText,showHeader=this.hasAvatarSlot||this.hasBadgesSlot||this.collapsible,actionsOutside=this.actionsPosition==="outside",showFooter=!!statusText||!!ts||!actionsOutside&&this.hasActionsSlot,authorLabel=this.localize(this.messageRole==="user"?"promptStudioRoleUser":this.messageRole==="system"?"promptStudioRoleSystem":"promptStudioRoleAssistant"),articleLabel=this.hasAttribute("aria-label")?this.getAttribute("aria-label")??"":authorLabel,actionsBlock=html`<span part="actions" ?hidden=${!this.hasActionsSlot}
|
|
15
15
|
><slot name="actions" @slotchange=${this.onActionsSlotChange}></slot
|
|
16
16
|
></span>`,attachmentsBlock=html`<div part="attachments" ?hidden=${!this.hasAttachmentsSlot}>
|
|
17
17
|
<slot name="attachments" @slotchange=${this.onAttachmentsSlotChange}></slot>
|
|
@@ -151,8 +151,14 @@ import{css}from"lit";const styles=css`
|
|
|
151
151
|
display: flex;
|
|
152
152
|
align-items: center;
|
|
153
153
|
gap: var(--lr-space-xs);
|
|
154
|
+
}
|
|
155
|
+
:host([message-role='user']) [part='actions'] {
|
|
154
156
|
margin-inline-start: auto;
|
|
155
157
|
}
|
|
158
|
+
:host([message-role='assistant']) [part='actions'],
|
|
159
|
+
:host([message-role='system']) [part='actions'] {
|
|
160
|
+
margin-inline-end: auto;
|
|
161
|
+
}
|
|
156
162
|
:host([actions-position='outside']) [part='actions'] {
|
|
157
163
|
margin-block-start: var(--lr-space-2xs);
|
|
158
164
|
}
|